From 2f3cf6d8b404dfe7b24db602eb0040dd527da64d Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 27 Mar 2010 23:18:07 +0000 Subject: [PATCH] Cleanup : less publicly editable members in Widget, renamed the name of tabs in options because there was a name conflict, improved widget search into the tree git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5086 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/gui/options_av.stkgui | 6 ++--- data/gui/options_input.stkgui | 6 ++--- data/gui/options_players.stkgui | 6 ++--- src/guiengine/event_handler.cpp | 9 ++------ src/guiengine/screen.cpp | 10 ++++---- src/guiengine/screen.hpp | 9 +++++++- src/guiengine/screen_loader.cpp | 15 ++++++------ src/guiengine/widget.cpp | 13 +++++++---- src/guiengine/widget.hpp | 21 +++++++++++++---- src/guiengine/widgets/button_widget.cpp | 15 ++++++++---- src/guiengine/widgets/check_box_widget.cpp | 7 ++++-- .../widgets/dynamic_ribbon_widget.cpp | 9 ++++---- src/guiengine/widgets/icon_button_widget.cpp | 3 +-- src/guiengine/widgets/label_widget.cpp | 7 ++++-- src/guiengine/widgets/list_widget.cpp | 23 +++++++++++++++---- src/guiengine/widgets/model_view_widget.cpp | 4 +++- src/guiengine/widgets/ribbon_widget.cpp | 8 ++++--- src/guiengine/widgets/spinner_widget.cpp | 19 +++++++-------- src/guiengine/widgets/text_box_widget.cpp | 12 ++++++++-- src/states_screens/kart_selection.cpp | 6 ++--- src/states_screens/options_screen_av.cpp | 8 +++---- src/states_screens/options_screen_input.cpp | 10 ++++---- src/states_screens/options_screen_players.cpp | 10 ++++---- 23 files changed, 143 insertions(+), 93 deletions(-) diff --git a/data/gui/options_av.stkgui b/data/gui/options_av.stkgui index 758218624..5be3100f1 100644 --- a/data/gui/options_av.stkgui +++ b/data/gui/options_av.stkgui @@ -6,11 +6,11 @@ - - - diff --git a/data/gui/options_input.stkgui b/data/gui/options_input.stkgui index 8fa8e4e92..27dbe428d 100644 --- a/data/gui/options_input.stkgui +++ b/data/gui/options_input.stkgui @@ -6,11 +6,11 @@ - - - diff --git a/data/gui/options_players.stkgui b/data/gui/options_players.stkgui index abb1de9c7..9e11a3d28 100644 --- a/data/gui/options_players.stkgui +++ b/data/gui/options_players.stkgui @@ -6,11 +6,11 @@ - - - diff --git a/src/guiengine/event_handler.cpp b/src/guiengine/event_handler.cpp index aca51cbfb..8a945fc7f 100644 --- a/src/guiengine/event_handler.cpp +++ b/src/guiengine/event_handler.cpp @@ -153,14 +153,9 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event) // we don't want that since we do our own custom processing for keys if (w->m_type == WTYPE_LIST) { - // cheap way to remove the focus from the element (nope, IGUIEnv::removeFocus doesn't work) - // Obviously will not work if the list if the first item of the screen. - GUIEngine::getGUIEnv()->setFocus( getCurrentScreen()->getFirstWidget()->getIrrlichtElement() ); - return EVENT_BLOCK; // confirms to irrLicht that we processed it + return EVENT_BLOCK; } - - //return w->focused(0); // is this still used with the new focus implementation? - + break; } case EGET_EDITBOX_ENTER: diff --git a/src/guiengine/screen.cpp b/src/guiengine/screen.cpp index acd6d2412..0b257faa8 100644 --- a/src/guiengine/screen.cpp +++ b/src/guiengine/screen.cpp @@ -402,9 +402,9 @@ Widget* Screen::getWidget(const char* name, ptr_vector* within_vector) { Widget& widget = (*within_vector)[n]; - if(widget.m_properties[PROP_ID] == name) return &widget; + if (widget.m_properties[PROP_ID] == name) return &widget; - if(widget.m_type == WTYPE_DIV) + if (widget.searchInsideMe() && widget.m_children.size() > 0) { Widget* el = getWidget(name, &(widget.m_children)); if(el != NULL) return el; @@ -422,9 +422,9 @@ Widget* Screen::getWidget(const int id, ptr_vector* within_vector) { Widget& widget = (*within_vector)[n]; - if(widget.m_element != NULL && widget.m_element->getID() == id) return &widget; + if (widget.m_element != NULL && widget.m_element->getID() == id) return &widget; - if(widget.m_children.size() > 0) + if (widget.searchInsideMe() && widget.m_children.size() > 0) { // std::cout << "widget = <" << widget.m_properties[PROP_ID].c_str() << "> widget.m_children.size()=" << widget.m_children.size() << std::endl; Widget* el = getWidget(id, &(widget.m_children)); @@ -443,7 +443,7 @@ Widget* Screen::getFirstWidget(ptr_vector* within_vector) { if (!within_vector->get(i)->m_focusable) continue; - // if container, also checks children + // if container, also checks children (FIXME: don't hardcode which types to avoid descending into) if (within_vector->get(i)->m_children.size() > 0 && within_vector->get(i)->m_type != WTYPE_RIBBON && within_vector->get(i)->m_type != WTYPE_SPINNER) diff --git a/src/guiengine/screen.hpp b/src/guiengine/screen.hpp index 703d5fc8f..a47ae682f 100644 --- a/src/guiengine/screen.hpp +++ b/src/guiengine/screen.hpp @@ -116,7 +116,14 @@ namespace GUIEngine /** returns an object by name, casted to specified type, or NULL if not found/wrong type */ template T* getWidget(const char* name) { - return dynamic_cast( getWidget(name) ); + Widget* out = getWidget(name); + T* outCasted = dynamic_cast( out ); + if (out != NULL && outCasted == NULL) + { + fprintf(stderr, "Screen::getWidget : Widget '%s' of type '%s' cannot be casted to " + "requested type '%s'!\n", name, typeid(*out).name(), typeid(T).name()); + } + return outCasted; } static Widget* getWidget(const char* name, ptr_vector* within_vector); diff --git a/src/guiengine/screen_loader.cpp b/src/guiengine/screen_loader.cpp index 0f35b5633..0ec9f775b 100644 --- a/src/guiengine/screen_loader.cpp +++ b/src/guiengine/screen_loader.cpp @@ -57,8 +57,7 @@ void parseScreenFileDiv(irr::io::IrrXMLReader* xml, ptr_vector& append_t /* find which type of widget is specified by the current tag, and instanciate it */ if (!strcmp("div", xml->getNodeName())) { - Widget* w = new Widget(); - w->m_type = WTYPE_DIV; + Widget* w = new Widget(WTYPE_DIV); append_to.push_back(w); } else if (!strcmp("stkgui", xml->getNodeName())) @@ -68,14 +67,12 @@ void parseScreenFileDiv(irr::io::IrrXMLReader* xml, ptr_vector& append_t } else if (!strcmp("placeholder", xml->getNodeName())) { - Widget* w = new Widget(true); - w->m_type = WTYPE_DIV; + Widget* w = new Widget(WTYPE_DIV, true); append_to.push_back(w); } else if (!strcmp("box", xml->getNodeName())) { - Widget* w = new Widget(); - w->m_type = WTYPE_DIV; + Widget* w = new Widget(WTYPE_DIV); w->m_show_bounding_box = true; append_to.push_back(w); } @@ -126,7 +123,7 @@ void parseScreenFileDiv(irr::io::IrrXMLReader* xml, ptr_vector& append_t } else if (!strcmp("spacer", xml->getNodeName())) { - append_to.push_back(new Widget()); + append_to.push_back(new Widget(WTYPE_NONE)); } else if (!strcmp("ribbon_grid", xml->getNodeName())) { @@ -195,8 +192,10 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = prop_name; else widget.m_ } /* a new div starts here, continue parsing with this new div as new parent */ - if( widget.m_type == WTYPE_DIV || widget.m_type == WTYPE_RIBBON) + if (widget.getType() == WTYPE_DIV || widget.getType() == WTYPE_RIBBON) + { parseScreenFileDiv( xml, append_to[append_to.size()-1].m_children ); + } }// end case EXN_ELEMENT break; diff --git a/src/guiengine/widget.cpp b/src/guiengine/widget.cpp index 97022d558..a26a5fd26 100644 --- a/src/guiengine/widget.cpp +++ b/src/guiengine/widget.cpp @@ -57,7 +57,7 @@ using namespace GUIEngine; // ----------------------------------------------------------------------------- -Widget::Widget(bool reserve_id) +Widget::Widget(WidgetType type, bool reserve_id) { m_magic_number = 0xCAFEC001; @@ -68,7 +68,7 @@ Widget::Widget(bool reserve_id) id = -1; m_element = NULL; m_title_font = false; - m_type = WTYPE_NONE; + m_type = type; m_focusable = true; m_event_handler = NULL; @@ -85,9 +85,12 @@ Widget::Widget(bool reserve_id) m_selected[n] = false; } - m_reserved_id = -1; - m_deactivated = false; - m_badges = 0; + m_reserved_id = -1; + m_deactivated = false; + m_badges = 0; + + // set a default value, derivates can override this as they wish + m_check_inside_me = (m_type == WTYPE_DIV); } // ----------------------------------------------------------------------------- diff --git a/src/guiengine/widget.hpp b/src/guiengine/widget.hpp index ac507a075..ed47954e8 100644 --- a/src/guiengine/widget.hpp +++ b/src/guiengine/widget.hpp @@ -120,6 +120,12 @@ namespace GUIEngine */ bool m_selected[MAX_PLAYER_COUNT]; + /** + * Whether to descend in the children of this widget when searching a widget + * from its ID or name. (children classes can override this value as they please) + */ + bool m_check_inside_me; + /** * called when left/right keys pressed and focus is on widget. * Returns 'EVENT_LET' if user's event handler should be notified of a change. @@ -191,6 +197,10 @@ namespace GUIEngine * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getHeightNeededAroundLabel() const { return 0; } + + /** Type of this widget */ + WidgetType m_type; + public: /** * This is set to NULL by default; set to something else in a widget to mean @@ -241,7 +251,7 @@ namespace GUIEngine /** A simple flag that can be raised to hide this widget */ bool m_deactivated; - Widget(bool reserve_id = false); + Widget(WidgetType type, bool reserve_id = false); virtual ~Widget(); /** @@ -278,10 +288,7 @@ namespace GUIEngine * one irrlicht widgets (e.g. Spinner) */ ptr_vector m_children; - - /** Type of this widget */ - WidgetType m_type; - + /** A map that holds values for all specified widget properties (in the XML file)*/ std::map m_properties; @@ -309,6 +316,8 @@ namespace GUIEngine */ virtual void move(const int x, const int y, const int w, const int h); + /** \return Type of this widget */ + WidgetType getType() const { return m_type; } bool isSelected(const int playerID) const { return m_selected[playerID]; } @@ -344,6 +353,8 @@ namespace GUIEngine * Called when irrLicht widgets cleared. Forget all references to them, they're no more valid. */ virtual void elementRemoved(); + + bool searchInsideMe() const { return m_check_inside_me; } }; diff --git a/src/guiengine/widgets/button_widget.cpp b/src/guiengine/widgets/button_widget.cpp index 4c0efa320..405cc251b 100644 --- a/src/guiengine/widgets/button_widget.cpp +++ b/src/guiengine/widgets/button_widget.cpp @@ -20,11 +20,14 @@ using namespace GUIEngine; using namespace irr::core; -ButtonWidget::ButtonWidget() -{ - m_type = WTYPE_BUTTON; -} // ----------------------------------------------------------------------------- + +ButtonWidget::ButtonWidget() : Widget(WTYPE_BUTTON) +{ +} + +// ----------------------------------------------------------------------------- + void ButtonWidget::add() { rect widget_size = rect(x, y, x + w, y + h); @@ -35,10 +38,14 @@ void ButtonWidget::add() m_element->setTabOrder(id); m_element->setTabGroup(false); } + // ----------------------------------------------------------------------------- + void ButtonWidget::setLabel(irr::core::stringw label) { m_element->setText( label.c_str() ); m_text = label; } +// ----------------------------------------------------------------------------- + diff --git a/src/guiengine/widgets/check_box_widget.cpp b/src/guiengine/widgets/check_box_widget.cpp index 734058353..3e44bbd8f 100644 --- a/src/guiengine/widgets/check_box_widget.cpp +++ b/src/guiengine/widgets/check_box_widget.cpp @@ -20,13 +20,16 @@ using namespace GUIEngine; using namespace irr::core; -CheckBoxWidget::CheckBoxWidget() +// ----------------------------------------------------------------------------- + +CheckBoxWidget::CheckBoxWidget() : Widget(WTYPE_CHECKBOX) { m_state = true; m_event_handler = this; - m_type = WTYPE_CHECKBOX; } + // ----------------------------------------------------------------------------- + void CheckBoxWidget::add() { rect widget_size = rect(x, y, x + w, y + h); diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.cpp b/src/guiengine/widgets/dynamic_ribbon_widget.cpp index 873a2adf6..a7db0e852 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.cpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.cpp @@ -31,7 +31,7 @@ using namespace irr::gui; const char* DynamicRibbonWidget::NO_ITEM_ID = "?"; -DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row) +DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row) : Widget(WTYPE_DYNAMIC_RIBBON) { m_scroll_offset = 0; m_needed_cols = 0; @@ -42,7 +42,8 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row) m_has_label = false; m_left_widget = NULL; m_right_widget = NULL; - m_type = WTYPE_DYNAMIC_RIBBON; + + m_check_inside_me = true; // by default, set all players to have no selection in this ribbon for (int n=0; n widget_size = rect(x, y, x + w, y + h); diff --git a/src/guiengine/widgets/list_widget.cpp b/src/guiengine/widgets/list_widget.cpp index dae2e2b93..302ce7d39 100644 --- a/src/guiengine/widgets/list_widget.cpp +++ b/src/guiengine/widgets/list_widget.cpp @@ -21,18 +21,23 @@ using namespace GUIEngine; using namespace irr::core; using namespace irr::gui; -ListWidget::ListWidget() -{ - m_type = WTYPE_LIST; -} // ----------------------------------------------------------------------------- + +ListWidget::ListWidget() : Widget(WTYPE_LIST) +{ +} + +// ----------------------------------------------------------------------------- + void ListWidget::add() { rect widget_size = rect(x, y, x + w, y + h); m_element = GUIEngine::getGUIEnv()->addListBox (widget_size, m_parent, getNewID()); } + // ----------------------------------------------------------------------------- + void ListWidget::clear() { IGUIListBox* list = getIrrlichtElement(); @@ -40,6 +45,7 @@ void ListWidget::clear() list->clear(); } + // ----------------------------------------------------------------------------- /* // Doesn't work, I would need to override CGUIListBox, but this class is private bool ListWidget::OnEvent (const SEvent &event) @@ -57,28 +63,36 @@ bool ListWidget::OnEvent (const SEvent &event) } } */ + // ----------------------------------------------------------------------------- + void ListWidget::addItem(const char* item) { IGUIListBox* list = getIrrlichtElement(); assert(list != NULL); list->addItem( stringw(item).c_str() ); } + // ----------------------------------------------------------------------------- + int ListWidget::getSelection() const { const IGUIListBox* list = getIrrlichtElement(); assert(list != NULL); return list->getSelected(); } + // ----------------------------------------------------------------------------- + std::string ListWidget::getSelectionName() const { const IGUIListBox* list = getIrrlichtElement(); assert(list != NULL); return stringc( list->getListItem( list->getSelected() ) ).c_str(); } + // ----------------------------------------------------------------------------- + void ListWidget::unfocused(const int playerID) { IGUIListBox* list = getIrrlichtElement(); @@ -87,3 +101,4 @@ void ListWidget::unfocused(const int playerID) if (list != NULL) list->setSelected(-1); } +// ----------------------------------------------------------------------------- diff --git a/src/guiengine/widgets/model_view_widget.cpp b/src/guiengine/widgets/model_view_widget.cpp index a18e81239..f50497d98 100644 --- a/src/guiengine/widgets/model_view_widget.cpp +++ b/src/guiengine/widgets/model_view_widget.cpp @@ -22,8 +22,10 @@ using namespace GUIEngine; using namespace irr::core; using namespace irr::gui; -ModelViewWidget::ModelViewWidget() : IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, false, false) +ModelViewWidget::ModelViewWidget() : + IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, false, false) { + //FIXME: find nicer way than overriding what IconButtonWidget's constructor already set... m_type = WTYPE_MODEL_VIEW; m_rtt_provider = NULL; m_rotation_mode = ROTATE_OFF; diff --git a/src/guiengine/widgets/ribbon_widget.cpp b/src/guiengine/widgets/ribbon_widget.cpp index 463591813..3101de2b5 100644 --- a/src/guiengine/widgets/ribbon_widget.cpp +++ b/src/guiengine/widgets/ribbon_widget.cpp @@ -33,7 +33,8 @@ using namespace irr::gui; #endif // ----------------------------------------------------------------------------- -RibbonWidget::RibbonWidget(const RibbonType type) + +RibbonWidget::RibbonWidget(const RibbonType type) : Widget(WTYPE_RIBBON) { for (int n=0; n0; - m_children.push_back( new Widget() ); - m_children.push_back( new Widget() ); - m_children.push_back( new Widget() ); + //FIXME: unclean to create "fake" button/label/icon widgets!! + m_children.push_back( new Widget(WTYPE_BUTTON) ); + m_children.push_back( new Widget(m_graphical ? WTYPE_ICON_BUTTON : WTYPE_LABEL) ); + m_children.push_back( new Widget(WTYPE_BUTTON) ); } int widgetID; @@ -93,7 +95,6 @@ void SpinnerWidget::add() rect subsize_left_arrow = rect(0 ,0, h, h); IGUIButton * left_arrow = GUIEngine::getGUIEnv()->addButton(subsize_left_arrow, btn, getNewNoFocusID(), L" "); m_children[0].m_element = left_arrow; - m_children[0].m_type = WTYPE_BUTTON; left_arrow->setTabStop(false); m_children[0].m_event_handler = this; m_children[0].m_properties[PROP_ID] = "left"; @@ -109,10 +110,8 @@ void SpinnerWidget::add() const int free_h_space = w-h*2-texture_width; // to center image rect subsize_label = rect(h+free_h_space/2, 0, w-h+free_h_space/2, h); - //IGUIButton* subbtn = GUIEngine::getGUIEnv()->addButton(subsize_label, btn, ++id_counter_2, L""); IGUIImage * subbtn = GUIEngine::getGUIEnv()->addImage(subsize_label, btn, getNewNoFocusID()); m_children[1].m_element = subbtn; - m_children[1].m_type = WTYPE_ICON_BUTTON; m_children[1].id = subbtn->getID(); m_children[1].m_event_handler = this; subbtn->setUseAlphaChannel(true); @@ -127,7 +126,6 @@ void SpinnerWidget::add() false /* border */, true /* word wrap */, btn, getNewNoFocusID()); m_children[1].m_element = label; - m_children[1].m_type = WTYPE_LABEL; m_children[1].m_event_handler = this; m_children[1].id = label->getID(); label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); @@ -141,7 +139,6 @@ void SpinnerWidget::add() IGUIButton * right_arrow = GUIEngine::getGUIEnv()->addButton(subsize_right_arrow, btn, getNewNoFocusID(), L" "); right_arrow->setTabStop(false); m_children[2].m_element = right_arrow; - m_children[2].m_type = WTYPE_BUTTON; m_children[2].m_event_handler = this; m_children[2].m_properties[PROP_ID] = "right"; m_children[2].id = m_children[2].m_element->getID(); diff --git a/src/guiengine/widgets/text_box_widget.cpp b/src/guiengine/widgets/text_box_widget.cpp index 3a5875aee..e682bf34c 100644 --- a/src/guiengine/widgets/text_box_widget.cpp +++ b/src/guiengine/widgets/text_box_widget.cpp @@ -23,11 +23,13 @@ using namespace irr::core; using namespace irr::gui; // ----------------------------------------------------------------------------- -TextBoxWidget::TextBoxWidget() + +TextBoxWidget::TextBoxWidget() : Widget(WTYPE_TEXTBOX) { - m_type = WTYPE_TEXTBOX; } + // ----------------------------------------------------------------------------- + void TextBoxWidget::add() { rect widget_size = rect(x, y, x + w, y + h); @@ -40,7 +42,9 @@ void TextBoxWidget::add() m_element->setTabGroup(false); m_element->setTabStop(true); } + // ----------------------------------------------------------------------------- + stringw TextBoxWidget::getText() const { const IGUIEditBox* textCtrl = Widget::getIrrlichtElement(); @@ -48,7 +52,9 @@ stringw TextBoxWidget::getText() const return stringw(textCtrl->getText()); } + // ----------------------------------------------------------------------------- + EventPropagation TextBoxWidget::focused(const int playerID) { assert(playerID == 0); // No support for multiple players in text areas! @@ -58,7 +64,9 @@ EventPropagation TextBoxWidget::focused(const int playerID) setWithinATextBox(true); return EVENT_LET; } + // ----------------------------------------------------------------------------- + void TextBoxWidget::unfocused(const int playerID) { assert(playerID == 0); // No support for multiple players in text areas! diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index 3c4e781e7..07fc5b585 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -66,10 +66,8 @@ class FocusDispatcher : public Widget KartSelectionScreen* m_parent; int m_reserved_id; public: - FocusDispatcher(KartSelectionScreen* parent) + FocusDispatcher(KartSelectionScreen* parent) : Widget(WTYPE_BUTTON) { - //m_type = WTYPE_LABEL; - m_type = WTYPE_BUTTON; m_parent = parent; m_reserved_id = -1; @@ -205,7 +203,7 @@ public: std::string m_kartInternalName; PlayerKartWidget(KartSelectionScreen* parent,StateManager:: ActivePlayer* associatedPlayer, - Widget* area, const int m_playerID, const int irrlichtWidgetID=-1) : Widget() + Widget* area, const int m_playerID, const int irrlichtWidgetID=-1) : Widget(WTYPE_DIV) { m_associatedPlayer = associatedPlayer; x_speed = 1.0f; diff --git a/src/states_screens/options_screen_av.cpp b/src/states_screens/options_screen_av.cpp index b70724ca0..399e84d7d 100644 --- a/src/states_screens/options_screen_av.cpp +++ b/src/states_screens/options_screen_av.cpp @@ -46,7 +46,7 @@ OptionsScreenAV::OptionsScreenAV() : Screen("options_av.stkgui") void OptionsScreenAV::init() { RibbonWidget* ribbon = this->getWidget("options_choice"); - if (ribbon != NULL) ribbon->select( "audio_video", GUI_PLAYER_ID ); + if (ribbon != NULL) ribbon->select( "tab_audio_video", GUI_PLAYER_ID ); // ---- sfx volume SpinnerWidget* gauge = this->getWidget("sfx_volume"); @@ -144,9 +144,9 @@ void OptionsScreenAV::eventCallback(Widget* widget, const std::string& name, con { std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str(); - if (selection == "audio_video") StateManager::get()->replaceTopMostScreen(OptionsScreenAV::getInstance()); - else if (selection == "players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance()); - else if (selection == "controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); + if (selection == "tab_audio_video") StateManager::get()->replaceTopMostScreen(OptionsScreenAV::getInstance()); + else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance()); + else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); } else if(name == "back") { diff --git a/src/states_screens/options_screen_input.cpp b/src/states_screens/options_screen_input.cpp index 147b84a1a..c38ceb2c0 100644 --- a/src/states_screens/options_screen_input.cpp +++ b/src/states_screens/options_screen_input.cpp @@ -262,8 +262,8 @@ void OptionsScreenInput::buildDeviceList() // ----------------------------------------------------------------------------- void OptionsScreenInput::init() { - RibbonWidget* ribbon = this->getWidget("options_choice"); - if (ribbon != NULL) ribbon->select( "controls", GUI_PLAYER_ID ); + RibbonWidget* tabBar = this->getWidget("options_choice"); + if (tabBar != NULL) tabBar->select( "tab_controls", GUI_PLAYER_ID ); DynamicRibbonWidget* devices = this->getWidget("devices"); @@ -393,9 +393,9 @@ void OptionsScreenInput::eventCallback(Widget* widget, const std::string& name, { std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str(); - if (selection == "audio_video") StateManager::get()->replaceTopMostScreen(OptionsScreenAV::getInstance()); - else if (selection == "players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance()); - else if (selection == "controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); + if (selection == "tab_audio_video") StateManager::get()->replaceTopMostScreen(OptionsScreenAV::getInstance()); + else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance()); + else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); } else if (name == "add_device") { diff --git a/src/states_screens/options_screen_players.cpp b/src/states_screens/options_screen_players.cpp index 8185499ad..1c371a1e7 100644 --- a/src/states_screens/options_screen_players.cpp +++ b/src/states_screens/options_screen_players.cpp @@ -49,8 +49,8 @@ OptionsScreenPlayers::OptionsScreenPlayers() : Screen("options_players.stkgui") void OptionsScreenPlayers::init() { - RibbonWidget* ribbon = this->getWidget("options_choice"); - if (ribbon != NULL) ribbon->select( "players", GUI_PLAYER_ID ); + RibbonWidget* tabBar = this->getWidget("options_choice"); + if (tabBar != NULL) tabBar->select( "tab_players", GUI_PLAYER_ID ); ListWidget* players = this->getWidget("players"); assert(players != NULL); @@ -140,9 +140,9 @@ void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name { std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str(); - if (selection == "audio_video") StateManager::get()->replaceTopMostScreen(OptionsScreenAV::getInstance()); - else if (selection == "players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance()); - else if (selection == "controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); + if (selection == "tab_audio_video") StateManager::get()->replaceTopMostScreen(OptionsScreenAV::getInstance()); + else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance()); + else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); } else if (name == "back") {