[Scummvm-cvs-logs] CVS: scummvm/gui dialog.cpp,1.13,1.14 dialog.h,1.6,1.7 widget.cpp,1.11,1.12
Max Horn
fingolfin at users.sourceforge.net
Wed Jul 10 09:50:05 CEST 2002
Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv17768/gui
Modified Files:
dialog.cpp dialog.h widget.cpp
Log Message:
improved the alpha blending code, now works properly for nesting/redraw (changed meaning of WIDGET_CLEARBG a little bit for this)
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- dialog.cpp 8 Jul 2002 22:11:45 -0000 1.13
+++ dialog.cpp 10 Jul 2002 16:49:45 -0000 1.14
@@ -25,12 +25,52 @@
#include "widget.h"
#include "newgui.h"
+Dialog::~Dialog()
+{
+ teardownScreenBuf();
+}
+
+void Dialog::setupScreenBuf()
+{
+ // Create _screenBuf if it doesn't already exist
+ if (!_screenBuf)
+ _screenBuf = new byte[320*200];
+
+ // Draw the fixed parts of the dialog: background and border.
+ _gui->blendArea(_x, _y, _w, _h, _gui->_bgcolor);
+ _gui->box(_x, _y, _w, _h);
+
+ // Draw a bgcolor rectangle for all widgets which have WIDGET_CLEARBG set.
+ Widget *w = _firstWidget;
+ while (w) {
+ if (w->_flags & WIDGET_CLEARBG)
+ _gui->fillArea(_x + w->_x, _y + w->_y, w->_w, w->_h, _gui->_bgcolor);
+ // FIXME - should we also draw borders here if WIDGET_BORDER is set?
+ w = w->_next;
+ }
+
+ // Finally blit this to _screenBuf
+ _gui->blitTo(_screenBuf, _x, _y, _w, _h);
+}
+
+void Dialog::teardownScreenBuf()
+{
+ if (_screenBuf) {
+ delete [] _screenBuf;
+ _screenBuf = 0;
+ }
+}
+
void Dialog::draw()
{
Widget *w = _firstWidget;
- _gui->fillArea(_x, _y, _w, _h, _gui->_bgcolor);
- _gui->box(_x, _y, _w, _h);
+ if (_screenBuf) {
+ _gui->blitFrom(_screenBuf, _x, _y, _w, _h);
+ } else {
+ _gui->fillArea(_x, _y, _w, _h, _gui->_bgcolor);
+ _gui->box(_x, _y, _w, _h);
+ }
_gui->setAreaDirty(_x, _y, _w, _h);
while (w) {
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dialog.h 8 Jul 2002 22:11:46 -0000 1.6
+++ dialog.h 10 Jul 2002 16:49:45 -0000 1.7
@@ -43,11 +43,13 @@
int16 _x, _y;
uint16 _w, _h;
Widget *_mouseWidget;
+ byte *_screenBuf;
public:
Dialog(NewGui *gui, int x, int y, int w, int h)
- : _gui(gui), _firstWidget(0), _x(x), _y(y), _w(w), _h(h), _mouseWidget(0)
+ : _gui(gui), _firstWidget(0), _x(x), _y(y), _w(w), _h(h), _mouseWidget(0), _screenBuf(0)
{}
+ virtual ~Dialog();
virtual void draw();
@@ -58,6 +60,9 @@
virtual void handleCommand(uint32 cmd);
NewGui *getGui() { return _gui; }
+
+ void setupScreenBuf();
+ void teardownScreenBuf();
protected:
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- widget.cpp 8 Jul 2002 22:11:47 -0000 1.11
+++ widget.cpp 10 Jul 2002 16:49:45 -0000 1.12
@@ -43,8 +43,8 @@
_x += _boss->_x;
_y += _boss->_y;
- // Clear background
- if (_flags & WIDGET_CLEARBG)
+ // Clear background (unless alpha blending is enabled)
+ if (_flags & WIDGET_CLEARBG && !_boss->_screenBuf)
gui->fillArea(_x, _y, _w, _h, gui->_bgcolor);
// Draw border
@@ -94,7 +94,7 @@
ButtonWidget::ButtonWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd, uint8 hotkey)
: StaticTextWidget(boss, x, y, w, h, label), _cmd(cmd), _hotkey(hotkey)
{
- _flags = WIDGET_ENABLED | WIDGET_BORDER /* | WIDGET_CLEARBG */ ;
+ _flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG ;
_type = kButtonWidget;
}
@@ -148,7 +148,7 @@
if (_state)
gui->drawBitmap(checked_img, _x + 3, _y + 3, gui->_textcolor);
else
- gui->fillArea(_x + 3, _y + 3, 8, 8, gui->_bgcolor);
+ gui->fillArea(_x + 2, _y + 2, 10, 10, gui->_bgcolor);
// Finally draw the label
gui->drawString(_text, _x + 20, _y + 3, _w, gui->_textcolor);
@@ -159,7 +159,7 @@
SliderWidget::SliderWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd, uint8 hotkey)
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _value(0), _old_value(1)
{
- _flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE;
+ _flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
_type = kSliderWidget;
}
More information about the Scummvm-git-logs
mailing list