From 655c1b52573483d0196103620267047b7f84a4ed Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 3 Aug 2005 13:26:02 +0000 Subject: [PATCH] More efficiency fixes. Redrawing a tab (in the TabDialog) no longer forces a redraw of the whole parent dialog (this is a big optimization in the case of the DebuggerDialog, since it will soon have a resolution of 1024x768). Made the TiaOutputWidget act as a dirty rect, and only redraw itself when necessary. Fixed selection of items in TabWidget which have the WIDGET_TAB_NAVIGATE property. Clicking them with the mouse now correctly selects them (and deselects other widgets in that chain). Still TODO here is have the TabWidget draw the outline around such widgets itself, so that when one is selected and the others deselected, only the outlines need to be redrawn (vs. the whole tab). Removed FrameBuffer::blendRect(), since the GUI code will never have blended rectangles (it would cause to much complexity in the dirty update/rectangle code). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@709 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/common/FrameBufferGL.cxx | 11 +---------- stella/src/common/FrameBufferGL.hxx | 17 ++--------------- stella/src/common/FrameBufferSoft.cxx | 11 +---------- stella/src/common/FrameBufferSoft.hxx | 17 ++--------------- stella/src/debugger/TiaOutputWidget.cxx | 12 ++++++++++-- stella/src/debugger/TiaOutputWidget.hxx | 6 ++---- stella/src/emucore/FrameBuffer.hxx | 17 ++--------------- stella/src/gui/DebuggerDialog.cxx | 3 ++- stella/src/gui/Dialog.cxx | 4 ++-- stella/src/gui/TabWidget.cxx | 15 ++++++--------- 10 files changed, 30 insertions(+), 83 deletions(-) diff --git a/stella/src/common/FrameBufferGL.cxx b/stella/src/common/FrameBufferGL.cxx index 681e558b7..4a34509ad 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.38 2005-08-02 15:59:43 stephena Exp $ +// $Id: FrameBufferGL.cxx,v 1.39 2005-08-03 13:26:01 stephena Exp $ //============================================================================ #ifdef DISPLAY_OPENGL @@ -349,15 +349,6 @@ void FrameBufferGL::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color) SDL_FillRect(myTexture, &tmp, myPalette[color]); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBufferGL::blendRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color, uInt32 level) -{ -// FIXME - make this do alpha-blending -// for now, just do a normal fill - fillRect(x, y, w, h, color); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color) diff --git a/stella/src/common/FrameBufferGL.hxx b/stella/src/common/FrameBufferGL.hxx index b7c653f10..4b29e12b2 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.21 2005-08-02 15:59:43 stephena Exp $ +// $Id: FrameBufferGL.hxx,v 1.22 2005-08-03 13:26:01 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.21 2005-08-02 15:59:43 stephena Exp $ + @version $Id: FrameBufferGL.hxx,v 1.22 2005-08-03 13:26:01 stephena Exp $ */ class FrameBufferGL : public FrameBuffer { @@ -132,19 +132,6 @@ class FrameBufferGL : public FrameBuffer */ virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color); - /** - This method is called to draw a blended rectangle. - - @param x The x coordinate - @param y The y coordinate - @param w The width of the box - @param h The height of the box - @param color FIXME - @param level FIXME - */ - virtual void blendRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color, uInt32 level = 3); - /** This method is called to draw a filled rectangle. diff --git a/stella/src/common/FrameBufferSoft.cxx b/stella/src/common/FrameBufferSoft.cxx index e385346f0..c45d30abd 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.31 2005-08-01 22:33:11 stephena Exp $ +// $Id: FrameBufferSoft.cxx,v 1.32 2005-08-03 13:26:01 stephena Exp $ //============================================================================ #include @@ -360,15 +360,6 @@ void FrameBufferSoft::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color) SDL_FillRect(myScreen, &tmp, myPalette[color]); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBufferSoft::blendRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color, uInt32 level) -{ -// FIXME - make this do alpha-blending -// for now, just do a normal fill - fillRect(x, y, w, h, color); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color) diff --git a/stella/src/common/FrameBufferSoft.hxx b/stella/src/common/FrameBufferSoft.hxx index 50d081500..214970ec1 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.19 2005-08-01 22:33:11 stephena Exp $ +// $Id: FrameBufferSoft.hxx,v 1.20 2005-08-03 13:26:01 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.19 2005-08-01 22:33:11 stephena Exp $ + @version $Id: FrameBufferSoft.hxx,v 1.20 2005-08-03 13:26:01 stephena Exp $ */ class FrameBufferSoft : public FrameBuffer { @@ -130,19 +130,6 @@ class FrameBufferSoft : public FrameBuffer */ virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color); - /** - This method is called to draw a blended rectangle. - - @param x The x coordinate - @param y The y coordinate - @param w The width of the box - @param h The height of the box - @param color FIXME - @param level FIXME - */ - virtual void blendRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color, uInt32 level = 3); - /** This method is called to draw a filled rectangle. diff --git a/stella/src/debugger/TiaOutputWidget.cxx b/stella/src/debugger/TiaOutputWidget.cxx index ffb5ad8f2..80aeef8e4 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.3 2005-08-01 22:33:12 stephena Exp $ +// $Id: TiaOutputWidget.cxx,v 1.4 2005-08-03 13:26:02 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -46,6 +46,7 @@ void TiaOutputWidget::advanceScanline(int lines) instance()->console().mediaSource().updateScanline(); --lines; } + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -56,12 +57,19 @@ void TiaOutputWidget::advance(int frames) instance()->console().mediaSource().update(); --frames; } + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaOutputWidget::handleMouseDown(int x, int y, int button, int clickCount) { -cerr << "TiaOutputWidget button press: x = " << x << ", y = " << y << endl; + int xstart = atoi(instance()->console().properties().get("Display.XStart").c_str()); + int ystart = atoi(instance()->console().properties().get("Display.YStart").c_str()); + +cerr << "TiaOutputWidget button press:" << endl + << "x = " << x << ", y = " << y << endl + << "xstart = " << xstart << ", ystart = " << ystart << endl + << endl; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/debugger/TiaOutputWidget.hxx b/stella/src/debugger/TiaOutputWidget.hxx index c46548d28..36d5b33e7 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.3 2005-08-01 22:33:12 stephena Exp $ +// $Id: TiaOutputWidget.hxx,v 1.4 2005-08-03 13:26:02 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -34,6 +34,7 @@ class TiaOutputWidget : public Widget, public CommandSender TiaOutputWidget(GuiObject *boss, int x, int y, int w, int h); virtual ~TiaOutputWidget(); + void handleMouseDown(int x, int y, int button, int clickCount); // Eventually, these methods will enable access to the onscreen TIA image // For example, clicking an area may cause an action @@ -45,15 +46,12 @@ class TiaOutputWidget : public Widget, public CommandSender virtual bool handleKeyUp(int ascii, int keycode, int modifiers); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); */ - void advanceScanline(int lines); void advance(int frames); protected: void drawWidget(bool hilite); bool wantsFocus() { return false; } - - void handleMouseDown(int x, int y, int button, int clickCount); }; #endif diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index 062c94683..4d859bd59 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.51 2005-08-01 22:33:13 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.52 2005-08-03 13:26:02 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.51 2005-08-01 22:33:13 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.52 2005-08-03 13:26:02 stephena Exp $ */ class FrameBuffer { @@ -334,19 +334,6 @@ class FrameBuffer */ virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color) = 0; - /** - This method should be called to draw a blended rectangle. - - @param x The x coordinate - @param y The y coordinate - @param w The width of the box - @param h The height of the box - @param color FIXME - @param level FIXME - */ - virtual void blendRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color, uInt32 level = 3) = 0; - /** This method should be called to draw a filled rectangle. diff --git a/stella/src/gui/DebuggerDialog.cxx b/stella/src/gui/DebuggerDialog.cxx index acb363646..f9d1b211b 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.28 2005-08-01 22:33:15 stephena Exp $ +// $Id: DebuggerDialog.cxx,v 1.29 2005-08-03 13:26:02 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -64,6 +64,7 @@ void DebuggerDialog::loadConfig() cerr << "DebuggerDialog::loadConfig()\n"; myTab->loadConfig(); myTiaInfo->loadConfig(); + myTiaOutput->loadConfig(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/Dialog.cxx b/stella/src/gui/Dialog.cxx index a19256d4d..999962066 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.22 2005-08-01 22:33:15 stephena Exp $ +// $Id: Dialog.cxx,v 1.23 2005-08-03 13:26:02 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -128,7 +128,7 @@ void Dialog::drawDialog() cerr << "Dialog::drawDialog()\n"; FrameBuffer& fb = instance()->frameBuffer(); - fb.blendRect(_x+1, _y+1, _w-2, _h-2, kBGColor); + fb.fillRect(_x+1, _y+1, _w-2, _h-2, kBGColor); fb.box(_x, _y, _w, _h, kColor, kShadowColor); // Make all child widget dirty diff --git a/stella/src/gui/TabWidget.cxx b/stella/src/gui/TabWidget.cxx index 42b4da617..4132d67d0 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.15 2005-08-02 15:59:45 stephena Exp $ +// $Id: TabWidget.cxx,v 1.16 2005-08-03 13:26:02 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -40,7 +40,7 @@ TabWidget::TabWidget(GuiObject *boss, int x, int y, int w, int h) : Widget(boss, x, y, w, h), CommandSender(boss) { - _flags = WIDGET_ENABLED; + _flags = WIDGET_ENABLED | WIDGET_CLEARBG; _type = kTabWidget; _activeTab = -1; @@ -100,11 +100,6 @@ 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(_tabs[tabID].parentWidget) _tabs[tabID].parentWidget->loadConfig(); @@ -129,6 +124,8 @@ void TabWidget::setActiveTab(int tabID) if(_activeWidget) _activeWidget->receivedFocus(); } + + setDirty(); draw(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -171,7 +168,6 @@ void TabWidget::cycleWidget(int direction) Widget::setNextInChain(_tabs[_activeTab].firstWidget, _tabs[_activeTab].activeWidget); - _boss->setDirty(); Widget::setDirtyInChain(_tabs[_activeTab].firstWidget); } @@ -200,7 +196,7 @@ void TabWidget::handleMouseDown(int x, int y, int button, int clickCount) } // If a tab was clicked, switch to that pane - if (tabID >= 0) + if (tabID >= 0 && tabID != _activeTab) setActiveTab(tabID); } @@ -250,6 +246,7 @@ void TabWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) { _tabs[_activeTab].activeWidget = _activeWidget; Widget::setFocusForChain(_firstWidget, _activeWidget); + setActiveTab(_activeTab); } break;