From: <hik...@us...> - 2010-01-03 03:39:01
|
Revision: 4390 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4390&view=rev Author: hikerstk Date: 2010-01-03 03:38:49 +0000 (Sun, 03 Jan 2010) Log Message: ----------- Removed VS compiler warnings. Modified Paths: -------------- main/trunk/src/guiengine/widgets/icon_button_widget.cpp main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/icon_button_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2010-01-02 21:30:55 UTC (rev 4389) +++ main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2010-01-03 03:38:49 UTC (rev 4390) @@ -59,13 +59,13 @@ } int suggested_h = h; - int suggested_w = (useAspectRatio < 0 ? w : useAspectRatio*suggested_h); + int suggested_w = (int)((useAspectRatio < 0 ? w : useAspectRatio*suggested_h)); if (suggested_w > w) { const float needed_scale_factor = (float)w / (float)suggested_w; - suggested_w *= needed_scale_factor; - suggested_h *= needed_scale_factor; + suggested_w = (int)(suggested_w*needed_scale_factor); + suggested_h = (int)(suggested_h*needed_scale_factor); } const int x_from = x + (w - suggested_w)/2; // center horizontally const int y_from = y + (h - suggested_h)/2; // center vertically Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-01-02 21:30:55 UTC (rev 4389) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-01-03 03:38:49 UTC (rev 4390) @@ -167,7 +167,7 @@ core::dimension2d< u32 > dim = GUIEngine::getFont()->getDimension( m_children[i].m_text.c_str() ); if ((int)dim.Width > one_button_space) { - line_count = std::ceil((float)dim.Width/(float)one_button_space); + line_count = (int)(std::ceil((float)dim.Width/(float)one_button_space)); } const int needed_space_under_button = has_label ? GUIEngine::getFontHeight()*line_count : 10; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-03-07 00:36:45
|
Revision: 4948 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4948&view=rev Author: auria Date: 2010-03-07 00:36:38 +0000 (Sun, 07 Mar 2010) Log Message: ----------- Fixed '?' icons still appearing at times in ribbons Modified Paths: -------------- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2010-03-07 00:21:51 UTC (rev 4947) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2010-03-07 00:36:38 UTC (rev 4948) @@ -142,7 +142,7 @@ // ---- Determine number of rows and columns // Find children size (and ratio) - m_child_width = atoi(m_properties[PROP_CHILD_WIDTH].c_str()); + m_child_width = atoi(m_properties[PROP_CHILD_WIDTH].c_str()); m_child_height = atoi(m_properties[PROP_CHILD_HEIGHT].c_str()); if (m_child_width <= 0 || m_child_height <= 0) @@ -258,7 +258,7 @@ // stretch the *texture* within the widget (and the widget has the right aspect ratio) // (Yeah, that's complicated, but screenshots are saved compressed horizontally so it's hard to be clean) IconButtonWidget* icon = new IconButtonWidget(IconButtonWidget::SCALE_MODE_STRETCH, false, true); - icon->m_properties[PROP_ICON]="gui/main_help.png"; + icon->m_properties[PROP_ICON]="textures/transparence.png"; // set size to get proper ratio (as most textures are saved scaled down to 256x256) icon->m_properties[PROP_WIDTH] = m_properties[PROP_CHILD_WIDTH]; @@ -705,7 +705,7 @@ } else { - icon->setImage( "/textures/transparence.png" ); + icon->setImage( "textures/transparence.png", IconButtonWidget::ICON_PATH_TYPE_RELATIVE ); icon->m_properties[PROP_ID] = NO_ITEM_ID; } } // next column Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-03-07 00:21:51 UTC (rev 4947) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-03-07 00:36:38 UTC (rev 4948) @@ -186,10 +186,20 @@ float image_h = (float)image->getSize().Height; float image_w = image_h*imageRatio; - // if button too high to fit, scale down + // scale to fit (FIXME: calculate the right value directly...) float zoom = global_zoom; - while (button_y + image_h*zoom + needed_space_under_button > h) zoom -= 0.01f; + if (button_y + image_h*zoom + needed_space_under_button > h) + { + // scale down + while (button_y + image_h*zoom + needed_space_under_button > h) zoom -= 0.01f; + } + else + { + // scale up + while (button_y + image_h*zoom + needed_space_under_button < h) zoom += 0.01f; + } + // ---- add bitmap button part // backup and restore position in case the same object is added multiple times (FIXME: unclean) int old_x = m_children[i].x; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-04-21 18:14:36
|
Revision: 5230 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5230&view=rev Author: auria Date: 2010-04-21 18:14:28 +0000 (Wed, 21 Apr 2010) Log Message: ----------- Added (currently disabled) code to add icons in list widgets, this could be useful in the future. Unfortunately, irrLicht is again unfreidnly to out scalable UI; I've not figured a way to make them scalable at this point so I won't be using them right now Modified Paths: -------------- main/trunk/src/guiengine/widgets/list_widget.cpp main/trunk/src/guiengine/widgets/list_widget.hpp Modified: main/trunk/src/guiengine/widgets/list_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/list_widget.cpp 2010-04-21 17:28:08 UTC (rev 5229) +++ main/trunk/src/guiengine/widgets/list_widget.cpp 2010-04-21 18:14:28 UTC (rev 5230) @@ -17,6 +17,9 @@ #include "guiengine/engine.hpp" #include "guiengine/widgets/list_widget.hpp" + +#include "io/file_manager.hpp" + using namespace GUIEngine; using namespace irr::core; using namespace irr::gui; @@ -25,6 +28,7 @@ ListWidget::ListWidget() : Widget(WTYPE_LIST) { + m_use_icons = false; //TODO: make configurable if needed } // ----------------------------------------------------------------------------- @@ -33,7 +37,22 @@ { rect<s32> widget_size = rect<s32>(x, y, x + w, y + h); - m_element = GUIEngine::getGUIEnv()->addListBox (widget_size, m_parent, getNewID()); + IGUIListBox* list = GUIEngine::getGUIEnv()->addListBox (widget_size, m_parent, getNewID()); + + if (m_use_icons) + { + //TODO: allow choosing which icons to use + video::ITexture* icon = irr_driver->getTexture( file_manager->getGUIDir() + "/difficulty_medium.png" ); + + //FIXME: I have no clue what the parameter to 'addEmptySpriteBank' is for + //FIXME: remember the created bank for future 'add's, since a bank must be created once only + IGUISpriteBank* bank = GUIEngine::getGUIEnv()->addEmptySpriteBank( file_manager->getGUIDir().c_str() ); + bank->addTextureAsSprite(icon); + list->setSpriteBank(bank); + list->setItemHeight( icon->getSize().Height ); + } + + m_element = list; } // ----------------------------------------------------------------------------- @@ -47,34 +66,27 @@ } // ----------------------------------------------------------------------------- -/* // Doesn't work, I would need to override CGUIListBox, but this class is private -bool ListWidget::OnEvent (const SEvent &event) + +void ListWidget::addItem(const char* item) { - // block input events, we will handle them (vertical navigation) ourselves - if (event.EventType == EET_KEY_INPUT_EVENT || - event.EventType == EET_JOYSTICK_INPUT_EVENT || - event.EventType == EET_MOUSE_INPUT_EVENT) + IGUIListBox* list = getIrrlichtElement<IGUIListBox>(); + assert(list != NULL); + + if (m_use_icons) { - return true; + //TODO: allow choosing which icon to use + u32 newItem = list->addItem( stringw(item).c_str(), 0 /* icon */ ); + list->setItemOverrideColor( newItem, gui::EGUI_LBC_ICON, video::SColor(255,255,255,255) ); + list->setItemOverrideColor( newItem, gui::EGUI_LBC_ICON_HIGHLIGHT, video::SColor(255,255,255,255) ); } else { - return false; + list->addItem( stringw(item).c_str() ); } } - */ // ----------------------------------------------------------------------------- -void ListWidget::addItem(const char* item) -{ - IGUIListBox* list = getIrrlichtElement<IGUIListBox>(); - assert(list != NULL); - list->addItem( stringw(item).c_str() ); -} - -// ----------------------------------------------------------------------------- - int ListWidget::getSelection() const { const IGUIListBox* list = getIrrlichtElement<IGUIListBox>(); Modified: main/trunk/src/guiengine/widgets/list_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/list_widget.hpp 2010-04-21 17:28:08 UTC (rev 5229) +++ main/trunk/src/guiengine/widgets/list_widget.hpp 2010-04-21 18:14:28 UTC (rev 5230) @@ -30,6 +30,8 @@ /** A vertical list widget with text entries. See guiengine/engine.hpp for a detailed overview */ class ListWidget : public Widget { + bool m_use_icons; + public: ListWidget(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-05-02 18:11:52
|
Revision: 5347 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5347&view=rev Author: auria Date: 2010-05-02 18:11:46 +0000 (Sun, 02 May 2010) Log Message: ----------- Minor cleanup & documentation in ListWidget Modified Paths: -------------- main/trunk/src/guiengine/widgets/list_widget.cpp main/trunk/src/guiengine/widgets/list_widget.hpp Modified: main/trunk/src/guiengine/widgets/list_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/list_widget.cpp 2010-05-02 18:08:14 UTC (rev 5346) +++ main/trunk/src/guiengine/widgets/list_widget.cpp 2010-05-02 18:11:46 UTC (rev 5347) @@ -91,15 +91,6 @@ // ----------------------------------------------------------------------------- -int ListWidget::getSelection() const -{ - const IGUIListBox* list = getIrrlichtElement<IGUIListBox>(); - assert(list != NULL); - return list->getSelected(); -} - -// ----------------------------------------------------------------------------- - std::string ListWidget::getSelectionName() const { const IGUIListBox* list = getIrrlichtElement<IGUIListBox>(); Modified: main/trunk/src/guiengine/widgets/list_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/list_widget.hpp 2010-05-02 18:08:14 UTC (rev 5346) +++ main/trunk/src/guiengine/widgets/list_widget.hpp 2010-05-02 18:11:46 UTC (rev 5347) @@ -39,13 +39,18 @@ SkinWidgetContainer m_selection_skin_info; - void add(); - void addItem(const char* item); + /** \brief implement add method from base class GUIEngine::Widget */ + virtual void add(); + /** \brief implement callback from base class GUIEngine::Widget */ virtual void unfocused(const int playerID); + + // ---- contents management + + /** \brief add an item to the list */ + void addItem(const char* item); - int getSelection() const; - std::string getSelectionName() const; + /** \brief erases all items in the list */ void clear(); /** \return the number of items in the list */ @@ -54,6 +59,9 @@ /** \return the index of the selected element within the list, or -1 if none */ int getSelectionID() const; + /** \return the text of the selected item */ + std::string getSelectionName() const; + /** * \brief change the selected item * \param index the index of the element to select within the list, or -1 to select nothing This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-05-08 17:47:18
|
Revision: 5412 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5412&view=rev Author: auria Date: 2010-05-08 17:47:12 +0000 (Sat, 08 May 2010) Log Message: ----------- Minor refactoring Modified Paths: -------------- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2010-05-07 23:29:40 UTC (rev 5411) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2010-05-08 17:47:12 UTC (rev 5412) @@ -178,12 +178,12 @@ //std::cout << "ribbon : getNewID returns " << m_ids[i] << std::endl; } - setSubElements(); + buildInternalStructure(); } // ----------------------------------------------------------------------------- -void DynamicRibbonWidget::setSubElements() +void DynamicRibbonWidget::buildInternalStructure() { - //printf("****DynamicRibbonWidget::setSubElements()****\n"); + //printf("****DynamicRibbonWidget::buildInternalStructure()****\n"); // ---- Clean-up what was previously there for (int i=0; i<m_children.size(); i++) @@ -673,7 +673,7 @@ // ---- Check if we need to update the number of icons in the ribbon if ((int)m_items.size() != m_previous_item_count) { - setSubElements(); + buildInternalStructure(); m_previous_item_count = m_items.size(); } @@ -683,7 +683,7 @@ const int row_amount = m_rows.size(); const int item_amount = m_items.size(); - //FIXME: isn't this set by 'setSubElements' already? + //FIXME: isn't this set by 'buildInternalStructure' already? m_needed_cols = (int)ceil( (float)item_amount / (float)row_amount ); //const int max_scroll = std::max(m_col_amount, m_needed_cols) - 1; Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2010-05-07 23:29:40 UTC (rev 5411) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2010-05-08 17:47:12 UTC (rev 5412) @@ -142,7 +142,7 @@ EventPropagation focused(const int playerID); /** Removes all previously added contents icons, and re-adds them (calculating the new amount) */ - void setSubElements(); + void buildInternalStructure(); /** Call this to scroll within a scrollable ribbon */ void scroll(const int x_delta); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-05-08 18:24:32
|
Revision: 5413 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5413&view=rev Author: auria Date: 2010-05-08 18:24:26 +0000 (Sat, 08 May 2010) Log Message: ----------- More improvements to dynamica ribbon, fixing annoyance when items don't take all space allowed, fixing an empty space appearing in challenges screen Modified Paths: -------------- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2010-05-08 17:47:12 UTC (rev 5412) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2010-05-08 18:24:26 UTC (rev 5413) @@ -45,6 +45,7 @@ m_right_widget = NULL; m_check_inside_me = true; m_supports_multiplayer = true; + m_scrolling_enabled = true; // by default, set all players to have no selection in this ribbon for (int n=0; n<MAX_PLAYER_COUNT; n++) @@ -217,11 +218,13 @@ // Hide arrows when everything is visible if (item_count <= m_row_amount*m_col_amount) { + m_scrolling_enabled = false; m_left_widget->m_element->setVisible(false); m_right_widget->m_element->setVisible(false); } else { + m_scrolling_enabled = true; m_left_widget->m_element->setVisible(true); m_right_widget->m_element->setVisible(true); } @@ -277,13 +280,41 @@ added_item_count++; // stop adding columns when we have enough items - if (added_item_count >= item_count) break; + if (added_item_count == item_count) + { + assert(!m_scrolling_enabled); // we can see all items, so scrolling must be off + break; + } + else if (added_item_count > item_count) + { + assert(false); + break; + } } m_children.push_back( ribbon ); m_rows.push_back( ribbon ); ribbon->add(); + + // stop filling rows when we have enough items + if (added_item_count == item_count) + { + assert(!m_scrolling_enabled); // we can see all items, so scrolling must be off + break; + } } +#ifdef DEBUG + if (!m_scrolling_enabled) + { + // debug checks + int childrenCount = 0; + for (int n=0; n<m_rows.size(); n++) + { + childrenCount += m_rows[n].m_children.size(); + } + assert(childrenCount == (int)m_items.size()); + } +#endif } // ----------------------------------------------------------------------------- void DynamicRibbonWidget::addItem( const irr::core::stringw& user_name, const std::string& code_name, @@ -667,7 +698,12 @@ if (selection_id == NO_ITEM_ID) m_label->setText( L"" ); else m_label->setText( L"Unknown Item" ); } + // ----------------------------------------------------------------------------- + +/** Set to 1 if you wish information about item placement within the ribbon to be printed */ +#define CHATTY_ABOUT_ITEM_PLACEMENT 0 + void DynamicRibbonWidget::updateItemDisplay() { // ---- Check if we need to update the number of icons in the ribbon @@ -690,7 +726,7 @@ // the number of items that fit perfectly the number of rows we have // (this value will be useful to compute scrolling) - int fitting_item_amount = m_needed_cols * row_amount; + int fitting_item_amount = (m_scrolling_enabled ? m_needed_cols * row_amount : m_items.size()); // ---- to determine which items go in which cell of the dynamic ribbon now, // we create a temporary 2D table and fill them with the ID of the item @@ -700,17 +736,30 @@ item_placement.resize(row_amount); for(int i=0; i<row_amount; i++) item_placement[i].resize(m_needed_cols); - + int counter = 0; + +#if CHATTY_ABOUT_ITEM_PLACEMENT + std::cout << m_items.size() << " items to be placed:\n{\n"; +#endif + for (int c=0; c<m_needed_cols; c++) { for (int r=0; r<row_amount; r++) { + +#if CHATTY_ABOUT_ITEM_PLACEMENT + std::cout << " "; +#endif + const int items_in_row = m_rows[r].m_children.size(); if (c >= items_in_row) { item_placement[r][c] = -1; - //std::cout << item_placement[r][c] << " "; + +#if CHATTY_ABOUT_ITEM_PLACEMENT + std::cout << item_placement[r][c] << " "; +#endif continue; } @@ -718,12 +767,23 @@ while (newVal >= fitting_item_amount) newVal -= fitting_item_amount; item_placement[r][c] = newVal; - //std::cout << newVal << " "; +#if CHATTY_ABOUT_ITEM_PLACEMENT + std::cout << newVal << " "; +#endif + counter++; } - //std::cout << std::endl; + +#if CHATTY_ABOUT_ITEM_PLACEMENT + std::cout << "\n"; +#endif + } +#if CHATTY_ABOUT_ITEM_PLACEMENT + std::cout << "}\n"; +#endif + // ---- iterate through the rows, and set the items of each row to match those of the table for (int n=0; n<row_amount; n++) { Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2010-05-08 17:47:12 UTC (rev 5412) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2010-05-08 18:24:26 UTC (rev 5413) @@ -82,6 +82,11 @@ /** Whether this ribbon contains at least one animated item */ bool m_animated_contents; + /** Whether there are more items than can fit in a single screen; arrows will then appear + * on each side of the ribbon to scroll the contents + */ + bool m_scrolling_enabled; + /** Used to keep track of item count changes */ int m_previous_item_count; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-09-03 20:06:57
|
Revision: 5880 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5880&view=rev Author: auria Date: 2010-09-03 20:06:51 +0000 (Fri, 03 Sep 2010) Log Message: ----------- Fixed bug with text not wrapping in small ribbon elements Modified Paths: -------------- main/trunk/src/guiengine/widgets/icon_button_widget.cpp main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/icon_button_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2010-09-03 19:42:36 UTC (rev 5879) +++ main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2010-09-03 20:06:51 UTC (rev 5880) @@ -92,10 +92,11 @@ y_from, x_from + suggested_w, y_from + suggested_h); - //std::cout << "Creating a IGUIButton " << widget_size.UpperLeftCorner.X << ", " << widget_size.UpperLeftCorner.Y << - //" : " << widget_size.getWidth() << "x" << widget_size.getHeight() << std::endl; - IGUIButton* btn = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, (m_tab_stop ? getNewID() : getNewNoFocusID()), L""); + IGUIButton* btn = GUIEngine::getGUIEnv()->addButton(widget_size, + m_parent, + (m_tab_stop ? getNewID() : getNewNoFocusID()), + L""); btn->setTabStop(m_tab_stop); m_element = btn; @@ -105,15 +106,19 @@ const stringw& message = getText(); if (message.size() > 0) { - //std::cout << "Adding label of icon widget, m_properties[PROP_EXTEND_LABEL] = " << m_properties[PROP_EXTEND_LABEL] << std::endl; + //std::cout << "Adding label of icon widget, m_properties[PROP_EXTEND_LABEL] = " + // << m_properties[PROP_EXTEND_LABEL] << std::endl; const int label_extra_size = ( m_properties[PROP_EXTEND_LABEL].size() == 0 ? 0 : atoi(m_properties[PROP_EXTEND_LABEL].c_str()) ); + + // leave enough room for two lines of text widget_size = rect<s32>(m_x - label_extra_size/2, m_y + m_h, m_x + m_w + label_extra_size/2, - m_y + m_h*2); + m_y + m_h + GUIEngine::getFontHeight()*2); - m_label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), widget_size, false, true /* word wrap */, m_parent); + m_label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), widget_size, + false, true /* word wrap */, m_parent); m_label->setTextAlignment(EGUIA_CENTER, EGUIA_UPPERLEFT); m_label->setTabStop(false); } Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-09-03 19:42:36 UTC (rev 5879) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-09-03 20:06:51 UTC (rev 5880) @@ -100,15 +100,15 @@ total_needed_space += m_children[i].m_w; } - int free_h_space = m_w - total_needed_space; + int free_w_space = m_w - total_needed_space; //int biggest_y = 0; const int button_y = 10; float global_zoom = 1; const int min_free_space = 50; - global_zoom = (float)m_w / (float)( m_w - free_h_space + min_free_space ); - free_h_space = (int)(m_w - total_needed_space*global_zoom); + global_zoom = (float)m_w / (float)( m_w - free_w_space + min_free_space ); + //free_w_space = (int)(m_w - total_needed_space*global_zoom); const int one_button_space = (int)round((float)m_w / (float)subbuttons_amount); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-09-04 23:40:37
|
Revision: 5889 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5889&view=rev Author: auria Date: 2010-09-04 23:40:30 +0000 (Sat, 04 Sep 2010) Log Message: ----------- Fixed remaining issues with text bubbles by moving them to top of the hierarchy when focused Modified Paths: -------------- main/trunk/src/guiengine/widgets/bubble_widget.cpp main/trunk/src/guiengine/widgets/bubble_widget.hpp Modified: main/trunk/src/guiengine/widgets/bubble_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/bubble_widget.cpp 2010-09-04 23:02:39 UTC (rev 5888) +++ main/trunk/src/guiengine/widgets/bubble_widget.cpp 2010-09-04 23:40:30 UTC (rev 5889) @@ -106,21 +106,26 @@ } // ---------------------------------------------------------------------------- -/* + EventPropagation BubbleWidget::focused(const int playerID) { if (m_element != NULL) { - IGUIStaticText* widget = getIrrlichtElement<IGUIStaticText>(); - //widget->setDrawBorder(true); - widget->setRelativePosition(m_expanded_size); - widget->setText(getText().c_str()); + // bring element to top (with a hack because irrlicht does not appear to offer a built-in way to do this) + m_element->grab(); + + IGUIElement* parent = m_parent; + if (parent == NULL) parent = GUIEngine::getGUIEnv()->getRootGUIElement(); + + parent->removeChild(m_element); + parent->addChild(m_element); + m_element->drop(); } return EVENT_LET; } // ---------------------------------------------------------------------------- - +/* void BubbleWidget::unfocused(const int playerID) { if (m_element != NULL) Modified: main/trunk/src/guiengine/widgets/bubble_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/bubble_widget.hpp 2010-09-04 23:02:39 UTC (rev 5888) +++ main/trunk/src/guiengine/widgets/bubble_widget.hpp 2010-09-04 23:40:30 UTC (rev 5889) @@ -50,6 +50,8 @@ virtual void add(); + virtual EventPropagation focused(const int playerID); + void updateSize(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-01-03 18:41:25
|
Revision: 7229 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7229&view=rev Author: auria Date: 2011-01-03 18:41:19 +0000 (Mon, 03 Jan 2011) Log Message: ----------- Remove a few unuseful FIXMEs, replace with appropriate documentation Modified Paths: -------------- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2011-01-03 18:41:16 UTC (rev 7228) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2011-01-03 18:41:19 UTC (rev 7229) @@ -101,7 +101,7 @@ if (m_has_label) { - // FIXME - won't work with multiline labels. + // m_label_height contains the height of ONE text line m_label_height = GUIEngine::getFontHeight(); } else @@ -112,7 +112,7 @@ // ----- add dynamic label at bottom if (m_has_label) { - // leave room for many lines, just in case (FIXME: remove this hack) + // leave room for many lines, just in case rect<s32> label_size = rect<s32>(m_x, m_y + m_h - m_label_height, m_x + m_w, Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2011-01-03 18:41:16 UTC (rev 7228) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2011-01-03 18:41:19 UTC (rev 7229) @@ -77,6 +77,10 @@ /** Used for ribbon grids that have a label at the bottom */ bool m_has_label; irr::gui::IGUIStaticText* m_label; + + /** Height of ONE label text line (if label is multiline only one line is measured here). + * If there is no label, will be 0. + */ int m_label_height; /** Whether this ribbon contains at least one animated item */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-02-05 20:47:15
|
Revision: 7630 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7630&view=rev Author: auria Date: 2011-02-05 20:47:09 +0000 (Sat, 05 Feb 2011) Log Message: ----------- Use irrlicht's 1.8 RTL support if 1.8 is the verison being used Modified Paths: -------------- main/trunk/src/guiengine/widgets/bubble_widget.cpp main/trunk/src/guiengine/widgets/label_widget.cpp Modified: main/trunk/src/guiengine/widgets/bubble_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/bubble_widget.cpp 2011-02-05 13:39:42 UTC (rev 7629) +++ main/trunk/src/guiengine/widgets/bubble_widget.cpp 2011-02-05 20:47:09 UTC (rev 7630) @@ -50,7 +50,11 @@ IGUIStaticText* irrwidget; irrwidget = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), m_shrinked_size, false, true /* word wrap */, m_parent, (m_focusable ? getNewID() : getNewNoFocusID())); - + +#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8) + irrwidget->setRightToLeft( translations->isRTLLanguage() ); +#endif + // find expanded bubble size int text_height = irrwidget->getTextHeight(); Modified: main/trunk/src/guiengine/widgets/label_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/label_widget.cpp 2011-02-05 13:39:42 UTC (rev 7629) +++ main/trunk/src/guiengine/widgets/label_widget.cpp 2011-02-05 20:47:09 UTC (rev 7630) @@ -20,6 +20,7 @@ #include "guiengine/engine.hpp" #include "guiengine/scalable_font.hpp" #include "guiengine/skin.hpp" +#include "utils/translation.hpp" #include <assert.h> @@ -62,6 +63,10 @@ irrwidget = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), widget_size, false, word_wrap, m_parent, -1); +#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8) + irrwidget->setRightToLeft( translations->isRTLLanguage() ); +#endif + m_element = irrwidget; irrwidget->setTextAlignment( align, valign ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-03-24 22:51:23
|
Revision: 8048 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8048&view=rev Author: auria Date: 2011-03-24 22:51:17 +0000 (Thu, 24 Mar 2011) Log Message: ----------- Fixed label scrolling code Modified Paths: -------------- main/trunk/src/guiengine/widgets/label_widget.cpp main/trunk/src/guiengine/widgets/label_widget.hpp Modified: main/trunk/src/guiengine/widgets/label_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/label_widget.cpp 2011-03-24 21:28:50 UTC (rev 8047) +++ main/trunk/src/guiengine/widgets/label_widget.cpp 2011-03-24 22:51:17 UTC (rev 8048) @@ -60,10 +60,18 @@ else if (m_properties[PROP_TEXT_ALIGN] == "right") align = EGUIA_LOWERRIGHT; EGUI_ALIGNMENT valign = EGUIA_CENTER ; //TODO: make label v-align configurable through XML file? - IGUIStaticText* irrwidget; - irrwidget = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), widget_size, - false, word_wrap, m_parent, -1); - + IGUIStaticText* irrwidget; + if (m_scroll_offset) + { + IGUIElement* container = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, -1); + irrwidget = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), core::rect<s32>( core::position2di(0,0), widget_size.getSize()), + false, word_wrap, /*m_parent*/ container, -1); + } + else + { + irrwidget = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), widget_size, + false, word_wrap, m_parent, -1); + } #if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8) irrwidget->setRightToLeft( translations->isRTLLanguage() ); #endif @@ -89,7 +97,18 @@ m_element->setTabStop(false); m_element->setTabGroup(false); - m_element->setNotClipped(true); + if (!m_scroll_offset) + { + m_element->setNotClipped(true); + } + + if (m_scroll_speed > 0) + { + IGUIFont* font = m_title_font ? GUIEngine::getTitleFont() + : GUIEngine::getFont(); + core::dimension2du r = font->getDimension(getText().c_str()); + m_scroll_offset = r.Width; + } } // add // ---------------------------------------------------------------------------- @@ -106,31 +125,13 @@ void LabelWidget::setText(const wchar_t *text) { m_scroll_offset = 0; - if(m_scroll_speed<=0) + + if (m_scroll_speed > 0) { - Widget::setText(text); - return; + m_scroll_offset = m_element->getAbsolutePosition().getWidth(); } - - // Now the widget is scrolling. So add enough spaces - // to the left and right of the string so that it scrolls - // in. - IGUIFont* font = m_title_font ? GUIEngine::getTitleFont() - : GUIEngine::getFont(); - core::dimension2du r = font->getDimension(stringw(" ").c_str()); - unsigned int n = m_w / r.Width+1; - - stringw spaces=""; - spaces.reserve(n+1); // include end 0 - for(unsigned int i=0; i<n; i++) - { - spaces.append(' '); - } - // The c_str is important, otherwise it will call - // LabelWidget::setText(wstring), which will turn - // this function again. - Widget::setText((spaces+text).c_str()); - + + Widget::setText(text); } // setText // ---------------------------------------------------------------------------- @@ -139,15 +140,13 @@ */ void LabelWidget::update(float dt) { - m_scroll_offset += dt*m_scroll_speed; - while(m_scroll_offset>1) + if (m_scroll_speed != 0) { - const core::stringw &w= getText(); - // The c_str is important, otherwise it will call - // LabelWidget::setText(wstring), which would add - // more spaces again. - Widget::setText(w.subString(1, w.size()-1).c_str()); - m_scroll_offset --; + m_scroll_offset -= dt*m_scroll_speed*5.0f; + + //printf("m_scroll_offset = %f; x = %f\n", m_scroll_offset, m_x + m_scroll_offset); + + m_element->setRelativePosition( core::position2di( /*m_x +*/ m_scroll_offset, /*m_y*/ 0 ) ); } } // update // ---------------------------------------------------------------------------- @@ -156,5 +155,14 @@ */ bool LabelWidget::scrolledOff() const { - return getText().size()==0; -} \ No newline at end of file + return m_scroll_offset <= -m_element->getAbsolutePosition().getWidth(); +} + +// ---------------------------------------------------------------------------- +/** Sets horizontal scroll speed. */ +void LabelWidget::setScrollSpeed(float speed) +{ + m_scroll_offset = -m_element->getAbsolutePosition().getWidth() - 10; // start scrolled off + m_scroll_speed = speed; +} // setScrollSpeed + Modified: main/trunk/src/guiengine/widgets/label_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/label_widget.hpp 2011-03-24 21:28:50 UTC (rev 8047) +++ main/trunk/src/guiengine/widgets/label_widget.hpp 2011-03-24 22:51:17 UTC (rev 8048) @@ -56,19 +56,19 @@ virtual void setText(const wchar_t *text); virtual void update(float dt); + // -------------------------------------------------------------------- /** Overloaded function which takes a stringw. */ virtual void setText(const irr::core::stringw &s) { setText(s.c_str()); } + // -------------------------------------------------------------------- + /** Sets horizontal scroll speed. */ - void setScrollSpeed(float speed) - { - m_scroll_offset = 0; - m_scroll_speed = speed; - } // setScrollSpeed + void setScrollSpeed(float speed); + // -------------------------------------------------------------------- bool scrolledOff() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-03-25 15:37:58
|
Revision: 8059 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8059&view=rev Author: auria Date: 2011-03-25 15:37:52 +0000 (Fri, 25 Mar 2011) Log Message: ----------- Fixed text clipping issues (only if using irrlicht 1.8) Modified Paths: -------------- main/trunk/src/guiengine/widgets/icon_button_widget.cpp main/trunk/src/guiengine/widgets/label_widget.cpp Modified: main/trunk/src/guiengine/widgets/icon_button_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2011-03-25 11:23:17 UTC (rev 8058) +++ main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2011-03-25 15:37:52 UTC (rev 8059) @@ -20,6 +20,7 @@ #include "guiengine/scalable_font.hpp" #include "guiengine/widgets/icon_button_widget.hpp" #include "io/file_manager.hpp" +#include "utils/translation.hpp" using namespace GUIEngine; using namespace irr::video; @@ -135,6 +136,11 @@ { m_label->setOverrideFont( GUIEngine::getSmallFont() ); } + +#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8) + m_label->setRightToLeft( translations->isRTLLanguage() ); + m_label->setTextRestrainedInside(false); +#endif } // ---- IDs Modified: main/trunk/src/guiengine/widgets/label_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/label_widget.cpp 2011-03-25 11:23:17 UTC (rev 8058) +++ main/trunk/src/guiengine/widgets/label_widget.cpp 2011-03-25 15:37:52 UTC (rev 8059) @@ -74,6 +74,8 @@ } #if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8) irrwidget->setRightToLeft( translations->isRTLLanguage() ); + + irrwidget->setTextRestrainedInside(false); #endif m_element = irrwidget; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-04-08 15:00:55
|
Revision: 8263 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8263&view=rev Author: auria Date: 2011-04-08 15:00:49 +0000 (Fri, 08 Apr 2011) Log Message: ----------- Add private header from irrlicht, *hopefully* this fixes some issues Modified Paths: -------------- main/trunk/src/guiengine/widgets/text_box_widget.cpp Added Paths: ----------- main/trunk/src/guiengine/widgets/CGUIEditBox.h Added: main/trunk/src/guiengine/widgets/CGUIEditBox.h =================================================================== --- main/trunk/src/guiengine/widgets/CGUIEditBox.h (rev 0) +++ main/trunk/src/guiengine/widgets/CGUIEditBox.h 2011-04-08 15:00:49 UTC (rev 8263) @@ -0,0 +1,167 @@ +// Copyright (C) 2002-2011 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_EDIT_BOX_H_INCLUDED__ +#define __C_GUI_EDIT_BOX_H_INCLUDED__ + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_GUI_ + +#include "IGUIEditBox.h" +#include "irrArray.h" +#include "IOSOperator.h" + +namespace irr +{ +namespace gui +{ + class CGUIEditBox : public IGUIEditBox + { + public: + + //! constructor + CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment, + IGUIElement* parent, s32 id, const core::rect<s32>& rectangle); + + //! destructor + virtual ~CGUIEditBox(); + + //! Sets another skin independent font. + virtual void setOverrideFont(IGUIFont* font=0); + + //! Sets another color for the text. + virtual void setOverrideColor(video::SColor color); + + //! Gets the override color + virtual video::SColor const & getOverrideColor() const; + + //! Sets if the text should use the overide color or the + //! color in the gui skin. + virtual void enableOverrideColor(bool enable); + + //! Checks if an override color is enabled + /** \return true if the override color is enabled, false otherwise */ + virtual bool isOverrideColorEnabled(void) const; + + //! Turns the border on or off + virtual void setDrawBorder(bool border); + + //! Enables or disables word wrap for using the edit box as multiline text editor. + virtual void setWordWrap(bool enable); + + //! Checks if word wrap is enabled + //! \return true if word wrap is enabled, false otherwise + virtual bool isWordWrapEnabled() const; + + //! Enables or disables newlines. + /** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired, + instead a newline character will be inserted. */ + virtual void setMultiLine(bool enable); + + //! Checks if multi line editing is enabled + //! \return true if mult-line is enabled, false otherwise + virtual bool isMultiLineEnabled() const; + + //! Enables or disables automatic scrolling with cursor position + //! \param enable: If set to true, the text will move around with the cursor position + virtual void setAutoScroll(bool enable); + + //! Checks to see if automatic scrolling is enabled + //! \return true if automatic scrolling is enabled, false if not + virtual bool isAutoScrollEnabled() const; + + //! Gets the size area of the text in the edit box + //! \return Returns the size in pixels of the text + virtual core::dimension2du getTextDimension(); + + //! Sets text justification + virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical); + + //! called if an event happened. + virtual bool OnEvent(const SEvent& event); + + //! draws the element and its children + virtual void draw(); + + //! Sets the new caption of this element. + virtual void setText(const wchar_t* text); + + //! Sets the maximum amount of characters which may be entered in the box. + //! \param max: Maximum amount of characters. If 0, the character amount is + //! infinity. + virtual void setMax(u32 max); + + //! Returns maximum amount of characters, previously set by setMax(); + virtual u32 getMax() const; + + //! Sets whether the edit box is a password box. Setting this to true will + /** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x + \param passwordBox: true to enable password, false to disable + \param passwordChar: the character that is displayed instead of letters */ + virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*'); + + //! Returns true if the edit box is currently a password box. + virtual bool isPasswordBox() const; + + //! Updates the absolute position, splits text if required + virtual void updateAbsolutePosition(); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + protected: + //! Breaks the single text line. + void breakText(); + //! sets the area of the given line + void setTextRect(s32 line); + //! returns the line number that the cursor is on + s32 getLineFromPos(s32 pos); + //! adds a letter to the edit box + void inputChar(wchar_t c); + //! calculates the current scroll position + void calculateScrollPos(); + //! send some gui event to parent + void sendGuiEvent(EGUI_EVENT_TYPE type); + //! set text markers + void setTextMarkers(s32 begin, s32 end); + + bool processKey(const SEvent& event); + bool processMouse(const SEvent& event); + s32 getCursorPos(s32 x, s32 y); + + bool MouseMarking; + bool Border; + bool OverrideColorEnabled; + s32 MarkBegin; + s32 MarkEnd; + + video::SColor OverrideColor; + gui::IGUIFont *OverrideFont, *LastBreakFont; + IOSOperator* Operator; + + u32 BlinkStartTime; + s32 CursorPos; + s32 HScrollPos, VScrollPos; // scroll position in characters + u32 Max; + + bool WordWrap, MultiLine, AutoScroll, PasswordBox; + wchar_t PasswordChar; + EGUI_ALIGNMENT HAlign, VAlign; + + core::array< core::stringw > BrokenText; + core::array< s32 > BrokenTextPositions; + + core::rect<s32> CurrentTextRect, FrameRect; // temporary values + }; + + +} // end namespace gui +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_GUI_ +#endif // __C_GUI_EDIT_BOX_H_INCLUDED__ + Property changes on: main/trunk/src/guiengine/widgets/CGUIEditBox.h ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: main/trunk/src/guiengine/widgets/text_box_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/text_box_widget.cpp 2011-04-07 23:48:25 UTC (rev 8262) +++ main/trunk/src/guiengine/widgets/text_box_widget.cpp 2011-04-08 15:00:49 UTC (rev 8263) @@ -19,7 +19,7 @@ #include "guiengine/modaldialog.hpp" #include "guiengine/widgets/text_box_widget.hpp" -#include <CGUIEditBox.h> +#include "guiengine/widgets/CGUIEditBox.h" #include "utils/ptr_vector.hpp" using namespace irr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-04-12 23:09:40
|
Revision: 8315 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8315&view=rev Author: hikerstk Date: 2011-04-12 23:09:34 +0000 (Tue, 12 Apr 2011) Log Message: ----------- Fixed compiler warnings (STK time function used 64-bit ints, so that stk still works after 2037 or so :) ). Modified Paths: -------------- main/trunk/src/guiengine/widgets/CGUIEditBox.cpp main/trunk/src/guiengine/widgets/CGUIEditBox.h Modified: main/trunk/src/guiengine/widgets/CGUIEditBox.cpp =================================================================== --- main/trunk/src/guiengine/widgets/CGUIEditBox.cpp 2011-04-12 21:17:58 UTC (rev 8314) +++ main/trunk/src/guiengine/widgets/CGUIEditBox.cpp 2011-04-12 23:09:34 UTC (rev 8315) @@ -26,7 +26,7 @@ */ -u32 getTime() +Time::TimeType getTime() { return Time::getTimeSinceEpoch(); } Modified: main/trunk/src/guiengine/widgets/CGUIEditBox.h =================================================================== --- main/trunk/src/guiengine/widgets/CGUIEditBox.h 2011-04-12 21:17:58 UTC (rev 8314) +++ main/trunk/src/guiengine/widgets/CGUIEditBox.h 2011-04-12 23:09:34 UTC (rev 8315) @@ -10,6 +10,7 @@ #include "irrArray.h" #include "IOSOperator.h" +#include "utils/time.hpp" using namespace irr; using namespace gui; @@ -141,7 +142,7 @@ gui::IGUIFont *OverrideFont, *LastBreakFont; IOSOperator* Operator; - u32 BlinkStartTime; + Time::TimeType BlinkStartTime; s32 CursorPos; s32 HScrollPos, VScrollPos; // scroll position in characters u32 Max; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-05-17 01:15:28
|
Revision: 8620 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8620&view=rev Author: auria Date: 2011-05-17 01:15:21 +0000 (Tue, 17 May 2011) Log Message: ----------- make list header non-focusable for keyboard-only navigation Modified Paths: -------------- main/trunk/src/guiengine/widgets/button_widget.cpp main/trunk/src/guiengine/widgets/list_widget.cpp Modified: main/trunk/src/guiengine/widgets/button_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/button_widget.cpp 2011-05-17 01:06:12 UTC (rev 8619) +++ main/trunk/src/guiengine/widgets/button_widget.cpp 2011-05-17 01:15:21 UTC (rev 8620) @@ -33,7 +33,9 @@ { rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h); const stringw& message = getText(); - m_element = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, getNewID(), message.c_str(), L""); + m_element = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, + (m_reserved_id == -1 ? getNewID() : m_reserved_id), + message.c_str(), L""); m_id = m_element->getID(); m_element->setTabOrder(m_id); Modified: main/trunk/src/guiengine/widgets/list_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/list_widget.cpp 2011-05-17 01:06:12 UTC (rev 8619) +++ main/trunk/src/guiengine/widgets/list_widget.cpp 2011-05-17 01:15:21 UTC (rev 8620) @@ -98,6 +98,9 @@ name << n; ButtonWidget* header = new ButtonWidget(); + + header->m_reserved_id = getNewNoFocusID(); + header->m_y = m_y; header->m_h = header_height; @@ -109,7 +112,9 @@ header->add(); header->m_event_handler = this; - + + header->getIrrlichtElement()->setTabStop(false); + m_children.push_back(header); m_header_elements.push_back(header); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-02 22:34:34
|
Revision: 8805 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8805&view=rev Author: auria Date: 2011-06-02 22:34:28 +0000 (Thu, 02 Jun 2011) Log Message: ----------- Fixed various crashes related to having more players than karts Modified Paths: -------------- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp main/trunk/src/guiengine/widgets/ribbon_widget.hpp Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2011-06-02 13:39:34 UTC (rev 8804) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2011-06-02 22:34:28 UTC (rev 8805) @@ -526,7 +526,8 @@ return nothing; } // ----------------------------------------------------------------------------- -const irr::core::stringw& DynamicRibbonWidget::getSelectionText(const int playerID) + +irr::core::stringw DynamicRibbonWidget::getSelectionText(const int playerID) { RibbonWidget* row = (RibbonWidget*)(m_rows.size() == 1 ? m_rows.get(0) : getSelectedRibbon(playerID)); @@ -535,6 +536,7 @@ static const irr::core::stringw nothing = ""; return nothing; } + // ----------------------------------------------------------------------------- RibbonWidget* DynamicRibbonWidget::getRowContaining(Widget* w) { @@ -1009,7 +1011,7 @@ int row = -1; int id; - for (int r=0; r<m_row_amount; r++) + for (int r=0; r<m_rows.size(); r++) { id = m_rows[r].findItemNamed(name); if (id > -1) @@ -1032,9 +1034,10 @@ //printf("****DynamicRibbonWidget::setSelection()****\n"); + if ((unsigned int)item_id >= m_items.size()) return false; + m_selected_item[playerID] = item_id; - const std::string& name = m_items[item_id].m_code_name; int row; Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2011-06-02 13:39:34 UTC (rev 8804) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2011-06-02 22:34:28 UTC (rev 8805) @@ -239,7 +239,7 @@ const std::string& getSelectionIDString(const int playerID); /** Get the user-visible text of the selected item */ - const irr::core::stringw& getSelectionText(const int playerID); + irr::core::stringw getSelectionText(const int playerID); /** Returns a read-only list of items added to this ribbon */ const std::vector<ItemDescription>& getItems() const { return m_items; } Modified: main/trunk/src/guiengine/widgets/ribbon_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.hpp 2011-06-02 13:39:34 UTC (rev 8804) +++ main/trunk/src/guiengine/widgets/ribbon_widget.hpp 2011-06-02 22:34:28 UTC (rev 8805) @@ -115,7 +115,12 @@ const std::string& getSelectionIDString(const int playerID); /** Returns the user-visible text of the selection */ - const irr::core::stringw& getSelectionText(const int playerID) { return m_children[m_selection[playerID]].m_text; } + irr::core::stringw getSelectionText(const int playerID) + { + const int selection = m_selection[playerID]; + if (selection < 0 || selection >= m_children.size()) return ""; + return m_children[selection].m_text; + } /** Sets the ID of the selected item within the ribbon */ void setSelection(const int i, const int playerID) { m_selection[playerID] = i; updateSelection(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-09-30 01:07:12
|
Revision: 9919 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9919&view=rev Author: hikerstk Date: 2011-09-30 01:07:05 +0000 (Fri, 30 Sep 2011) Log Message: ----------- Besides some cosmetic changes added & to setSelection parameter. Modified Paths: -------------- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2011-09-29 23:03:00 UTC (rev 9918) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2011-09-30 01:07:05 UTC (rev 9919) @@ -1045,7 +1045,9 @@ // ----------------------------------------------------------------------------- -bool DynamicRibbonWidget::setSelection(int item_id, const int playerID, const bool focusIt, bool evenIfDeactivated) +bool DynamicRibbonWidget::setSelection(int item_id, const int playerID, + const bool focusIt, + bool evenIfDeactivated) { if (m_deactivated && !evenIfDeactivated) return false; @@ -1100,8 +1102,10 @@ propagateSelection(); return true; } -// ----------------------------------------------------------------------------- -bool DynamicRibbonWidget::setSelection(const std::string item_codename, const int playerID, const bool focusIt, bool evenIfDeactivated) +// ---------------------------------------------------------------------------- +bool DynamicRibbonWidget::setSelection(const std::string &item_codename, + const int playerID, const bool focusIt, + bool evenIfDeactivated) { if (m_deactivated && !evenIfDeactivated) return false; Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2011-09-29 23:03:00 UTC (rev 9918) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2011-09-30 01:07:05 UTC (rev 9919) @@ -39,8 +39,10 @@ { public: virtual ~DynamicRibbonHoverListener() {} - virtual void onSelectionChanged(DynamicRibbonWidget* theWidget, const std::string& selectionID, - const irr::core::stringw& selectionText, const int playerID) = 0; + virtual void onSelectionChanged(DynamicRibbonWidget* theWidget, + const std::string& selectionID, + const irr::core::stringw& selectionText, + const int playerID) = 0; }; /** The description of an item added to a DynamicRibbonWidget */ @@ -259,7 +261,9 @@ * * \return Whether setting the selection was successful (whether the item exists) */ - bool setSelection(const std::string item_codename, const int playerID, const bool focusIt, bool evenIfDeactivated=false); + bool setSelection(const std::string &item_codename, + const int playerID, const bool focusIt, + bool evenIfDeactivated=false); /** \brief Callback from parent class Widget. */ virtual void elementRemoved(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-10-18 11:00:03
|
Revision: 10008 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10008&view=rev Author: hikerstk Date: 2011-10-18 10:59:55 +0000 (Tue, 18 Oct 2011) Log Message: ----------- Cosmetic changes only. Modified Paths: -------------- main/trunk/src/guiengine/widgets/ribbon_widget.cpp main/trunk/src/guiengine/widgets/ribbon_widget.hpp Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2011-10-18 02:01:30 UTC (rev 10007) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2011-10-18 10:59:55 UTC (rev 10008) @@ -44,7 +44,7 @@ const char* RibbonWidget::NO_ITEM_ID = "?"; -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- RibbonWidget::RibbonWidget(const RibbonType type) : Widget(WTYPE_RIBBON) { @@ -62,10 +62,9 @@ m_supports_multiplayer = (type == RIBBON_TOOLBAR); updateSelection(); -} +} // RibbonWidget -// ----------------------------------------------------------------------------- - +// ---------------------------------------------------------------------------- void RibbonWidget::add() { m_labels.clearWithoutDeleting(); @@ -75,16 +74,19 @@ int id = (m_reserved_id == -1 ? getNewID() : m_reserved_id); - IGUIButton * btn = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, id, L""); + IGUIButton * btn = GUIEngine::getGUIEnv()->addButton(widget_size, + m_parent, id, L""); m_element = btn; const int subbuttons_amount = m_children.size(); - // For some ribbon types, we can have unequal sizes depending on whether items have labels or not + // For some ribbon types, we can have unequal sizes depending on whether + // items have labels or not int with_label = 0; int without_label = 0; - // ---- check how much space each child button will take and fit them within available space + // ---- check how much space each child button will take and fit + // them within available space int total_needed_space = 0; for (int i=0; i<subbuttons_amount; i++) { @@ -92,13 +94,16 @@ LayoutManager::readCoords(m_children.get(i)); LayoutManager::applyCoords(m_children.get(i), NULL, this); - if (m_children[i].m_type != WTYPE_ICON_BUTTON && m_children[i].m_type != WTYPE_BUTTON) + if (m_children[i].m_type != WTYPE_ICON_BUTTON && + m_children[i].m_type != WTYPE_BUTTON) { - fprintf(stderr, "/!\\ Warning /!\\ : ribbon widgets can only have (icon)button widgets as children\n"); + fprintf(stderr, "/!\\ Warning /!\\ : ribbon widgets can only have " + "(icon)button widgets as children\n"); continue; } - // ribbon children must not be keyboard navigatable, the parent ribbon takes care of that + // ribbon children must not be keyboard navigatable, the parent + // ribbon takes care of that if (m_children[i].m_type == WTYPE_ICON_BUTTON) { IconButtonWidget* icon = ((IconButtonWidget*)m_children.get(i)); @@ -122,7 +127,8 @@ global_zoom = (float)m_w / (float)( m_w - free_w_space + min_free_space ); //free_w_space = (int)(m_w - total_needed_space*global_zoom); - const int one_button_space = (int)round((float)m_w / (float)subbuttons_amount); + const int one_button_space = + (int)round((float)m_w / (float)subbuttons_amount); int widget_x = -1; @@ -163,14 +169,19 @@ if (m_children[i].m_type == WTYPE_BUTTON) { - subbtn = GUIEngine::getGUIEnv()->addButton(subsize, btn, getNewNoFocusID(), message.c_str(), L""); + subbtn = GUIEngine::getGUIEnv() + ->addButton(subsize, btn, getNewNoFocusID(), + message.c_str(), L""); subbtn->setTabStop(false); subbtn->setTabGroup(false); - if ((int)GUIEngine::getFont()->getDimension(message.c_str()).Width > subsize.getWidth() && - message.findFirst(L' ') == -1 && message.findFirst(L'\u00AD') == -1) + if ((int)GUIEngine::getFont()->getDimension(message.c_str()) + .Width > subsize.getWidth() && + message.findFirst(L' ') == -1 && + message.findFirst(L'\u00AD') == -1 ) { - // if message too long and contains no space and no soft hyphen, make the font smaller + // if message too long and contains no space and no soft + // hyphen, make the font smaller subbtn->setOverrideFont(GUIEngine::getSmallFont()); } } @@ -197,28 +208,38 @@ subsize.getWidth()-15, subsize.getHeight()); - // use the same ID for all subcomponents; since event handling is done per-ID, no matter - // which one your hover, this widget will get it + // use the same ID for all subcomponents; since event handling + // is done per-ID, no matter which one your hover, this + // widget will get it int same_id = getNewNoFocusID(); - subbtn = GUIEngine::getGUIEnv()->addButton(subsize, btn, same_id, L"", L""); + subbtn = GUIEngine::getGUIEnv()->addButton(subsize, btn, + same_id, L"", L""); - //MyGUIButton* icon = new MyGUIButton(GUIEngine::getGUIEnv(), subbtn, same_id, icon_part, true); - IGUIButton* icon = GUIEngine::getGUIEnv()->addButton(icon_part, subbtn, same_id, L""); + IGUIButton* icon = + GUIEngine::getGUIEnv()->addButton(icon_part, subbtn, + same_id, L""); icon->setScaleImage(true); - icon->setImage( irr_driver->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str()) ); + std::string filename = file_manager->getDataDir() + "/" + + m_children[i].m_properties[PROP_ICON]; + icon->setImage( irr_driver->getTexture(filename.c_str()) ); icon->setUseAlphaChannel(true); icon->setDrawBorder(false); icon->setTabStop(false); - IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), label_part, - false /* border */, - true /* word wrap */, - subbtn, same_id); + IGUIStaticText* label = + GUIEngine::getGUIEnv()->addStaticText(message.c_str(), + label_part, + false /* border */, + true /* word wrap */, + subbtn, same_id); - if ((int)GUIEngine::getFont()->getDimension(message.c_str()).Width > label_part.getWidth() && - message.findFirst(L' ') == -1 && message.findFirst(L'\u00AD') == -1) + if ((int)GUIEngine::getFont()->getDimension(message.c_str()) + .Width > label_part.getWidth()&& + message.findFirst(L' ') == -1 && + message.findFirst(L'\u00AD') == -1 ) { - // if message too long and contains no space and no soft hyphen, make the font smaller + // if message too long and contains no space and no soft + // hyphen, make the font smaller label->setOverrideFont(GUIEngine::getSmallFont()); } label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); @@ -248,12 +269,18 @@ // consider font size, whether the label is multiline, etc... const bool has_label = m_children[i].m_text.size() > 0; - const int needed_space_under_button = has_label ? GUIEngine::getFontHeight() : 10; + const int needed_space_under_button = has_label + ? GUIEngine::getFontHeight() + : 10; - float imageRatio = (float)m_children[i].m_w / (float)m_children[i].m_h; + float imageRatio = + (float)m_children[i].m_w / (float)m_children[i].m_h; // calculate the size of the image - video::ITexture* image = irr_driver->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str()); + std::string filename = file_manager->getDataDir()+"/" + + m_children[i].m_properties[PROP_ICON]; + video::ITexture* image = + irr_driver->getTexture((filename).c_str()); float image_h = (float)image->getSize().Height; float image_w = image_h*imageRatio; @@ -263,16 +290,19 @@ if (button_y + image_h*zoom + needed_space_under_button > m_h) { // scale down - while (button_y + image_h*zoom + needed_space_under_button > m_h) zoom -= 0.01f; + while (button_y + image_h*zoom + + needed_space_under_button > m_h) zoom -= 0.01f; } else { // scale up - while (button_y + image_h*zoom + needed_space_under_button < m_h) zoom += 0.01f; + while (button_y + image_h*zoom + + needed_space_under_button < m_h) zoom += 0.01f; } // ---- add bitmap button part - // backup and restore position in case the same object is added multiple times (FIXME: unclean) + // backup and restore position in case the same object is added + // multiple times (FIXME: unclean) int old_x = m_children[i].m_x; int old_y = m_children[i].m_y; int old_w = m_children[i].m_w; @@ -284,7 +314,8 @@ m_children[i].m_h = (int)(image_h*zoom); IconButtonWidget* icon = ((IconButtonWidget*)m_children.get(i)); - icon->m_properties[PROP_EXTEND_LABEL] = StringUtils::toString(one_button_space - icon->m_w); + icon->m_properties[PROP_EXTEND_LABEL] = + StringUtils::toString(one_button_space - icon->m_w); m_children.get(i)->m_parent = btn; m_children.get(i)->add(); @@ -295,14 +326,16 @@ m_children[i].m_w = old_w; m_children[i].m_h = old_h; - // the label itself will be added by the icon widget. since it adds the label outside of the - // widget area it is assigned to, the label will appear in the area we want at the bottom + // the label itself will be added by the icon widget. since it + // adds the label outside of the widget area it is assigned to, + // the label will appear in the area we want at the bottom widget_x += one_button_space; } else { - fprintf(stderr, "/!\\ Warning /!\\ : Invalid contents type in ribbon\n"); + fprintf(stderr, + "/!\\ Warning /!\\ : Invalid contents type in ribbon\n"); } @@ -314,9 +347,9 @@ m_element->setTabOrder(id); m_element->setTabGroup(false); updateSelection(); -} +} // add -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- void RibbonWidget::addTextChild(const wchar_t* text, const std::string id) { @@ -328,13 +361,14 @@ item->m_properties[PROP_ID] = id; m_children.push_back(item); -} +} // addTextChild -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- -void RibbonWidget::addIconChild(const wchar_t* text, const std::string id, - const int w, const int h, const std::string icon, - const IconButtonWidget::IconPathType iconPathType) +void RibbonWidget::addIconChild(const wchar_t* text, const std::string &id, + const int w, const int h, + const std::string &icon, + const IconButtonWidget::IconPathType icon_path_type) { // This method should only be called BEFORE a widget is added assert(m_element == NULL); @@ -343,16 +377,16 @@ ribbon_item->m_properties[PROP_ID] = id; - ribbon_item->setImage(icon.c_str(), iconPathType); + ribbon_item->setImage(icon.c_str(), icon_path_type); ribbon_item->m_properties[PROP_WIDTH] = StringUtils::toString(w); ribbon_item->m_properties[PROP_HEIGHT] = StringUtils::toString(h); ribbon_item->m_text = text; m_children.push_back(ribbon_item); -} +} // addIconChild -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- void RibbonWidget::clearAllChildren() { @@ -360,9 +394,9 @@ assert(m_element == NULL); m_children.clearAndDeleteAll(); -} +} // clearAllChildren -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- void RibbonWidget::select(std::string item, const int mousePlayerID) { @@ -378,20 +412,21 @@ } } -} -// ----------------------------------------------------------------------------- +} // select + +// ---------------------------------------------------------------------------- EventPropagation RibbonWidget::rightPressed(const int playerID) { if (m_deactivated) return EVENT_LET; - if (m_children.size() < 2) return EVENT_LET; // empty ribbon, or only one item (can't move right) + // empty ribbon, or only one item (can't move right) + if (m_children.size() < 2) return EVENT_LET; m_selection[playerID]++; if (m_selection[playerID] >= m_children.size()) { - if (m_listener != NULL) m_listener->onRibbonWidgetScroll(1); + if (m_listener != NULL) m_listener->onRibbonWidgetScroll(1); - if (m_event_handler != NULL) m_selection[playerID] = m_children.size()-1; - else m_selection[playerID] = 0; + m_selection[playerID] = m_event_handler ? m_children.size()-1 : 0; } updateSelection(); @@ -413,29 +448,24 @@ } } - if (m_ribbon_type != RIBBON_TOOLBAR) - { - //GUIEngine::transmitEvent( this, m_properties[PROP_ID], playerID ); - return EVENT_LET; - } - else - { - return EVENT_BLOCK; - } -} -// ----------------------------------------------------------------------------- + return m_ribbon_type != RIBBON_TOOLBAR ? EVENT_LET : EVENT_BLOCK; +} // rightPressed + +// ---------------------------------------------------------------------------- EventPropagation RibbonWidget::leftPressed(const int playerID) { if (m_deactivated) return EVENT_LET; - if (m_children.size() < 2) return EVENT_LET; // empty ribbon, or only one item (can't move left) + // empty ribbon, or only one item (can't move left) + if (m_children.size() < 2) return EVENT_LET; m_selection[playerID]--; if (m_selection[playerID] < 0) { - if (m_listener != NULL) m_listener->onRibbonWidgetScroll(-1); + if (m_listener != NULL) m_listener->onRibbonWidgetScroll(-1); - if (m_event_handler != NULL) m_selection[playerID] = 0; - else m_selection[playerID] = m_children.size()-1; + m_selection[playerID] = m_event_handler + ? 0 + : m_children.size()-1; } updateSelection(); @@ -463,9 +493,10 @@ { return EVENT_BLOCK; } -} -// ----------------------------------------------------------------------------- +} // leftPressed +// ---------------------------------------------------------------------------- + EventPropagation RibbonWidget::focused(const int playerID) { Widget::focused(playerID); @@ -486,20 +517,20 @@ return EVENT_LET; -} +} // focused -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- void RibbonWidget::unfocused(const int playerID) { -} +} // unfocused -// ----------------------------------------------------------------------------- -EventPropagation RibbonWidget::mouseHovered(Widget* child, const int mousePlayerID) +// ---------------------------------------------------------------------------- +EventPropagation RibbonWidget::mouseHovered(Widget* child, + const int mousePlayerID) { if (m_deactivated) return EVENT_LET; - //std::cout << "RibbonWidget::mouseHovered " << mousePlayerID << std::endl; const int subbuttons_amount = m_children.size(); if (m_ribbon_type == RIBBON_COMBO || m_ribbon_type == RIBBON_TABS) @@ -515,8 +546,10 @@ { if (m_children.get(i) == child) { - if (m_selection[mousePlayerID] == i) return EVENT_BLOCK; // was already selected, don't send another event - m_selection[mousePlayerID] = i; // don't change selection on hover for others + // Was already selected, don't send another event + if (m_selection[mousePlayerID] == i) return EVENT_BLOCK; + // Don't change selection on hover for others + m_selection[mousePlayerID] = i; break; } } @@ -524,9 +557,9 @@ updateSelection(); return EVENT_BLOCK; -} +} // mouseHovered -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- const std::string& RibbonWidget::getSelectionIDString(const int playerID) { static std::string empty; @@ -540,9 +573,9 @@ if(m_selection[playerID]>=m_children.size()) return m_children[0].m_properties[PROP_ID]; return m_children[m_selection[playerID]].m_properties[PROP_ID]; -} +} // getSelectionIDString -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- void RibbonWidget::updateSelection() { const int subbuttons_amount = m_children.size(); @@ -555,34 +588,17 @@ { for (int i=0; i<subbuttons_amount; i++) { - m_children[i].m_selected[p] = (i == m_selection[p]); - - /* - if (m_children[i].m_selected[p]) - std::cout << "m_children[" << i << "].m_selected[" << p << "] = " << m_children[i].m_selected[p] << std::endl; - if (p == 0 && m_children.get(i) == m_mouse_focus) - std::cout << "m_children[" << i << "] is mouse focus" << std::endl; - */ + m_children[i].m_selected[p] = (i == m_selection[p]); } } - - // Update the 'mouse focus' if necessary - /* - if (subbuttons_amount > 0 && m_ribbon_type == RIBBON_COMBO) - { - const int mousePlayerID = input_manager->getPlayerKeyboardID(); - if (mousePlayerID != -1 && m_selection[mousePlayerID] != -1) - { - m_mouse_focus = m_children.get(m_selection[mousePlayerID]); - std::cout << "RESET mouse focus\n"; - } - } - */ - + if (m_listener) m_listener->onSelectionChange(); -} -// ----------------------------------------------------------------------------- -EventPropagation RibbonWidget::transmitEvent(Widget* w, std::string& originator, const int playerID) +} // updateSelection + +// ---------------------------------------------------------------------------- +EventPropagation RibbonWidget::transmitEvent(Widget* w, + const std::string& originator, + const int playerID) { assert(m_magic_number == 0xCAFEC001); @@ -610,28 +626,32 @@ { if (m_children[m_selection[playerID]].m_deactivated) { - GUIEngine::getCurrentScreen()->onDisabledItemClicked(m_children[m_selection[playerID]].m_properties[PROP_ID]); + GUIEngine::getCurrentScreen()->onDisabledItemClicked( + m_children[m_selection[playerID]].m_properties[PROP_ID]); return EVENT_BLOCK; } } return EVENT_LET; -} -// ----------------------------------------------------------------------------- +} // transmitEvent + +// ---------------------------------------------------------------------------- void RibbonWidget::setLabel(const int id, irr::core::stringw new_name) { // This method should only be called AFTER a widget is added assert(m_element != NULL); + + // ignore this call for ribbons without labels + if (m_labels.size() == 0) return; - if (m_labels.size() == 0) return; // ignore this call for ribbons without labels - assert(id >= 0); assert(id < m_labels.size()); m_labels[id].setText( new_name.c_str() ); m_text = new_name; -} -// ----------------------------------------------------------------------------- +} // setLabel + +// ---------------------------------------------------------------------------- int RibbonWidget::findItemNamed(const char* internalName) { const int size = m_children.size(); @@ -640,8 +660,9 @@ for (int n=0; n<size; n++) { - //printf(" Ribbon : Looking for %s in item %i : %s\n", internalName, n, m_children[n].m_properties[PROP_ID].c_str()); + //printf(" Ribbon : Looking for %s in item %i : %s\n", + // internalName, n, m_children[n].m_properties[PROP_ID].c_str()); if (m_children[n].m_properties[PROP_ID] == internalName) return n; } return -1; -} +} // findItemNamed Modified: main/trunk/src/guiengine/widgets/ribbon_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.hpp 2011-10-18 02:01:30 UTC (rev 10007) +++ main/trunk/src/guiengine/widgets/ribbon_widget.hpp 2011-10-18 10:59:55 UTC (rev 10008) @@ -42,8 +42,9 @@ /** \brief A static text/icons/tabs bar widget. * The contents of this ribbon are static. * \ingroup widgets - * \note items you add to a list are kept after the the ribbon was in is removed - * (i.e. you don't need to add items everytime the screen is shown, only upon loading) + * \note items you add to a list are kept after the the ribbon was in + * is removed (i.e. you don't need to add items everytime the + * screen is shown, only upon loading) */ class RibbonWidget : public Widget { @@ -53,7 +54,8 @@ public: virtual ~IRibbonListener(){} virtual void onRibbonWidgetScroll(const int delta_x) = 0; - virtual void onRibbonWidgetFocus(RibbonWidget* emitter, const int playerID) = 0; + virtual void onRibbonWidgetFocus(RibbonWidget* emitter, + const int playerID) = 0; virtual void onSelectionChange() = 0; }; @@ -66,16 +68,19 @@ /** The type of this ribbon (toolbar, combo, tabs) */ RibbonType m_ribbon_type; - /** Each item within the ribbon holds a flag saying whether it is selected or not. - This method updates the flag in all of this ribbon's children. Called everytime - selection changes.*/ + /** Each item within the ribbon holds a flag saying whether it is + * selected or not. This method updates the flag in all of this + * ribbon's children. Called everytime selection changes.*/ void updateSelection(); /** Callbacks */ virtual EventPropagation rightPressed(const int playerID=0); virtual EventPropagation leftPressed(const int playerID=0); - virtual EventPropagation mouseHovered(Widget* child, const int playerID); - virtual EventPropagation transmitEvent(Widget* w, std::string& originator, const int playerID=0); + virtual EventPropagation mouseHovered(Widget* child, + const int playerID); + virtual EventPropagation transmitEvent(Widget* w, + const std::string& originator, + const int playerID=0); virtual EventPropagation focused(const int playerID); virtual void unfocused(const int playerID); @@ -88,15 +93,16 @@ LEAK_CHECK() - /** - * Internal identifier of filler items that are added in a ribbon widget to fill - * lines when the number of items cannot be divided by the number of rows in the grid - * (mostly used by dynamic ribbon widgets, but the base ribbon needs to know about filler items) + /** Internal identifier of filler items that are added in a ribbon + * widget to filllines when the number of items cannot be divided + * by the number of rows in the grid (mostly used by dynamic ribbon + * widgets, but the base ribbon needs to know about filler items) */ static const char* NO_ITEM_ID; - /** Contains which element within the ribbon is currently focused by player 0 (used by the skin to - show mouse hovers over items that are not selected). Only used for COMBO and TAB ribbons. */ + /** Contains which element within the ribbon is currently focused by + * player 0 (used by the skin to show mouse hovers over items that + * are not selected). Only used for COMBO and TAB ribbons. */ Widget* m_mouse_focus; RibbonWidget(const RibbonType type=RIBBON_COMBO); @@ -105,19 +111,22 @@ void add(); /** Sets a listener that will be notified of changes on this ribbon. - * Does _not_ take ownership of the listener, i.e. will not delete it. - * You may call this with the listener parameter set to NULL to remove the listener. */ + * Does _not_ take ownership of the listener, i.e. will not delete it. + * You may call this with the listener parameter set to NULL to + * remove the listener. */ void setListener(IRibbonListener* listener) { m_listener = listener; } - - /** Returns the type of this ribbon (see the GUI module overview page for detailed descriptions) */ + // -------------------------------------------------------------------- + /** Returns the type of this ribbon (see the GUI module overview page + * for detailed descriptions) */ RibbonType getRibbonType() const { return m_ribbon_type; } - + // -------------------------------------------------------------------- /** Returns the numerical ID of the selected item within the ribbon */ - int getSelection(const int playerID) const { return m_selection[playerID]; } - + int getSelection(const int playerID) const + { return m_selection[playerID]; } + // -------------------------------------------------------------------- /** Returns the string ID (internal name) of the selection */ const std::string& getSelectionIDString(const int playerID); - + // -------------------------------------------------------------------- /** Returns the user-visible text of the selection */ irr::core::stringw getSelectionText(const int playerID) { @@ -125,9 +134,11 @@ if (selection < 0 || selection >= m_children.size()) return ""; return m_children[selection].m_text; } - + // -------------------------------------------------------------------- + /** Sets the ID of the selected item within the ribbon */ - void setSelection(const int i, const int playerID) { m_selection[playerID] = i; updateSelection(); } + void setSelection(const int i, const int playerID) + { m_selection[playerID] = i; updateSelection(); } /** Select an item in the ribbon by its internal name */ void select(std::string item, const int playerID); @@ -144,20 +155,24 @@ /** Returns the ID of the item, or -1 if not found */ int findItemNamed(const char* internalName); - /** \brief dynamically (at runtime) add a text item to this ribbon - * \pre this must be called before RibbonWidget::add, while the widget is not yet displayed - * \pre only valid for ribbons that take text-only contents (e.g. tab bars) + /** \brief Dynamically (at runtime) add a text item to this ribbon + * \pre This must be called before RibbonWidget::add, while the + * widget is not yet displayed + * \pre only valid for ribbons that take text-only contents + * (e.g. tab bars) */ void addTextChild(const wchar_t* text, const std::string id); - /** \brief dynamically (at runtime) add an icon item to this ribbon - * \pre this must be called before RibbonWidget::add, while the widget is not yet displayed + /** \brief Dynamically (at runtime) add an icon item to this ribbon. + * \pre this must be called before RibbonWidget::add, while the widget + * is not yet displayed * \pre only valid for ribbons that take icon contents */ - void addIconChild(const wchar_t* text, const std::string id, - const int w, const int h, const std::string icon, - const IconButtonWidget::IconPathType iconPathType=IconButtonWidget::ICON_PATH_TYPE_RELATIVE); + void addIconChild(const wchar_t* text, const std::string &id, + const int w, const int h, const std::string &icon, + const IconButtonWidget::IconPathType iconPathType= + IconButtonWidget::ICON_PATH_TYPE_RELATIVE); /** * \brief clear all children of this ribbon (likely because new ones will be added soon after) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-11-20 00:15:54
|
Revision: 10229 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10229&view=rev Author: auria Date: 2011-11-20 00:15:47 +0000 (Sun, 20 Nov 2011) Log Message: ----------- Apply patch by winterheart to build with latest irrlicht SVN. Yes, this means you need to update to latest irrlicht :) Modified Paths: -------------- main/trunk/src/guiengine/widgets/CGUIEditBox.cpp main/trunk/src/guiengine/widgets/CGUIEditBox.h Modified: main/trunk/src/guiengine/widgets/CGUIEditBox.cpp =================================================================== --- main/trunk/src/guiengine/widgets/CGUIEditBox.cpp 2011-11-19 23:41:26 UTC (rev 10228) +++ main/trunk/src/guiengine/widgets/CGUIEditBox.cpp 2011-11-20 00:15:47 UTC (rev 10229) @@ -115,7 +115,7 @@ } -video::SColor const& CGUIEditBox::getOverrideColor() const +video::SColor CGUIEditBox::getOverrideColor() const { return OverrideColor; } Modified: main/trunk/src/guiengine/widgets/CGUIEditBox.h =================================================================== --- main/trunk/src/guiengine/widgets/CGUIEditBox.h 2011-11-19 23:41:26 UTC (rev 10228) +++ main/trunk/src/guiengine/widgets/CGUIEditBox.h 2011-11-20 00:15:47 UTC (rev 10229) @@ -36,7 +36,7 @@ virtual void setOverrideColor(video::SColor color); //! Gets the override color - virtual video::SColor const & getOverrideColor() const; + virtual video::SColor getOverrideColor() const; //! Sets if the text should use the overide color or the //! color in the gui skin. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |