From 0efd96d8da67b19f8ad8b53df4d68eb473842b5f Mon Sep 17 00:00:00 2001 From: auria Date: Sun, 7 Mar 2010 00:36:38 +0000 Subject: [PATCH] Fixed '?' icons still appearing at times in ribbons git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4948 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/guiengine/widgets/dynamic_ribbon_widget.cpp | 6 +++--- src/guiengine/widgets/ribbon_widget.cpp | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.cpp b/src/guiengine/widgets/dynamic_ribbon_widget.cpp index 52165fead..6cdffa52c 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.cpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.cpp @@ -142,7 +142,7 @@ void DynamicRibbonWidget::add() // ---- 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 @@ void DynamicRibbonWidget::setSubElements() // 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 @@ void DynamicRibbonWidget::updateItemDisplay() } 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 diff --git a/src/guiengine/widgets/ribbon_widget.cpp b/src/guiengine/widgets/ribbon_widget.cpp index 0a1892ced..26e5677d9 100644 --- a/src/guiengine/widgets/ribbon_widget.cpp +++ b/src/guiengine/widgets/ribbon_widget.cpp @@ -186,9 +186,19 @@ void RibbonWidget::add() 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)