mirror of https://github.com/stella-emu/stella.git
Finalized tab handling for dialogs containing multiple tabs
(for now, only the debugger, but might as well deal with the problem in a general way once and for all). The Shift-Left/Right keys now work as they did before, and switch between tabs in a tabset. For dialogs with multiple tabs, it now selects among those tabs where the focused object is. Clicking on another tabset then changes the focus, and allows the same keys to switch among *that* tabset. Now I can finally start the cart-specific bankswitch UI items. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2679 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
ac1bccf454
commit
831edca24e
|
@ -129,7 +129,7 @@ class CartridgeDPCPlus : public Cartridge
|
|||
|
||||
@return The name of the object
|
||||
*/
|
||||
string name() const { return "CartridgeDPCPlus"; }
|
||||
string name() const { return "CartridgeDPC+"; }
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -212,7 +212,8 @@ void Dialog::setFocus(Widget* w)
|
|||
// Redraw widgets for new focus
|
||||
_focusedWidget = Widget::setFocusForChain(this, getFocusList(), w, 0);
|
||||
|
||||
cerr << "set focus for " << _focusedWidget << endl;
|
||||
// Update current tab based on new focused widget
|
||||
getTabIdForWidget(_focusedWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,7 +229,6 @@ void Dialog::buildCurrentFocusList(int tabID)
|
|||
Widget* tabFocusWidget = 0;
|
||||
if(tabID >= 0 && tabID < (int)_myTabList.size())
|
||||
{
|
||||
cerr << "save tab, move to next\n";
|
||||
// Save focus in previously selected tab column,
|
||||
// and get focus for new tab column
|
||||
TabFocus& tabfocus = _myTabList[tabID];
|
||||
|
@ -238,23 +238,11 @@ cerr << "save tab, move to next\n";
|
|||
_tabID = tabID;
|
||||
}
|
||||
|
||||
// Special case for dialogs containing only one tab widget, with all items
|
||||
// arranged in separate tabs
|
||||
bool containsSingleTab = _myFocus.list.size() == 1 && _myTabList.size() == 1;
|
||||
|
||||
// A dialog containing only one tabwidget should be added first
|
||||
if(containsSingleTab)
|
||||
{
|
||||
_focusList.push_back(_myFocus.list);
|
||||
_focusedWidget = _focusList[0];
|
||||
}
|
||||
|
||||
// Now add appropriate items from tablist (if present)
|
||||
// Add appropriate items from tablist (if present)
|
||||
for(uInt32 id = 0; id < _myTabList.size(); ++id)
|
||||
_myTabList[id].appendFocusList(_focusList);
|
||||
|
||||
// Add remaining items from main focus list
|
||||
if(!containsSingleTab)
|
||||
_focusList.push_back(_myFocus.list);
|
||||
|
||||
// Add button group at end of current focus list
|
||||
|
@ -266,9 +254,7 @@ cerr << "save tab, move to next\n";
|
|||
// Finally, the moment we've all been waiting for :)
|
||||
// Set the actual focus widget
|
||||
if(tabFocusWidget)
|
||||
{cerr << "tab focus changed\n";
|
||||
_focusedWidget = tabFocusWidget;
|
||||
}
|
||||
else if(!_focusedWidget && _focusList.size() > 0)
|
||||
_focusedWidget = _focusList[0];
|
||||
}
|
||||
|
@ -549,6 +535,9 @@ bool Dialog::handleNavEvent(Event::Type e)
|
|||
{
|
||||
_focusedWidget = Widget::setFocusForChain(this, getFocusList(),
|
||||
_focusedWidget, -1);
|
||||
// Update current tab based on new focused widget
|
||||
getTabIdForWidget(_focusedWidget);
|
||||
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
@ -558,6 +547,9 @@ bool Dialog::handleNavEvent(Event::Type e)
|
|||
{
|
||||
_focusedWidget = Widget::setFocusForChain(this, getFocusList(),
|
||||
_focusedWidget, +1);
|
||||
// Update current tab based on new focused widget
|
||||
getTabIdForWidget(_focusedWidget);
|
||||
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
@ -587,30 +579,31 @@ bool Dialog::handleNavEvent(Event::Type e)
|
|||
return false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Dialog::getTabIdForWidget(Widget* w)
|
||||
{
|
||||
if(_myTabList.size() == 0)
|
||||
return;
|
||||
|
||||
for(uInt32 id = 0; id < _myTabList.size(); ++id)
|
||||
{
|
||||
if(w->_boss == _myTabList[id].widget)
|
||||
{
|
||||
_tabID = id;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Dialog::cycleTab(int direction)
|
||||
{
|
||||
cerr << "cycle " << (direction < 0 ? "left" : "right") << ", tabID = " << _tabID << endl;
|
||||
|
||||
if(_tabID >= 0 && _tabID < (int)_myTabList.size())
|
||||
{
|
||||
_myTabList[_tabID].widget->cycleTab(direction);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
#if 0
|
||||
if(key == KBDK_LEFT && _ourTab) // left arrow
|
||||
{
|
||||
_ourTab->cycleTab(-1);
|
||||
return;
|
||||
}
|
||||
else if(key == KBDK_RIGHT && _ourTab) // right arrow
|
||||
{
|
||||
_ourTab->cycleTab(+1);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -711,28 +704,10 @@ void Dialog::TabFocus::appendFocusList(WidgetArray& list)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Dialog::TabFocus::saveCurrentFocus(Widget* w)
|
||||
{
|
||||
#if 1
|
||||
if(currentTab >= 0 && currentTab < focus.size())
|
||||
{
|
||||
cerr << "chain len = " << focus[currentTab].list.size() << endl;
|
||||
|
||||
if(Widget::isWidgetInChain(focus[currentTab].list, w))
|
||||
{
|
||||
cerr << "saving widget\n";
|
||||
focus[currentTab].widget = w;
|
||||
}
|
||||
else
|
||||
cerr << "not in chain\n";
|
||||
}
|
||||
|
||||
#else
|
||||
if(currentTab >= 0 && currentTab < focus.size() &&
|
||||
Widget::isWidgetInChain(focus[currentTab].list, w))
|
||||
{cerr << "saving widget\n";
|
||||
focus[currentTab].widget = w;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Widget* Dialog::TabFocus::getNewFocus()
|
||||
|
|
|
@ -100,6 +100,7 @@ class Dialog : public GuiObject
|
|||
private:
|
||||
void buildCurrentFocusList(int tabID = -1);
|
||||
bool handleNavEvent(Event::Type e);
|
||||
void getTabIdForWidget(Widget* w);
|
||||
bool cycleTab(int direction);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -70,7 +70,6 @@ GameInfoDialog::GameInfoDialog(
|
|||
myTab = new TabWidget(this, font, xpos, ypos, _w - 2*xpos,
|
||||
_h - buttonHeight - fontHeight - ifont.getLineHeight() - 20);
|
||||
addTabWidget(myTab);
|
||||
addFocusWidget(myTab);
|
||||
|
||||
// 1) Cartridge properties
|
||||
wid.clear();
|
||||
|
|
|
@ -56,8 +56,6 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
|
|||
xpos = 2; ypos = vBorder;
|
||||
myTab = new TabWidget(this, font, xpos, ypos, _w - 2*xpos, _h - buttonHeight - 20);
|
||||
addTabWidget(myTab);
|
||||
wid.push_back(myTab);
|
||||
addToFocusList(wid);
|
||||
|
||||
// 1) Event mapper for emulation actions
|
||||
tabID = myTab->addTab("Emul. Events");
|
||||
|
|
|
@ -92,7 +92,6 @@ RomAuditDialog::RomAuditDialog(OSystem* osystem, DialogContainer* parent,
|
|||
kTextAlignLeft);
|
||||
|
||||
// Add OK and Cancel buttons
|
||||
wid.clear();
|
||||
addOKCancelBGroup(wid, font, "Audit", "Done");
|
||||
addBGroupToFocusList(wid);
|
||||
|
||||
|
|
|
@ -73,14 +73,7 @@ int TabWidget::getChildY() const
|
|||
int TabWidget::addTab(const string& title)
|
||||
{
|
||||
// Add a new tab page
|
||||
Tab newTab;
|
||||
newTab.title = title;
|
||||
newTab.firstWidget = NULL;
|
||||
newTab.parentWidget = NULL;
|
||||
newTab.enabled = true;
|
||||
|
||||
_tabs.push_back(newTab);
|
||||
|
||||
_tabs.push_back(Tab(title));
|
||||
int numTabs = _tabs.size();
|
||||
|
||||
// Determine the new tab width
|
||||
|
@ -145,7 +138,7 @@ void TabWidget::updateActiveTab()
|
|||
void TabWidget::activateTabs()
|
||||
{
|
||||
for(unsigned int i = 0; i <_tabs.size(); ++i)
|
||||
sendCommand(kTabChangedCmd, i-1, -1);
|
||||
sendCommand(kTabChangedCmd, i-1, _id);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -31,14 +31,6 @@
|
|||
|
||||
class TabWidget : public Widget, public CommandSender
|
||||
{
|
||||
struct Tab {
|
||||
string title;
|
||||
Widget* firstWidget;
|
||||
Widget* parentWidget;
|
||||
bool enabled;
|
||||
};
|
||||
typedef Common::Array<Tab> TabList;
|
||||
|
||||
public:
|
||||
TabWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h);
|
||||
~TabWidget();
|
||||
|
@ -77,7 +69,18 @@ class TabWidget : public Widget, public CommandSender
|
|||
virtual void drawWidget(bool hilite);
|
||||
virtual Widget* findWidget(int x, int y);
|
||||
|
||||
protected:
|
||||
private:
|
||||
struct Tab {
|
||||
string title;
|
||||
Widget* firstWidget;
|
||||
Widget* parentWidget;
|
||||
bool enabled;
|
||||
|
||||
Tab(const string& t = "", Widget* first = 0, Widget* parent = 0, bool e = true)
|
||||
: title(t), firstWidget(first), parentWidget(parent), enabled(e) { }
|
||||
};
|
||||
typedef Common::Array<Tab> TabList;
|
||||
|
||||
TabList _tabs;
|
||||
int _tabWidth;
|
||||
int _tabHeight;
|
||||
|
|
|
@ -61,7 +61,6 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
|
|||
xpos = ypos = vBorder;
|
||||
myTab = new TabWidget(this, font, xpos, ypos, _w - 2*xpos, _h - buttonHeight - 20);
|
||||
addTabWidget(myTab);
|
||||
addFocusWidget(myTab);
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// 1) Launcher options
|
||||
|
|
|
@ -66,7 +66,6 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
|
|||
xpos = ypos = 5;
|
||||
myTab = new TabWidget(this, font, xpos, ypos, _w - 2*xpos, _h - buttonHeight - 20);
|
||||
addTabWidget(myTab);
|
||||
addFocusWidget(myTab);
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// 1) General options
|
||||
|
|
Loading…
Reference in New Issue