Don't allow selecting ribbon grid filler items
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4949 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
0efd96d8da
commit
2827533e70
@ -690,15 +690,15 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
|
||||
widget->m_event_handler->m_event_handler->m_properties[PROP_SQUARE] == "true") use_glow = false;
|
||||
|
||||
/* in combo ribbons, always show selection */
|
||||
RibbonWidget* w = NULL;
|
||||
RibbonWidget* parentRibbonWidget = NULL;
|
||||
|
||||
if (widget->m_event_handler != NULL && widget->m_event_handler->m_type == WTYPE_RIBBON)
|
||||
{
|
||||
w = dynamic_cast<RibbonWidget*>(widget->m_event_handler);
|
||||
if(w->getRibbonType() == RIBBON_COMBO) always_show_selection = true;
|
||||
parentRibbonWidget = dynamic_cast<RibbonWidget*>(widget->m_event_handler);
|
||||
if(parentRibbonWidget->getRibbonType() == RIBBON_COMBO) always_show_selection = true;
|
||||
}
|
||||
|
||||
const bool mark_focused = focused || (parent_focused && w != NULL && w->m_mouse_focus == widget) ||
|
||||
const bool mark_focused = focused || (parent_focused && parentRibbonWidget != NULL && parentRibbonWidget->m_mouse_focus == widget) ||
|
||||
(mark_selected && !always_show_selection && parent_focused);
|
||||
|
||||
/* draw "selection bubble" if relevant */
|
||||
@ -762,18 +762,21 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
|
||||
GUIEngine::getDriver()->draw2DImage(tex_ficonhighlight, rect2, source_area,
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
}
|
||||
/* if we're not using glow */
|
||||
// if we're not using glow, draw square focus instead
|
||||
else
|
||||
{
|
||||
const bool show_focus = focused || parent_focused;
|
||||
const bool show_focus = (focused || parent_focused);
|
||||
|
||||
if (!always_show_selection && !show_focus) return;
|
||||
|
||||
// don't mark filler items as focused
|
||||
if (widget->m_properties[PROP_ID] == DynamicRibbonWidget::NO_ITEM_ID) return;
|
||||
|
||||
//const int texture_w = m_tex_squarefocus->getSize().Width;
|
||||
//const int texture_h = m_tex_squarefocus->getSize().Height;
|
||||
//core::rect<s32> source_area = core::rect<s32>(0, 0, texture_w, texture_h);
|
||||
|
||||
drawBoxFromStretchableTexture(w, rect, SkinConfig::m_render_params["squareFocusHalo::neutral"]);
|
||||
drawBoxFromStretchableTexture(parentRibbonWidget, rect, SkinConfig::m_render_params["squareFocusHalo::neutral"]);
|
||||
nPlayersOnThisItem++;
|
||||
}
|
||||
} // end if mark_focused
|
||||
@ -796,11 +799,11 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
|
||||
rect2.UpperLeftCorner.Y -= enlarge;
|
||||
rect2.LowerRightCorner.X += enlarge;
|
||||
rect2.LowerRightCorner.Y += enlarge;
|
||||
drawBoxFromStretchableTexture(w, rect2, SkinConfig::m_render_params["squareFocusHalo2::neutral"]);
|
||||
drawBoxFromStretchableTexture(parentRibbonWidget, rect2, SkinConfig::m_render_params["squareFocusHalo2::neutral"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawBoxFromStretchableTexture(w, rect, SkinConfig::m_render_params["squareFocusHalo2::neutral"]);
|
||||
drawBoxFromStretchableTexture(parentRibbonWidget, rect, SkinConfig::m_render_params["squareFocusHalo2::neutral"]);
|
||||
}
|
||||
|
||||
nPlayersOnThisItem++;
|
||||
@ -808,13 +811,13 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const
|
||||
|
||||
if (parentRibbon->isFocusedForPlayer(2) && parentRibbon->getSelectionIDString(2) == widget->m_properties[PROP_ID])
|
||||
{
|
||||
drawBoxFromStretchableTexture(w, rect, SkinConfig::m_render_params["squareFocusHalo3::neutral"]);
|
||||
drawBoxFromStretchableTexture(parentRibbonWidget, rect, SkinConfig::m_render_params["squareFocusHalo3::neutral"]);
|
||||
nPlayersOnThisItem++;
|
||||
}
|
||||
|
||||
if (parentRibbon->isFocusedForPlayer(3) && parentRibbon->getSelectionIDString(3) == widget->m_properties[PROP_ID])
|
||||
{
|
||||
drawBoxFromStretchableTexture(w, rect, SkinConfig::m_render_params["squareFocusHalo4::neutral"]);
|
||||
drawBoxFromStretchableTexture(parentRibbonWidget, rect, SkinConfig::m_render_params["squareFocusHalo4::neutral"]);
|
||||
}
|
||||
|
||||
drawIconButton(rect, widget, pressed, focused);
|
||||
|
@ -29,10 +29,7 @@ using namespace irr::gui;
|
||||
# define round(x) (floor(x+0.5f))
|
||||
#endif
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
const char* NO_ITEM_ID = "?";
|
||||
}
|
||||
const char* DynamicRibbonWidget::NO_ITEM_ID = "?";
|
||||
|
||||
DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row)
|
||||
{
|
||||
|
@ -28,9 +28,6 @@
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
/** The identifier returned for empty "cells" in the ribbon */
|
||||
extern const char* NO_ITEM_ID;
|
||||
|
||||
/**
|
||||
* Even if you have a ribbon that only acts on click/enter, you may wish to know which
|
||||
* item is currently highlighted. In this case, create a listener and pass it to the ribbon.
|
||||
@ -154,6 +151,12 @@ namespace GUIEngine
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/** Internal identifier of filler items that aer added in a grid ribbon widget to fill
|
||||
* lines when the number of items cannot be divided by the number of rows in the grid
|
||||
*/
|
||||
static const char* NO_ITEM_ID;
|
||||
|
||||
/**
|
||||
* \param combo Whether this is a "combo" ribbon, i.e. whether there is always one selected item.
|
||||
* If set to false, will behave more like a toolbar.
|
||||
|
@ -284,6 +284,12 @@ EventPropagation RibbonWidget::rightPressed(const int playerID)
|
||||
}
|
||||
}
|
||||
|
||||
// if we reached a filler item, move again
|
||||
if (getSelectionIDString(playerID) == DynamicRibbonWidget::NO_ITEM_ID)
|
||||
{
|
||||
rightPressed(playerID);
|
||||
}
|
||||
|
||||
if (m_ribbon_type != RIBBON_TOOLBAR)
|
||||
{
|
||||
//GUIEngine::transmitEvent( this, m_properties[PROP_ID], playerID );
|
||||
@ -319,6 +325,12 @@ EventPropagation RibbonWidget::leftPressed(const int playerID)
|
||||
}
|
||||
}
|
||||
|
||||
// if we reached a filler item, move again
|
||||
if (getSelectionIDString(playerID) == DynamicRibbonWidget::NO_ITEM_ID)
|
||||
{
|
||||
leftPressed(playerID);
|
||||
}
|
||||
|
||||
if (m_ribbon_type != RIBBON_TOOLBAR)
|
||||
{
|
||||
//GUIEngine::transmitEvent( this, m_properties[PROP_ID], playerID );
|
||||
|
@ -1366,7 +1366,7 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
|
||||
unlock_manager->playLockSound();
|
||||
}
|
||||
//FIXME: what does this do there???
|
||||
else if (selected_kart_group == NO_ITEM_ID)
|
||||
else if (selected_kart_group == DynamicRibbonWidget::NO_ITEM_ID)
|
||||
{
|
||||
}
|
||||
else
|
||||
|
@ -103,7 +103,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const
|
||||
{
|
||||
unlock_manager->playLockSound();
|
||||
}
|
||||
else if (selection == NO_ITEM_ID)
|
||||
else if (selection == DynamicRibbonWidget::NO_ITEM_ID)
|
||||
{
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user