Fixed glitch with "selection bubble"

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4321 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-12-19 18:49:06 +00:00
parent 5fe41e5625
commit 542320a2e6
2 changed files with 13 additions and 8 deletions

View File

@ -103,7 +103,7 @@ when the border that intersect at this corner are enabled.
left_border="6" right_border ="6" top_border="6" bottom_border="6" left_border="6" right_border ="6" top_border="6" bottom_border="6"
hborder_out_portion="1.0" /> hborder_out_portion="1.0" />
<!-- Stateless. No splitting into 9 areas is done; the image is just stretched. --> <!-- Stateless. No splitting into 9 areas is done; the image is just resized. -->
<element type="selectionHalo" image="glass/bubble.png" /> <element type="selectionHalo" image="glass/bubble.png" />
<element type="focusHalo" image="glass/glass_iconhighlight_focus.png" /> <element type="focusHalo" image="glass/glass_iconhighlight_focus.png" />

View File

@ -684,22 +684,27 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
const bool mark_focused = focused || (parent_focused && w != NULL && w->m_mouse_focus == widget) || const bool mark_focused = focused || (parent_focused && w != NULL && w->m_mouse_focus == widget) ||
(mark_selected && !always_show_selection && parent_focused); (mark_selected && !always_show_selection && parent_focused);
/* draw "selection bubble" if relevant */
if (always_show_selection && mark_selected) if (always_show_selection && mark_selected)
{ {
core::rect< s32 > rect2 = rect;
rect2.UpperLeftCorner.X -= rect.getWidth() / 5;
rect2.UpperLeftCorner.Y -= rect.getHeight() / 5;
rect2.LowerRightCorner.X += rect.getWidth() / 5;
rect2.LowerRightCorner.Y += rect.getHeight() / 5;
ITexture* tex_bubble = SkinConfig::m_render_params["selectionHalo::neutral"].getImage(); ITexture* tex_bubble = SkinConfig::m_render_params["selectionHalo::neutral"].getImage();
const int texture_w = tex_bubble->getSize().Width; const int texture_w = tex_bubble->getSize().Width;
const int texture_h = tex_bubble->getSize().Height; const int texture_h = tex_bubble->getSize().Height;
const float aspectRatio = (float)texture_w / (float)texture_h;
core::rect<s32> source_area = core::rect<s32>(0, 0, texture_w, texture_h); core::rect<s32> source_area = core::rect<s32>(0, 0, texture_w, texture_h);
const float outgrow = 0.35f; // make slightly bigger than the icon it's on
const int rectHeight = rect.getHeight() * (1.0f + outgrow);
const int rectWidth = rectHeight * aspectRatio;
const int x_gap = (rect.getWidth() - rectWidth)/2;
const int y_shift_up = rect.getHeight() * (outgrow/2.0f);
core::rect< s32 > rect2( position2d< s32 >(rect.UpperLeftCorner.X + x_gap,
rect.UpperLeftCorner.Y - y_shift_up),
dimension2d< s32 >(rectWidth, rectHeight) );
GUIEngine::getDriver()->draw2DImage(tex_bubble, rect2, source_area, GUIEngine::getDriver()->draw2DImage(tex_bubble, rect2, source_area,
0 /* no clipping */, 0, true /* alpha */); 0 /* no clipping */, 0, true /* alpha */);
} }