Show tooltips when hovering options tabs

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8002 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-03-20 19:49:55 +00:00
parent 2634dd6e74
commit a078105aee
10 changed files with 61 additions and 12 deletions

View File

@ -6,12 +6,10 @@
<spacer height="15" width="10"/>
<tabs id="options_choice" height="10%" max_height="110" width="100%" align="center">
<icon-button id="tab_video" width="128" height="128" icon="gui/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/options_audio.png"
I18N="Section in the settings menu" text="Audio"/>
<icon-button id="tab_players" width="128" height="128" icon="gui/options_players.png"
I18N="Section in the settings menu" text="Players"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/options_video.png"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/options_audio.png"/>
<icon-button id="tab_ui" width="128" height="128" icon="gui/options_ui.png"/>
<icon-button id="tab_players" width="128" height="128" icon="gui/options_players.png"/>
<icon-button id="tab_controls" width="128" height="128" icon="gui/options_input.png"
I18N="Section in the settings menu" text="Controls"/>
</tabs>

View File

@ -944,6 +944,15 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
} // end if icon ribbons
if (/*mark_selected && widget->hasTooltip() && (focused || parent_focused) &&*/ parentRibbon->m_mouse_focus == widget)
{
if (rect.isPointInside(irr_driver->getDevice()->getCursorControl()->getPosition()))
{
m_tooltip_at_mouse.push_back(true);
m_tooltips.push_back(widget);
}
}
}
/**
@ -1050,6 +1059,7 @@ void Skin::drawSpinnerBody(const core::rect< s32 > &rect, Widget* widget, const
if (focused && widget->hasTooltip())
{
m_tooltip_at_mouse.push_back(false);
m_tooltips.push_back(widget);
}
}
@ -1376,16 +1386,23 @@ void Skin::drawTooltips()
{
for (unsigned int n=0; n<m_tooltips.size(); n++)
{
drawTooltip(m_tooltips[n]);
drawTooltip(m_tooltips[n], m_tooltip_at_mouse[n]);
}
m_tooltips.clear();
m_tooltip_at_mouse.clear();
}
void Skin::drawTooltip(Widget* widget)
void Skin::drawTooltip(Widget* widget, bool atMouse)
{
irr::gui::ScalableFont* font = GUIEngine::getSmallFont();
core::dimension2d<u32> size = font->getDimension(widget->getTooltipText().c_str());
core::position2di pos(widget->m_x + 15, widget->m_y + widget->m_h);
if (atMouse)
{
pos = irr_driver->getDevice()->getCursorControl()->getPosition() + core::position2di(15, 15);
}
core::rect<s32> r(pos, size);
GUIEngine::getDriver()->draw2DRectangle( video::SColor(255, 200, 200, 200), r );
font->draw(widget->getTooltipText(), r, video::SColor(255, 0, 0, 0), false, false);
@ -1606,14 +1623,14 @@ void Skin::draw3DButtonPaneStandard (IGUIElement *element, const core::rect< s32
void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, bool flat, bool fillBackGround,
const core::rect< s32 > &rect, const core::rect< s32 > *clip)
{
{
const int id = element->getID();
Widget* widget = GUIEngine::getWidget(id);
if (widget == NULL) return;
const WidgetType type = widget->m_type;
IGUIElement* focusedElem = NULL;
if (GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) != NULL)
{

View File

@ -244,6 +244,7 @@ namespace GUIEngine
std::vector<Widget*> m_tooltips;
std::vector<bool> m_tooltip_at_mouse;
#ifdef USE_PER_LINE_BACKGROUND
public:
@ -271,7 +272,7 @@ namespace GUIEngine
void drawScrollbarThumb(const irr::core::rect< irr::s32 > &rect);
void drawScrollbarButton(const irr::core::rect< irr::s32 > &rect, const bool pressed, const bool bottomArrow);
void drawTooltip(Widget* widget);
void drawTooltip(Widget* widget, bool atMouse);
public:

View File

@ -148,6 +148,8 @@ namespace GUIEngine
* \brief clear all children of this ribbon (likely because new ones will be added soon after)
*/
void clearAllChildren();
PtrVector<Widget>& getRibbonChildren() { return m_children; }
};
}

View File

@ -60,6 +60,11 @@ void OptionsScreenAudio::init()
RibbonWidget* ribbon = this->getWidget<RibbonWidget>("options_choice");
if (ribbon != NULL) ribbon->select( "tab_audio", PLAYER_ID_GAME_MASTER );
ribbon->getRibbonChildren()[0].setTooltip( _("Graphics") );
ribbon->getRibbonChildren()[2].setTooltip( _("User Interface") );
ribbon->getRibbonChildren()[3].setTooltip( _("Players") );
ribbon->getRibbonChildren()[4].setTooltip( _("Controls") );
// ---- sfx volume
SpinnerWidget* gauge = this->getWidget<SpinnerWidget>("sfx_volume");
assert(gauge != NULL);

View File

@ -126,6 +126,11 @@ void OptionsScreenInput::init()
RibbonWidget* tabBar = this->getWidget<RibbonWidget>("options_choice");
if (tabBar != NULL) tabBar->select( "tab_controls", PLAYER_ID_GAME_MASTER );
tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") );
tabBar->getRibbonChildren()[1].setTooltip( _("Audio") );
tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") );
tabBar->getRibbonChildren()[3].setTooltip( _("Players") );
/*
DynamicRibbonWidget* devices = this->getWidget<DynamicRibbonWidget>("devices");
assert( devices != NULL );

View File

@ -67,6 +67,12 @@ void OptionsScreenInput2::init()
RibbonWidget* tabBar = this->getWidget<RibbonWidget>("options_choice");
if (tabBar != NULL) tabBar->select( "tab_controls", PLAYER_ID_GAME_MASTER );
tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") );
tabBar->getRibbonChildren()[1].setTooltip( _("Audio") );
tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") );
tabBar->getRibbonChildren()[3].setTooltip( _("Players") );
ButtonWidget* deleteBtn = this->getWidget<ButtonWidget>("delete");
if (m_config->getType() != DEVICE_CONFIG_TYPE_KEYBOARD)
{

View File

@ -64,6 +64,11 @@ void OptionsScreenPlayers::init()
RibbonWidget* tabBar = this->getWidget<RibbonWidget>("options_choice");
if (tabBar != NULL) tabBar->select( "tab_players", PLAYER_ID_GAME_MASTER );
tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") );
tabBar->getRibbonChildren()[1].setTooltip( _("Audio") );
tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") );
tabBar->getRibbonChildren()[4].setTooltip( _("Controls") );
ListWidget* players = this->getWidget<ListWidget>("players");
assert(players != NULL);

View File

@ -105,6 +105,11 @@ void OptionsScreenUI::init()
RibbonWidget* ribbon = this->getWidget<RibbonWidget>("options_choice");
if (ribbon != NULL) ribbon->select( "tab_ui", PLAYER_ID_GAME_MASTER );
ribbon->getRibbonChildren()[0].setTooltip( _("Graphics") );
ribbon->getRibbonChildren()[1].setTooltip( _("Audio") );
ribbon->getRibbonChildren()[3].setTooltip( _("Players") );
ribbon->getRibbonChildren()[4].setTooltip( _("Controls") );
GUIEngine::SpinnerWidget* skinSelector = this->getWidget<GUIEngine::SpinnerWidget>("skinchoice");
assert( skinSelector != NULL );

View File

@ -77,6 +77,11 @@ void OptionsScreenVideo::init()
RibbonWidget* ribbon = this->getWidget<RibbonWidget>("options_choice");
if (ribbon != NULL) ribbon->select( "tab_video", PLAYER_ID_GAME_MASTER );
ribbon->getRibbonChildren()[1].setTooltip( _("Audio") );
ribbon->getRibbonChildren()[2].setTooltip( _("User Interface") );
ribbon->getRibbonChildren()[3].setTooltip( _("Players") );
ribbon->getRibbonChildren()[4].setTooltip( _("Controls") );
GUIEngine::ButtonWidget* applyBtn = this->getWidget<GUIEngine::ButtonWidget>("apply_resolution");
assert( applyBtn != NULL );