From c54a87d6a1bf30af1a7262a67400eccb9b6dc00a Mon Sep 17 00:00:00 2001 From: auria Date: Thu, 16 Apr 2009 00:05:16 +0000 Subject: [PATCH] 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 --- src/gui/skin.cpp | 32 ++++++++++++++++++++++++++++++-- src/gui/skin.hpp | 2 +- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp index f1f75a174..d668edf0a 100644 --- a/src/gui/skin.cpp +++ b/src/gui/skin.cpp @@ -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); } diff --git a/src/gui/skin.hpp b/src/gui/skin.hpp index 55ec19f99..e04f0c226 100644 --- a/src/gui/skin.hpp +++ b/src/gui/skin.hpp @@ -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);