Finally fixed widget focus issue with the EventMappingWidget and the

TabWidget.  The fix is not as clean as I'd like, since it basically
checks for a certain case only (a hack).  The TabWidget really does
cause a lot of problems, but for now I just work around it.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@921 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-12-21 01:50:16 +00:00
parent 34284d0af9
commit e1e492f622
7 changed files with 33 additions and 31 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Dialog.cxx,v 1.36 2005-12-20 19:05:16 stephena Exp $ // $Id: Dialog.cxx,v 1.37 2005-12-21 01:50:16 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -101,6 +101,7 @@ void Dialog::addFocusWidget(Widget* w)
if(_ourFocusList.size() == 0) if(_ourFocusList.size() == 0)
{ {
Focus f; Focus f;
f.focusedWidget = 0;
_ourFocusList.push_back(f); _ourFocusList.push_back(f);
} }
_ourFocusList[0].focusedWidget = w; _ourFocusList[0].focusedWidget = w;
@ -121,8 +122,8 @@ void Dialog::addToFocusList(WidgetArray& list, int id)
} }
_ourFocusList[id].focusList.push_back(list); _ourFocusList[id].focusList.push_back(list);
if(id == 0) if(id == 0 && _ourFocusList.size() > 0)
_focusList = _ourFocusList[id].focusList; _focusList = _ourFocusList[0].focusList;
if(list.size() > 0 && !(list[0]->getFlags() & WIDGET_NODRAW_FOCUS)) if(list.size() > 0 && !(list[0]->getFlags() & WIDGET_NODRAW_FOCUS))
_ourFocusList[id].focusedWidget = list[0]; _ourFocusList[id].focusedWidget = list[0];
@ -167,7 +168,11 @@ void Dialog::buildFocusWidgetList(int id)
_focusList.push_back(_ourFocusList[_focusID].focusList); _focusList.push_back(_ourFocusList[_focusID].focusList);
// Only update _focusedWidget if it doesn't belong to the main focus list // Only update _focusedWidget if it doesn't belong to the main focus list
if(!Widget::isWidgetInChain(_ourFocusList[0].focusList, _focusedWidget)) // HACK - figure out how to properly deal with only one focus-able widget
// in a tab -- TabWidget is the spawn of the devil
if(_focusList.size() == 1)
_focusedWidget = _focusList[0];
else if(!Widget::isWidgetInChain(_ourFocusList[0].focusList, _focusedWidget))
_focusedWidget = _ourFocusList[_focusID].focusedWidget; _focusedWidget = _ourFocusList[_focusID].focusedWidget;
} }
else else
@ -230,13 +235,7 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount)
_dragWidget = w; _dragWidget = w;
// If the click occured inside a widget which is not the currently setFocus(w);
// focused one, change the focus to that widget.
if(w && w != _focusedWidget && w->wantsFocus())
{
// Redraw widgets for new focus
_focusedWidget = Widget::setFocusForChain(this, getFocusList(), w, 0);
}
if(w) if(w)
w->handleMouseDown(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount); w->handleMouseDown(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
@ -265,8 +264,6 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleMouseWheel(int x, int y, int direction) void Dialog::handleMouseWheel(int x, int y, int direction)
{ {
cerr << "_focusedWidget = " << _focusedWidget << endl;
Widget* w; Widget* w;
// This may look a bit backwards, but I think it makes more sense for // This may look a bit backwards, but I think it makes more sense for

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventMappingWidget.cxx,v 1.3 2005-12-20 19:05:16 stephena Exp $ // $Id: EventMappingWidget.cxx,v 1.4 2005-12-21 01:50:16 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -152,7 +152,6 @@ void EventMappingWidget::stopRemapping()
myCancelMapButton->setEnabled(false); myCancelMapButton->setEnabled(false);
// Make sure the list widget is in a known state // Make sure the list widget is in a known state
cerr << "myActionSelected = " << myActionSelected << endl;
if(myActionSelected >= 0) if(myActionSelected >= 0)
{ {
drawKeyMapping(); drawKeyMapping();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: InputDialog.cxx,v 1.7 2005-12-20 19:05:16 stephena Exp $ // $Id: InputDialog.cxx,v 1.8 2005-12-21 01:50:16 stephena Exp $
//============================================================================ //============================================================================
#include "OSystem.hxx" #include "OSystem.hxx"
@ -56,13 +56,11 @@ InputDialog::InputDialog(
myTab->setParentWidget(tabID, myEventMapper); myTab->setParentWidget(tabID, myEventMapper);
addToFocusList(myEventMapper->getFocusList(), tabID); addToFocusList(myEventMapper->getFocusList(), tabID);
cerr << "size = " << myEventMapper->getFocusList().size()
<< ", tabid = " << tabID << endl;
// 2) Virtual device support // 2) Virtual device support
addVDeviceTab(); addVDeviceTab();
// Activate the first tab // Finalize the tabs, and activate the first tab
myTab->activateTabs();
myTab->setActiveTab(0); myTab->setActiveTab(0);
// Add OK and Cancel buttons // Add OK and Cancel buttons
@ -182,8 +180,6 @@ void InputDialog::addVDeviceTab()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::loadConfig() void InputDialog::loadConfig()
{ {
myEventMapper->loadConfig();
// Left & right ports // Left & right ports
const string& sa1 = instance()->settings().getString("sa1"); const string& sa1 = instance()->settings().getString("sa1");
int lport = sa1 == "right" ? 2 : 1; int lport = sa1 == "right" ? 2 : 1;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TabWidget.cxx,v 1.18 2005-09-29 18:50:51 stephena Exp $ // $Id: TabWidget.cxx,v 1.19 2005-12-21 01:50:16 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -126,6 +126,13 @@ void TabWidget::updateActiveTab()
_boss->redrawFocus(); _boss->redrawFocus();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::activateTabs()
{
for(unsigned int i = 0; i <_tabs.size(); ++i)
sendCommand(kTabChangedCmd, i-1, -1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::cycleTab(int direction) void TabWidget::cycleTab(int direction)
{ {

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TabWidget.hxx,v 1.10 2005-12-09 01:16:14 stephena Exp $ // $Id: TabWidget.hxx,v 1.11 2005-12-21 01:50:16 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -58,6 +58,7 @@ class TabWidget : public Widget, public CommandSender
//void removeTab(int tabID); //void removeTab(int tabID);
// Setting the active tab: // Setting the active tab:
void setActiveTab(int tabID, bool show = false); void setActiveTab(int tabID, bool show = false);
void activateTabs();
void cycleTab(int direction); void cycleTab(int direction);
// setActiveTab changes the value of _firstWidget. This means Widgets added afterwards // setActiveTab changes the value of _firstWidget. This means Widgets added afterwards
// will be added to the active tab. // will be added to the active tab.

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Widget.cxx,v 1.39 2005-12-19 02:19:49 stephena Exp $ // $Id: Widget.cxx,v 1.40 2005-12-21 01:50:16 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -333,10 +333,11 @@ void StaticTextWidget::drawWidget(bool hilite)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h,
const string& label, int cmd, uInt8 hotkey) const string& label, int cmd, uInt8 hotkey)
: StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), : StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter),
CommandSender(boss), CommandSender(boss),
_cmd(cmd), _cmd(cmd),
_hotkey(hotkey) _editable(false),
_hotkey(hotkey)
{ {
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG; _flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
_type = kButtonWidget; _type = kButtonWidget;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Widget.hxx,v 1.41 2005-12-19 02:19:49 stephena Exp $ // $Id: Widget.hxx,v 1.42 2005-12-21 01:50:16 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -72,7 +72,7 @@ enum {
This is the base class for all widgets. This is the base class for all widgets.
@author Stephen Anthony @author Stephen Anthony
@version $Id: Widget.hxx,v 1.41 2005-12-19 02:19:49 stephena Exp $ @version $Id: Widget.hxx,v 1.42 2005-12-21 01:50:16 stephena Exp $
*/ */
class Widget : public GuiObject class Widget : public GuiObject
{ {
@ -212,6 +212,7 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
protected: protected:
int _cmd; int _cmd;
bool _editable;
uInt8 _hotkey; uInt8 _hotkey;
}; };