file browser arrow buttons now steal focus

This commit is contained in:
dborth 2009-04-15 06:32:40 +00:00
parent 884ccc90a6
commit 5ccb18fce9
3 changed files with 22 additions and 13 deletions

View File

@ -224,6 +224,9 @@ class GuiElement
//!Set the element's parent
//!\param e Pointer to parent element
void SetParent(GuiElement * e);
//!Gets the element's parent
//!\return Pointer to parent element
GuiElement * GetParent();
//!Gets the current leftmost coordinate of the element
//!Considers horizontal alignment, x offset, width, and parent element's GetLeft() / GetWidth() values
//!\return left coordinate

View File

@ -64,6 +64,11 @@ void GuiElement::SetParent(GuiElement * e)
{
parentElement = e;
}
GuiElement * GuiElement::GetParent()
{
return parentElement;
}
/**
* Get the left position of the GuiElement.
* @see SetLeft()

View File

@ -30,9 +30,6 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigHeldA = new GuiTrigger;
if(GCSettings.WiimoteOrientation)
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
else
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
@ -254,6 +251,19 @@ void GuiFileBrowser::Update(GuiTrigger * t)
listChanged = true;
}
if(arrowDownBtn->GetState() == STATE_HELD && arrowDownBtn->GetStateChan() == t->chan)
{
t->wpad.btns_h |= WPAD_BUTTON_DOWN;
if(!this->IsFocused())
((GuiWindow *)this->GetParent())->ChangeFocus(this);
}
else if(arrowUpBtn->GetState() == STATE_HELD && arrowUpBtn->GetStateChan() == t->chan)
{
t->wpad.btns_h |= WPAD_BUTTON_UP;
if(!this->IsFocused())
((GuiWindow *)this->GetParent())->ChangeFocus(this);
}
// pad/joystick navigation
if(!focus)
{
@ -261,15 +271,6 @@ void GuiFileBrowser::Update(GuiTrigger * t)
listChanged = false;
}
if(arrowDownBtn->GetState() == STATE_CLICKED && arrowDownBtn->GetStateChan() == t->chan)
t->wpad.btns_d |= WPAD_BUTTON_DOWN;
else if(arrowUpBtn->GetState() == STATE_CLICKED && arrowUpBtn->GetStateChan() == t->chan)
t->wpad.btns_d |= WPAD_BUTTON_UP;
else if(arrowDownBtn->GetState() == STATE_HELD && arrowDownBtn->GetStateChan() == t->chan)
t->wpad.btns_h |= WPAD_BUTTON_DOWN;
else if(arrowUpBtn->GetState() == STATE_HELD && arrowUpBtn->GetStateChan() == t->chan)
t->wpad.btns_h |= WPAD_BUTTON_UP;
if(t->Right())
{
if(browser.pageIndex < browser.numEntries && browser.numEntries > PAGESIZE)