diff --git a/source/gui/gfactory.cpp b/source/gui/gfactory.cpp index 222c09af6..7e38a918f 100644 --- a/source/gui/gfactory.cpp +++ b/source/gui/gfactory.cpp @@ -71,7 +71,7 @@ Params: Returns: ---------------------------------------------------------------------- */ -void CGUIFactory::createValueButtonFrame(class CGUIObject *_parent, +CGUIObject *CGUIFactory::createValueButtonFrame(class CGUIObject *_parent, int _x,int _y,int _w,int _h, int _textId, int *_target,int _value) @@ -91,6 +91,8 @@ void CGUIFactory::createValueButtonFrame(class CGUIObject *_parent, vb->init(fr); vb->setButtonTarget(_target); vb->setButtonValue(_value); + + return fr; } /*---------------------------------------------------------------------- @@ -99,7 +101,7 @@ void CGUIFactory::createValueButtonFrame(class CGUIObject *_parent, Params: Returns: ---------------------------------------------------------------------- */ -void CGUIFactory::createCycleButtonFrame(class CGUIObject *_parent, +CGUIObject *CGUIFactory::createCycleButtonFrame(class CGUIObject *_parent, int _x,int _y,int _w,int _h, int _textId, int *_target,int *_data,CGUITextReadout::TextReadoutData *_readoutData) @@ -125,6 +127,8 @@ void CGUIFactory::createCycleButtonFrame(class CGUIObject *_parent, tr->setObjectXYWH(0,(_h*2)/3,_w,(_h*1)/3); tr->setReadoutTarget(_target); tr->setReadoutData(_readoutData); + + return fr; } /*---------------------------------------------------------------------- @@ -133,7 +137,7 @@ void CGUIFactory::createCycleButtonFrame(class CGUIObject *_parent, Params: Returns: ---------------------------------------------------------------------- */ -void CGUIFactory::createSliderButtonFrame(class CGUIObject *_parent, +CGUIObject *CGUIFactory::createSliderButtonFrame(class CGUIObject *_parent, int _x,int _y,int _w,int _h, int _textId, int *_target,int _min,int _max) @@ -159,6 +163,8 @@ void CGUIFactory::createSliderButtonFrame(class CGUIObject *_parent, br->setObjectXYWH(0,(_h*2)/3,_w,(_h*1)/3); br->setReadoutTarget(_target); br->setReadoutRange(_min,_max); + + return fr; } diff --git a/source/gui/gfactory.h b/source/gui/gfactory.h index 871ca6412..4a31276e1 100644 --- a/source/gui/gfactory.h +++ b/source/gui/gfactory.h @@ -40,22 +40,22 @@ class CGUIFactory { public: // Creates a frame containing a value button with text label - static void createValueButtonFrame(class CGUIObject *_parent, - int _x,int _y,int _w,int _h, - int _textId, - int *_target,int _value); + static CGUIObject *createValueButtonFrame(class CGUIObject *_parent, + int _x,int _y,int _w,int _h, + int _textId, + int *_target,int _value); // Creates a frame containing a cycle button, text readout and text label - static void createCycleButtonFrame(class CGUIObject *_parent, - int _x,int _y,int _w,int _h, - int _textId, - int *_target,int *_data,CGUITextReadout::TextReadoutData *_readoutData); + static CGUIObject *createCycleButtonFrame(class CGUIObject *_parent, + int _x,int _y,int _w,int _h, + int _textId, + int *_target,int *_data,CGUITextReadout::TextReadoutData *_readoutData); // Creates a frame containing a slider button, readout and text label - static void createSliderButtonFrame(class CGUIObject *_parent, - int _x,int _y,int _w,int _h, - int _textId, - int *_target,int _min,int _max); + static CGUIObject *createSliderButtonFrame(class CGUIObject *_parent, + int _x,int _y,int _w,int _h, + int _textId, + int *_target,int _min,int _max); }; diff --git a/source/gui/gframe.cpp b/source/gui/gframe.cpp index 4b3123e8e..b84acd8ad 100644 --- a/source/gui/gframe.cpp +++ b/source/gui/gframe.cpp @@ -100,15 +100,18 @@ int CGUIGroupFrame::isSelectable() CGUIObject *pGUI; int selectable=false; - pGUI=getChild(); - while(pGUI) + if(!isHidden()) { - if(pGUI->isSelectable()) + pGUI=getChild(); + while(pGUI) { - selectable=true; - break; + if(pGUI->isSelectable()) + { + selectable=true; + break; + } + pGUI=pGUI->getNext(); } - pGUI=pGUI->getNext(); } return selectable; @@ -143,8 +146,6 @@ int CGUIGroupFrame::isUnselectable() - - /*---------------------------------------------------------------------- Function: Purpose: @@ -161,71 +162,12 @@ void CGUIControlFrame::think(int _frames) pad=PadGetRepeat(0); if(pad&PAD_DOWN) { - CGUIObject *pGUI; - - pGUI=getChild(); - if(pGUI) - { - // Get current selection and deselect it - while(!pGUI->isSelected()) - { - ASSERT(pGUI); - pGUI=pGUI->getNext(); - } - if(pGUI->isUnselectable()) - { - pGUI->unselect(); - - // Find next selectable object and select it - do - { - pGUI=pGUI->getNext(); - if(!pGUI)pGUI=getChild(); - } - while(!pGUI->isSelectable()); - pGUI->select(); - } - } + selectNextItem(); makeNoise=true; } else if(pad&PAD_UP) { - CGUIObject *pGUI,*prevGUI; - - pGUI=getChild(); - prevGUI=0; - if(pGUI) - { - // Get current selection and deselect it - while(!pGUI->isSelected()) - { - ASSERT(pGUI); - if(pGUI->isSelectable()) - { - prevGUI=pGUI; - } - pGUI=pGUI->getNext(); - } - if(pGUI->isUnselectable()) - { - pGUI->unselect(); - - // Find previous selectable object and select it - if(!prevGUI) - { - do - { - if(pGUI->isSelectable()) - { - prevGUI=pGUI; - } - pGUI=pGUI->getNext(); - } - while(pGUI); - } - prevGUI->select(); - } - } + selectPreviousItem(); makeNoise=true; } @@ -257,6 +199,89 @@ void CGUIControlFrame::setFlags(GUI_FLAGS _flags) } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGUIControlFrame::selectPreviousItem() +{ + CGUIObject *pGUI,*prevGUI; + + pGUI=getChild(); + prevGUI=0; + if(pGUI) + { + // Get current selection and deselect it + while(!pGUI->isSelected()) + { + ASSERT(pGUI); + if(pGUI->isSelectable()) + { + prevGUI=pGUI; + } + pGUI=pGUI->getNext(); + } + if(pGUI->isUnselectable()) + { + pGUI->unselect(); + + // Find previous selectable object and select it + if(!prevGUI) + { + do + { + if(pGUI->isSelectable()) + { + prevGUI=pGUI; + } + pGUI=pGUI->getNext(); + } + while(pGUI); + } + prevGUI->select(); + } + } +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGUIControlFrame::selectNextItem() +{ + CGUIObject *pGUI; + + pGUI=getChild(); + if(pGUI) + { + // Get current selection and deselect it + while(!pGUI->isSelected()) + { + ASSERT(pGUI); + pGUI=pGUI->getNext(); + } + if(pGUI->isUnselectable()) + { + pGUI->unselect(); + + // Find next selectable object and select it + do + { + pGUI=pGUI->getNext(); + if(!pGUI)pGUI=getChild(); + } + while(!pGUI->isSelectable()); + pGUI->select(); + } + } +} + + /*---------------------------------------------------------------------- Function: Purpose: diff --git a/source/gui/gframe.h b/source/gui/gframe.h index 10c4725b7..1c713b0f0 100644 --- a/source/gui/gframe.h +++ b/source/gui/gframe.h @@ -58,6 +58,9 @@ public: virtual void setFlags(GUI_FLAGS _flags); virtual void clearFlags(GUI_FLAGS _flags); + void selectPreviousItem(); + void selectNextItem(); + protected: GUI_FLAGS getInitialFlags() {return FLAG_DRAWBORDER;}