From 56f77a2d490068aa5e18e3d01fa030a3e4ced08f Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 27 Mar 2010 18:49:35 +0000 Subject: [PATCH] Render scrollbar in some way (not skinnable yet) when the list of players is very long git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5083 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/guiengine/skin.cpp | 49 +++++++++++++++++++++++++++++++++++++++--- src/guiengine/skin.hpp | 5 +++++ 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp index 3f1d8d803..814b3c072 100644 --- a/src/guiengine/skin.cpp +++ b/src/guiengine/skin.cpp @@ -1089,6 +1089,27 @@ void Skin::renderSections(ptr_vector* within_vector) } +void Skin::drawScrollbarBackground(const irr::core::rect< irr::s32 > &rect) +{ + //TODO: allow skinning scrollbar + GUIEngine::getDriver()->draw2DRectangle( video::SColor(255,200,200,200), rect ); +} + +void Skin::drawScrollbarThumb(const irr::core::rect< irr::s32 > &rect) +{ + //TODO: allow skinning scrollbar + GUIEngine::getDriver()->draw2DRectangle( video::SColor(255,0,150,0), rect ); +} + +void Skin::drawScrollbarButton(const irr::core::rect< irr::s32 > &rect, const bool pressed) +{ + //TODO: allow skinning scrollbar + GUIEngine::getDriver()->draw2DRectangle( (pressed ? + video::SColor(255, 0, 175, 0) : + video::SColor(255, 150, 150, 150)), + rect ); +} + #if 0 #pragma mark - #pragma mark irrlicht skin functions @@ -1098,6 +1119,12 @@ void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, co { if (GUIEngine::getStateManager()->getGameState() == GUIEngine::GAME) return; // ignore in game mode + if (element->getType()==gui::EGUIET_SCROLL_BAR) + { + drawScrollbarBackground(rect); + return; + } + const int id = element->getID(); Widget* widget = GUIEngine::getWidget(id); @@ -1107,7 +1134,7 @@ void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, co const bool focused = GUIEngine::isFocusedForPlayer(widget, playerID); const WidgetType type = widget->m_type; - if(type == WTYPE_LIST) + if (type == WTYPE_LIST) { // list selection background drawListSelection(rect, widget, focused); @@ -1123,7 +1150,16 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co Widget* widget = NULL; if (id != -1) widget = GUIEngine::getWidget(id); - if (widget == NULL) return; + if (widget == NULL) + { + if (element->getType() == gui::EGUIET_BUTTON && element->getParent() != NULL && + element->getParent()->getType() == EGUIET_SCROLL_BAR) + { + drawScrollbarButton(rect, pressed); + } + + return; + } const int playerID = 0; // FIXME: don't hardcode player 0? const bool focused = GUIEngine::isFocusedForPlayer(widget, playerID); @@ -1252,7 +1288,14 @@ void Skin::draw3DButtonPanePressed (IGUIElement *element, const core::rect< s32 void Skin::draw3DButtonPaneStandard (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip) { - process3DPane(element, rect, false /* pressed */ ); + if (element->getType()==gui::EGUIET_SCROLL_BAR) + { + drawScrollbarThumb(rect); + } + else + { + process3DPane(element, rect, false /* pressed */ ); + } } // ----------------------------------------------------------------------------- diff --git a/src/guiengine/skin.hpp b/src/guiengine/skin.hpp index 3cea317f4..dc3ede43e 100644 --- a/src/guiengine/skin.hpp +++ b/src/guiengine/skin.hpp @@ -233,7 +233,12 @@ namespace GUIEngine void drawListSelection(const irr::core::rect< irr::s32 > &rect, Widget* widget, bool focused); void drawIconButton(const irr::core::rect< irr::s32 > &rect, Widget* widget, const bool pressed, bool focused); + void drawScrollbarBackground(const irr::core::rect< irr::s32 > &rect); + void drawScrollbarThumb(const irr::core::rect< irr::s32 > &rect); + void drawScrollbarButton(const irr::core::rect< irr::s32 > &rect, const bool pressed); + public: + // dirty way to have dialogs that zoom in bool m_dialog; float m_dialog_size;