From baabc572aaad9d1fd4da707649ac6b0015468dda Mon Sep 17 00:00:00 2001 From: auria Date: Fri, 30 Apr 2010 01:28:57 +0000 Subject: [PATCH] Fixed crash when pressing left/right on an empty row of a ribbon (more work later to avoid letting the user focus ever go on an empty row...) git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5322 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/guiengine/widgets/ribbon_widget.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/guiengine/widgets/ribbon_widget.cpp b/src/guiengine/widgets/ribbon_widget.cpp index 6c92a3a6f..0e779da4c 100644 --- a/src/guiengine/widgets/ribbon_widget.cpp +++ b/src/guiengine/widgets/ribbon_widget.cpp @@ -308,7 +308,8 @@ void RibbonWidget::select(std::string item, const int mousePlayerID) EventPropagation RibbonWidget::rightPressed(const int playerID) { if (m_deactivated) return EVENT_LET; - + if (m_children.size() < 2) return EVENT_LET; // empty ribbon, or only one item (can't move right) + m_selection[playerID]++; if (m_selection[playerID] >= m_children.size()) { @@ -328,11 +329,14 @@ EventPropagation RibbonWidget::rightPressed(const int playerID) } } - // if we reached a filler item, move again + // if we reached a filler item, move again (but don't warp) // FIXME: why is a constant from DynamicRibbon used here?? if (getSelectionIDString(playerID) == DynamicRibbonWidget::NO_ITEM_ID) { - rightPressed(playerID); + if (m_selection[playerID] + 1 < m_children.size()) + { + rightPressed(playerID); + } } if (m_ribbon_type != RIBBON_TOOLBAR) @@ -349,7 +353,8 @@ EventPropagation RibbonWidget::rightPressed(const int playerID) EventPropagation RibbonWidget::leftPressed(const int playerID) { if (m_deactivated) return EVENT_LET; - + if (m_children.size() < 2) return EVENT_LET; // empty ribbon, or only one item (can't move left) + m_selection[playerID]--; if (m_selection[playerID] < 0) { @@ -369,10 +374,10 @@ EventPropagation RibbonWidget::leftPressed(const int playerID) } } - // if we reached a filler item, move again + // if we reached a filler item, move again (but don't warp) if (getSelectionIDString(playerID) == DynamicRibbonWidget::NO_ITEM_ID) { - leftPressed(playerID); + if (m_selection[playerID] > 0) leftPressed(playerID); } if (m_ribbon_type != RIBBON_TOOLBAR)