Added higher-level calls to RibbonWidget so that Screens don't need to manually manipulate the internals of GUIEngine (they shouldn't even have access to them xD)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5269 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
702934c50e
commit
e9b621c93c
@ -96,10 +96,15 @@
|
||||
\li The "tabs" subcategory will show a tab bar. behaviour is same as normal ribbon, only looks are different.
|
||||
Orientation of tabs (up or down) is automatically inferred from on-screen position
|
||||
|
||||
\note Ribbon widgets are of spawn type (\<ribbon\> ... \</ribbon\>) and may contain icon-buttons or buttons as children.
|
||||
\note Property PROP_SQUARE can be set to tell the engine if the ribbon's contents are rectangular or not (this will
|
||||
affect the type of highlighting used)
|
||||
\note Ribbon widgets are of spawn type (\<ribbon\> ... \</ribbon\>) and may contain icon-buttons or buttons
|
||||
as children.
|
||||
\note Property PROP_SQUARE can be set to tell the engine if the ribbon's contents are rectangular or not
|
||||
(this will affect the type of highlighting used)
|
||||
\note All elements within a ribbon must have an 'ID' property
|
||||
\note Text-only ribbons (e.g. tabs) can have their elements dynamically added at runtime, too. Just add
|
||||
no children to the ribbon in the XML file, and add them at runtime through the method for this.
|
||||
Dynamic contents creation for other types RibbonWidget is currently NOT implemented because we had
|
||||
no need for it. It can be added as needed.
|
||||
|
||||
\n
|
||||
\subsection widget2 WTYPE_SPINNER
|
||||
|
@ -248,6 +248,18 @@ void RibbonWidget::add()
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RibbonWidget::addTextChild(const wchar_t* text, const std::string id)
|
||||
{
|
||||
ButtonWidget* item = new ButtonWidget();
|
||||
item->m_text = text;
|
||||
item->m_properties[PROP_ID] = id;
|
||||
|
||||
m_children.push_back(item);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RibbonWidget::select(std::string item, const int mousePlayerID)
|
||||
{
|
||||
const int subbuttons_amount = m_children.size();
|
||||
|
@ -118,6 +118,12 @@ namespace GUIEngine
|
||||
|
||||
/** Returns the ID of the item, or -1 if not found */
|
||||
int findItemNamed(const char* internalName);
|
||||
|
||||
/** \brief dynamically (at runtime) add a text item to this ribbon
|
||||
* \precondition this must be called before RibbonWidget::add, while the widget is not yet displayed
|
||||
* \precondition only valid for ribbons that take text-only contents (e.g. tab bars)
|
||||
*/
|
||||
void addTextChild(const wchar_t* text, const std::string id);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -51,19 +51,14 @@ ArenasScreen::ArenasScreen() : Screen("arenas.stkgui")
|
||||
const int group_amount = groups.size();
|
||||
for (int n=0; n<group_amount; n++)
|
||||
{
|
||||
ButtonWidget* item = new ButtonWidget();
|
||||
item->m_text = groups[n].c_str(); // FIXME: i18n ?
|
||||
item->m_properties[PROP_ID] = groups[n];
|
||||
tabs->m_children.push_back(item);
|
||||
//FIXME: group name not translated
|
||||
tabs->addTextChild( stringw(groups[n].c_str()).c_str(), groups[n]);
|
||||
}
|
||||
|
||||
if (group_amount > 1)
|
||||
{
|
||||
ButtonWidget* item = new ButtonWidget();
|
||||
//I18N: name of the tab that will show tracks from all groups
|
||||
item->m_text = _("All");
|
||||
item->m_properties[PROP_ID] = ALL_ARENA_GROUPS_ID;
|
||||
tabs->m_children.push_back(item);
|
||||
//I18N: name of the tab that will show arenas from all groups
|
||||
tabs->addTextChild( _("All") , ALL_ARENA_GROUPS_ID);
|
||||
}
|
||||
|
||||
} // ArenasScreen
|
||||
|
@ -713,7 +713,6 @@ KartSelectionScreen::KartSelectionScreen() : Screen("karts.stkgui")
|
||||
m_player_confirmed = false;
|
||||
|
||||
// Dynamically add tabs
|
||||
// FIXME: it's not very well documented that RibbonWidgets can have dynamically generated contents
|
||||
RibbonWidget* tabs = this->getWidget<RibbonWidget>("kartgroups");
|
||||
assert( tabs != NULL );
|
||||
|
||||
@ -724,19 +723,14 @@ KartSelectionScreen::KartSelectionScreen() : Screen("karts.stkgui")
|
||||
const int group_amount = groups.size();
|
||||
for (int n=0; n<group_amount; n++)
|
||||
{
|
||||
ButtonWidget* item = new ButtonWidget();
|
||||
item->m_text = groups[n].c_str(); // FIXME: i18n ?
|
||||
item->m_properties[PROP_ID] = groups[n];
|
||||
tabs->m_children.push_back(item);
|
||||
//FIXME: group name not translated
|
||||
tabs->addTextChild( stringw(groups[n].c_str()).c_str() , groups[n]);
|
||||
}
|
||||
|
||||
if (group_amount > 1)
|
||||
{
|
||||
ButtonWidget* item = new ButtonWidget();
|
||||
//I18N: name of the tab that will show tracks from all groups
|
||||
item->m_text = _("All");
|
||||
item->m_properties[PROP_ID] = ALL_KART_GROUPS_ID;
|
||||
tabs->m_children.push_back(item);
|
||||
tabs->addTextChild( _("All") , ALL_KART_GROUPS_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ DEFINE_SCREEN_SINGLETON( TracksScreen );
|
||||
TracksScreen::TracksScreen() : Screen("tracks.stkgui")
|
||||
{
|
||||
// Dynamically add tabs
|
||||
// FIXME: it's not very well documented that RibbonWidgets can have dynamically generated contents
|
||||
RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups");
|
||||
assert( tabs != NULL );
|
||||
|
||||
@ -52,19 +51,14 @@ TracksScreen::TracksScreen() : Screen("tracks.stkgui")
|
||||
const int group_amount = groups.size();
|
||||
for (int n=0; n<group_amount; n++)
|
||||
{
|
||||
ButtonWidget* item = new ButtonWidget();
|
||||
item->m_text = groups[n].c_str(); // FIXME: i18n ?
|
||||
item->m_properties[PROP_ID] = groups[n];
|
||||
tabs->m_children.push_back(item);
|
||||
// FIXME: group name is not translated
|
||||
tabs->addTextChild( stringw(groups[n].c_str()).c_str(), groups[n] );
|
||||
}
|
||||
|
||||
if (group_amount > 1)
|
||||
{
|
||||
ButtonWidget* item = new ButtonWidget();
|
||||
//I18N: name of the tab that will show tracks from all groups
|
||||
item->m_text = _("All");
|
||||
item->m_properties[PROP_ID] = ALL_TRACK_GROUPS_ID;
|
||||
tabs->m_children.push_back(item);
|
||||
tabs->addTextChild(_("All"), ALL_TRACK_GROUPS_ID );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user