From 64c554e8c5a90dba85ef29d629b60a34a0cb119a Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 1 Aug 2005 22:33:16 +0000 Subject: [PATCH] OK, I'm not sitting on this any longer, for fear it'll get too far out of sync. Implemented dirty widget support for the GUI. That means the widgets will only be drawn when necessary. There are still a few gotcha's: 1) OpenGL mode hasn't been ported to this new scheme. 2) It's not totally finished, so some artifacts may appear onscreen. 3) Selecting active widgets with the mouse is borked. 4) Prompt commands that change the core aren't shown in the other tabs/interface. Fixing this will require some infrastructure work in Debugger and DebuggerParser. 5) A lot of print debug code has been left in; please ignore it for now. Moved a lot of the debugger widgets to use non-proportional font (still TODO is get a larger font) and not use 'magic numbers' for the layout. That means when a new font is added, the layout should re-arrange itself. Moved various Debugger tab widgets from 'src/gui' to 'src/debugger', because they shouldn't be compiled when debugger support isn't included. So now (for example), RamWidget and RamDebug are both in the debugger directory. Probably more stuff I'm forgetting about. It looks like the ScummVM code can be made adequately fast, so the jump to Qt won't be necessary. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@705 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/common/FrameBufferGL.cxx | 26 +++--- stella/src/common/FrameBufferGL.hxx | 45 ++++++---- stella/src/common/FrameBufferSoft.cxx | 61 +++++++++++--- stella/src/common/FrameBufferSoft.hxx | 48 +++++++---- stella/src/{gui => debugger}/CheatWidget.cxx | 7 +- stella/src/{gui => debugger}/CheatWidget.hxx | 2 +- stella/src/{gui => debugger}/CpuWidget.cxx | 8 +- stella/src/{gui => debugger}/CpuWidget.hxx | 2 +- stella/src/debugger/Debugger.hxx | 12 ++- stella/src/{gui => debugger}/PromptWidget.cxx | 83 ++++++++++--------- stella/src/{gui => debugger}/PromptWidget.hxx | 7 +- stella/src/{gui => debugger}/RamWidget.cxx | 66 ++++++++------- stella/src/{gui => debugger}/RamWidget.hxx | 2 +- stella/src/debugger/TiaOutputWidget.cxx | 16 ++-- stella/src/debugger/TiaOutputWidget.hxx | 5 +- stella/src/{gui => debugger}/TiaWidget.cxx | 70 ++++++++-------- stella/src/{gui => debugger}/TiaWidget.hxx | 2 +- stella/src/debugger/module.mk | 7 +- stella/src/emucore/EventHandler.cxx | 5 +- stella/src/emucore/FrameBuffer.cxx | 63 +++++++------- stella/src/emucore/FrameBuffer.hxx | 15 +++- stella/src/gui/AboutDialog.cxx | 9 +- stella/src/gui/AddrValueWidget.cxx | 25 +++--- stella/src/gui/AudioDialog.cxx | 4 +- stella/src/gui/BrowserDialog.cxx | 4 +- stella/src/gui/ColorWidget.cxx | 9 +- stella/src/gui/ColorWidget.hxx | 6 +- stella/src/gui/DataGridWidget.cxx | 31 +++---- stella/src/gui/DebuggerDialog.cxx | 3 +- stella/src/gui/Dialog.cxx | 26 ++++-- stella/src/gui/DialogContainer.cxx | 19 +++-- stella/src/gui/DialogContainer.hxx | 6 +- stella/src/gui/EditNumWidget.cxx | 13 ++- stella/src/gui/EditTextWidget.cxx | 8 +- stella/src/gui/EditableWidget.cxx | 9 +- stella/src/gui/EventMappingDialog.cxx | 8 +- stella/src/gui/Font.hxx | 4 +- stella/src/gui/GameInfoDialog.cxx | 12 +-- stella/src/gui/GuiObject.hxx | 9 +- stella/src/gui/GuiUtils.hxx | 17 ++-- stella/src/gui/HelpDialog.cxx | 12 +-- stella/src/gui/LauncherOptionsDialog.cxx | 26 +++--- stella/src/gui/LauncherOptionsDialog.hxx | 4 +- stella/src/gui/ListWidget.cxx | 24 ++---- stella/src/gui/PopUpWidget.cxx | 83 +++++++++---------- stella/src/gui/ProgressDialog.cxx | 4 +- stella/src/gui/ScrollBarWidget.cxx | 29 +++++-- stella/src/gui/ScrollBarWidget.hxx | 6 +- stella/src/gui/TabWidget.cxx | 35 ++++---- stella/src/gui/ToggleBitWidget.cxx | 19 ++--- stella/src/gui/VideoDialog.cxx | 4 +- stella/src/gui/Widget.cxx | 80 ++++++++++++++---- stella/src/gui/Widget.hxx | 31 ++++--- stella/src/gui/module.mk | 5 -- 54 files changed, 645 insertions(+), 491 deletions(-) rename stella/src/{gui => debugger}/CheatWidget.cxx (98%) rename stella/src/{gui => debugger}/CheatWidget.hxx (96%) rename stella/src/{gui => debugger}/CpuWidget.cxx (97%) rename stella/src/{gui => debugger}/CpuWidget.hxx (96%) rename stella/src/{gui => debugger}/PromptWidget.cxx (93%) rename stella/src/{gui => debugger}/PromptWidget.hxx (95%) rename stella/src/{gui => debugger}/RamWidget.cxx (78%) rename stella/src/{gui => debugger}/RamWidget.hxx (96%) rename stella/src/{gui => debugger}/TiaWidget.cxx (79%) rename stella/src/{gui => debugger}/TiaWidget.hxx (96%) diff --git a/stella/src/common/FrameBufferGL.cxx b/stella/src/common/FrameBufferGL.cxx index a52e3926a..e609e66c5 100644 --- a/stella/src/common/FrameBufferGL.cxx +++ b/stella/src/common/FrameBufferGL.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: FrameBufferGL.cxx,v 1.36 2005-07-20 17:33:02 stephena Exp $ +// $Id: FrameBufferGL.cxx,v 1.37 2005-08-01 22:33:11 stephena Exp $ //============================================================================ #ifdef DISPLAY_OPENGL @@ -33,14 +33,14 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FrameBufferGL::FrameBufferGL(OSystem* osystem) - : FrameBuffer(osystem), - myTexture(NULL), - myScreenmode(0), - myScreenmodeCount(0), - myTextureID(0), - myFilterParam(GL_NEAREST), - myFilterParamName("GL_NEAREST"), - myFSScaleFactor(1.0) + : FrameBuffer(osystem), + myTexture(NULL), + myScreenmode(0), + myScreenmodeCount(0), + myTextureID(0), + myFilterParam(GL_NEAREST), + myFilterParamName("GL_NEAREST"), + myFSScaleFactor(1.0) { } @@ -255,7 +255,7 @@ void FrameBufferGL::postFrameUpdate() { // Do the following twice, since OpenGL mode is double-buffered, // and we need the contents placed in both buffers - if(theRedrawTIAIndicator || theRedrawOverlayIndicator) +// FIXME if(theRedrawTIAIndicator || theRedrawOverlayIndicator) { // Texturemap complete texture to surface so we have free scaling // and antialiasing @@ -439,6 +439,12 @@ void FrameBufferGL::translateCoords(Int32* x, Int32* y) *y = (Int32) (((*y - myImageDim.y) / (theZoomLevel * myFSScaleFactor))); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBufferGL::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) +{ + // FIXME +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FrameBufferGL::createTextures() { diff --git a/stella/src/common/FrameBufferGL.hxx b/stella/src/common/FrameBufferGL.hxx index fe46b8fc9..31fd850bf 100644 --- a/stella/src/common/FrameBufferGL.hxx +++ b/stella/src/common/FrameBufferGL.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: FrameBufferGL.hxx,v 1.19 2005-07-02 01:28:42 stephena Exp $ +// $Id: FrameBufferGL.hxx,v 1.20 2005-08-01 22:33:11 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_GL_HXX @@ -37,7 +37,7 @@ class GUI::Font; This class implements an SDL OpenGL framebuffer. @author Stephen Anthony - @version $Id: FrameBufferGL.hxx,v 1.19 2005-07-02 01:28:42 stephena Exp $ + @version $Id: FrameBufferGL.hxx,v 1.20 2005-08-01 22:33:11 stephena Exp $ */ class FrameBufferGL : public FrameBuffer { @@ -56,18 +56,18 @@ class FrameBufferGL : public FrameBuffer // The following methods are derived from FrameBuffer.hxx ////////////////////////////////////////////////////////////////////// /** - This routine is called to initialize OpenGL video mode. + This method is called to initialize OpenGL video mode. Return false if any operation fails, otherwise return true. */ virtual bool initSubsystem(); /** - This routine is called to set the aspect ratio of the screen. + This method is called to set the aspect ratio of the screen. */ virtual void setAspectRatio(); /** - This routine is called whenever the screen needs to be recreated. + This method is called whenever the screen needs to be recreated. It updates the global screen variable. */ virtual bool createScreen(); @@ -79,23 +79,23 @@ class FrameBufferGL : public FrameBuffer virtual void toggleFilter(); /** - This routine should be called anytime the MediaSource needs to be redrawn + This method should be called anytime the MediaSource needs to be redrawn to the screen. */ virtual void drawMediaSource(); /** - This routine is called before any drawing is done (per-frame). + This method is called before any drawing is done (per-frame). */ virtual void preFrameUpdate(); /** - This routine is called after any drawing is done (per-frame). + This method is called after any drawing is done (per-frame). */ virtual void postFrameUpdate(); /** - This routine is called to get the specified scanline data. + This method is called to get the specified scanline data. @param row The row we are looking for @param data The actual pixel data (in bytes) @@ -103,7 +103,7 @@ class FrameBufferGL : public FrameBuffer virtual void scanline(uInt32 row, uInt8* data); /** - This routine is called to map a given r,g,b triple to the screen palette. + This method is called to map a given r,g,b triple to the screen palette. @param r The red component of the color. @param g The green component of the color. @@ -113,7 +113,7 @@ class FrameBufferGL : public FrameBuffer { return SDL_MapRGB(myTexture->format, r, g, b); } /** - This routine is called to draw a horizontal line. + This method is called to draw a horizontal line. @param x The first x coordinate @param y The y coordinate @@ -123,7 +123,7 @@ class FrameBufferGL : public FrameBuffer virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color); /** - This routine is called to draw a vertical line. + This method is called to draw a vertical line. @param x The x coordinate @param y The first y coordinate @@ -133,7 +133,7 @@ class FrameBufferGL : public FrameBuffer virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color); /** - This routine is called to draw a blended rectangle. + This method is called to draw a blended rectangle. @param x The x coordinate @param y The y coordinate @@ -146,7 +146,7 @@ class FrameBufferGL : public FrameBuffer OverlayColor color, uInt32 level = 3); /** - This routine is called to draw a filled rectangle. + This method is called to draw a filled rectangle. @param x The x coordinate @param y The y coordinate @@ -158,7 +158,7 @@ class FrameBufferGL : public FrameBuffer OverlayColor color); /** - This routine is called to draw the specified character. + This method is called to draw the specified character. @param font The font to use to draw the character @param c The character to draw @@ -170,7 +170,7 @@ class FrameBufferGL : public FrameBuffer OverlayColor color); /** - This routine is called to draw the bitmap image. + This method is called to draw the bitmap image. @param bitmap The data to draw @param x The x coordinate @@ -182,7 +182,7 @@ class FrameBufferGL : public FrameBuffer Int32 h = 8); /** - This routine translates the given coordinates to their + This method translates the given coordinates to their unzoomed/unscaled equivalents. @param x X coordinate to translate @@ -190,6 +190,17 @@ class FrameBufferGL : public FrameBuffer */ inline virtual void translateCoords(Int32* x, Int32* y); + /** + This method adds a dirty rectangle + (ie, an area of the screen that has changed) + + @param x The x coordinate + @param y The y coordinate + @param w The width of the area + @param h The height of the area + */ + virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h); + private: bool createTextures(); diff --git a/stella/src/common/FrameBufferSoft.cxx b/stella/src/common/FrameBufferSoft.cxx index 814853c00..e385346f0 100644 --- a/stella/src/common/FrameBufferSoft.cxx +++ b/stella/src/common/FrameBufferSoft.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: FrameBufferSoft.cxx,v 1.30 2005-07-20 17:33:03 stephena Exp $ +// $Id: FrameBufferSoft.cxx,v 1.31 2005-08-01 22:33:11 stephena Exp $ //============================================================================ #include @@ -32,7 +32,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FrameBufferSoft::FrameBufferSoft(OSystem* osystem) : FrameBuffer(osystem), - myRectList(NULL) + myRectList(NULL), + myOverlayRectList(NULL) { } @@ -40,6 +41,7 @@ FrameBufferSoft::FrameBufferSoft(OSystem* osystem) FrameBufferSoft::~FrameBufferSoft() { delete myRectList; + delete myOverlayRectList; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -50,7 +52,10 @@ bool FrameBufferSoft::initSubsystem() // Set up the rectangle list to be used in the dirty update delete myRectList; myRectList = new RectList(); - if(!myRectList) + delete myOverlayRectList; + myOverlayRectList = new RectList(); + + if(!myRectList || !myOverlayRectList) { cerr << "ERROR: Unable to get memory for SDL rects" << endl; return false; @@ -258,6 +263,12 @@ void FrameBufferSoft::preFrameUpdate() { // Start a new rectlist on each display update myRectList->start(); + + // Add all previous overlay rects, then erase + SDL_Rect* dirtyOverlayRects = myOverlayRectList->rects(); + for(unsigned int i = 0; i < myOverlayRectList->numRects(); ++i) + myRectList->add(&dirtyOverlayRects[i]); + myOverlayRectList->start(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -369,7 +380,6 @@ void FrameBufferSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, tmp.y = y * theZoomLevel; tmp.w = w * theZoomLevel; tmp.h = h * theZoomLevel; - myRectList->add(&tmp); SDL_FillRect(myScreen, &tmp, myPalette[color]); } @@ -378,21 +388,20 @@ void FrameBufferSoft::drawChar(const GUI::Font* FONT, uInt8 chr, uInt32 xorig, uInt32 yorig, OverlayColor color) { GUI::Font* font = (GUI::Font*)FONT; + const FontDesc& desc = font->desc(); // If this character is not included in the font, use the default char. - if(chr < font->desc().firstchar || - chr >= font->desc().firstchar + font->desc().size) + if(chr < desc.firstchar || chr >= desc.firstchar + desc.size) { if (chr == ' ') return; - chr = font->desc().defaultchar; + chr = desc.defaultchar; } const Int32 w = font->getCharWidth(chr); const Int32 h = font->getFontHeight(); - chr -= font->desc().firstchar; - const uInt16* tmp = font->desc().bits + (font->desc().offset ? - font->desc().offset[chr] : (chr * h)); + chr -= desc.firstchar; + const uInt16* tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * h)); SDL_Rect rect; for(int y = 0; y < h; y++) @@ -444,6 +453,38 @@ void FrameBufferSoft::translateCoords(Int32* x, Int32* y) *y /= theZoomLevel; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBufferSoft::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) +{ + x *= theZoomLevel; + y *= theZoomLevel; + w *= theZoomLevel; + h *= theZoomLevel; + + // Check if rect is in screen area + // This is probably a bug, since the GUI code shouldn't be setting + // a dirty rect larger than the screen + int x1 = x, y1 = y, x2 = x + w, y2 = y + h; + int sx1 = myScreenDim.x, sy1 = myScreenDim.y, + sx2 = myScreenDim.x + myScreenDim.w, sy2 = myScreenDim.y + myScreenDim.h; + if(x1 < sx1 || y1 < sy1 || x2 > sx2 || y2 > sy2) + return; + + // Add a dirty rect to the overlay rectangle list + // They will actually be added to the main rectlist in preFrameUpdate() + // TODO - intelligent merging of rectangles, to avoid overlap + SDL_Rect temp; + temp.x = x; + temp.y = y; + temp.w = w; + temp.h = h; + + myOverlayRectList->add(&temp); + +// cerr << "addDirtyRect(): " +// << "x=" << temp.x << ", y=" << temp.y << ", w=" << temp.w << ", h=" << temp.h << endl; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RectList::RectList(Uint32 size) { diff --git a/stella/src/common/FrameBufferSoft.hxx b/stella/src/common/FrameBufferSoft.hxx index 64cfdc06e..50d081500 100644 --- a/stella/src/common/FrameBufferSoft.hxx +++ b/stella/src/common/FrameBufferSoft.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: FrameBufferSoft.hxx,v 1.18 2005-07-02 01:28:42 stephena Exp $ +// $Id: FrameBufferSoft.hxx,v 1.19 2005-08-01 22:33:11 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_SOFT_HXX @@ -35,7 +35,7 @@ class RectList; This class implements an SDL software framebuffer. @author Stephen Anthony - @version $Id: FrameBufferSoft.hxx,v 1.18 2005-07-02 01:28:42 stephena Exp $ + @version $Id: FrameBufferSoft.hxx,v 1.19 2005-08-01 22:33:11 stephena Exp $ */ class FrameBufferSoft : public FrameBuffer { @@ -54,18 +54,18 @@ class FrameBufferSoft : public FrameBuffer // The following methods are derived from FrameBuffer.hxx ////////////////////////////////////////////////////////////////////// /** - This routine is called to initialize software video mode. + This method is called to initialize software video mode. Return false if any operation fails, otherwise return true. */ virtual bool initSubsystem(); /** - This routine is called to set the aspect ratio of the screen. + This method is called to set the aspect ratio of the screen. */ virtual void setAspectRatio(); /** - This routine is called whenever the screen needs to be recreated. + This method is called whenever the screen needs to be recreated. It updates the global screen variable. */ virtual bool createScreen(); @@ -77,23 +77,23 @@ class FrameBufferSoft : public FrameBuffer virtual void toggleFilter(); /** - This routine should be called anytime the MediaSource needs to be redrawn + This method should be called anytime the MediaSource needs to be redrawn to the screen. */ virtual void drawMediaSource(); /** - This routine is called before any drawing is done (per-frame). + This method is called before any drawing is done (per-frame). */ virtual void preFrameUpdate(); /** - This routine is called after any drawing is done (per-frame). + This method is called after any drawing is done (per-frame). */ virtual void postFrameUpdate(); /** - This routine is called to get the specified scanline data. + This method is called to get the specified scanline data. @param row The row we are looking for @param data The actual pixel data (in bytes) @@ -101,7 +101,7 @@ class FrameBufferSoft : public FrameBuffer virtual void scanline(uInt32 row, uInt8* data); /** - This routine is called to map a given r,g,b triple to the screen palette. + This method is called to map a given r,g,b triple to the screen palette. @param r The red component of the color. @param g The green component of the color. @@ -111,7 +111,7 @@ class FrameBufferSoft : public FrameBuffer { return SDL_MapRGB(myScreen->format, r, g, b); } /** - This routine is called to draw a horizontal line. + This method is called to draw a horizontal line. @param x The first x coordinate @param y The y coordinate @@ -121,7 +121,7 @@ class FrameBufferSoft : public FrameBuffer virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color); /** - This routine is called to draw a vertical line. + This method is called to draw a vertical line. @param x The x coordinate @param y The first y coordinate @@ -131,7 +131,7 @@ class FrameBufferSoft : public FrameBuffer virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color); /** - This routine is called to draw a blended rectangle. + This method is called to draw a blended rectangle. @param x The x coordinate @param y The y coordinate @@ -144,7 +144,7 @@ class FrameBufferSoft : public FrameBuffer OverlayColor color, uInt32 level = 3); /** - This routine is called to draw a filled rectangle. + This method is called to draw a filled rectangle. @param x The x coordinate @param y The y coordinate @@ -156,7 +156,7 @@ class FrameBufferSoft : public FrameBuffer OverlayColor color); /** - This routine is called to draw the specified character. + This method is called to draw the specified character. @param font The font to use to draw the character @param c The character to draw @@ -168,7 +168,7 @@ class FrameBufferSoft : public FrameBuffer OverlayColor color); /** - This routine is called to draw the bitmap image. + This method is called to draw the bitmap image. @param bitmap The data to draw @param x The x coordinate @@ -180,7 +180,7 @@ class FrameBufferSoft : public FrameBuffer Int32 h = 8); /** - This routine translates the given coordinates to their + This method translates the given coordinates to their unzoomed/unscaled equivalents. @param x X coordinate to translate @@ -188,9 +188,23 @@ class FrameBufferSoft : public FrameBuffer */ inline virtual void translateCoords(Int32* x, Int32* y); + /** + This method adds a dirty rectangle + (ie, an area of the screen that has changed) + + @param x The x coordinate + @param y The y coordinate + @param w The width of the area + @param h The height of the area + */ + virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h); + private: // Used in the dirty update of the SDL surface RectList* myRectList; + + // Used in the dirty update of the overlay surface + RectList* myOverlayRectList; }; class RectList diff --git a/stella/src/gui/CheatWidget.cxx b/stella/src/debugger/CheatWidget.cxx similarity index 98% rename from stella/src/gui/CheatWidget.cxx rename to stella/src/debugger/CheatWidget.cxx index cc59702c5..7b86136e9 100644 --- a/stella/src/gui/CheatWidget.cxx +++ b/stella/src/debugger/CheatWidget.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: CheatWidget.cxx,v 1.12 2005-07-08 14:36:18 stephena Exp $ +// $Id: CheatWidget.cxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -58,7 +58,7 @@ CheatWidget::CheatWidget(GuiObject* boss, int x, int y, int w, int h) myEditBox->setFont(instance()->consoleFont()); // myEditBox->setTarget(this); myActiveWidget = myEditBox; - ypos += border; + ypos += border; // Add the result text string area myResult = new StaticTextWidget(boss, border + 5, ypos, 175, kLineHeight, @@ -91,9 +91,6 @@ CheatWidget::CheatWidget(GuiObject* boss, int x, int y, int w, int h) myResultsList = new AddrValueWidget(boss, xpos, ypos, 100, 75, 0xff); myResultsList->setFont(instance()->consoleFont()); myResultsList->setTarget(this); - - // Start in a known state - doRestart(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/CheatWidget.hxx b/stella/src/debugger/CheatWidget.hxx similarity index 96% rename from stella/src/gui/CheatWidget.hxx rename to stella/src/debugger/CheatWidget.hxx index 3bc0ba700..cbbbb8ddb 100644 --- a/stella/src/gui/CheatWidget.hxx +++ b/stella/src/debugger/CheatWidget.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: CheatWidget.hxx,v 1.6 2005-07-05 15:25:44 stephena Exp $ +// $Id: CheatWidget.hxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project diff --git a/stella/src/gui/CpuWidget.cxx b/stella/src/debugger/CpuWidget.cxx similarity index 97% rename from stella/src/gui/CpuWidget.cxx rename to stella/src/debugger/CpuWidget.cxx index 859fe1809..5dcfb6b75 100644 --- a/stella/src/gui/CpuWidget.cxx +++ b/stella/src/debugger/CpuWidget.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: CpuWidget.cxx,v 1.15 2005-07-12 02:27:07 urchlay Exp $ +// $Id: CpuWidget.cxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -128,8 +128,6 @@ CpuWidget::CpuWidget(GuiObject* boss, int x, int y, int w, int h) on.push_back(onstr[i]); } myPSRegister->setList(off, on); - - loadConfig(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -209,14 +207,12 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) } } } - - // TODO - dirty rect, or is it necessary here? - instance()->frameBuffer().refreshOverlay(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CpuWidget::loadConfig() { +cerr << "CpuWidget::loadConfig()\n"; fillGrid(); } diff --git a/stella/src/gui/CpuWidget.hxx b/stella/src/debugger/CpuWidget.hxx similarity index 96% rename from stella/src/gui/CpuWidget.hxx rename to stella/src/debugger/CpuWidget.hxx index 9c6f4402f..dc3305095 100644 --- a/stella/src/gui/CpuWidget.hxx +++ b/stella/src/debugger/CpuWidget.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: CpuWidget.hxx,v 1.5 2005-07-05 15:25:44 stephena Exp $ +// $Id: CpuWidget.hxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index cf6184118..7a0bbba70 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.63 2005-07-30 16:25:48 urchlay Exp $ +// $Id: Debugger.hxx,v 1.64 2005-08-01 22:33:12 stephena Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -46,11 +46,19 @@ typedef ListFile::const_iterator ListIter; typedef map FunctionMap; +#if 0 +enum { + kDebuggerWidth = 1023, + kDebuggerLineHeight = 12, // based on the height of the console font + kDebuggerLines = 35, +}; +#else enum { kDebuggerWidth = 639, kDebuggerLineHeight = 12, // based on the height of the console font kDebuggerLines = 20, }; +#endif // Constants for RAM area enum { @@ -74,7 +82,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.63 2005-07-30 16:25:48 urchlay Exp $ + @version $Id: Debugger.hxx,v 1.64 2005-08-01 22:33:12 stephena Exp $ */ class Debugger : public DialogContainer { diff --git a/stella/src/gui/PromptWidget.cxx b/stella/src/debugger/PromptWidget.cxx similarity index 93% rename from stella/src/gui/PromptWidget.cxx rename to stella/src/debugger/PromptWidget.cxx index 10652baad..f742f3943 100644 --- a/stella/src/gui/PromptWidget.cxx +++ b/stella/src/debugger/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.28 2005-07-20 15:52:58 stephena Exp $ +// $Id: PromptWidget.cxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -45,8 +45,9 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PromptWidget::PromptWidget(GuiObject* boss, int x, int y, int w, int h) - : Widget(boss, x, y, w - kScrollBarWidth, h), - CommandSender(boss) + : Widget(boss, x, y, w - kScrollBarWidth, h), + CommandSender(boss), + _makeDirty(false) { _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS; _type = kPromptWidget; @@ -104,13 +105,11 @@ PromptWidget::~PromptWidget() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PromptWidget::drawWidget(bool hilite) { +cerr << "PromptWidget::drawWidget\n"; OverlayColor fgcolor, bgcolor; FrameBuffer& fb = _boss->instance()->frameBuffer(); - // Fill the background - fb.fillRect(_x, _y, _w, _h, kBGColor); - // Draw text int start = _scrollLine - _linesPerPage + 1; int y = _y + 2; @@ -156,11 +155,12 @@ void PromptWidget::handleMouseWheel(int x, int y, int direction) _scrollBar->handleMouseWheel(x, y, direction); } -void PromptWidget::printPrompt() { - print( instance()->debugger().showWatches() ); - print( instance()->debugger().cpuState() ); - print(PROMPT); - _promptStartPos = _promptEndPos = _currentPos; +void PromptWidget::printPrompt() +{ + print( instance()->debugger().showWatches() ); + print( instance()->debugger().cpuState() ); + print(PROMPT); + _promptStartPos = _promptEndPos = _currentPos; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -202,7 +202,6 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) } printPrompt(); - dirty = true; break; } @@ -290,9 +289,8 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) print(prefix); _promptEndPos = _currentPos; } - draw(); - instance()->frameBuffer().refreshOverlay(); delete[] str; + dirty = true; break; } @@ -433,11 +431,24 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) break; } + // Take care of changes made above if(dirty) { - draw(); - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); + } + + // There are times when we want the prompt and scrollbar to be marked + // as dirty *after* they've been drawn above. One such occurrence is + // when we issue a command that indirectly redraws the entire parent + // dialog (such as 'scanline' or 'frame'). + // In those cases, the retunr code of the command must be shown, but the + // entire dialog contents are redrawn at a later time. So the prompt and + // scrollbar won't be redrawn unless they're dirty again. + if(_makeDirty) + { + setDirty(); + _scrollBar->setDirty(); + _makeDirty = false; } return handled; @@ -469,13 +480,19 @@ void PromptWidget::handleCommand(CommandSender* sender, int cmd, if (newPos != _scrollLine) { _scrollLine = newPos; - draw(); - instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } break; } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void PromptWidget::loadConfig() +{ + // See logic at the end of handleKeyDown for an explanation of this + _makeDirty = true; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PromptWidget::specialKeys(int keycode) { @@ -516,8 +533,7 @@ void PromptWidget::specialKeys(int keycode) if(handled) { - draw(); - instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } } @@ -669,9 +685,7 @@ void PromptWidget::historyScroll(int direction) // Ensure once more the caret is visible (in case of very long history entries) scrollToCurrent(); - draw(); - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -746,9 +760,7 @@ void PromptWidget::putchar(int c) { putcharIntern(c); - draw(); // FIXME - not nice to redraw the full console just for one char! - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); // FIXME - not nice to redraw the full console just for one char! } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -781,20 +793,11 @@ void PromptWidget::putcharIntern(int c) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PromptWidget::print(string str) // laziness/convenience method +void PromptWidget::print(const string& str) { - print(str.c_str()); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PromptWidget::print(const char *str) -{ - while (*str) - putcharIntern(*str++); - - draw(); - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); + const char* c = str.c_str(); + while(*c) + putcharIntern(*c++); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/PromptWidget.hxx b/stella/src/debugger/PromptWidget.hxx similarity index 95% rename from stella/src/gui/PromptWidget.hxx rename to stella/src/debugger/PromptWidget.hxx index 74c3ca9b9..7b9f0dfae 100644 --- a/stella/src/gui/PromptWidget.hxx +++ b/stella/src/debugger/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.8 2005-07-16 16:09:38 urchlay Exp $ +// $Id: PromptWidget.hxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -49,8 +49,7 @@ class PromptWidget : public Widget, public CommandSender int vprintf(const char *format, va_list argptr); #undef putchar void putchar(int c); - void print(const char *str); - void print(string str); + void print(const string& str); void printPrompt(); bool saveBuffer(string& filename); @@ -79,6 +78,7 @@ class PromptWidget : public Widget, public CommandSender void handleMouseWheel(int x, int y, int direction); bool handleKeyDown(int ascii, int keycode, int modifiers); void handleCommand(CommandSender* sender, int cmd, int data, int id); + void loadConfig(); protected: int _buffer[kBufferSize]; @@ -108,6 +108,7 @@ class PromptWidget : public Widget, public CommandSender OverlayColor textColor; OverlayColor bgColor; bool _inverse; + bool _makeDirty; int compareHistory(const char *histLine); }; diff --git a/stella/src/gui/RamWidget.cxx b/stella/src/debugger/RamWidget.cxx similarity index 78% rename from stella/src/gui/RamWidget.cxx rename to stella/src/debugger/RamWidget.cxx index d8623d9d4..ff934d9bc 100644 --- a/stella/src/gui/RamWidget.cxx +++ b/stella/src/debugger/RamWidget.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: RamWidget.cxx,v 1.19 2005-07-12 02:27:07 urchlay Exp $ +// $Id: RamWidget.cxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -37,57 +37,64 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) : Widget(boss, x, y, w, h), CommandSender(boss) { - int xpos = 10; - int ypos = 20; - int lwidth = 30; + int xpos = 10, ypos = 20, lwidth = 4 * kCFontWidth; const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24; const GUI::Font& font = instance()->consoleFont(); + StaticTextWidget* t; // Create a 16x8 grid holding byte values (16 x 8 = 128 RAM bytes) with labels - myRamGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 16, 8, 2, 8, kBASE_16); + myRamGrid = new DataGridWidget(boss, xpos + lwidth, ypos, 16, 8, 2, 8, kBASE_16); myRamGrid->setTarget(this); myRamGrid->clearFlags(WIDGET_TAB_NAVIGATE); myActiveWidget = myRamGrid; for(int row = 0; row < 8; ++row) { - StaticTextWidget* t = new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2, - lwidth, kLineHeight, - Debugger::to_hex_16(row*16 + kRamStart) + string(":"), - kTextAlignLeft); + t = new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2, + lwidth, kCFontHeight, + Debugger::to_hex_8(row*16 + kRamStart) + string(":"), + kTextAlignLeft); t->setFont(font); } for(int col = 0; col < 16; ++col) { - StaticTextWidget* t = new StaticTextWidget(boss, - xpos + col*myRamGrid->colWidth() + lwidth + 12, - ypos - kLineHeight, - lwidth, kLineHeight, - Debugger::to_hex_4(col), - kTextAlignLeft); + t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 7, + ypos - kLineHeight, + kCFontWidth, kCFontHeight, + Debugger::to_hex_4(col), + kTextAlignLeft); t->setFont(font); } xpos = 20; ypos = 11 * kLineHeight; - new StaticTextWidget(boss, xpos, ypos, 30, kLineHeight, "Label: ", kTextAlignLeft); - xpos += 30; - myLabel = new EditTextWidget(boss, xpos, ypos-2, 100, kLineHeight, ""); + t = new StaticTextWidget(boss, xpos, ypos, + 6*kCFontWidth, kCFontHeight, + "Label:", kTextAlignLeft); + t->setFont(font); + xpos += 6*kCFontWidth + 5; + myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*kCFontWidth, kLineHeight, ""); myLabel->clearFlags(WIDGET_TAB_NAVIGATE); myLabel->setFont(font); myLabel->setEditable(false); - xpos += 120; - new StaticTextWidget(boss, xpos, ypos, 35, kLineHeight, "Decimal: ", kTextAlignLeft); - xpos += 35; - myDecValue = new EditTextWidget(boss, xpos, ypos-2, 30, kLineHeight, ""); + xpos += 15*kCFontWidth + 20; + t = new StaticTextWidget(boss, xpos, ypos, + 4*kCFontWidth, kCFontHeight, + "Dec:", kTextAlignLeft); + t->setFont(font); + xpos += 4*kCFontWidth + 5; + myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*kCFontWidth, kLineHeight, ""); myDecValue->clearFlags(WIDGET_TAB_NAVIGATE); myDecValue->setFont(font); myDecValue->setEditable(false); - xpos += 48; - new StaticTextWidget(boss, xpos, ypos, 35, kLineHeight, "Binary: ", kTextAlignLeft); - xpos += 35; - myBinValue = new EditTextWidget(boss, xpos, ypos-2, 60, kLineHeight, ""); + xpos += 4*kCFontWidth + 20; + t = new StaticTextWidget(boss, xpos, ypos, + 4*kCFontWidth, kCFontHeight, + "Bin:", kTextAlignLeft); + t->setFont(font); + xpos += 4*kCFontWidth + 5; + myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*kCFontWidth, kLineHeight, ""); myBinValue->clearFlags(WIDGET_TAB_NAVIGATE); myBinValue->setFont(font); myBinValue->setEditable(false); @@ -135,8 +142,6 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) ypos += 16 + space; b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, ">>", kDGShiftRCmd, 0); b->setTarget(myRamGrid); - - loadConfig(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -193,16 +198,13 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) myUndoButton->setEnabled(false); fillGrid(false); break; - } - - // TODO - dirty rect, or is it necessary here? - instance()->frameBuffer().refreshOverlay(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RamWidget::loadConfig() { +cerr << "RamWidget::loadConfig()\n"; fillGrid(true); } diff --git a/stella/src/gui/RamWidget.hxx b/stella/src/debugger/RamWidget.hxx similarity index 96% rename from stella/src/gui/RamWidget.hxx rename to stella/src/debugger/RamWidget.hxx index 6528cddad..e61594e60 100644 --- a/stella/src/gui/RamWidget.hxx +++ b/stella/src/debugger/RamWidget.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: RamWidget.hxx,v 1.8 2005-07-07 15:19:04 stephena Exp $ +// $Id: RamWidget.hxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project diff --git a/stella/src/debugger/TiaOutputWidget.cxx b/stella/src/debugger/TiaOutputWidget.cxx index 090a64961..ffb5ad8f2 100644 --- a/stella/src/debugger/TiaOutputWidget.cxx +++ b/stella/src/debugger/TiaOutputWidget.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: TiaOutputWidget.cxx,v 1.2 2005-07-19 18:21:27 stephena Exp $ +// $Id: TiaOutputWidget.cxx,v 1.3 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,8 +29,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TiaOutputWidget::TiaOutputWidget(GuiObject* boss, int x, int y, int w, int h) : Widget(boss, x, y, w, h), - CommandSender(boss), - _dirty(true) + CommandSender(boss) { } @@ -47,7 +46,6 @@ void TiaOutputWidget::advanceScanline(int lines) instance()->console().mediaSource().updateScanline(); --lines; } - _dirty = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -58,7 +56,6 @@ void TiaOutputWidget::advance(int frames) instance()->console().mediaSource().update(); --frames; } - _dirty = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -70,10 +67,7 @@ cerr << "TiaOutputWidget button press: x = " << x << ", y = " << y << endl; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaOutputWidget::drawWidget(bool hilite) { -// if(_dirty) // FIXME - only redraw this when necessary?? - { - instance()->frameBuffer().refreshTIA(); - instance()->frameBuffer().drawMediaSource(); - _dirty = false; - } +cerr << "TiaOutputWidget::drawWidget\n"; + instance()->frameBuffer().refreshTIA(); + instance()->frameBuffer().drawMediaSource(); } diff --git a/stella/src/debugger/TiaOutputWidget.hxx b/stella/src/debugger/TiaOutputWidget.hxx index 357f7b743..c46548d28 100644 --- a/stella/src/debugger/TiaOutputWidget.hxx +++ b/stella/src/debugger/TiaOutputWidget.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: TiaOutputWidget.hxx,v 1.2 2005-07-19 18:21:27 stephena Exp $ +// $Id: TiaOutputWidget.hxx,v 1.3 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -54,9 +54,6 @@ class TiaOutputWidget : public Widget, public CommandSender bool wantsFocus() { return false; } void handleMouseDown(int x, int y, int button, int clickCount); - - private: - bool _dirty; }; #endif diff --git a/stella/src/gui/TiaWidget.cxx b/stella/src/debugger/TiaWidget.cxx similarity index 79% rename from stella/src/gui/TiaWidget.cxx rename to stella/src/debugger/TiaWidget.cxx index 48ec85cc2..cba8bf40a 100644 --- a/stella/src/gui/TiaWidget.cxx +++ b/stella/src/debugger/TiaWidget.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: TiaWidget.cxx,v 1.12 2005-07-21 19:30:17 stephena Exp $ +// $Id: TiaWidget.cxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -52,70 +52,77 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h) : Widget(boss, x, y, w, h), CommandSender(boss) { - int xpos = 10; - int ypos = 20; - int lwidth = 25; + int xpos = 10, ypos = 20, lwidth = 4 * kCFontWidth; // const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24; const GUI::Font& font = instance()->consoleFont(); // Create a 16x1 grid holding byte values with labels - myRamGrid = new DataGridWidget(boss, xpos+lwidth, ypos, 16, 1, 2, 8, kBASE_16); + myRamGrid = new DataGridWidget(boss, xpos + lwidth, ypos, 16, 1, 2, 8, kBASE_16); myRamGrid->setEditable(false); myRamGrid->setTarget(this); myRamGrid->setID(kRamID); myActiveWidget = myRamGrid; StaticTextWidget* t = new StaticTextWidget(boss, xpos, ypos + 2, - lwidth, kLineHeight, + lwidth, kCFontHeight, Debugger::to_hex_8(0) + string(":"), kTextAlignLeft); t->setFont(font); for(int col = 0; col < 16; ++col) { - StaticTextWidget* t = new StaticTextWidget(boss, - xpos + col*myRamGrid->colWidth() + lwidth + 7, - ypos - kLineHeight, - lwidth, kLineHeight, - Debugger::to_hex_4(col), - kTextAlignLeft); + t = new StaticTextWidget(boss, xpos + col*myRamGrid->colWidth() + lwidth + 7, + ypos - kLineHeight, + kCFontWidth, kCFontHeight, + Debugger::to_hex_4(col), + kTextAlignLeft); t->setFont(font); } xpos = 20; ypos = 4 * kLineHeight; - new StaticTextWidget(boss, xpos, ypos, 30, kLineHeight, "Label: ", kTextAlignLeft); - xpos += 30; - myLabel = new EditTextWidget(boss, xpos, ypos-2, 100, kLineHeight, ""); + t = new StaticTextWidget(boss, xpos, ypos, + 6*kCFontWidth, kCFontHeight, + "Label:", kTextAlignLeft); + t->setFont(font); + xpos += 6*kCFontWidth + 5; + myLabel = new EditTextWidget(boss, xpos, ypos-2, 15*kCFontWidth, kLineHeight, ""); myLabel->clearFlags(WIDGET_TAB_NAVIGATE); myLabel->setFont(font); myLabel->setEditable(false); - xpos += 120; - new StaticTextWidget(boss, xpos, ypos, 35, kLineHeight, "Decimal: ", kTextAlignLeft); - xpos += 35; - myDecValue = new EditTextWidget(boss, xpos, ypos-2, 30, kLineHeight, ""); + xpos += 15*kCFontWidth + 20; + t = new StaticTextWidget(boss, xpos, ypos, + 4*kCFontWidth, kCFontHeight, + "Dec:", kTextAlignLeft); + t->setFont(font); + xpos += 4*kCFontWidth + 5; + myDecValue = new EditTextWidget(boss, xpos, ypos-2, 4*kCFontWidth, kLineHeight, ""); myDecValue->clearFlags(WIDGET_TAB_NAVIGATE); myDecValue->setFont(font); myDecValue->setEditable(false); - xpos += 48; - new StaticTextWidget(boss, xpos, ypos, 35, kLineHeight, "Binary: ", kTextAlignLeft); - xpos += 35; - myBinValue = new EditTextWidget(boss, xpos, ypos-2, 60, kLineHeight, ""); + xpos += 4*kCFontWidth + 20; + t = new StaticTextWidget(boss, xpos, ypos, + 4*kCFontWidth, kCFontHeight, + "Bin:", kTextAlignLeft); + t->setFont(font); + xpos += 4*kCFontWidth + 5; + myBinValue = new EditTextWidget(boss, xpos, ypos-2, 9*kCFontWidth, kLineHeight, ""); myBinValue->clearFlags(WIDGET_TAB_NAVIGATE); myBinValue->setFont(font); myBinValue->setEditable(false); // Color registers - const char* regNames[] = { "COLUP0", "COLUP1", "COLUPF", "COLUBK" }; + const char* regNames[] = { "COLUP0:", "COLUP1:", "COLUPF:", "COLUBK:" }; xpos = 10; ypos += 2* kLineHeight; for(int row = 0; row < 4; ++row) { - new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2, - 40, kLineHeight, - regNames[row] + string(":"), - kTextAlignLeft); + t = new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2, + 7*kCFontWidth, kCFontHeight, + regNames[row], + kTextAlignLeft); + t->setFont(font); } - xpos += 40; + xpos += 7*kCFontWidth + 5; myColorRegs = new DataGridWidget(boss, xpos, ypos, 1, 4, 2, 8, kBASE_16); myColorRegs->setTarget(this); myColorRegs->setID(kColorRegsID); @@ -148,7 +155,6 @@ TiaWidget::TiaWidget(GuiObject* boss, int x, int y, int w, int h) // b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "", kRCmd, 0); // b->setTarget(this); */ - loadConfig(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -213,14 +219,12 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) } break; } - - // TODO - dirty rect, or is it necessary here? - instance()->frameBuffer().refreshOverlay(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaWidget::loadConfig() { +cerr << "TiaWidget::loadConfig()\n"; fillGrid(); } diff --git a/stella/src/gui/TiaWidget.hxx b/stella/src/debugger/TiaWidget.hxx similarity index 96% rename from stella/src/gui/TiaWidget.hxx rename to stella/src/debugger/TiaWidget.hxx index 615ecd650..740ad2c83 100644 --- a/stella/src/gui/TiaWidget.hxx +++ b/stella/src/debugger/TiaWidget.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: TiaWidget.hxx,v 1.7 2005-07-21 19:30:17 stephena Exp $ +// $Id: TiaWidget.hxx,v 1.1 2005-08-01 22:33:12 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project diff --git a/stella/src/debugger/module.mk b/stella/src/debugger/module.mk index 718d1d4e1..f1871bd26 100644 --- a/stella/src/debugger/module.mk +++ b/stella/src/debugger/module.mk @@ -41,7 +41,12 @@ MODULE_OBJS := \ src/debugger/RamDebug.o \ src/debugger/TIADebug.o \ src/debugger/TiaInfoWidget.o \ - src/debugger/TiaOutputWidget.o + src/debugger/TiaOutputWidget.o \ + src/debugger/CheatWidget.o \ + src/debugger/CpuWidget.o \ + src/debugger/PromptWidget.o \ + src/debugger/RamWidget.o \ + src/debugger/TiaWidget.o MODULE_DIRS += \ src/debugger diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 288d5eaff..7c5593249 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.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: EventHandler.cxx,v 1.82 2005-07-27 20:19:26 urchlay Exp $ +// $Id: EventHandler.cxx,v 1.83 2005-08-01 22:33:12 stephena Exp $ //============================================================================ #include @@ -463,6 +463,7 @@ void EventHandler::poll(uInt32 time) break; // SDL_QUIT case SDL_VIDEOEXPOSE: +cerr << "SDL_VIDEOEXPOSE\n"; myOSystem->frameBuffer().refreshTIA(); myOSystem->frameBuffer().refreshOverlay(); break; // SDL_VIDEOEXPOSE @@ -654,7 +655,7 @@ void EventHandler::handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 sta break; case S_DEBUGGER: - if(myKeyTable[key] == Event::DebuggerMode && mod == 0 && state == 1) + if(myKeyTable[key] == Event::DebuggerMode && mod == 4096 && state == 1) { leaveDebugMode(); return; diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 3c17829ab..423eb71fa 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.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: FrameBuffer.cxx,v 1.57 2005-07-20 18:44:38 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.58 2005-08-01 22:33:12 stephena Exp $ //============================================================================ #include @@ -44,7 +44,7 @@ FrameBuffer::FrameBuffer(OSystem* osystem) theAspectRatio(1.0), myFrameRate(0), myPauseStatus(false), - myMessageTime(-1), + myMessageTime(0), myMessageText(""), myNumRedraws(0) { @@ -163,30 +163,29 @@ void FrameBuffer::update() // We always draw the screen, even if the core is paused drawMediaSource(); - if(!myPauseStatus) + // Draw any pending messages + if(myMessageTime > 0 && !myPauseStatus) { - // Draw any pending messages - if(myMessageTime > 0) + int w = myOSystem->font().getStringWidth(myMessageText) + 10; + int h = myOSystem->font().getFontHeight() + 8; + int x = (myBaseDim.w >> 1) - (w >> 1); + int y = myBaseDim.h - h - 10/2; + + // Draw the bounded box and text + fillRect(x+1, y+2, w-2, h-4, kBGColor); + box(x, y+1, w, h-2, kColor, kColor); + drawString(&myOSystem->font(), myMessageText, x+1, y+4, w, kTextColor, kTextAlignCenter); + myMessageTime--; + + // Either erase the entire message (when time is reached), + // or show again this frame + if(myMessageTime == 0) { - int w = myOSystem->font().getStringWidth(myMessageText) + 10; - int h = myOSystem->font().getFontHeight() + 8; - int x = (myBaseDim.w >> 1) - (w >> 1); - int y = myBaseDim.h - h - 10/2; - - // Draw the bounded box and text - blendRect(x+1, y+2, w-2, h-4, kBGColor); - box(x, y+1, w, h-2, kColor, kColor); - drawString(&myOSystem->font(), myMessageText, x+1, y+4, w, kTextColor, kTextAlignCenter); - myMessageTime--; - - // Erase this message on next update - if(myMessageTime == 0) - { - myMessageTime = -1; - theRedrawTIAIndicator = true; - drawMediaSource(); // show the changes right now, not next frame - } + theRedrawTIAIndicator = true; + drawMediaSource(); } + else + addDirtyRect(x, y, w, h); } break; // S_EMULATE } @@ -198,17 +197,15 @@ void FrameBuffer::update() drawMediaSource(); // Only update the overlay if it's changed - if(theRedrawOverlayIndicator) - myOSystem->menu().draw(); + myOSystem->menu().draw(theRedrawOverlayIndicator); break; // S_MENU } case EventHandler::S_LAUNCHER: { - // Only update the screen if it's been invalidated or the overlay have changed - if(theRedrawOverlayIndicator) - myOSystem->launcher().draw(); + // Only update the overlay if it's changed + myOSystem->launcher().draw(theRedrawOverlayIndicator); break; // S_LAUNCHER } @@ -216,9 +213,7 @@ void FrameBuffer::update() case EventHandler::S_DEBUGGER: { // Only update the overlay if it's changed - // This is a performance hack to only draw the menus when necessary - if(theRedrawOverlayIndicator) - myOSystem->debugger().draw(); + myOSystem->debugger().draw(theRedrawOverlayIndicator); break; // S_DEBUGGER } @@ -238,7 +233,7 @@ void FrameBuffer::update() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::refreshTIA(bool now) { -// cerr << "refreshTIA() " << myNumRedraws++ << endl; + cerr << "refreshTIA() " << myNumRedraws++ << endl; theRedrawTIAIndicator = true; if(now) { @@ -250,7 +245,7 @@ void FrameBuffer::refreshTIA(bool now) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::refreshOverlay(bool now) { -// cerr << "refreshOverlay()\n"; + cerr << "refreshOverlay()\n"; if(myOSystem->eventHandler().state() == EventHandler::S_MENU) refreshTIA(now); @@ -262,7 +257,7 @@ void FrameBuffer::refreshOverlay(bool now) void FrameBuffer::showMessage(const string& message) { // Erase old messages on the screen - if(myMessageTime != -1) + if(myMessageTime > 0) { theRedrawTIAIndicator = true; drawMediaSource(); diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index ac1c718a6..062c94683 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.50 2005-07-20 15:52:58 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.51 2005-08-01 22:33:13 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_HXX @@ -52,7 +52,7 @@ enum FrameStyle { All GUI elements (ala ScummVM) are drawn here as well. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.50 2005-07-20 15:52:58 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.51 2005-08-01 22:33:13 stephena Exp $ */ class FrameBuffer { @@ -392,6 +392,17 @@ class FrameBuffer */ virtual void translateCoords(Int32* x, Int32* y) = 0; + /** + This method should be called to add a dirty rectangle + (ie, an area of the screen that has changed) + + @param x The x coordinate + @param y The y coordinate + @param w The width of the area + @param h The height of the area + */ + virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) = 0; + protected: // The parent system for the framebuffer OSystem* myOSystem; diff --git a/stella/src/gui/AboutDialog.cxx b/stella/src/gui/AboutDialog.cxx index 22769343b..215e41fd3 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.4 2005-07-05 15:25:44 stephena Exp $ +// $Id: AboutDialog.cxx,v 1.5 2005-08-01 22:33:14 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -43,13 +43,13 @@ AboutDialog::AboutDialog(OSystem* osystem, DialogContainer* parent, addButton(w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C'); myPrevButton->clearFlags(WIDGET_ENABLED); - myTitle = new StaticTextWidget(this, 0, 5, w, 16, "", kTextAlignCenter); + myTitle = new StaticTextWidget(this, 0, 5, w, kFontHeight, "", kTextAlignCenter); myTitle->setColor(kTextColorHi); for(int i = 0; i < LINES_PER_PAGE; i++) { myDesc[i] = new StaticTextWidget(this, 10, 18 + (10 * i), w - 20, - kLineHeight, "", kTextAlignLeft); + kFontHeight, "", kTextAlignLeft); } } @@ -226,7 +226,8 @@ void AboutDialog::displayInfo() delete[] dscStr; - instance()->frameBuffer().refreshOverlay(); + // Redraw entire dialog + _dirty = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/AddrValueWidget.cxx b/stella/src/gui/AddrValueWidget.cxx index 75de01dac..0572a2077 100644 --- a/stella/src/gui/AddrValueWidget.cxx +++ b/stella/src/gui/AddrValueWidget.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: AddrValueWidget.cxx,v 1.8 2005-07-05 15:25:44 stephena Exp $ +// $Id: AddrValueWidget.cxx,v 1.9 2005-08-01 22:33:14 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -94,6 +94,9 @@ void AddrValueWidget::setList(const AddrList& alist, const ValueList& vlist) _selectedItem = -1; _editMode = false; scrollBarRecalc(); + + // The list should now be redrawn + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -143,14 +146,9 @@ void AddrValueWidget::handleMouseDown(int x, int y, int button, int clickCount) abortEditMode(); _selectedItem = newSelectedItem; sendCommand(kAVSelectionChangedCmd, _selectedItem, _id); - - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); } - // TODO: Determine where inside the string the user clicked and place the - // caret accordingly. See _editScrollOffset and EditTextWidget::handleMouseDown. - draw(); + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -196,6 +194,8 @@ bool AddrValueWidget::handleKeyDown(int ascii, int keycode, int modifiers) { // Class EditableWidget handles all text editing related key presses for us handled = EditableWidget::handleKeyDown(ascii, keycode, modifiers); + if(handled) + setDirty(); draw(); } else { @@ -255,16 +255,12 @@ bool AddrValueWidget::handleKeyDown(int ascii, int keycode, int modifiers) } if (dirty || _selectedItem != oldSelectedItem) - draw(); - - if (_selectedItem != oldSelectedItem) { sendCommand(kAVSelectionChangedCmd, _selectedItem, _id); // also draw scrollbar _scrollBar->draw(); - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } _currentKeyDown = keycode; @@ -283,7 +279,6 @@ bool AddrValueWidget::handleKeyUp(int ascii, int keycode, int modifiers) void AddrValueWidget::lostFocusWidget() { _editMode = false; - draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -296,7 +291,7 @@ void AddrValueWidget::handleCommand(CommandSender* sender, int cmd, if (_currentPos != (int)data) { _currentPos = data; - draw(); + setDirty(); draw(); } break; } @@ -305,6 +300,7 @@ void AddrValueWidget::handleCommand(CommandSender* sender, int cmd, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void AddrValueWidget::drawWidget(bool hilite) { +cerr << "AddrValueWidget::drawWidget\n"; FrameBuffer& fb = _boss->instance()->frameBuffer(); int i, pos, len = _valueList.size(); string buffer; @@ -401,7 +397,6 @@ void AddrValueWidget::startEditMode() { _editMode = true; setEditString(""); // Erase current entry when starting editing - draw(); } } diff --git a/stella/src/gui/AudioDialog.cxx b/stella/src/gui/AudioDialog.cxx index ba7e7ce62..5502bceaa 100644 --- a/stella/src/gui/AudioDialog.cxx +++ b/stella/src/gui/AudioDialog.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: AudioDialog.cxx,v 1.10 2005-07-05 15:25:44 stephena Exp $ +// $Id: AudioDialog.cxx,v 1.11 2005-08-01 22:33:14 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -181,7 +181,7 @@ void AudioDialog::setDefaults() // Make sure that mutually-exclusive items are not enabled at the same time handleSoundEnableChange(true); - instance()->frameBuffer().refreshOverlay(); + _dirty = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/BrowserDialog.cxx b/stella/src/gui/BrowserDialog.cxx index 04e3ce7f1..ec12b12c5 100644 --- a/stella/src/gui/BrowserDialog.cxx +++ b/stella/src/gui/BrowserDialog.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: BrowserDialog.cxx,v 1.7 2005-07-05 15:25:44 stephena Exp $ +// $Id: BrowserDialog.cxx,v 1.8 2005-08-01 22:33:14 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -149,5 +149,5 @@ void BrowserDialog::updateListing() _fileList->scrollTo(0); // Finally, redraw - draw(); + setDirty(); draw(); } diff --git a/stella/src/gui/ColorWidget.cxx b/stella/src/gui/ColorWidget.cxx index 229be5820..9f3041d55 100644 --- a/stella/src/gui/ColorWidget.cxx +++ b/stella/src/gui/ColorWidget.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: ColorWidget.cxx,v 1.1 2005-07-14 23:47:17 stephena Exp $ +// $Id: ColorWidget.cxx,v 1.2 2005-08-01 22:33:14 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -43,6 +43,13 @@ ColorWidget::~ColorWidget() { } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ColorWidget::setColor(int color) +{ + _color = color; + setDirty(); draw(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ColorWidget::handleMouseDown(int x, int y, int button, int clickCount) { diff --git a/stella/src/gui/ColorWidget.hxx b/stella/src/gui/ColorWidget.hxx index 936ea9125..d5590a8b8 100644 --- a/stella/src/gui/ColorWidget.hxx +++ b/stella/src/gui/ColorWidget.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: ColorWidget.hxx,v 1.1 2005-07-14 23:47:17 stephena Exp $ +// $Id: ColorWidget.hxx,v 1.2 2005-08-01 22:33:14 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -35,7 +35,7 @@ class GuiObject; be expanded with a TIA palette table, to set the color visually. @author Stephen Anthony - @version $Id: ColorWidget.hxx,v 1.1 2005-07-14 23:47:17 stephena Exp $ + @version $Id: ColorWidget.hxx,v 1.2 2005-08-01 22:33:14 stephena Exp $ */ class ColorWidget : public Widget, public CommandSender { @@ -45,7 +45,7 @@ class ColorWidget : public Widget, public CommandSender ColorWidget(GuiObject* boss, int x, int y, int w, int h, int cmd = 0); ~ColorWidget(); - void setColor(int color) { _color = color; } + void setColor(int color); int getColor() const { return _color; } protected: diff --git a/stella/src/gui/DataGridWidget.cxx b/stella/src/gui/DataGridWidget.cxx index b65471882..fc1747682 100644 --- a/stella/src/gui/DataGridWidget.cxx +++ b/stella/src/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.14 2005-07-14 18:28:36 stephena Exp $ +// $Id: DataGridWidget.cxx,v 1.15 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -95,6 +95,13 @@ cerr << "alist.size() = " << alist.size() _valueStringList.push_back(temp); } +/* +cerr << "_addrList.size() = " << _addrList.size() + << ", _valueList.size() = " << _valueList.size() + << ", _changedList.size() = " << _changedList.size() + << ", _valueStringList.size() = " << _valueStringList.size() + << ", _rows*_cols = " << _rows * _cols << endl << endl; +*/ _editMode = false; // Send item selected signal for starting with cell 0 @@ -140,14 +147,11 @@ void DataGridWidget::handleMouseDown(int x, int y, int button, int clickCount) _currentCol = _selectedItem - (_currentRow * _cols); sendCommand(kDGSelectionChangedCmd, _selectedItem, _id); - - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); } - // TODO: Determine where inside the string the user clicked and place the - // caret accordingly. See _editScrollOffset and EditTextWidget::handleMouseDown. - draw(); + // FIXME - this is only here for focus + // it needs to be fixed + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -192,6 +196,8 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) { // Class EditableWidget handles all text editing related key presses for us handled = EditableWidget::handleKeyDown(ascii, keycode, modifiers); + if(handled) + setDirty(); draw(); } else { @@ -365,12 +371,11 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers) { int oldItem = _selectedItem; _selectedItem = _currentRow*_cols + _currentCol; - draw(); - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); if(_selectedItem != oldItem) sendCommand(kDGSelectionChangedCmd, _selectedItem, _id); + + setDirty(); draw(); } _currentKeyDown = keycode; @@ -389,7 +394,6 @@ bool DataGridWidget::handleKeyUp(int ascii, int keycode, int modifiers) void DataGridWidget::lostFocusWidget() { _editMode = false; - draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -400,10 +404,7 @@ void DataGridWidget::handleCommand(CommandSender* sender, int cmd, { case kSetPositionCmd: if (_selectedItem != (int)data) - { _selectedItem = data; - draw(); - } break; case kDGZeroCmd: @@ -439,6 +440,7 @@ void DataGridWidget::handleCommand(CommandSender* sender, int cmd, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::drawWidget(bool hilite) { +cerr << "DataGridWidget::drawWidget\n"; FrameBuffer& fb = _boss->instance()->frameBuffer(); int row, col, deltax; string buffer; @@ -520,7 +522,6 @@ void DataGridWidget::startEditMode() { _editMode = true; setEditString(""); // Erase current entry when starting editing - draw(); } } diff --git a/stella/src/gui/DebuggerDialog.cxx b/stella/src/gui/DebuggerDialog.cxx index 851700bd8..acb363646 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.27 2005-07-21 19:30:16 stephena Exp $ +// $Id: DebuggerDialog.cxx,v 1.28 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -61,6 +61,7 @@ DebuggerDialog::~DebuggerDialog() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::loadConfig() { +cerr << "DebuggerDialog::loadConfig()\n"; myTab->loadConfig(); myTiaInfo->loadConfig(); } diff --git a/stella/src/gui/Dialog.cxx b/stella/src/gui/Dialog.cxx index 0fb55107a..a19256d4d 100644 --- a/stella/src/gui/Dialog.cxx +++ b/stella/src/gui/Dialog.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: Dialog.cxx,v 1.21 2005-07-05 15:25:44 stephena Exp $ +// $Id: Dialog.cxx,v 1.22 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -57,11 +57,11 @@ Dialog::~Dialog() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::open() { +cerr << " ==> Dialog::open()\n"; _result = 0; _visible = true; + _dirty = true; - // Keep count of how many times this dialog was opened - // Load the config only on the first open (ie, since close was last called) if(_openCount++ == 0) loadConfig(); @@ -76,6 +76,10 @@ void Dialog::open() w->receivedFocus(); _focusedWidget = w; } + + // Make all child widget dirty + w = _firstWidget; + Widget::setDirtyInChain(w); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -119,10 +123,20 @@ void Dialog::drawDialog() if(!isVisible()) return; - FrameBuffer& fb = instance()->frameBuffer(); + if(_dirty) + { + cerr << "Dialog::drawDialog()\n"; + FrameBuffer& fb = instance()->frameBuffer(); - fb.blendRect(_x+1, _y+1, _w-2, _h-2, kBGColor); - fb.box(_x, _y, _w, _h, kColor, kShadowColor); + fb.blendRect(_x+1, _y+1, _w-2, _h-2, kBGColor); + fb.box(_x, _y, _w, _h, kColor, kShadowColor); + + // Make all child widget dirty + Widget* w = _firstWidget; + Widget::setDirtyInChain(w); + + _dirty = false; + } // Draw all children Widget* w = _firstWidget; diff --git a/stella/src/gui/DialogContainer.cxx b/stella/src/gui/DialogContainer.cxx index ab86f930d..0c5b11e7a 100644 --- a/stella/src/gui/DialogContainer.cxx +++ b/stella/src/gui/DialogContainer.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: DialogContainer.cxx,v 1.12 2005-07-20 15:52:58 stephena Exp $ +// $Id: DialogContainer.cxx,v 1.13 2005-08-01 22:33:15 stephena Exp $ //============================================================================ #include "OSystem.hxx" @@ -72,13 +72,20 @@ void DialogContainer::updateTime(uInt32 time) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DialogContainer::draw() +void DialogContainer::draw(bool fullrefresh) { - // Draw all the dialogs on the stack - for(int i = 0; i < myDialogStack.size(); i++) + // Draw all the dialogs on the stack when we want a full refresh + if(fullrefresh) { - myDialogStack[i]->open(); - myDialogStack[i]->drawDialog(); + for(int i = 0; i < myDialogStack.size(); i++) + { + myDialogStack[i]->open(); + myDialogStack[i]->drawDialog(); + } + } + else if(!myDialogStack.empty()) + { + myDialogStack.top()->drawDialog(); } } diff --git a/stella/src/gui/DialogContainer.hxx b/stella/src/gui/DialogContainer.hxx index 260d7a04c..a3aad2d14 100644 --- a/stella/src/gui/DialogContainer.hxx +++ b/stella/src/gui/DialogContainer.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: DialogContainer.hxx,v 1.6 2005-06-16 00:55:59 stephena Exp $ +// $Id: DialogContainer.hxx,v 1.7 2005-08-01 22:33:15 stephena Exp $ //============================================================================ #ifndef DIALOG_CONTAINER_HXX @@ -37,7 +37,7 @@ typedef FixedStack DialogStack; a stack, and handles their events. @author Stephen Anthony - @version $Id: DialogContainer.hxx,v 1.6 2005-06-16 00:55:59 stephena Exp $ + @version $Id: DialogContainer.hxx,v 1.7 2005-08-01 22:33:15 stephena Exp $ */ class DialogContainer { @@ -102,7 +102,7 @@ class DialogContainer /** Draw the stack of menus. */ - void draw(); + void draw(bool fullrefresh = false); /** Add a dialog box to the stack diff --git a/stella/src/gui/EditNumWidget.cxx b/stella/src/gui/EditNumWidget.cxx index 7dd395c48..d5e4c036a 100644 --- a/stella/src/gui/EditNumWidget.cxx +++ b/stella/src/gui/EditNumWidget.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: EditNumWidget.cxx,v 1.6 2005-06-30 00:08:01 stephena Exp $ +// $Id: EditNumWidget.cxx,v 1.7 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -27,7 +27,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EditNumWidget::EditNumWidget(GuiObject* boss, int x, int y, int w, int h, - const string& text) + const string& text) : EditableWidget(boss, x, y - 1, w, h + 2) { _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | @@ -72,17 +72,14 @@ void EditNumWidget::handleMouseDown(int x, int y, int button, int clickCount) break; } - if (setCaretPos(i)) - { - draw(); - // TODO - dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); - } + setCaretPos(i); + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditNumWidget::drawWidget(bool hilite) { +cerr << "EditNumWidget::drawWidget\n"; FrameBuffer& fb = _boss->instance()->frameBuffer(); // Draw a thin frame around us. diff --git a/stella/src/gui/EditTextWidget.cxx b/stella/src/gui/EditTextWidget.cxx index 5c3a8f64f..69c2fb75d 100644 --- a/stella/src/gui/EditTextWidget.cxx +++ b/stella/src/gui/EditTextWidget.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: EditTextWidget.cxx,v 1.6 2005-06-30 00:08:01 stephena Exp $ +// $Id: EditTextWidget.cxx,v 1.7 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -63,11 +63,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) } if (setCaretPos(i)) - { - draw(); - // TODO - dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); - } + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/EditableWidget.cxx b/stella/src/gui/EditableWidget.cxx index e7a002b56..bbade8028 100644 --- a/stella/src/gui/EditableWidget.cxx +++ b/stella/src/gui/EditableWidget.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: EditableWidget.cxx,v 1.7 2005-06-23 14:33:11 stephena Exp $ +// $Id: EditableWidget.cxx,v 1.8 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -54,8 +54,7 @@ void EditableWidget::setEditString(const string& str) _editScrollOffset = 0; // Make sure the new string is seen onscreen - // TODO - dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -141,9 +140,7 @@ bool EditableWidget::handleKeyDown(int ascii, int keycode, int modifiers) if (dirty) { - draw(); - // TODO - dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } return handled; diff --git a/stella/src/gui/EventMappingDialog.cxx b/stella/src/gui/EventMappingDialog.cxx index 3b878bde7..0b3d76266 100644 --- a/stella/src/gui/EventMappingDialog.cxx +++ b/stella/src/gui/EventMappingDialog.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: EventMappingDialog.cxx,v 1.16 2005-07-05 15:25:44 stephena Exp $ +// $Id: EventMappingDialog.cxx,v 1.17 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -42,13 +42,13 @@ EventMappingDialog::EventMappingDialog(OSystem* osystem, DialogContainer* parent myDefaultsButton = addButton(10, h - 24, "Defaults", kDefaultsCmd, 0); myOKButton = addButton(w - (kButtonWidth + 10), h - 24, "OK", kOKCmd, 0); - new StaticTextWidget(this, 10, 8, 150, 16, "Select an event to remap:", kTextAlignCenter); + new StaticTextWidget(this, 10, 8, 150, kFontHeight, "Select an event to remap:", kTextAlignCenter); myActionsList = new ListWidget(this, 10, 20, 150, 100); myActionsList->setNumberingMode(kListNumberingOff); myActionsList->setEditable(false); myActionsList->clearFlags(WIDGET_TAB_NAVIGATE); - myKeyMapping = new StaticTextWidget(this, 10, 125, w - 20, 16, + myKeyMapping = new StaticTextWidget(this, 10, 125, w - 20, kFontHeight, "Action: ", kTextAlignLeft); myKeyMapping->setFlags(WIDGET_CLEARBG); @@ -59,7 +59,7 @@ EventMappingDialog::EventMappingDialog(OSystem* osystem, DialogContainer* parent myCancelMapButton->setEnabled(false); // Add 'mouse to paddle' mapping - myPaddleModeText = new StaticTextWidget(this, 168, 93, 50, kLineHeight, + myPaddleModeText = new StaticTextWidget(this, 168, 93, 50, kFontHeight, "Mouse is", kTextAlignCenter); myPaddleModePopup = new PopUpWidget(this, 160, 105, 60, kLineHeight, "paddle: ", 40, 0); diff --git a/stella/src/gui/Font.hxx b/stella/src/gui/Font.hxx index 4e17cc812..61893962a 100644 --- a/stella/src/gui/Font.hxx +++ b/stella/src/gui/Font.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: Font.hxx,v 1.2 2005-06-16 00:55:59 stephena Exp $ +// $Id: Font.hxx,v 1.3 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -36,7 +36,7 @@ typedef struct int firstchar; /* first character in bitmap */ int size; /* font size in glyphs */ const uInt16* bits; /* 16-bit right-padded bitmap data */ - const int* offset; /* offsets into bitmap data */ + const uInt16* offset; /* offsets into bitmap data */ const uInt8* width; /* character widths or NULL if fixed */ int defaultchar; /* default char (not glyph index) */ long bits_size; /* # words of bitmap_t bits */ diff --git a/stella/src/gui/GameInfoDialog.cxx b/stella/src/gui/GameInfoDialog.cxx index 99252ef8b..58d78a177 100644 --- a/stella/src/gui/GameInfoDialog.cxx +++ b/stella/src/gui/GameInfoDialog.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: GameInfoDialog.cxx,v 1.8 2005-07-05 15:25:44 stephena Exp $ +// $Id: GameInfoDialog.cxx,v 1.9 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -43,11 +43,13 @@ GameInfoDialog::GameInfoDialog(OSystem* osystem, DialogContainer* parent, addButton(w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C'); myPrevButton->clearFlags(WIDGET_ENABLED); - myTitle = new StaticTextWidget(this, 0, 5, w, 16, "", kTextAlignCenter); + myTitle = new StaticTextWidget(this, 0, 5, w, kFontHeight, "", kTextAlignCenter); for(uInt8 i = 0; i < LINES_PER_PAGE; i++) { - myKey[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, 16, "", kTextAlignLeft); - myDesc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 160, 16, "", kTextAlignLeft); + myKey[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, kFontHeight, + "", kTextAlignLeft); + myDesc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 160, kFontHeight, + "", kTextAlignLeft); } } @@ -118,7 +120,7 @@ void GameInfoDialog::displayInfo() delete[] keyStr; delete[] dscStr; - instance()->frameBuffer().refreshOverlay(); + _dirty = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/GuiObject.hxx b/stella/src/gui/GuiObject.hxx index b30afc203..2714450b3 100644 --- a/stella/src/gui/GuiObject.hxx +++ b/stella/src/gui/GuiObject.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: GuiObject.hxx,v 1.12 2005-06-16 00:55:59 stephena Exp $ +// $Id: GuiObject.hxx,v 1.13 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -32,7 +32,7 @@ class Widget; This is the base class for all GUI objects/widgets. @author Stephen Anthony - @version $Id: GuiObject.hxx,v 1.12 2005-06-16 00:55:59 stephena Exp $ + @version $Id: GuiObject.hxx,v 1.13 2005-08-01 22:33:15 stephena Exp $ */ class GuiObject : public CommandReceiver { @@ -47,6 +47,7 @@ class GuiObject : public CommandReceiver _y(y), _w(w), _h(h), + _dirty(true), _firstWidget(0) { } virtual ~GuiObject() { } @@ -64,6 +65,8 @@ class GuiObject : public CommandReceiver virtual void setWidth(int w) { _w = w; } virtual void setHeight(int h) { _h = h; } + virtual void setDirty() { _dirty = true; } + virtual bool isVisible() const = 0; virtual void draw() = 0; @@ -76,6 +79,8 @@ class GuiObject : public CommandReceiver int _x, _y; int _w, _h; + bool _dirty; + Widget* _firstWidget; static Widget* _activeWidget; diff --git a/stella/src/gui/GuiUtils.hxx b/stella/src/gui/GuiUtils.hxx index 797f2bfbd..2037da54a 100644 --- a/stella/src/gui/GuiUtils.hxx +++ b/stella/src/gui/GuiUtils.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: GuiUtils.hxx,v 1.13 2005-07-06 19:09:26 stephena Exp $ +// $Id: GuiUtils.hxx,v 1.14 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,11 +29,17 @@ Probably not very neat, but at least it works ... @author Stephen Anthony - @version $Id: GuiUtils.hxx,v 1.13 2005-07-06 19:09:26 stephena Exp $ + @version $Id: GuiUtils.hxx,v 1.14 2005-08-01 22:33:15 stephena Exp $ */ -#define kLineHeight 12 -#define kScrollBarWidth 9 +#define kFontHeight 10 +#define kLineHeight 12 + +#define kCFontWidth 6 +#define kCFontHeight 10 +#define kCLineHeight 12 + +#define kScrollBarWidth 9 // Colors indices to use for the various GUI elements enum OverlayColor { @@ -56,6 +62,7 @@ enum { kSetPositionCmd = 'SETP', kActiveWidgetCmd = 'ACTW', kCheckActionCmd = 'CBAC', + kRefreshAllCmd = 'REFA', kRendererChanged, kAspectRatioChanged, kFrameRateChanged, @@ -71,7 +78,7 @@ enum Size { NextSize }; -static const string EmptyString(""); +static const string& EmptyString(""); template inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; } template inline T ABS (T x) { return (x>=0) ? x : -x; } diff --git a/stella/src/gui/HelpDialog.cxx b/stella/src/gui/HelpDialog.cxx index 4139fe6ac..ac04164a1 100644 --- a/stella/src/gui/HelpDialog.cxx +++ b/stella/src/gui/HelpDialog.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: HelpDialog.cxx,v 1.10 2005-07-05 15:25:44 stephena Exp $ +// $Id: HelpDialog.cxx,v 1.11 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -41,11 +41,13 @@ HelpDialog::HelpDialog(OSystem* osystem, DialogContainer* parent, addButton(w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C'); myPrevButton->clearFlags(WIDGET_ENABLED); - myTitle = new StaticTextWidget(this, 0, 5, w, 16, "", kTextAlignCenter); + myTitle = new StaticTextWidget(this, 0, 5, w, kFontHeight, "", kTextAlignCenter); for(uInt8 i = 0; i < LINES_PER_PAGE; i++) { - myKey[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, 16, "", kTextAlignLeft); - myDesc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 160, 16, "", kTextAlignLeft); + myKey[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, kFontHeight, + "", kTextAlignLeft); + myDesc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 160, kFontHeight, + "", kTextAlignLeft); } } @@ -173,7 +175,7 @@ void HelpDialog::displayInfo() delete[] keyStr; delete[] dscStr; - instance()->frameBuffer().refreshOverlay(); + _dirty = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/LauncherOptionsDialog.cxx b/stella/src/gui/LauncherOptionsDialog.cxx index 5a597d050..11c026c9c 100644 --- a/stella/src/gui/LauncherOptionsDialog.cxx +++ b/stella/src/gui/LauncherOptionsDialog.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: LauncherOptionsDialog.cxx,v 1.7 2005-07-05 15:25:44 stephena Exp $ +// $Id: LauncherOptionsDialog.cxx,v 1.8 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -40,42 +40,42 @@ LauncherOptionsDialog::LauncherOptionsDialog( int yoffset; // The tab widget - TabWidget* tab = new TabWidget(this, 0, vBorder, _w, _h - 24 - 2 * vBorder); + myTab = new TabWidget(this, 0, vBorder, _w, _h - 24 - 2 * vBorder); // 1) The ROM locations tab - tab->addTab("ROM Settings"); + myTab->addTab("ROM Settings"); yoffset = vBorder; // ROM path - new ButtonWidget(tab, 15, yoffset, kButtonWidth + 14, 16, "Path", kChooseRomDirCmd, 0); - myRomPath = new StaticTextWidget(tab, 5 + kButtonWidth + 30, + new ButtonWidget(myTab, 15, yoffset, kButtonWidth + 14, 16, "Path", kChooseRomDirCmd, 0); + myRomPath = new StaticTextWidget(myTab, 5 + kButtonWidth + 30, yoffset + 3, _w - (5 + kButtonWidth + 20) - 10, kLineHeight, "", kTextAlignLeft); // 2) The snapshot settings tab - tab->addTab(" Snapshot Settings "); + myTab->addTab(" Snapshot Settings "); yoffset = vBorder; // Snapshot path - new ButtonWidget(tab, 15, yoffset, kButtonWidth + 14, 16, "Path", kChooseSnapDirCmd, 0); - mySnapPath = new StaticTextWidget(tab, 5 + kButtonWidth + 30, + new ButtonWidget(myTab, 15, yoffset, kButtonWidth + 14, 16, "Path", kChooseSnapDirCmd, 0); + mySnapPath = new StaticTextWidget(myTab, 5 + kButtonWidth + 30, yoffset + 3, _w - (5 + kButtonWidth + 20) - 10, kLineHeight, "", kTextAlignLeft); yoffset += 22; // Snapshot save name - mySnapTypePopup = new PopUpWidget(tab, 10, yoffset, 140, kLineHeight, + mySnapTypePopup = new PopUpWidget(myTab, 10, yoffset, 140, kLineHeight, "Save snapshot as: ", 87, 0); mySnapTypePopup->appendEntry("romname", 1); mySnapTypePopup->appendEntry("md5sum", 2); yoffset += 18; // Snapshot single or multiple saves - mySnapSingleCheckbox = new CheckboxWidget(tab, 30, yoffset, 80, kLineHeight, + mySnapSingleCheckbox = new CheckboxWidget(myTab, 30, yoffset, 80, kLineHeight, "Multiple snapshots"); // Activate the first tab - tab->setActiveTab(0); + myTab->setActiveTab(0); // Add OK & Cancel buttons #ifndef MAC_OSX @@ -90,6 +90,8 @@ LauncherOptionsDialog::LauncherOptionsDialog( int baseW = instance()->frameBuffer().baseWidth(); int baseH = instance()->frameBuffer().baseHeight(); myBrowser = new BrowserDialog(this, 60, 20, baseW - 120, baseH - 40); + + loadConfig(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -120,6 +122,8 @@ void LauncherOptionsDialog::loadConfig() b = instance()->settings().getBool("sssingle"); mySnapSingleCheckbox->setState(!b); + + myTab->loadConfig(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/LauncherOptionsDialog.hxx b/stella/src/gui/LauncherOptionsDialog.hxx index 1ccb203a0..82a4b1891 100644 --- a/stella/src/gui/LauncherOptionsDialog.hxx +++ b/stella/src/gui/LauncherOptionsDialog.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: LauncherOptionsDialog.hxx,v 1.6 2005-07-05 15:25:44 stephena Exp $ +// $Id: LauncherOptionsDialog.hxx,v 1.7 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,6 +29,7 @@ class BrowserDialog; class CheckboxWidget; class PopUpWidget; class StaticTextWidget; +class TabWidget; #include "Dialog.hxx" #include "Command.hxx" @@ -48,6 +49,7 @@ class LauncherOptionsDialog : public Dialog, public CommandSender protected: BrowserDialog* myBrowser; + TabWidget* myTab; // Rom path controls StaticTextWidget* myRomPath; diff --git a/stella/src/gui/ListWidget.cxx b/stella/src/gui/ListWidget.cxx index f0eef89ac..256782e57 100644 --- a/stella/src/gui/ListWidget.cxx +++ b/stella/src/gui/ListWidget.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: ListWidget.cxx,v 1.23 2005-07-05 15:25:44 stephena Exp $ +// $Id: ListWidget.cxx,v 1.24 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -76,10 +76,7 @@ void ListWidget::setSelected(int item) _currentPos = _selectedItem - _entriesPerPage / 2; scrollToCurrent(); - draw(); - - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } } @@ -144,14 +141,11 @@ void ListWidget::handleMouseDown(int x, int y, int button, int clickCount) abortEditMode(); _selectedItem = newSelectedItem; sendCommand(kListSelectionChangedCmd, _selectedItem, _id); - - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); } // TODO: Determine where inside the string the user clicked and place the // caret accordingly. See _editScrollOffset and EditTextWidget::handleMouseDown. - draw(); + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -173,6 +167,7 @@ void ListWidget::handleMouseUp(int x, int y, int button, int clickCount) void ListWidget::handleMouseWheel(int x, int y, int direction) { _scrollBar->handleMouseWheel(x, y, direction); + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -297,17 +292,13 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers) scrollToCurrent(); } - if (dirty || _selectedItem != oldSelectedItem) - draw(); - if (_selectedItem != oldSelectedItem) { sendCommand(kListSelectionChangedCmd, _selectedItem, _id); // also draw scrollbar _scrollBar->draw(); - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } _currentKeyDown = keycode; @@ -326,7 +317,6 @@ bool ListWidget::handleKeyUp(int ascii, int keycode, int modifiers) void ListWidget::lostFocusWidget() { _editMode = false; - draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -338,7 +328,7 @@ void ListWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) if (_currentPos != (int)data) { _currentPos = data; - draw(); + setDirty(); draw(); } break; } @@ -347,6 +337,7 @@ void ListWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ListWidget::drawWidget(bool hilite) { +cerr << "ListWidget::drawWidget\n"; FrameBuffer& fb = _boss->instance()->frameBuffer(); int i, pos, len = _list.size(); string buffer; @@ -456,7 +447,6 @@ void ListWidget::startEditMode() { _editMode = true; setEditString(_list[_selectedItem]); - draw(); } } diff --git a/stella/src/gui/PopUpWidget.cxx b/stella/src/gui/PopUpWidget.cxx index 5898a421c..6d010f274 100644 --- a/stella/src/gui/PopUpWidget.cxx +++ b/stella/src/gui/PopUpWidget.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: PopUpWidget.cxx,v 1.14 2005-07-05 15:25:44 stephena Exp $ +// $Id: PopUpWidget.cxx,v 1.15 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -75,18 +75,45 @@ PopUpDialog::PopUpDialog(PopUpWidget* boss, int clickX, int clickY) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PopUpDialog::drawDialog() { - FrameBuffer& fb = _popUpBoss->instance()->frameBuffer(); + // Normally we add widgets and let Dialog::draw() take care of this + // logic. But for some reason, this Dialog was written differently + // by the ScummVM guys, so I'm not going to mess with it. + if(_dirty) + { + cerr << "PopUpDialog::drawDialog()\n"; + FrameBuffer& fb = _popUpBoss->instance()->frameBuffer(); - // Draw the menu border - fb.hLine(_x, _y, _x+_w - 1, kColor); - fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor); - fb.vLine(_x, _y, _y+_h - 1, kColor); - fb.vLine(_x + _w - 1, _y, _y + _h - 1, kShadowColor); + // Draw the menu border + fb.hLine(_x, _y, _x+_w - 1, kColor); + fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor); + fb.vLine(_x, _y, _y+_h - 1, kColor); + fb.vLine(_x + _w - 1, _y, _y + _h - 1, kShadowColor); - // Draw the entries - int count = _popUpBoss->_entries.size(); - for(int i = 0; i < count; i++) - drawMenuEntry(i, i == _selection); + // Draw the entries + int count = _popUpBoss->_entries.size(); + for(int i = 0; i < count; i++) + { + bool hilite = i == _selection; + int x = _x + 1; + int y = _y + 1 + i * kLineHeight; + int w = _w - 2; + string& name = _popUpBoss->_entries[i].name; + + fb.fillRect(x, y, w, kLineHeight, hilite ? kTextColorHi : kBGColor); + + if(name.size() == 0) + { + // Draw a separator + fb.hLine(x - 1, y + kLineHeight / 2, x + w, kShadowColor); + fb.hLine(x, y + 1 + kLineHeight / 2, x + w, kColor); + } + else + fb.drawString(_popUpBoss->font(), name, x + 1, y + 2, w - 2, + hilite ? kBGColor : kTextColor); + } + _dirty = false; + fb.addDirtyRect(_x, _y, _w, _h); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -165,20 +192,11 @@ void PopUpDialog::setSelection(int item) { if(item != _selection) { - // Undraw old selection - if(_selection >= 0) - drawMenuEntry(_selection, false); - // Change selection _selection = item; _popUpBoss->_selectedItem = item; - // Draw new selection - if(item >= 0) - drawMenuEntry(item, true); - - // TODO - dirty rectangle - _popUpBoss->instance()->frameBuffer().refreshOverlay(); + setDirty(); _popUpBoss->setDirty(); _popUpBoss->draw(); } } @@ -240,29 +258,6 @@ void PopUpDialog::moveDown() } } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PopUpDialog::drawMenuEntry(int entry, bool hilite) -{ - // Draw one entry of the popup menu, including selection - assert(entry >= 0); - int x = _x + 1; - int y = _y + 1 + kLineHeight * entry; - int w = _w - 2; - string& name = _popUpBoss->_entries[entry].name; - - FrameBuffer& fb = _popUpBoss->instance()->frameBuffer(); - fb.fillRect(x, y, w, kLineHeight, hilite ? kTextColorHi : kBGColor); - if(name.size() == 0) - { - // Draw a separator - fb.hLine(x - 1, y + kLineHeight / 2, x + w, kShadowColor); - fb.hLine(x, y + 1 + kLineHeight / 2, x + w, kColor); - } - else - fb.drawString(_popUpBoss->font(), name, x + 1, y + 2, w - 2, - hilite ? kBGColor : kTextColor); -} - // // PopUpWidget // diff --git a/stella/src/gui/ProgressDialog.cxx b/stella/src/gui/ProgressDialog.cxx index 86a59e1c8..60e4ca932 100644 --- a/stella/src/gui/ProgressDialog.cxx +++ b/stella/src/gui/ProgressDialog.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: ProgressDialog.cxx,v 1.3 2005-06-23 14:33:11 stephena Exp $ +// $Id: ProgressDialog.cxx,v 1.4 2005-08-01 22:33:15 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -47,7 +47,6 @@ ProgressDialog::ProgressDialog(OSystem* osystem, DialogContainer* parent, // across the entire screen for a split-second parent->addDialog(this); - instance()->frameBuffer().refreshOverlay(true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -59,7 +58,6 @@ ProgressDialog::~ProgressDialog() void ProgressDialog::done() { parent()->removeDialog(); - instance()->frameBuffer().refreshOverlay(true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/ScrollBarWidget.cxx b/stella/src/gui/ScrollBarWidget.cxx index 6491cdf49..b4bde3035 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.9 2005-07-05 15:25:44 stephena Exp $ +// $Id: ScrollBarWidget.cxx,v 1.10 2005-08-01 22:33:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -184,11 +184,7 @@ void ScrollBarWidget::handleMouseMoved(int x, int y, int button) if (old_part != _part) { - draw(); - - // Refresh the FB, since the selected part has changed - // TODO - dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } } } @@ -204,11 +200,26 @@ void ScrollBarWidget::checkBounds(int old_pos) if (old_pos != _currentPos) { recalc(); // This takes care of the required refresh - draw(); + setDirty(); draw(); sendCommand(kSetPositionCmd, _currentPos, _id); } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::handleMouseEntered(int button) +{ + setFlags(WIDGET_HILITED); + setDirty(); draw(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::handleMouseLeft(int button) +{ + _part = kNoPart; + clearFlags(WIDGET_HILITED); + setDirty(); draw(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ScrollBarWidget::recalc() { @@ -229,13 +240,13 @@ void ScrollBarWidget::recalc() _sliderPos = UP_DOWN_BOX_HEIGHT; } - // TODO - dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ScrollBarWidget::drawWidget(bool hilite) { +cerr << "ScrollBarWidget::drawWidget\n"; FrameBuffer& fb = _boss->instance()->frameBuffer(); int bottomY = _y + _h; bool isSinglePage = (_numEntries <= _entriesPerPage); diff --git a/stella/src/gui/ScrollBarWidget.hxx b/stella/src/gui/ScrollBarWidget.hxx index 796887334..ee390b21a 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.4 2005-06-16 00:56:00 stephena Exp $ +// $Id: ScrollBarWidget.hxx,v 1.5 2005-08-01 22:33:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -47,8 +47,8 @@ class ScrollBarWidget : public Widget, public CommandSender virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseWheel(int x, int y, int direction); virtual void handleMouseMoved(int x, int y, int button); - virtual void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); } - virtual void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); _part = kNoPart; draw(); } + virtual void handleMouseEntered(int button); + virtual void handleMouseLeft(int button); // FIXME - this should be private, but then we also have to add accessors // for _numEntries, _entriesPerPage and _currentPos. This again leads to the question: diff --git a/stella/src/gui/TabWidget.cxx b/stella/src/gui/TabWidget.cxx index 95410be4c..805d2c27c 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.13 2005-07-05 15:25:44 stephena Exp $ +// $Id: TabWidget.cxx,v 1.14 2005-08-01 22:33:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -99,6 +99,12 @@ int TabWidget::addTab(const string& title) void TabWidget::setActiveTab(int tabID) { assert(0 <= tabID && tabID < (int)_tabs.size()); + + // Make sure all child widgets are shown + _boss->setDirty(); _boss->draw(); + Widget::setDirtyInChain(_tabs[tabID].firstWidget); + Widget::setDirtyInChain(_tabs[tabID].parentWidget); + if (_activeTab != tabID) { // Exchange the widget lists, and switch to the new tab @@ -108,10 +114,6 @@ void TabWidget::setActiveTab(int tabID) _activeTab = tabID; _firstWidget = _tabs[tabID].firstWidget; - // Reload the settings for the parent widget in this tab - if(_tabs[tabID].parentWidget) - _tabs[tabID].parentWidget->loadConfig(); - // If a widget has been activated elsewhere and it belongs to the // current view, use it. Otherwise use the default. if(_activeWidget && isWidgetInChain(_firstWidget, _activeWidget)) @@ -123,11 +125,6 @@ void TabWidget::setActiveTab(int tabID) // in the tabview lose focus if(_activeWidget) _activeWidget->receivedFocus(); - - _boss->draw(); - - // TODO - dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); } } @@ -170,6 +167,9 @@ void TabWidget::cycleWidget(int direction) else if(direction == +1) Widget::setNextInChain(_tabs[_activeTab].firstWidget, _tabs[_activeTab].activeWidget); + + _boss->setDirty(); + Widget::setDirtyInChain(_tabs[_activeTab].firstWidget); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -247,10 +247,6 @@ void TabWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) { _tabs[_activeTab].activeWidget = _activeWidget; Widget::setFocusForChain(_firstWidget, _activeWidget); - - // Make sure the changes are shown onscreen - // TODO - dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); } break; @@ -263,6 +259,8 @@ void TabWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TabWidget::loadConfig() { +cerr << "TabWidget::loadConfig()\n"; + // (Re)load the contents of all tabs // It's up to each tab to decide if it wants to do anything on a reload for (int id = 0; id < (int)_tabs.size(); ++id) @@ -272,8 +270,7 @@ void TabWidget::loadConfig() } // Make sure changes are seen onscreen - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); + setActiveTab(_activeTab); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -299,6 +296,12 @@ 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. + Widget::setDirtyInChain(_tabs[_activeTab].firstWidget); + FrameBuffer& fb = instance()->frameBuffer(); const int left1 = _x + 1; diff --git a/stella/src/gui/ToggleBitWidget.cxx b/stella/src/gui/ToggleBitWidget.cxx index 0d35f6b21..039982963 100644 --- a/stella/src/gui/ToggleBitWidget.cxx +++ b/stella/src/gui/ToggleBitWidget.cxx @@ -13,15 +13,11 @@ // 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.3 2005-07-05 15:25:44 stephena Exp $ +// $Id: ToggleBitWidget.cxx,v 1.4 2005-08-01 22:33:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project //============================================================================ -/* -#include -#include -*/ #include "OSystem.hxx" #include "Widget.hxx" @@ -95,12 +91,9 @@ void ToggleBitWidget::handleMouseDown(int x, int y, int button, int clickCount) _selectedItem = newSelectedItem; _currentRow = _selectedItem / _cols; _currentCol = _selectedItem - (_currentRow * _cols); - - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); } - draw(); + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -112,6 +105,7 @@ void ToggleBitWidget::handleMouseUp(int x, int y, int button, int clickCount) { _stateList[_selectedItem] = !_stateList[_selectedItem]; sendCommand(kTBItemDataChangedCmd, _selectedItem, _id); + setDirty(); draw(); } } @@ -227,9 +221,7 @@ bool ToggleBitWidget::handleKeyDown(int ascii, int keycode, int modifiers) sendCommand(kTBItemDataChangedCmd, _selectedItem, _id); } - draw(); - // TODO - dirty rectangle - instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); } return handled; @@ -245,7 +237,7 @@ void ToggleBitWidget::handleCommand(CommandSender* sender, int cmd, if (_selectedItem != (int)data) { _selectedItem = data; - draw(); + setDirty(); draw(); } break; } @@ -254,6 +246,7 @@ void ToggleBitWidget::handleCommand(CommandSender* sender, int cmd, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToggleBitWidget::drawWidget(bool hilite) { +cerr << "ToggleBitWidget::drawWidget\n"; FrameBuffer& fb = instance()->frameBuffer(); int row, col; string buffer; diff --git a/stella/src/gui/VideoDialog.cxx b/stella/src/gui/VideoDialog.cxx index de0d3e889..01b7fe797 100644 --- a/stella/src/gui/VideoDialog.cxx +++ b/stella/src/gui/VideoDialog.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: VideoDialog.cxx,v 1.18 2005-07-05 15:25:44 stephena Exp $ +// $Id: VideoDialog.cxx,v 1.19 2005-08-01 22:33:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -335,8 +335,6 @@ void VideoDialog::setDefaults() // Make sure that mutually-exclusive items are not enabled at the same time handleRendererChange(0); // 0 indicates software mode - - instance()->frameBuffer().refreshOverlay(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/Widget.cxx b/stella/src/gui/Widget.cxx index 5539d4094..5ef39daf8 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.25 2005-07-21 19:30:17 stephena Exp $ +// $Id: Widget.cxx,v 1.26 2005-08-01 22:33:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,7 +29,7 @@ #include "GuiUtils.hxx" #include "Widget.hxx" -//FIXMEstatic int COUNT = 0; +//static int COUNT = 0; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Widget::Widget(GuiObject* boss, int x, int y, int w, int h) @@ -57,12 +57,17 @@ Widget::~Widget() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Widget::draw() { + if(!_dirty) + return; + + _dirty = false; + FrameBuffer& fb = _boss->instance()->frameBuffer(); if(!isVisible() || !_boss->isVisible()) return; - int oldX = _x, oldY = _y; + int oldX = _x, oldY = _y, oldW = _w, oldH = _h; // Account for our relative position in the dialog _x = getAbsX(); @@ -111,6 +116,9 @@ void Widget::draw() w->draw(); w = w->_next; } + + // Tell the framebuffer this area is dirty + fb.addDirtyRect(getAbsX(), getAbsY(), oldW, oldH); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -131,6 +139,17 @@ void Widget::receivedFocus() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Widget::setEnabled(bool e) +{ + if(e) + setFlags(WIDGET_ENABLED); + else + clearFlags(WIDGET_ENABLED); + + setDirty(); draw(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Widget* Widget::findWidgetInChain(Widget *w, int x, int y) { @@ -311,13 +330,23 @@ void Widget::setNextInChain(Widget* start, Widget* hasFocus) active->receivedFocus(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Widget::setDirtyInChain(Widget* start) +{ + while(start) + { + start->setDirty(); + start = start->_next; + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const string& text, TextAlignment align) : Widget(boss, x, y, w, h), _align(align) { - _flags = WIDGET_ENABLED; + _flags = WIDGET_ENABLED | WIDGET_CLEARBG; _type = kStaticTextWidget; setLabel(text); } @@ -329,9 +358,14 @@ void StaticTextWidget::setValue(int value) sprintf(buf, "%d", value); _label = buf; - // Refresh the screen when the text has changed - // TODO - create dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); + setDirty(); draw(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void StaticTextWidget::setLabel(const string& label) +{ + _label = label; + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -354,6 +388,20 @@ ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, _type = kButtonWidget; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ButtonWidget::handleMouseEntered(int button) +{ + setFlags(WIDGET_HILITED); + setDirty(); draw(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ButtonWidget::handleMouseLeft(int button) +{ + clearFlags(WIDGET_HILITED); + setDirty(); draw(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) { @@ -413,12 +461,8 @@ void CheckboxWidget::setState(bool state) { _state = state; _flags ^= WIDGET_INV_BORDER; - draw(); + setDirty(); draw(); } - - // Refresh the screen after the checkbox is drawn - // TODO - create dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -455,6 +499,13 @@ SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, _type = kSliderWidget; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void SliderWidget::setValue(int value) +{ + _value = value; + setDirty(); draw(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SliderWidget::handleMouseMoved(int x, int y, int button) { @@ -472,12 +523,9 @@ void SliderWidget::handleMouseMoved(int x, int y, int button) if(newValue != _value) { _value = newValue; - draw(); + setDirty(); draw(); sendCommand(_cmd, _value, _id); } - // Refresh the screen while the slider is being redrawn - // TODO - create dirty rectangle - _boss->instance()->frameBuffer().refreshOverlay(); } } diff --git a/stella/src/gui/Widget.hxx b/stella/src/gui/Widget.hxx index c79168392..510572dda 100644 --- a/stella/src/gui/Widget.hxx +++ b/stella/src/gui/Widget.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: Widget.hxx,v 1.25 2005-07-21 19:30:17 stephena Exp $ +// $Id: Widget.hxx,v 1.26 2005-08-01 22:33:16 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -69,7 +69,7 @@ enum { This is the base class for all widgets. @author Stephen Anthony - @version $Id: Widget.hxx,v 1.25 2005-07-21 19:30:17 stephena Exp $ + @version $Id: Widget.hxx,v 1.26 2005-08-01 22:33:16 stephena Exp $ */ class Widget : public GuiObject { @@ -89,7 +89,7 @@ class Widget : public GuiObject virtual void handleMouseMoved(int x, int y, int button) {} virtual void handleMouseWheel(int x, int y, int direction) {} virtual bool handleKeyDown(int ascii, int keycode, int modifiers) { return false; } - virtual bool handleKeyUp(int ascii, int keycode, int modifiers) { return false; } + virtual bool handleKeyUp(int ascii, int keycode, int modifiers) { return false; } virtual void handleJoyDown(int stick, int button) {} virtual void handleJoyUp(int stick, int button) {} @@ -99,15 +99,13 @@ class Widget : public GuiObject virtual bool wantsFocus() { return false; }; - void setFlags(int flags) { _flags |= flags; - _boss->instance()->frameBuffer().refreshOverlay(); - } - void clearFlags(int flags) { _flags &= ~flags; - _boss->instance()->frameBuffer().refreshOverlay(); - } + /** Set/clear WIDGET_ENABLED flag and immediately redraw */ + void setEnabled(bool e); + + void setFlags(int flags) { _flags |= flags; } + void clearFlags(int flags) { _flags &= ~flags; } int getFlags() const { return _flags; } - void setEnabled(bool e) { if (e) setFlags(WIDGET_ENABLED); else clearFlags(WIDGET_ENABLED); } bool isEnabled() const { return _flags & WIDGET_ENABLED; } bool isVisible() const { return !(_flags & WIDGET_INVISIBLE); } @@ -160,6 +158,9 @@ class Widget : public GuiObject /** Select next widget in chain with WIDGET_TAB_NOTIFY property to have focus, starting from 'hasFocus' */ static void setNextInChain(Widget* start, Widget* hasFocus); + + /** Sets all widgets in this chain to be dirty (must be redrawn) */ + static void setDirtyInChain(Widget* start); }; @@ -171,10 +172,8 @@ class StaticTextWidget : public Widget int x, int y, int w, int h, const string& text, TextAlignment align); void setValue(int value); + void setLabel(const string& label); void setAlign(TextAlignment align) { _align = align; } - void setLabel(const string& label) { _label = label; - _boss->instance()->frameBuffer().refreshOverlay(); - } const string& getLabel() const { return _label; } protected: @@ -198,8 +197,8 @@ class ButtonWidget : public StaticTextWidget, public CommandSender int getCmd() const { return _cmd; } void handleMouseUp(int x, int y, int button, int clickCount); - void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } - void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); } + void handleMouseEntered(int button); + void handleMouseLeft(int button); protected: void drawWidget(bool hilite); @@ -243,7 +242,7 @@ class SliderWidget : public ButtonWidget SliderWidget(GuiObject *boss, int x, int y, int w, int h, const string& label = "", int labelWidth = 0, int cmd = 0, uInt8 hotkey = 0); - void setValue(int value) { _value = value; } + void setValue(int value); int getValue() const { return _value; } void setMinValue(int value) { _valueMin = value; } diff --git a/stella/src/gui/module.mk b/stella/src/gui/module.mk index 79ccfb617..66879c08f 100644 --- a/stella/src/gui/module.mk +++ b/stella/src/gui/module.mk @@ -5,9 +5,7 @@ MODULE_OBJS := \ src/gui/AddrValueWidget.o \ src/gui/AudioDialog.o \ src/gui/BrowserDialog.o \ - src/gui/CheatWidget.o \ src/gui/ColorWidget.o \ - src/gui/CpuWidget.o \ src/gui/DataGridWidget.o \ src/gui/DebuggerDialog.o \ src/gui/DialogContainer.o \ @@ -28,11 +26,8 @@ MODULE_OBJS := \ src/gui/OptionsDialog.o \ src/gui/PopUpWidget.o \ src/gui/ProgressDialog.o \ - src/gui/PromptWidget.o \ - src/gui/RamWidget.o \ src/gui/ScrollBarWidget.o \ src/gui/TabWidget.o \ - src/gui/TiaWidget.o \ src/gui/ToggleBitWidget.o \ src/gui/VideoDialog.o \ src/gui/Widget.o \