From 037d675f60dc677261d1aa04677e6f7b7b176e8e Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 15 Aug 2007 17:43:51 +0000 Subject: [PATCH] More palette fixes for the debugger (PromptWidget & DataGridWidget). Fixed DebuggerParser::red() method so it always uses the same color, regardless of NTSC/PAL/SECAM format. Added Home/End/PgUp/PgDn navigation to TiaZoomWidget. Added a 'Defaults' button to FileSnapDialog. Made configurable the number of lines a mouse scrollwheel will move the scrollbar. This can be set by the '-mwheel' commandline argument, as well as in UIDialog. Removed some dead code in several debugger classes. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1347 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/Debugger.cxx | 23 ++++----- stella/src/debugger/Debugger.hxx | 10 +--- stella/src/debugger/DebuggerParser.cxx | 32 +----------- stella/src/debugger/DebuggerParser.hxx | 9 ++-- stella/src/debugger/gui/DataGridWidget.cxx | 10 ++-- stella/src/debugger/gui/PromptWidget.cxx | 22 ++++---- stella/src/debugger/gui/PromptWidget.hxx | 6 +-- stella/src/debugger/gui/RomListWidget.cxx | 5 +- stella/src/debugger/gui/TiaZoomWidget.cxx | 43 +++++++++++----- stella/src/debugger/gui/TiaZoomWidget.hxx | 4 +- stella/src/debugger/gui/ToggleBitWidget.cxx | 6 +-- stella/src/emucore/FrameBuffer.hxx | 10 ++-- stella/src/emucore/OSystem.cxx | 57 ++++++++++++--------- stella/src/emucore/Settings.cxx | 4 +- stella/src/gui/AboutDialog.cxx | 4 +- stella/src/gui/FileSnapDialog.cxx | 35 ++++++++++--- stella/src/gui/FileSnapDialog.hxx | 11 ++-- stella/src/gui/OptionsDialog.cxx | 4 +- stella/src/gui/ScrollBarWidget.cxx | 14 ++--- stella/src/gui/ScrollBarWidget.hxx | 35 +++++++------ stella/src/gui/TabWidget.cxx | 3 +- stella/src/gui/UIDialog.cxx | 40 +++++++++++++-- stella/src/gui/UIDialog.hxx | 8 ++- stella/src/gui/Widget.cxx | 4 +- 24 files changed, 220 insertions(+), 179 deletions(-) diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index 119f437a7..c0affdcea 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.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: Debugger.cxx,v 1.113 2007-08-14 19:49:20 stephena Exp $ +// $Id: Debugger.cxx,v 1.114 2007-08-15 17:43:51 stephena Exp $ //============================================================================ #include "bspf.hxx" @@ -389,15 +389,16 @@ const string Debugger::valueToString(int value, BaseFormat outputBase) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string Debugger::invIfChanged(int reg, int oldReg) { - string ret; +const string Debugger::invIfChanged(int reg, int oldReg) +{ + string ret; - bool changed = !(reg == oldReg); - if(changed) ret += "\177"; - ret += valueToString(reg); - if(changed) ret += "\177"; + bool changed = reg != oldReg; + if(changed) ret += "\177"; + ret += valueToString(reg); + if(changed) ret += "\177"; - return ret; + return ret; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1038,12 +1039,6 @@ GUI::Rect Debugger::getTabBounds() const return r; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::resizeDialog() -{ -// cerr << "Debugger::resizeDialog()\n"; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Debugger::addFunction(string name, string definition, Expression *exp, bool builtin) { functions.insert(make_pair(name, exp)); diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index 7e9bc52ee..004a561c5 100644 --- a/stella/src/debugger/Debugger.hxx +++ b/stella/src/debugger/Debugger.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: Debugger.hxx,v 1.89 2007-08-14 19:49:20 stephena Exp $ +// $Id: Debugger.hxx,v 1.90 2007-08-15 17:43:51 stephena Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -69,7 +69,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)(); for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.89 2007-08-14 19:49:20 stephena Exp $ + @version $Id: Debugger.hxx,v 1.90 2007-08-15 17:43:51 stephena Exp $ */ class Debugger : public DialogContainer { @@ -301,12 +301,6 @@ class Debugger : public DialogContainer */ void setQuitState(); - /** - Resize the debugger dialog based on the current dimensions from - getDialogBounds. - */ - void resizeDialog(); - int step(); int trace(); void nextScanline(int lines); diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 4404f9e9a..d8825893b 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.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: DebuggerParser.cxx,v 1.99 2007-08-14 20:36:18 stephena Exp $ +// $Id: DebuggerParser.cxx,v 1.100 2007-08-15 17:43:51 stephena Exp $ //============================================================================ #include @@ -1357,27 +1357,6 @@ void DebuggerParser::executeZ() debugger->cpuDebug().setZ(args[0]); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// "change resolution" -void DebuggerParser::executeResolution() -{ - commandResult = "TODO - add functionality"; - -/* - int height = debugger->setHeight(args[0]); - commandResult = "height set to " + debugger->valueToString(height, kBASE_10) + - "\nExit debugger and reload ROM to take effect"; -*/ -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// .hxx -// Table of RGB values for NTSC -// static const uInt32 ourNTSCPalette[256]; - -// .cxx -// const uInt32 Console::ourNTSCPalette[256] = { - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // List of all commands available to the parser @@ -1902,14 +1881,5 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { true, { kARG_BOOL, kARG_END_ARGS }, &DebuggerParser::executeZ - }, - - { - "resolution", - "Change resolution of debugger window", - true, - false, - { kARG_WORD, kARG_END_ARGS }, - &DebuggerParser::executeResolution } }; diff --git a/stella/src/debugger/DebuggerParser.hxx b/stella/src/debugger/DebuggerParser.hxx index 41f18680e..1d2ce1999 100644 --- a/stella/src/debugger/DebuggerParser.hxx +++ b/stella/src/debugger/DebuggerParser.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: DebuggerParser.hxx,v 1.49 2007-08-10 18:27:11 stephena Exp $ +// $Id: DebuggerParser.hxx,v 1.50 2007-08-15 17:43:51 stephena Exp $ //============================================================================ #ifndef DEBUGGER_PARSER_HXX @@ -24,6 +24,7 @@ struct Command; #include "bspf.hxx" #include "Array.hxx" +#include "FrameBuffer.hxx" typedef enum { kBASE_16, @@ -63,8 +64,7 @@ class DebuggerParser static inline string red(const string& msg = "") { - // This is TIA color 0x34. The octal value is 0x80+(0x34>>1). - return "\232" + msg; + return char(kDbgChangedColor) + msg; } static inline string inverse(const string& msg = "") { @@ -81,7 +81,7 @@ class DebuggerParser private: enum { - kNumCommands = 59, + kNumCommands = 58, kMAX_ARG_TYPES = 10 // TODO: put in separate header file Command.hxx }; @@ -193,7 +193,6 @@ class DebuggerParser void executeX(); void executeY(); void executeZ(); - void executeResolution(); // List of commands available static Command commands[kNumCommands]; diff --git a/stella/src/debugger/gui/DataGridWidget.cxx b/stella/src/debugger/gui/DataGridWidget.cxx index c711f387e..f9dddf4dc 100644 --- a/stella/src/debugger/gui/DataGridWidget.cxx +++ b/stella/src/debugger/gui/DataGridWidget.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: DataGridWidget.cxx,v 1.11 2007-07-31 15:46:20 stephena Exp $ +// $Id: DataGridWidget.cxx,v 1.12 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -524,15 +524,15 @@ void DataGridWidget::drawWidget(bool hilite) int color = kTextColor; if(_changedList[pos]) { - fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kTextColorEm); + fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kDbgChangedColor); if(_hiliteList[pos]) - color = kHiliteColor; + color = kDbgColorHi; else - color = kTextColorHi; + color = kDbgChangedTextColor; } else if(_hiliteList[pos]) - color = kHiliteColor; + color = kDbgColorHi; fb.drawString(_font, buffer, x, y, _colWidth, color); } diff --git a/stella/src/debugger/gui/PromptWidget.cxx b/stella/src/debugger/gui/PromptWidget.cxx index 06701bf2c..dd6e78f0f 100644 --- a/stella/src/debugger/gui/PromptWidget.cxx +++ b/stella/src/debugger/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.20 2007-08-14 20:36:18 stephena Exp $ +// $Id: PromptWidget.cxx,v 1.21 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -55,6 +55,7 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font, _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANTS_TAB | WIDGET_WANTS_RAWDATA; _type = kPromptWidget; + _textcolor = kTextColor; _bgcolor = kWidColor; _kConsoleCharWidth = font.getMaxCharWidth(); @@ -77,10 +78,6 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font, _scrollBar->setTarget(this); // Init colors - defaultTextColor = kTextColor; - defaultBGColor = kBGColor; - textColor = defaultTextColor; - bgColor = defaultBGColor; _inverse = false; // Init History @@ -119,12 +116,11 @@ void PromptWidget::drawWidget(bool hilite) int c = buffer((start + line) * _lineWidth + column); if(c & (1 << 17)) { // inverse video flag - fgcolor = bgColor; + fgcolor = _bgcolor; bgcolor = (c & 0x1ffff) >> 8; fb.fillRect(x, y, _kConsoleCharWidth, _kConsoleCharHeight, bgcolor); } else { fgcolor = c >> 8; - bgcolor = bgColor; } fb.drawChar(&instance()->consoleFont(), c & 0x7f, x, y, fgcolor); x += _kConsoleCharWidth; @@ -526,6 +522,7 @@ void PromptWidget::loadConfig() _promptStartPos = _promptEndPos = _currentPos; _firstTime = false; + _exitedEarly = false; // Take care of one-time debugger stuff instance()->debugger().autoExec(); @@ -730,9 +727,8 @@ void PromptWidget::historyScroll(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PromptWidget::nextLine() { - // reset colors every line, so I don't have to remember to do it myself - textColor = defaultTextColor; - bgColor = defaultBGColor; + // Reset colors every line, so I don't have to remember to do it myself + _textcolor = kTextColor; _inverse = false; int line = _currentPos / _lineWidth; @@ -807,17 +803,17 @@ void PromptWidget::putcharIntern(int c) // don't print or advance cursor // there are only 128 TIA colors, but // OverlayColor contains 256 of them - textColor = (c & 0x7f) << 1; + _textcolor = (c & 0x7f) << 1; } else if(c < ' ') { // More colors (the regular GUI ones) - textColor = c + 0x100; + _textcolor = c + 0x100; } else if(c == 0x7f) { // toggle inverse video (DEL char) _inverse = !_inverse; } else { - buffer(_currentPos) = c | (textColor << 8) | (_inverse << 17); + buffer(_currentPos) = c | (_textcolor << 8) | (_inverse << 17); _currentPos++; if ((_scrollLine + 1) * _lineWidth == _currentPos) { diff --git a/stella/src/debugger/gui/PromptWidget.hxx b/stella/src/debugger/gui/PromptWidget.hxx index 259db88ac..e0be8a11a 100644 --- a/stella/src/debugger/gui/PromptWidget.hxx +++ b/stella/src/debugger/gui/PromptWidget.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: PromptWidget.hxx,v 1.11 2007-08-14 20:36:18 stephena Exp $ +// $Id: PromptWidget.hxx,v 1.12 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -107,10 +107,6 @@ class PromptWidget : public Widget, public CommandSender int _kConsoleCharWidth, _kConsoleCharHeight, _kConsoleLineHeight; - int defaultTextColor; - int defaultBGColor; - int textColor; - int bgColor; bool _inverse; bool _makeDirty; bool _firstTime; diff --git a/stella/src/debugger/gui/RomListWidget.cxx b/stella/src/debugger/gui/RomListWidget.cxx index 42a7cd004..a03459286 100644 --- a/stella/src/debugger/gui/RomListWidget.cxx +++ b/stella/src/debugger/gui/RomListWidget.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: RomListWidget.cxx,v 1.9 2007-01-01 18:04:44 stephena Exp $ +// $Id: RomListWidget.cxx,v 1.10 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -112,8 +112,7 @@ void RomListWidget::drawWidget(bool hilite) if (_highlightedItem == pos) { fb.frameRect(_x + l.left - 3, _y + 1 + _fontHeight * i, - _w - l.left, _fontHeight, - kHiliteColor); + _w - l.left, _fontHeight, kDbgColorHi); } // Draw the selected item inverted, on a highlighted background. diff --git a/stella/src/debugger/gui/TiaZoomWidget.cxx b/stella/src/debugger/gui/TiaZoomWidget.cxx index e37d6b73a..b84011198 100644 --- a/stella/src/debugger/gui/TiaZoomWidget.cxx +++ b/stella/src/debugger/gui/TiaZoomWidget.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: TiaZoomWidget.cxx,v 1.12 2007-08-14 19:49:20 stephena Exp $ +// $Id: TiaZoomWidget.cxx,v 1.13 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -34,8 +34,7 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font, CommandSender(boss), myMenu(NULL) { - _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | - WIDGET_WANTS_RAWDATA; + _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS; _type = kTiaZoomWidget; _bgcolor = _bgcolorhi = kDlgColor; @@ -147,30 +146,46 @@ void TiaZoomWidget::handleMouseDown(int x, int y, int button, int clickCount) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool TiaZoomWidget::handleKeyDown(int ascii, int keycode, int modifiers) +bool TiaZoomWidget::handleEvent(Event::Type event) { - bool handled = false; + bool handled = true; - switch(ascii) + switch(event) { - case 256+17: // up arrow + case Event::UIUp: myYCenter -= 4; - handled = true; break; - case 256+18: // down arrow + case Event::UIDown: myYCenter += 4; - handled = true; break; - case 256+20: // left arrow + case Event::UILeft: myXCenter -= 2; - handled = true; break; - case 256+19: // right arrow + case Event::UIRight: myXCenter += 2; - handled = true; + break; + + case Event::UIPgUp: + myYCenter = 0; + break; + + case Event::UIPgDown: + myYCenter = 260; + break; + + case Event::UIHome: + myXCenter = 0; + break; + + case Event::UIEnd: + myXCenter = 320; + break; + + default: + handled = false; break; } diff --git a/stella/src/debugger/gui/TiaZoomWidget.hxx b/stella/src/debugger/gui/TiaZoomWidget.hxx index 576564787..171305006 100644 --- a/stella/src/debugger/gui/TiaZoomWidget.hxx +++ b/stella/src/debugger/gui/TiaZoomWidget.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: TiaZoomWidget.hxx,v 1.7 2007-08-14 19:49:21 stephena Exp $ +// $Id: TiaZoomWidget.hxx,v 1.8 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -41,7 +41,7 @@ class TiaZoomWidget : public Widget, public CommandSender protected: void handleMouseDown(int x, int y, int button, int clickCount); - bool handleKeyDown(int ascii, int keycode, int modifiers); + bool handleEvent(Event::Type event); void handleCommand(CommandSender* sender, int cmd, int data, int id); void drawWidget(bool hilite); diff --git a/stella/src/debugger/gui/ToggleBitWidget.cxx b/stella/src/debugger/gui/ToggleBitWidget.cxx index 91a1f8787..15bd0d3b9 100644 --- a/stella/src/debugger/gui/ToggleBitWidget.cxx +++ b/stella/src/debugger/gui/ToggleBitWidget.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: ToggleBitWidget.cxx,v 1.6 2007-01-01 18:04:44 stephena Exp $ +// $Id: ToggleBitWidget.cxx,v 1.7 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -107,8 +107,8 @@ void ToggleBitWidget::drawWidget(bool hilite) // Highlight changes if(_changedList[pos]) { - fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kTextColorEm); - fb.drawString(_font, buffer, x, y, _colWidth, kTextColorHi); + fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kDbgChangedColor); + fb.drawString(_font, buffer, x, y, _colWidth, kDbgChangedTextColor); } else fb.drawString(_font, buffer, x, y, _colWidth, kTextColor); diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index d121bb922..5c3fa89d2 100644 --- a/stella/src/emucore/FrameBuffer.hxx +++ b/stella/src/emucore/FrameBuffer.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: FrameBuffer.hxx,v 1.89 2007-08-12 23:05:12 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.90 2007-08-15 17:43:51 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_HXX @@ -70,12 +70,12 @@ enum { kColor = 256, kBGColor, kShadowColor, - kHiliteColor, kTextColor, kTextColorHi, kTextColorEm, kDlgColor, kWidColor, + kWidFrameColor, kBtnColor, kBtnColorHi, kBtnTextColor, @@ -85,7 +85,9 @@ enum { kScrollColorHi, kSliderColor, kSliderColorHi, - kWidFrameColor, + kDbgChangedColor, + kDbgChangedTextColor, + kDbgColorHi, kNumColors }; @@ -98,7 +100,7 @@ enum { All GUI elements (ala ScummVM) are drawn here as well. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.89 2007-08-12 23:05:12 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.90 2007-08-15 17:43:51 stephena Exp $ */ class FrameBuffer { diff --git a/stella/src/emucore/OSystem.cxx b/stella/src/emucore/OSystem.cxx index aef2c5133..23c44c98b 100644 --- a/stella/src/emucore/OSystem.cxx +++ b/stella/src/emucore/OSystem.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: OSystem.cxx,v 1.105 2007-08-12 23:05:12 stephena Exp $ +// $Id: OSystem.cxx,v 1.106 2007-08-15 17:43:51 stephena Exp $ //============================================================================ #include @@ -46,6 +46,7 @@ #include "bspf.hxx" #include "OSystem.hxx" #include "Widget.hxx" +#include "ScrollBarWidget.hxx" #define MAX_ROM_SIZE 512 * 1024 @@ -183,6 +184,9 @@ bool OSystem::create() myDebugger = new Debugger(this); #endif + // Set number of lines a mousewheel will scroll + ScrollBarWidget::setWheelLines(mySettings->getInt("mwheel")); + // Create the sound object; the sound subsystem isn't actually // opened until needed, so this is non-blocking (on those systems // that only have a single sound device (no hardware mixing) @@ -769,54 +773,57 @@ void OSystem::queryVideoHardware() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* Palette is defined as follows: + // Base colors kColor TODO kBGColor TODO kShadowColor Item is disabled - kHiliteColor Highlighted color in debugger data cells kTextColor Normal text color kTextColorHi Highlighted text color kTextColorEm TODO + // UI elements (dialog and widgets) kDlgColor Dialog background kWidColor Widget background + kWidFrameColor Border for currently selected widget + // Button colors kBtnColor Normal button background kBtnColorHi Highlighted button background kBtnTextColor Normal button font color kBtnTextColorHi Highlighted button font color + // Checkbox colors + kCheckColor Color of 'X' in checkbox + + // Scrollbar colors kScrollColor Normal scrollbar color kScrollColorHi Highlighted scrollbar color - kWidFrameColor Border for currently selected widget + // Debugger colors + kDbgChangedColor Background color for changed cells + kDbgChangedTextColor Text color for changed cells + kDbgColorHi Highlighted color in debugger data cells */ uInt32 OSystem::ourGUIColors[kNumUIPalettes][kNumColors-256] = { // Standard - { 0x686868, // kColor - 0x000000, // kBGColor - 0x404040, // kShadowColor - 0xc8c8ff, // kHiliteColor - 0x000000, // kTextColor - 0x62a108, // kTextColorHi - 0xc80000, // kTextColorEm - 0xc9af7c, // kDlgColor - 0xf0f0cf, // kWidColor - 0xac3410, // kBtnColor - 0xd55941, // kBtnColorHi - 0xffffff, // kBtnTextColor - 0xffd652, // kBtnTextColorHi - 0xac3410, // kCheckColor - 0xac3410, // kScrollColor - 0xd55941, // kScrollColorHi - 0xac3410, // kSliderColor - 0xd55941, // kSliderColorHi - 0xc80000 // kWidFrameColor + { 0x686868, 0x000000, 0x404040, 0x000000, 0x62a108, 0x9f0000, + 0xc9af7c, 0xf0f0cf, 0xc80000, + 0xac3410, 0xd55941, 0xffffff, 0xffd652, + 0xac3410, + 0xac3410, 0xd55941, + 0xac3410, 0xd55941, + 0xc80000, 0x00ff00, 0xc8c8ff }, // Classic - { 0x686868, 0x000000, 0x404040, 0xc8c8ff, 0x20a020, 0x00ff00, 0xc80000, - 0x000000, 0x000000, 0x000000, 0x000000, 0x20a020, 0x00ff00, 0x20a020, - 0x20a020, 0x00ff00, 0x20a020, 0x00ff00, 0xc80000 } + { 0x686868, 0x000000, 0x404040, 0x20a020, 0x00ff00, 0xc80000, + 0x000000, 0x000000, 0xc80000, + 0x000000, 0x000000, 0x20a020, 0x00ff00, + 0x20a020, + 0x20a020, 0x00ff00, + 0x20a020, 0x00ff00, + 0xc80000, 0x00ff00, 0xc8c8ff + } }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/Settings.cxx b/stella/src/emucore/Settings.cxx index eed233b5a..be564f47d 100644 --- a/stella/src/emucore/Settings.cxx +++ b/stella/src/emucore/Settings.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: Settings.cxx,v 1.122 2007-08-10 18:27:11 stephena Exp $ +// $Id: Settings.cxx,v 1.123 2007-08-15 17:43:51 stephena Exp $ //============================================================================ #include @@ -84,6 +84,7 @@ Settings::Settings(OSystem* osystem) setInternal("debuggerres", "1030x690"); setInternal("launcherres", "400x300"); setInternal("uipalette", "0"); + setInternal("mwheel", "4"); setInternal("autoslot", "false"); } @@ -307,6 +308,7 @@ void Settings::usage() << " -rominfo Display detailed information for the given ROM\n" << " -launcherres The resolution to use in ROM launcher mode\n" << " -uipalette <1|2> Used the specified palette for UI elements\n" + << " -mwheel Number of lines the mouse wheel will scroll in UI\n" << " -statedir Directory in which to save state files\n" << " -cheatfile Full pathname of cheatfile database\n" << " -palettefile Full pathname of user-defined palette file\n" diff --git a/stella/src/gui/AboutDialog.cxx b/stella/src/gui/AboutDialog.cxx index 76667c5ef..eed6c507e 100644 --- a/stella/src/gui/AboutDialog.cxx +++ b/stella/src/gui/AboutDialog.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: AboutDialog.cxx,v 1.20 2007-08-06 20:16:51 stephena Exp $ +// $Id: AboutDialog.cxx,v 1.21 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -54,7 +54,7 @@ AboutDialog::AboutDialog(OSystem* osystem, DialogContainer* parent, myTitle = new StaticTextWidget(this, font, 5, 5, w - 10, font.getFontHeight(), "", kTextAlignCenter); - myTitle->setTextColor(kTextColorHi); + myTitle->setTextColor(kTextColorEm); for(int i = 0; i < LINES_PER_PAGE; i++) { diff --git a/stella/src/gui/FileSnapDialog.cxx b/stella/src/gui/FileSnapDialog.cxx index 0e0332304..fd86a7fb5 100644 --- a/stella/src/gui/FileSnapDialog.cxx +++ b/stella/src/gui/FileSnapDialog.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: FileSnapDialog.cxx,v 1.10 2007-08-07 14:38:51 stephena Exp $ +// $Id: FileSnapDialog.cxx,v 1.11 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -120,11 +120,9 @@ FileSnapDialog::FileSnapDialog( "Multiple snapshots"); wid.push_back(mySnapSingleCheckbox); - // Add focus widgets for Snapshot tab - addToFocusList(wid); - // Add OK & Cancel buttons - wid.clear(); + b = addButton(font, 10, _h - 24, "Defaults", kDefaultsCmd); + wid.push_back(b); #ifndef MAC_OSX b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd); wid.push_back(b); @@ -140,7 +138,8 @@ FileSnapDialog::FileSnapDialog( wid.push_back(b); addOKWidget(b); #endif - addBGroupToFocusList(wid); + + addToFocusList(wid); // Create file browser dialog myBrowser = new BrowserDialog(this, font, 60, 20, 200, 200); @@ -182,6 +181,26 @@ void FileSnapDialog::saveConfig() instance()->setConfigPaths(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FileSnapDialog::setDefaults() +{ + const string& basedir = instance()->baseDir(); + const string& romdir = "roms"; + const string& statedir = basedir + BSPF_PATH_SEPARATOR + "state"; + const string& cheatfile = basedir + BSPF_PATH_SEPARATOR + "stella.cht"; + const string& palettefile = basedir + BSPF_PATH_SEPARATOR + "stella.pal"; + const string& propsfile = basedir + BSPF_PATH_SEPARATOR + "stella.pro"; + + myRomPath->setEditString(romdir); + myStatePath->setEditString(statedir); + myCheatFile->setEditString(cheatfile); + myPaletteFile->setEditString(palettefile); + myPropsFile->setEditString(propsfile); + + mySnapPath->setEditString(string(".") + BSPF_PATH_SEPARATOR); + mySnapSingleCheckbox->setState(true); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FileSnapDialog::openBrowser(const string& title, const string& startpath, FilesystemNode::ListMode mode, int cmd) @@ -206,6 +225,10 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd, sendCommand(kRomDirChosenCmd, 0, 0); // Let the boss know romdir has changed break; + case kDefaultsCmd: + setDefaults(); + break; + case kChooseRomDirCmd: openBrowser("Select ROM directory:", myRomPath->getEditString(), FilesystemNode::kListDirectoriesOnly, kRomDirChosenCmd); diff --git a/stella/src/gui/FileSnapDialog.hxx b/stella/src/gui/FileSnapDialog.hxx index 3e713cd39..222c13751 100644 --- a/stella/src/gui/FileSnapDialog.hxx +++ b/stella/src/gui/FileSnapDialog.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: FileSnapDialog.hxx,v 1.6 2007-08-07 14:38:51 stephena Exp $ +// $Id: FileSnapDialog.hxx,v 1.7 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -42,12 +42,13 @@ class FileSnapDialog : public Dialog, public CommandSender int x, int y, int w, int h); ~FileSnapDialog(); - virtual void loadConfig(); - virtual void saveConfig(); - - virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); + void handleCommand(CommandSender* sender, int cmd, int data, int id); private: + void loadConfig(); + void saveConfig(); + void setDefaults(); + void openBrowser(const string& title, const string& startpath, FilesystemNode::ListMode mode, int cmd); diff --git a/stella/src/gui/OptionsDialog.cxx b/stella/src/gui/OptionsDialog.cxx index 58c3e5c28..2114806cc 100644 --- a/stella/src/gui/OptionsDialog.cxx +++ b/stella/src/gui/OptionsDialog.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: OptionsDialog.cxx,v 1.56 2007-08-10 18:27:11 stephena Exp $ +// $Id: OptionsDialog.cxx,v 1.57 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -123,7 +123,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent, #endif myInputDialog = new InputDialog(myOSystem, parent, font, x, y, w, h); - w = 200; h = 135; + w = 200; h = 155; myUIDialog = new UIDialog(myOSystem, parent, font, x, y, w, h); w = 280; h = 170; diff --git a/stella/src/gui/ScrollBarWidget.cxx b/stella/src/gui/ScrollBarWidget.cxx index 0e9b0b306..283dd624b 100644 --- a/stella/src/gui/ScrollBarWidget.cxx +++ b/stella/src/gui/ScrollBarWidget.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: ScrollBarWidget.cxx,v 1.19 2007-08-13 19:45:42 stephena Exp $ +// $Id: ScrollBarWidget.cxx,v 1.20 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -27,16 +27,12 @@ /* * TODO: - * - Auto-repeat: if user clicks & holds on one of the arrows, then after a - * brief delay, it should start to contiously scroll * - Allow for a horizontal scrollbar, too? * - If there are less items than fit on one pages, no scrolling can be done * and we thus should not highlight the arrows/slider. - * - Allow the mouse wheel to scroll more than one line at a time */ #define UP_DOWN_BOX_HEIGHT 10 -#define WHEEL_LINES 4 // Up arrow static unsigned int up_arrow[8] = { @@ -140,9 +136,9 @@ void ScrollBarWidget::handleMouseWheel(int x, int y, int direction) return; if(direction < 0) - _currentPos -= WHEEL_LINES; + _currentPos -= _WHEEL_LINES; else - _currentPos += WHEEL_LINES; + _currentPos += _WHEEL_LINES; // Make sure that _currentPos is still inside the bounds checkBounds(old_pos); @@ -284,3 +280,7 @@ void ScrollBarWidget::drawWidget(bool hilite) fb.hLine(_x + 2, y + 2, _x + _w - 3, kWidColor); } } + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int ScrollBarWidget::_WHEEL_LINES = 4; diff --git a/stella/src/gui/ScrollBarWidget.hxx b/stella/src/gui/ScrollBarWidget.hxx index c221a8e41..07593b420 100644 --- a/stella/src/gui/ScrollBarWidget.hxx +++ b/stella/src/gui/ScrollBarWidget.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: ScrollBarWidget.hxx,v 1.8 2007-01-01 18:04:54 stephena Exp $ +// $Id: ScrollBarWidget.hxx,v 1.9 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -31,14 +31,6 @@ class ScrollBarWidget : public Widget, public CommandSender { protected: - typedef enum { - kNoPart, - kUpArrowPart, - kDownArrowPart, - kSliderPart, - kPageUpPart, - kPageDownPart - } Part; public: ScrollBarWidget(GuiObject* boss, const GUI::Font& font, @@ -56,21 +48,34 @@ class ScrollBarWidget : public Widget, public CommandSender // should these accessors force a redraw? void recalc(); + static void setWheelLines(int lines) { _WHEEL_LINES = lines; } + + private: + void drawWidget(bool hilite); + void checkBounds(int old_pos); + public: int _numEntries; int _entriesPerPage; int _currentPos; - protected: - void drawWidget(bool hilite); - void checkBounds(int old_pos); + private: + typedef enum { + kNoPart, + kUpArrowPart, + kDownArrowPart, + kSliderPart, + kPageUpPart, + kPageDownPart + } Part; - protected: - Part _part; + Part _part; + Part _draggingPart; int _sliderHeight; int _sliderPos; - Part _draggingPart; int _sliderDeltaMouseDownPos; + + static int _WHEEL_LINES; }; #endif diff --git a/stella/src/gui/TabWidget.cxx b/stella/src/gui/TabWidget.cxx index 15b5b18e0..0791206e3 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.28 2007-08-06 20:16:51 stephena Exp $ +// $Id: TabWidget.cxx,v 1.29 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -273,7 +273,6 @@ void TabWidget::box(int x, int y, int width, int height, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TabWidget::drawWidget(bool hilite) { -//cerr << "TabWidget::drawWidget\n"; // The tab widget is strange in that it acts as both a widget (obviously) // and a dialog (it contains other widgets). Because of the latter, // it must assume responsibility for refreshing all its children. diff --git a/stella/src/gui/UIDialog.cxx b/stella/src/gui/UIDialog.cxx index ba52fdc8e..45c23115b 100644 --- a/stella/src/gui/UIDialog.cxx +++ b/stella/src/gui/UIDialog.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: UIDialog.cxx,v 1.6 2007-08-10 18:27:12 stephena Exp $ +// $Id: UIDialog.cxx,v 1.7 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -28,6 +28,7 @@ #include "Dialog.hxx" #include "UIDialog.hxx" #include "GuiUtils.hxx" +#include "ScrollBarWidget.hxx" #include "bspf.hxx" @@ -103,7 +104,23 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent, myDebuggerHeightLabel->setFlags(WIDGET_CLEARBG); ypos += lineHeight + 4; + // Number of lines a mouse wheel will scroll + myWheelLinesSlider = new SliderWidget(this, font, xpos, ypos, pwidth, + lineHeight, "Mouse wheel scroll: ", + lwidth, kWLinesChanged); + myWheelLinesSlider->setMinValue(1); + myWheelLinesSlider->setMaxValue(10); + myWheelLinesSlider->setStepValue(1); + wid.push_back(myWheelLinesSlider); + myWheelLinesLabel = + new StaticTextWidget(this, font, + xpos + myWheelLinesSlider->getWidth() + 4, + ypos + 1, 20, fontHeight, "", kTextAlignLeft); + myWheelLinesLabel->setFlags(WIDGET_CLEARBG); + ypos += lineHeight + 4; + // UI Palette + ypos += 1; myPalettePopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, "Interface Palette: ", lwidth); myPalettePopup->appendEntry("Standard", 1); @@ -185,10 +202,15 @@ void UIDialog::loadConfig() myDebuggerHeightSlider->setValue(h); myDebuggerHeightLabel->setValue(h); + // Mouse wheel lines + int mw = instance()->settings().getInt("mwheel"); + if(mw < 1 || mw > 10) mw = 1; + myWheelLinesSlider->setValue(mw); + myWheelLinesLabel->setValue(mw); + // UI palette int i = instance()->settings().getInt("uipalette"); - if(i < 1 || i > 2) - i = 1; + if(i < 1 || i > 2) i = 1; myPalettePopup->setSelectedTag(i); } @@ -203,6 +225,11 @@ void UIDialog::saveConfig() instance()->settings().setSize("debuggerres", myDebuggerWidthSlider->getValue(), myDebuggerHeightSlider->getValue()); + // Mouse wheel lines + int mw = myWheelLinesSlider->getValue(); + instance()->settings().setInt("mwheel", mw); + ScrollBarWidget::setWheelLines(mw); + // UI palette instance()->settings().setInt("uipalette", myPalettePopup->getSelectedTag()); @@ -223,6 +250,9 @@ void UIDialog::setDefaults() myDebuggerHeightSlider->setValue(690); myDebuggerHeightLabel->setValue(690); + myWheelLinesSlider->setValue(4); + myWheelLinesLabel->setValue(4); + myPalettePopup->setSelectedTag(1); _dirty = true; @@ -249,6 +279,10 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id) myDebuggerHeightLabel->setValue(myDebuggerHeightSlider->getValue()); break; + case kWLinesChanged: + myWheelLinesLabel->setValue(myWheelLinesSlider->getValue()); + break; + case kOKCmd: saveConfig(); close(); diff --git a/stella/src/gui/UIDialog.hxx b/stella/src/gui/UIDialog.hxx index aae895c6a..8a8dd1533 100644 --- a/stella/src/gui/UIDialog.hxx +++ b/stella/src/gui/UIDialog.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: UIDialog.hxx,v 1.4 2007-08-10 18:27:12 stephena Exp $ +// $Id: UIDialog.hxx,v 1.5 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -50,6 +50,9 @@ class UIDialog : public Dialog SliderWidget* myDebuggerHeightSlider; StaticTextWidget* myDebuggerHeightLabel; + SliderWidget* myWheelLinesSlider; + StaticTextWidget* myWheelLinesLabel; + PopUpWidget* myPalettePopup; private: @@ -63,7 +66,8 @@ class UIDialog : public Dialog kLWidthChanged = 'UIlw', kLHeightChanged = 'UIlh', kDWidthChanged = 'UIdw', - kDHeightChanged = 'UIdh' + kDHeightChanged = 'UIdh', + kWLinesChanged = 'UIsl' }; }; diff --git a/stella/src/gui/Widget.cxx b/stella/src/gui/Widget.cxx index 29d36cc8a..e6fb5d192 100644 --- a/stella/src/gui/Widget.cxx +++ b/stella/src/gui/Widget.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: Widget.cxx,v 1.54 2007-08-12 23:05:12 stephena Exp $ +// $Id: Widget.cxx,v 1.55 2007-08-15 17:43:51 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -246,7 +246,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr, if(tmp->_hasFocus) { tmp->lostFocus(); - fb.frameRect(x, y, w, h, kDlgColor); // FIXME - static issues + fb.frameRect(x, y, w, h, kDlgColor); tmp->setDirty(); tmp->draw(); fb.addDirtyRect(x, y, w, h);