From ff49f7d3b1b7a2a0157ca8e27c0c374c765dd691 Mon Sep 17 00:00:00 2001 From: stephena Date: Fri, 24 Jun 2005 12:01:27 +0000 Subject: [PATCH] Added infrastructure whereby any tab area (in a TabWidget) that doesn't want to navigate with the TAB key will actually receive the key (ie, it won't be swallowed). Updated PromptWidget to use the TAB key for command completion (Escape is still used as well). Added 'Alt t' and 'Alt s' for 'Trace' and 'Step' (respectively) to the debugger area. These keys are accessible while in any tab, since the buttons (and associated actions) don't belong to any particular tab. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@554 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/gui/DebuggerDialog.cxx | 51 +++++++++++++++++++++++++------ stella/src/gui/DebuggerDialog.hxx | 8 ++++- stella/src/gui/PromptWidget.cxx | 5 +-- stella/src/gui/TabWidget.cxx | 25 ++++++++++----- 4 files changed, 70 insertions(+), 19 deletions(-) diff --git a/stella/src/gui/DebuggerDialog.cxx b/stella/src/gui/DebuggerDialog.cxx index 2c6d4f9d2..8da906bd9 100644 --- a/stella/src/gui/DebuggerDialog.cxx +++ b/stella/src/gui/DebuggerDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerDialog.cxx,v 1.17 2005-06-23 14:33:11 stephena Exp $ +// $Id: DebuggerDialog.cxx,v 1.18 2005-06-24 12:01:26 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -106,7 +106,16 @@ void DebuggerDialog::loadConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::handleKeyDown(int ascii, int keycode, int modifiers) { - myTab->handleKeyDown(ascii, keycode, modifiers); + // Doing this means we disallow 'Alt xxx' events to any widget in the tabset + if(instance()->eventHandler().kbdAlt(modifiers)) + { + if(ascii == 's') + doStep(); + else if(ascii == 't') + doTrace(); + } + else + myTab->handleKeyDown(ascii, keycode, modifiers); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -117,22 +126,19 @@ void DebuggerDialog::handleCommand(CommandSender* sender, int cmd, int data) switch(cmd) { case kDDStepCmd: - instance()->debugger().step(); - myTab->loadConfig(); + doStep(); break; case kDDTraceCmd: - instance()->debugger().trace(); - myTab->loadConfig(); + doTrace(); break; case kDDAdvCmd: - instance()->debugger().nextFrame(1); - myTab->loadConfig(); + doAdvance(); break; case kDDExitCmd: - instance()->debugger().quit(); + doExit(); break; default: @@ -140,6 +146,33 @@ void DebuggerDialog::handleCommand(CommandSender* sender, int cmd, int data) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doStep() +{ + instance()->debugger().step(); + myTab->loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doTrace() +{ + instance()->debugger().trace(); + myTab->loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doAdvance() +{ + instance()->debugger().nextFrame(1); + myTab->loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doExit() +{ + instance()->debugger().quit(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PromptWidget *DebuggerDialog::prompt() { diff --git a/stella/src/gui/DebuggerDialog.hxx b/stella/src/gui/DebuggerDialog.hxx index 813446610..064cdb796 100644 --- a/stella/src/gui/DebuggerDialog.hxx +++ b/stella/src/gui/DebuggerDialog.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerDialog.hxx,v 1.9 2005-06-17 14:42:49 stephena Exp $ +// $Id: DebuggerDialog.hxx,v 1.10 2005-06-24 12:01:27 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -44,6 +44,12 @@ class DebuggerDialog : public Dialog protected: TabWidget* myTab; PromptWidget *myPrompt; + + private: + void doStep(); + void doTrace(); + void doAdvance(); + void doExit(); }; #endif diff --git a/stella/src/gui/PromptWidget.cxx b/stella/src/gui/PromptWidget.cxx index 0dde762c5..23028adae 100644 --- a/stella/src/gui/PromptWidget.cxx +++ b/stella/src/gui/PromptWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: PromptWidget.cxx,v 1.14 2005-06-24 00:03:38 urchlay Exp $ +// $Id: PromptWidget.cxx,v 1.15 2005-06-24 12:01:27 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -192,7 +192,8 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) break; } - case 27: // escape + case 27: // escape FIXME - possibly remove this one? + case 9: // tab { if(_currentPos <= _promptStartPos) break; diff --git a/stella/src/gui/TabWidget.cxx b/stella/src/gui/TabWidget.cxx index 4c44fc6f9..695575917 100644 --- a/stella/src/gui/TabWidget.cxx +++ b/stella/src/gui/TabWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: TabWidget.cxx,v 1.10 2005-06-23 14:33:11 stephena Exp $ +// $Id: TabWidget.cxx,v 1.11 2005-06-24 12:01:27 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -204,6 +204,12 @@ void TabWidget::handleMouseDown(int x, int y, int button, int clickCount) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool TabWidget::handleKeyDown(int ascii, int keycode, int modifiers) { + // Pass the tab key to the activeWidget if we know that widget + // navigation won't be needed + bool navigateWanted = false; + if(_activeWidget && (_activeWidget->getFlags() & WIDGET_TAB_NAVIGATE)) + navigateWanted = true; + // Test for TAB character // Ctrl-Tab selects next tab // Shift-Ctrl-Tab selects previous tab @@ -218,14 +224,19 @@ bool TabWidget::handleKeyDown(int ascii, int keycode, int modifiers) else cycleTab(+1); } - else if(_boss->instance()->eventHandler().kbdShift(modifiers)) - cycleWidget(-1); - else - cycleWidget(+1); + else if(navigateWanted) + { + if(_boss->instance()->eventHandler().kbdShift(modifiers)) + cycleWidget(-1); + else + cycleWidget(+1); + } - return true; + if(navigateWanted) + return true; } - else if (_activeWidget) + + if (_activeWidget && !navigateWanted) return _activeWidget->handleKeyDown(ascii, keycode, modifiers); else return Widget::handleKeyDown(ascii, keycode, modifiers);