you can now warp vertically in menus

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3370 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-06 23:31:02 +00:00
parent b1964b2bff
commit d0fc9b1179
3 changed files with 27 additions and 7 deletions

@ -322,15 +322,15 @@ bool Screen::OnEvent(const SEvent& event)
{
IGUIElement *el, *first=NULL, *closest=NULL;
el = GUIEngine::getGUIEnv()->getFocus();
if(el != NULL && el->getTabGroup() != NULL)
if(el != NULL && el->getTabGroup() != NULL &&
el->getTabGroup()->getNextElement(el->getTabOrder(), true, false, first, closest))
{
if( el->getTabGroup()->getNextElement(el->getTabOrder(), true, false, first, closest) )
GUIEngine::getGUIEnv()->setFocus(closest);
}
else
{
// select the first widget
Widget* w = getFirstWidget();
Widget* w = getLastWidget();
if(w != NULL) GUIEngine::getGUIEnv()->setFocus( w->m_element );
}
return true;
@ -487,4 +487,25 @@ Widget* Screen::getFirstWidget(ptr_vector<Widget>* within_vector)
}
return NULL;
}
// -----------------------------------------------------------------------------
Widget* Screen::getLastWidget(ptr_vector<Widget>* within_vector)
{
if(within_vector == NULL) within_vector = &m_widgets;
for(int i = within_vector->size()-1; i >= 0; i--)
{
// if container, also checks children
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)
{
Widget* w = getLastWidget(&within_vector->get(i)->m_children);
if(w != NULL) return w;
}
if(within_vector->get(i)->m_element == NULL || within_vector->get(i)->m_element->getTabOrder() == -1) continue;
return within_vector->get(i);
}
return NULL;
}

@ -42,6 +42,7 @@ namespace GUIEngine
Widget* getWidget(const int id, ptr_vector<Widget>* within_vector=NULL);
Widget* getFirstWidget(ptr_vector<Widget>* within_vector=NULL);
Widget* getLastWidget(ptr_vector<Widget>* within_vector=NULL);
void addWidgets();
void calculateLayout();

@ -300,9 +300,7 @@ void IconButtonWidget::add()
// irrlicht widgets don't support scaling while keeping aspect ratio
// so, happily, let's implement it ourselves
const int x_gap = (float)w - (float)texture_w * (float)h / texture_h;
std::cout << "x_gap = " << x_gap << std::endl;
widget_size = rect<s32>(x + x_gap/2, y, x + w - x_gap/2, y + h);
IGUIImage* btn = GUIEngine::getGUIEnv()->addImage(widget_size, NULL, ++id_counter_2);