Fixed clicking spinner arrows

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3387 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-16 00:05:16 +00:00
parent d6bb49e492
commit c54a87d6a1
2 changed files with 31 additions and 3 deletions

View File

@ -391,7 +391,7 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
}
void Skin::drawSpinnerBody(const core::rect< s32 > &rect, const Widget* widget, const bool pressed, const bool focused)
void Skin::drawSpinnerBody(const core::rect< s32 > &rect, const Widget* widget, const bool pressed, bool focused)
{
// FIXME - move these numbers to a config file
const int left_border = 110;
@ -399,6 +399,34 @@ void Skin::drawSpinnerBody(const core::rect< s32 > &rect, const Widget* widget,
const int border_above = 0;
const int border_below = 36;
if(!focused)
{
IGUIElement* focused_widget = GUIEngine::getGUIEnv()->getFocus();
//{
//Widget* widget = GUIEngine::getCurrentScreen()->getWidget(focused_widget->getID());
//if(focused_widget == NULL) std::cout << "no focus\n";
//else if(widget != NULL)
//{
// std::cout << "focused : " << widget->m_properties[PROP_ID].c_str() << " (id " << focused_widget->getID() << ")" << std::endl;
//}
//}
//Widget* stupid_stl = (Widget*)widget;
//std::cout << "widget name : " << (stupid_stl->m_properties[PROP_ID].c_str()) << std::endl;
if(focused_widget != NULL && widget->m_children.size()>2)
{
//std::cout << "checking against " << widget->m_children[0].id << " and " << widget->m_children[2].id << std::endl;
if(widget->m_children[0].id == focused_widget->getID() ||
widget->m_children[2].id == focused_widget->getID())
{
//std::cout << "focused = true;\n";
focused = true;
}
}
}
drawBoxFromStretchableTexture(rect, (focused || pressed ? m_tex_fspinner : m_tex_spinner),
left_border, right_border,
border_above, border_below, 0);
@ -479,7 +507,7 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
{
drawRibbon(rect, widget, pressed, focused);
}
else if(widget->m_type == WTYPE_SPINNER)
else if(type == WTYPE_SPINNER)
{
drawSpinnerBody(rect, widget, pressed, focused);
}

View File

@ -53,7 +53,7 @@ public:
void drawRibbon(const core::rect< s32 > &rect, const Widget* widget, const bool pressed, bool focused);
void drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget, const bool pressed, bool focused);
void drawSpinnerChild(const core::rect< s32 > &rect, Widget* widget, const bool pressed, bool focused);
void drawSpinnerBody(const core::rect< s32 > &rect, const Widget* widget, const bool pressed, const bool focused);
void drawSpinnerBody(const core::rect< s32 > &rect, const Widget* widget, const bool pressed, bool focused);
// irrlicht's callbacks
virtual void draw2DRectangle (IGUIElement *element, const video::SColor &color, const core::rect< s32 > &pos, const core::rect< s32 > *clip);