From 5ccb18fce96a548c21ed72b4881bac7333bd510a Mon Sep 17 00:00:00 2001 From: dborth Date: Wed, 15 Apr 2009 06:32:40 +0000 Subject: [PATCH] file browser arrow buttons now steal focus --- source/ngc/gui/gui.h | 3 +++ source/ngc/gui/gui_element.cpp | 5 +++++ source/ngc/gui/gui_filebrowser.cpp | 27 ++++++++++++++------------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/source/ngc/gui/gui.h b/source/ngc/gui/gui.h index 441ca97..f933880 100644 --- a/source/ngc/gui/gui.h +++ b/source/ngc/gui/gui.h @@ -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 diff --git a/source/ngc/gui/gui_element.cpp b/source/ngc/gui/gui_element.cpp index d6575d7..6a40946 100644 --- a/source/ngc/gui/gui_element.cpp +++ b/source/ngc/gui/gui_element.cpp @@ -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() diff --git a/source/ngc/gui/gui_filebrowser.cpp b/source/ngc/gui/gui_filebrowser.cpp index d46a7a8..0982357 100644 --- a/source/ngc/gui/gui_filebrowser.cpp +++ b/source/ngc/gui/gui_filebrowser.cpp @@ -30,10 +30,7 @@ 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); + 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); btnSoundClick = new GuiSound(button_click_pcm, button_click_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)