From de492f69dcc704b1e93e8eee8b79adaef6886dd6 Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 31 Oct 2009 21:43:39 +0000 Subject: [PATCH] Fixed list navigation and ribbon selection in input option screens git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4181 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/guiengine/widget.cpp | 54 +++++++++++++-------- src/guiengine/widget.hpp | 2 +- src/guiengine/widgets/list_widget.cpp | 15 ++++++ src/guiengine/widgets/list_widget.hpp | 2 + src/guiengine/widgets/model_view_widget.cpp | 5 ++ 5 files changed, 56 insertions(+), 22 deletions(-) diff --git a/src/guiengine/widget.cpp b/src/guiengine/widget.cpp index 36e0bd9c9..e76ad9c57 100644 --- a/src/guiengine/widget.cpp +++ b/src/guiengine/widget.cpp @@ -42,27 +42,6 @@ using namespace gui; namespace GUIEngine { - -// ----------------------------------------------------------------------------- -static unsigned int id_counter = 0; -static unsigned int id_counter_2 = 1000; // for items that can't be reached with keyboard navigation but can be clicked - -int Widget::getNewID() -{ - return id_counter++; -} -int Widget::getNewNoFocusID() -{ - return id_counter_2++; -} -/** When switching to a new screen, this function will be called to reset ID counters - * (so we start again from ID 0, and don't grow to big numbers) */ -void Widget::resetIDCounters() -{ - id_counter = 0; - id_counter_2 = 1000; -} - // ----------------------------------------------------------------------------- Widget::Widget(bool reserve_id) { @@ -89,7 +68,40 @@ Widget::Widget(bool reserve_id) m_reserved_id = -1; } + +Widget::~Widget() +{ + // If any player focused this widget, unset that focus + for (int n=0; nclear(); } // ----------------------------------------------------------------------------- +bool ListWidget::OnEvent (const SEvent &event) +{ + // block input events, we will handle them (vertical navigation) ourselves + if (event.EventType == EET_KEY_INPUT_EVENT || + event.EventType == EET_JOYSTICK_INPUT_EVENT || + event.EventType == EET_MOUSE_INPUT_EVENT) + { + return true; + } + else + { + return false; + } +} +// ----------------------------------------------------------------------------- void ListWidget::addItem(const char* item) { IGUIListBox* list = getIrrlichtElement(); diff --git a/src/guiengine/widgets/list_widget.hpp b/src/guiengine/widgets/list_widget.hpp index 76ec088cd..91d5ec84b 100644 --- a/src/guiengine/widgets/list_widget.hpp +++ b/src/guiengine/widgets/list_widget.hpp @@ -35,6 +35,8 @@ namespace GUIEngine SkinWidgetContainer m_selection_skin_info; + virtual bool OnEvent (const SEvent &event); + void add(); void addItem(const char* item); diff --git a/src/guiengine/widgets/model_view_widget.cpp b/src/guiengine/widgets/model_view_widget.cpp index fb0c8d0e7..3544f5afa 100644 --- a/src/guiengine/widgets/model_view_widget.cpp +++ b/src/guiengine/widgets/model_view_widget.cpp @@ -50,6 +50,11 @@ void ModelViewWidget::add() //m_element = GUIEngine::getGUIEnv()->addMeshViewer(widget_size, NULL, ++id_counter_2); + /* + TODO: remove this unclean thing, I think irrlicht provides this feature: + virtual void IGUIElement::OnPostRender (u32 timeMs) + \brief animate the element and its children. + */ GUIEngine::needsUpdate.push_back(this); angle = 0;