Fixed rare focus issue in modal dialogs, and generally improved code
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4365 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
8f2fc46211
commit
2b152135da
@ -117,12 +117,15 @@ void ModalDialog::onEnterPressedInternal()
|
||||
|
||||
Widget* ModalDialog::getLastWidget()
|
||||
{
|
||||
// FIXME: don't duplicate this code from 'Screen.cpp'
|
||||
const int childrenCount = m_children.size();
|
||||
|
||||
for (int i=childrenCount-1; i>=0; i--)
|
||||
{
|
||||
if (m_children[i].getIrrlichtElement() == NULL || m_children[i].getIrrlichtElement()->getTabOrder() == -1 ||
|
||||
m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */)
|
||||
if (m_children[i].getIrrlichtElement() == NULL ||
|
||||
m_children[i].getIrrlichtElement()->getTabOrder() == -1 ||
|
||||
m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */ ||
|
||||
!m_children[i].m_focusable)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -133,12 +136,15 @@ Widget* ModalDialog::getLastWidget()
|
||||
}
|
||||
Widget* ModalDialog::getFirstWidget()
|
||||
{
|
||||
// FIXME: don't duplicate this code from 'Screen.cpp'
|
||||
const int childrenCount = m_children.size();
|
||||
|
||||
for (int i=0; i<childrenCount; i++)
|
||||
{
|
||||
if (m_children[i].getIrrlichtElement() == NULL || m_children[i].getIrrlichtElement()->getTabOrder() == -1 ||
|
||||
m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */)
|
||||
if (m_children[i].getIrrlichtElement() == NULL ||
|
||||
m_children[i].getIrrlichtElement()->getTabOrder() == -1 ||
|
||||
m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */ ||
|
||||
!m_children[i].m_focusable)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -406,10 +406,16 @@ Widget* Screen::getFirstWidget(ptr_vector<Widget>* within_vector)
|
||||
if (w != NULL) return w;
|
||||
}
|
||||
|
||||
if (within_vector->get(i)->m_element == NULL || within_vector->get(i)->m_element->getTabOrder() == -1 ||
|
||||
within_vector->get(i)->m_element->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */) continue;
|
||||
Widget* item = within_vector->get(i);
|
||||
if (item->m_element == NULL ||
|
||||
item->m_element->getTabOrder() == -1 ||
|
||||
item->m_element->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */ ||
|
||||
!item->m_focusable)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return within_vector->get(i);
|
||||
return item;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -431,10 +437,16 @@ Widget* Screen::getLastWidget(ptr_vector<Widget>* within_vector)
|
||||
if (w != NULL) return w;
|
||||
}
|
||||
|
||||
if (within_vector->get(i)->m_element == NULL || within_vector->get(i)->m_element->getTabOrder() == -1 ||
|
||||
within_vector->get(i)->m_element->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */) continue;
|
||||
Widget* item = within_vector->get(i);
|
||||
if (item->m_element == NULL ||
|
||||
item->m_element->getTabOrder() == -1 ||
|
||||
item->m_element->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */ ||
|
||||
!item->m_focusable)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return within_vector->get(i);
|
||||
return item;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -50,42 +50,6 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
|
||||
|
||||
m_track_ident = trackIdent;
|
||||
|
||||
// ---- Lap count m_spinner
|
||||
m_spinner = new SpinnerWidget();
|
||||
m_spinner->x = m_area.getWidth()/2 - 200;
|
||||
m_spinner->y = y2;
|
||||
m_spinner->w = 400;
|
||||
m_spinner->h = y3 - y2 - 15;
|
||||
m_spinner->setParent(m_irrlicht_window);
|
||||
|
||||
m_spinner->m_properties[PROP_MIN_VALUE] = "1";
|
||||
m_spinner->m_properties[PROP_MAX_VALUE] = "99";
|
||||
|
||||
//I18N: In the track setup screen (number of laps choice, where %i is the number)
|
||||
m_spinner->m_text = _("%i laps");
|
||||
|
||||
m_children.push_back(m_spinner);
|
||||
m_spinner->add();
|
||||
m_spinner->setValue(3);
|
||||
m_spinner->getIrrlichtElement()->setTabStop(true);
|
||||
m_spinner->getIrrlichtElement()->setTabGroup(false);
|
||||
|
||||
// ---- Start button
|
||||
ButtonWidget* okBtn = new ButtonWidget();
|
||||
okBtn->m_properties[PROP_ID] = "start";
|
||||
okBtn->m_text = _("Start Race");
|
||||
okBtn->x = m_area.getWidth()/2 - 200;
|
||||
okBtn->y = y3;
|
||||
okBtn->w = 400;
|
||||
okBtn->h = m_area.getHeight() - y3 - 15;
|
||||
okBtn->setParent(m_irrlicht_window);
|
||||
m_children.push_back(okBtn);
|
||||
okBtn->add();
|
||||
okBtn->getIrrlichtElement()->setTabStop(true);
|
||||
okBtn->getIrrlichtElement()->setTabGroup(false);
|
||||
|
||||
okBtn->setFocusForPlayer( GUI_PLAYER_ID );
|
||||
|
||||
// ---- Track title
|
||||
core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1);
|
||||
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( trackName.c_str(),
|
||||
@ -206,6 +170,42 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
|
||||
a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
b->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
|
||||
// ---- Lap count m_spinner
|
||||
m_spinner = new SpinnerWidget();
|
||||
m_spinner->x = m_area.getWidth()/2 - 200;
|
||||
m_spinner->y = y2;
|
||||
m_spinner->w = 400;
|
||||
m_spinner->h = y3 - y2 - 15;
|
||||
m_spinner->setParent(m_irrlicht_window);
|
||||
|
||||
m_spinner->m_properties[PROP_MIN_VALUE] = "1";
|
||||
m_spinner->m_properties[PROP_MAX_VALUE] = "99";
|
||||
|
||||
//I18N: In the track setup screen (number of laps choice, where %i is the number)
|
||||
m_spinner->m_text = _("%i laps");
|
||||
|
||||
m_children.push_back(m_spinner);
|
||||
m_spinner->add();
|
||||
m_spinner->setValue(3);
|
||||
m_spinner->getIrrlichtElement()->setTabStop(true);
|
||||
m_spinner->getIrrlichtElement()->setTabGroup(false);
|
||||
|
||||
// ---- Start button
|
||||
ButtonWidget* okBtn = new ButtonWidget();
|
||||
okBtn->m_properties[PROP_ID] = "start";
|
||||
okBtn->m_text = _("Start Race");
|
||||
okBtn->x = m_area.getWidth()/2 - 200;
|
||||
okBtn->y = y3;
|
||||
okBtn->w = 400;
|
||||
okBtn->h = m_area.getHeight() - y3 - 15;
|
||||
okBtn->setParent(m_irrlicht_window);
|
||||
m_children.push_back(okBtn);
|
||||
okBtn->add();
|
||||
okBtn->getIrrlichtElement()->setTabStop(true);
|
||||
okBtn->getIrrlichtElement()->setTabGroup(false);
|
||||
|
||||
okBtn->setFocusForPlayer( GUI_PLAYER_ID );
|
||||
|
||||
}
|
||||
|
||||
TrackInfoDialog::~TrackInfoDialog()
|
||||
|
Loading…
Reference in New Issue
Block a user