From: <au...@us...> - 2009-12-30 18:08:32
|
Revision: 4367 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4367&view=rev Author: auria Date: 2009-12-30 18:08:23 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Added support for multi-line ribbon labels (it doesn't look sexy atm, but fixes unreadable text issues) Modified Paths: -------------- main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2009-12-30 18:00:23 UTC (rev 4366) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2009-12-30 18:08:23 UTC (rev 4367) @@ -22,6 +22,8 @@ #include "io/file_manager.hpp" #include "utils/string_utils.hpp" +#include <cmath> + using namespace GUIEngine; using namespace irr::core; using namespace irr::gui; @@ -159,8 +161,16 @@ { // how much space to keep for the label under the button const bool has_label = m_children[i].m_text.size() > 0; - const int needed_space_under_button = has_label ? GUIEngine::getFontHeight() : 10; + int line_number = 1; + core::dimension2d< u32 > dim = GUIEngine::getFont()->getDimension( m_children[i].m_text.c_str() ); + if ((int)dim.Width > one_button_space) + { + line_number = std::ceil((float)dim.Width/(float)one_button_space); + } + + const int needed_space_under_button = has_label ? GUIEngine::getFontHeight()*line_number : 10; + float imageRatio = (float)m_children[i].w/(float)m_children[i].h; // size of the image @@ -204,28 +214,8 @@ m_children[i].w = old_w; m_children[i].h = old_h; - // ---- label part - /* - if (has_label) - { - subsize = rect<s32>(widget_x - one_button_space/2, - (int)((button_y + m_children[i].h)*zoom) + 5, // leave 5 pixels between button and label - widget_x + (int)(one_button_space/2.0f), h); - - stringw& message = m_children[i].m_text; - IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), subsize, false, true, btn); - label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); - label->setTabStop(false); - label->setNotClipped(true); - - m_labels.push_back(label); - - const int final_y = subsize.getHeight() + label->getTextHeight(); - if(final_y > biggest_y) biggest_y = final_y; - } - */ - //subbtn->setTabStop(false); - //subbtn->setTabGroup(false); + // 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 } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-30 18:14:13
|
Revision: 4368 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4368&view=rev Author: auria Date: 2009-12-30 18:14:05 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Cleanup in ribbon code Modified Paths: -------------- main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2009-12-30 18:08:23 UTC (rev 4367) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2009-12-30 18:14:05 UTC (rev 4368) @@ -159,24 +159,24 @@ // ---- non-tabs ribbons else if (m_children[i].m_type == WTYPE_ICON_BUTTON) { - // how much space to keep for the label under the button + // find how much space to keep for the label under the button. + // consider font size, whether the label is multiline, etc... const bool has_label = m_children[i].m_text.size() > 0; - int line_number = 1; + int line_count = 1; core::dimension2d< u32 > dim = GUIEngine::getFont()->getDimension( m_children[i].m_text.c_str() ); if ((int)dim.Width > one_button_space) { - line_number = std::ceil((float)dim.Width/(float)one_button_space); + line_count = std::ceil((float)dim.Width/(float)one_button_space); } - const int needed_space_under_button = has_label ? GUIEngine::getFontHeight()*line_number : 10; + const int needed_space_under_button = has_label ? GUIEngine::getFontHeight()*line_count : 10; float imageRatio = (float)m_children[i].w/(float)m_children[i].h; - // size of the image + // calculate the size of the image video::ITexture* image = GUIEngine::getDriver()->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str()); float image_h = (float)image->getSize().Height; - //float image_w = (float)image->getSize().Width; float image_w = image_h*imageRatio; // if button too high to fit, scale down @@ -184,9 +184,6 @@ while (button_y + image_h*zoom + needed_space_under_button > h) zoom -= 0.01f; // ---- add bitmap button part - //rect<s32> subsize = rect<s32>(widget_x - (int)(image_w/2.0f), button_y, - // widget_x + (int)(image_w/2.0f), button_y + (int)(m_children[i].h*zoom)); - // backup and restore position in case the same object is added multiple times (FIXME: unclean) int old_x = m_children[i].x; int old_y = m_children[i].y; @@ -198,17 +195,13 @@ m_children[i].w = (int)(image_w*zoom); m_children[i].h = (int)(image_h*zoom); - //std::wcout << L"Widget has text '" << m_children[i].m_text.c_str() << "'\n"; - IconButtonWidget* icon = ((IconButtonWidget*)m_children.get(i)); - //std::cout << "Setting PROP_EXTEND_LABEL to " << (one_button_space - icon->w) << std::endl; icon->m_properties[PROP_EXTEND_LABEL] = StringUtils::toString(one_button_space - icon->w); m_children.get(i)->m_parent = btn; m_children.get(i)->add(); - //subbtn->setUseAlphaChannel(true); - //subbtn->setImage( GUIEngine::getDriver()->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str()) ); - + + // restore backuped size and location (see above for more info) m_children[i].x = old_x; m_children[i].y = old_y; m_children[i].w = old_w; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2013-11-21 00:15:02
|
Revision: 14506 http://sourceforge.net/p/supertuxkart/code/14506 Author: auria Date: 2013-11-21 00:14:57 +0000 (Thu, 21 Nov 2013) Log Message: ----------- Fix crash on empty ribbons, required for what's coming next Modified Paths: -------------- main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2013-11-20 22:37:12 UTC (rev 14505) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2013-11-21 00:14:57 UTC (rev 14506) @@ -583,7 +583,7 @@ { if (new_focus != NULL && new_focus != this && !m_children.contains(new_focus)) { - if (m_selection[playerID] != -1) + if (m_selection[playerID] >= 0 && m_selection[playerID] < m_children.size()) { m_children.get(m_selection[playerID])->unfocused(playerID, new_focus); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-01-13 00:56:38
|
Revision: 4445 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4445&view=rev Author: auria Date: 2010-01-13 00:56:31 +0000 (Wed, 13 Jan 2010) Log Message: ----------- Fixed warning Modified Paths: -------------- main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-01-12 23:13:38 UTC (rev 4444) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-01-13 00:56:31 UTC (rev 4445) @@ -103,7 +103,7 @@ if (getRibbonType() == RIBBON_TABS) { - IGUIButton * subbtn; + IGUIButton * subbtn = NULL; rect<s32> subsize = rect<s32>(widget_x - one_button_space/2+2, 0, widget_x + one_button_space/2-2, h); @@ -153,6 +153,10 @@ subbtn->setTabGroup(false); } + else + { + std::cerr << "Invalid tab bar contents\n"; + } m_children[i].m_element = subbtn; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-04-30 01:29:03
|
Revision: 5322 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5322&view=rev Author: auria Date: 2010-04-30 01:28:57 +0000 (Fri, 30 Apr 2010) Log Message: ----------- Fixed crash when pressing left/right on an empty row of a ribbon (more work later to avoid letting the user focus ever go on an empty row...) Modified Paths: -------------- main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-04-30 01:16:27 UTC (rev 5321) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2010-04-30 01:28:57 UTC (rev 5322) @@ -308,7 +308,8 @@ 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) + m_selection[playerID]++; if (m_selection[playerID] >= m_children.size()) { @@ -328,11 +329,14 @@ } } - // if we reached a filler item, move again + // if we reached a filler item, move again (but don't warp) // FIXME: why is a constant from DynamicRibbon used here?? if (getSelectionIDString(playerID) == DynamicRibbonWidget::NO_ITEM_ID) { - rightPressed(playerID); + if (m_selection[playerID] + 1 < m_children.size()) + { + rightPressed(playerID); + } } if (m_ribbon_type != RIBBON_TOOLBAR) @@ -349,7 +353,8 @@ 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) + m_selection[playerID]--; if (m_selection[playerID] < 0) { @@ -369,10 +374,10 @@ } } - // if we reached a filler item, move again + // if we reached a filler item, move again (but don't warp) if (getSelectionIDString(playerID) == DynamicRibbonWidget::NO_ITEM_ID) { - leftPressed(playerID); + if (m_selection[playerID] > 0) leftPressed(playerID); } if (m_ribbon_type != RIBBON_TOOLBAR) 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:19:03
|
Revision: 8316 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8316&view=rev Author: hikerstk Date: 2011-04-12 23:18:57 +0000 (Tue, 12 Apr 2011) Log Message: ----------- Fixed crash in kart selection screen that happens if an addon tab was selected previously, then that group is removed (by deinstalling its contents with the addon manager). The gui code tried then to access the previously selected tab, which doesn't exist anymore. Now it will fall back to use the first element (which at this stage is sure to exist). Modified Paths: -------------- main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2011-04-12 23:09:34 UTC (rev 8315) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2011-04-12 23:18:57 UTC (rev 8316) @@ -513,7 +513,13 @@ static std::string empty; if (m_selection[playerID] == -1) return empty; if (m_children.size() == 0) return empty; - + + // This can happen if an addon is removed, which causes a tab group + // to be removed. If this tab group was previously selected, an + // invalid array element would be accessed. In this case just pretend + // that the first child was selected previously. + 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]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-04-26 17:39:13
|
Revision: 8465 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8465&view=rev Author: auria Date: 2011-04-26 17:39:07 +0000 (Tue, 26 Apr 2011) Log Message: ----------- Fixed disabled ribbon items can be accessed anyway if you use keyboard and not mouse Modified Paths: -------------- main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2011-04-26 17:22:11 UTC (rev 8464) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2011-04-26 17:39:07 UTC (rev 8465) @@ -586,6 +586,11 @@ // bring focus back to enclosing ribbon widget this->setFocusForPlayer( playerID ); + if (m_selection[playerID] != -1) + { + if (m_children[m_selection[playerID]].m_deactivated) return EVENT_BLOCK; + } + return EVENT_LET; } // ----------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-09-06 15:54:37
|
Revision: 9775 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9775&view=rev Author: auria Date: 2011-09-06 15:54:30 +0000 (Tue, 06 Sep 2011) Log Message: ----------- Improve handling on long strings in tabs Modified Paths: -------------- main/trunk/src/guiengine/widgets/ribbon_widget.cpp Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2011-09-06 12:45:43 UTC (rev 9774) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2011-09-06 15:54:30 UTC (rev 9775) @@ -166,6 +166,13 @@ 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 message too long and contains no space and no soft hyphen, make the font smaller + subbtn->setOverrideFont(GUIEngine::getSmallFont()); + } } else if (m_children[i].m_type == WTYPE_ICON_BUTTON) { @@ -207,6 +214,13 @@ 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 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); label->setTabStop(false); label->setNotClipped(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |