[Scummvm-cvs-logs] CVS: scummvm/gui widget.cpp,1.20,1.21 widget.h,1.24,1.25 dialog.cpp,1.34,1.35 newgui.h,1.30,1.31 newgui.cpp,1.63,1.64
Max Horn
fingolfin at users.sourceforge.net
Sun Nov 2 10:58:10 CET 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2 build_display.cpp,1.41,1.42 console.cpp,1.26,1.27 controls.cpp,1.44,1.45 debug.cpp,1.21,1.22 icons.cpp,1.19,1.20 mouse.cpp,1.34,1.35 mouse.h,1.8,1.9 resman.cpp,1.59,1.60 speech.cpp,1.39,1.40 sword2.cpp,1.73,1.74 sword2.h,1.31,1.32
- Next message: [Scummvm-cvs-logs] CVS: scummvm/gui TabWidget.cpp,NONE,1.1 TabWidget.h,NONE,1.1 launcher.cpp,1.63,1.64 module.mk,1.7,1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv32139
Modified Files:
widget.cpp widget.h dialog.cpp newgui.h newgui.cpp
Log Message:
refactored code in Dialog::findWidget to Widget::findWidgetInChain; changed NewGui::box() to take colors as param (instead of hard coding _color and _shadowColor)
Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- widget.cpp 2 Nov 2003 14:50:44 -0000 1.20
+++ widget.cpp 2 Nov 2003 18:57:19 -0000 1.21
@@ -19,9 +19,10 @@
*/
#include "stdafx.h"
-#include "widget.h"
-#include "dialog.h"
-#include "newgui.h"
+#include "common/util.h"
+#include "gui/widget.h"
+#include "gui/dialog.h"
+#include "gui/newgui.h"
Widget::Widget(GuiObject *boss, int x, int y, int w, int h)
@@ -39,8 +40,8 @@
return;
// Account for our relative position in the dialog
- _x += _boss->_x;
- _y += _boss->_y;
+ _x += _boss->getAbsX();
+ _y += _boss->getAbsY();
// Clear background (unless alpha blending is enabled)
if (_flags & WIDGET_CLEARBG)
@@ -48,7 +49,11 @@
// Draw border
if (_flags & WIDGET_BORDER) {
- gui->box(_x, _y, _w, _h, (_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER);
+ NewGuiColor colorA = gui->_color;
+ NewGuiColor colorB = gui->_shadowcolor;
+ if ((_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER)
+ SWAP(colorA, colorB);
+ gui->box(_x, _y, _w, _h, colorA, colorB);
_x += 4;
_y += 4;
_w -= 8;
@@ -69,10 +74,21 @@
// Flag the draw area as dirty
gui->addDirtyRect(_x, _y, _w, _h);
- _x -= _boss->_x;
- _y -= _boss->_y;
+ _x -= _boss->getAbsX();
+ _y -= _boss->getAbsY();
}
+Widget *Widget::findWidgetInChain(Widget *w, int x, int y) {
+ while (w) {
+ // Stop as soon as we find a widget that contains the point (x,y)
+ if (x >= w->_x && x < w->_x + w->_w && y >= w->_y && y < w->_y + w->_h)
+ break;
+ w = w->_next;
+ }
+ if (w)
+ w = w->findWidget(x - w->_x, y - w->_y);
+ return w;
+}
#pragma mark -
@@ -161,7 +177,7 @@
NewGui *gui = &g_gui;
// Draw the box
- gui->box(_x, _y, 14, 14);
+ gui->box(_x, _y, 14, 14, gui->_color, gui->_shadowcolor);
// If checked, draw cross inside the box
if (_state)
@@ -218,7 +234,7 @@
NewGui *gui = &g_gui;
// Draw the box
- gui->box(_x, _y, _w, _h);
+ gui->box(_x, _y, _w, _h, gui->_color, gui->_shadowcolor);
// Draw the 'bar'
gui->fillRect(_x + 2, _y + 2, valueToPos(_value), _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- widget.h 2 Nov 2003 17:41:01 -0000 1.24
+++ widget.h 2 Nov 2003 18:57:20 -0000 1.25
@@ -73,6 +73,9 @@
bool _hasFocus;
public:
+ static Widget *findWidgetInChain(Widget *start, int x, int y);
+
+public:
Widget(GuiObject *boss, int x, int y, int w, int h);
virtual ~Widget() {}
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- dialog.cpp 2 Nov 2003 17:41:01 -0000 1.34
+++ dialog.cpp 2 Nov 2003 18:57:20 -0000 1.35
@@ -103,7 +103,7 @@
return;
g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor);
- g_gui.box(_x, _y, _w, _h);
+ g_gui.box(_x, _y, _w, _h, g_gui._color, g_gui._shadowcolor);
while (w) {
w->draw();
@@ -267,16 +267,7 @@
* in the local coordinate system, i.e. relative to the top left of the dialog.
*/
Widget *Dialog::findWidget(int x, int y) {
- Widget *w = _firstWidget;
- while (w) {
- // Stop as soon as we find a widget that contains the point (x,y)
- if (x >= w->_x && x < w->_x + w->_w && y >= w->_y && y < w->_y + w->_h)
- break;
- w = w->_next;
- }
- if (w)
- w = w->findWidget(x - w->_x, y - w->_y);
- return w;
+ return Widget::findWidgetInChain(_firstWidget, x, y);
}
ButtonWidget *Dialog::addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey) {
Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- newgui.h 2 Nov 2003 02:18:14 -0000 1.30
+++ newgui.h 2 Nov 2003 18:57:20 -0000 1.31
@@ -128,7 +128,7 @@
// Drawing primitives
NewGuiColor *getBasePtr(int x, int y);
- void box(int x, int y, int width, int height, bool inverted = false);
+ void box(int x, int y, int width, int height, NewGuiColor colorA, NewGuiColor colorB);
void line(int x, int y, int x2, int y2, NewGuiColor color);
void blendRect(int x, int y, int w, int h, NewGuiColor color, int level = 3);
void fillRect(int x, int y, int w, int h, NewGuiColor color);
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- newgui.cpp 2 Nov 2003 02:18:14 -0000 1.63
+++ newgui.cpp 2 Nov 2003 18:57:20 -0000 1.64
@@ -285,10 +285,7 @@
return _screen + x + y * _screenPitch;
}
-void NewGui::box(int x, int y, int width, int height, bool inverted) {
- NewGuiColor colorA = inverted ? _shadowcolor : _color;
- NewGuiColor colorB = inverted ? _color : _shadowcolor;
-
+void NewGui::box(int x, int y, int width, int height, NewGuiColor colorA, NewGuiColor colorB) {
hLine(x + 1, y, x + width - 2, colorA);
hLine(x, y + 1, x + width - 1, colorA);
vLine(x, y + 1, y + height - 2, colorA);
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2 build_display.cpp,1.41,1.42 console.cpp,1.26,1.27 controls.cpp,1.44,1.45 debug.cpp,1.21,1.22 icons.cpp,1.19,1.20 mouse.cpp,1.34,1.35 mouse.h,1.8,1.9 resman.cpp,1.59,1.60 speech.cpp,1.39,1.40 sword2.cpp,1.73,1.74 sword2.h,1.31,1.32
- Next message: [Scummvm-cvs-logs] CVS: scummvm/gui TabWidget.cpp,NONE,1.1 TabWidget.h,NONE,1.1 launcher.cpp,1.63,1.64 module.mk,1.7,1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list