[Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.8,1.9 ListWidget.h,1.7,1.8 dialog.cpp,1.20,1.21 dialog.h,1.10,1.11 newgui.cpp,1.22,1.23 newgui.h,1.14,1.15 widget.cpp,1.7,1.8 widget.h,1.7,1.8
Max Horn
fingolfin at users.sourceforge.net
Fri Oct 18 18:23:03 CEST 2002
Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv24677/gui
Modified Files:
ListWidget.cpp ListWidget.h dialog.cpp dialog.h newgui.cpp
newgui.h widget.cpp widget.h
Log Message:
reworked the way the save/load dialog works. yup, still not perfect, but we're hopefully getting closer. Feedback welcome
Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ListWidget.cpp 16 Oct 2002 20:32:11 -0000 1.8
+++ ListWidget.cpp 19 Oct 2002 01:22:41 -0000 1.9
@@ -48,6 +48,17 @@
{
}
+void ListWidget::setList(const StringList& list)
+{
+ int size = list.size();
+ _list = list;
+ if (_currentPos >= size)
+ _currentPos = size - 1;
+ _selectedItem = -1;
+ _editMode = false;
+ scrollBarRecalc();
+}
+
void ListWidget::scrollBarRecalc()
{
_scrollBar->_numEntries = _list.size();
@@ -136,8 +147,8 @@
if (_selectedItem >= 0) {
// override continuous enter keydown
if (_editable && (_currentKeyDown != '\n' && _currentKeyDown != '\r')) {
- _editMode = true;
dirty = true;
+ _editMode = true;
_backupString = _list[_selectedItem];
}
}
@@ -270,4 +281,23 @@
_scrollBar->_currentPos = _currentPos;
_scrollBar->recalc();
+}
+
+void ListWidget::startEditMode()
+{
+ if (_editable && !_editMode && _selectedItem >= 0) {
+ _editMode = true;
+ _backupString = _list[_selectedItem];
+ _list[_selectedItem] += '_';
+ draw();
+ }
+}
+
+void ListWidget::abortEditMode()
+{
+ if (_editMode) {
+ _editMode = false;
+ _list[_selectedItem] = _backupString;
+ draw();
+ }
}
Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ListWidget.h 16 Oct 2002 20:32:11 -0000 1.7
+++ ListWidget.h 19 Oct 2002 01:22:41 -0000 1.8
@@ -58,7 +58,7 @@
ListWidget(Dialog *boss, int x, int y, int w, int h);
virtual ~ListWidget();
- void setList(const StringList& list) { _list = list; scrollBarRecalc(); }
+ void setList(const StringList& list);
const StringList& getList() const { return _list; }
int getSelected() const { return _selectedItem; }
const String& getSelectedString() const { return _list[_selectedItem]; }
@@ -76,6 +76,9 @@
virtual bool wantsFocus() { return true; };
void scrollBarRecalc();
+
+ void startEditMode();
+ void abortEditMode();
protected:
void drawWidget(bool hilite);
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- dialog.cpp 16 Oct 2002 20:32:11 -0000 1.20
+++ dialog.cpp 19 Oct 2002 01:22:41 -0000 1.21
@@ -287,3 +287,8 @@
return new ButtonWidget(this, x, y, kButtonWidth, 16, label, cmd, hotkey);
}
+Widget *Dialog::addPushButton(int x, int y, const ScummVM::String &label, uint32 cmd, char hotkey)
+{
+ return new PushButtonWidget(this, x, y, kButtonWidth, 16, label, cmd, hotkey);
+}
+
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dialog.h 16 Oct 2002 20:32:11 -0000 1.10
+++ dialog.h 19 Oct 2002 01:22:41 -0000 1.11
@@ -73,6 +73,7 @@
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
Widget* addButton(int x, int y, const ScummVM::String &label, uint32 cmd, char hotkey);
+ Widget* addPushButton(int x, int y, const ScummVM::String &label, uint32 cmd, char hotkey);
};
#endif
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- newgui.cpp 16 Oct 2002 20:32:11 -0000 1.22
+++ newgui.cpp 19 Oct 2002 01:22:41 -0000 1.23
@@ -87,7 +87,7 @@
// Setup some default GUI colors.
// TODO - either use nicer values, or maybe make this configurable?
_bgcolor = RGB_TO_16(0, 0, 0);
- _color = RGB_TO_16(80, 80, 80);
+ _color = RGB_TO_16(96, 96, 96);
_shadowcolor = RGB_TO_16(64, 64, 64);
_textcolor = RGB_TO_16(32, 160, 32);
_textcolorhi = RGB_TO_16(0, 255, 0);
@@ -261,17 +261,20 @@
return _screen + x + y * _screenPitch;
}
-void NewGui::box(int x, int y, int width, int height)
+void NewGui::box(int x, int y, int width, int height, bool inverted)
{
- hline(x + 1, y, x + width - 2, _color);
- hline(x, y + 1, x + width - 1, _color);
- vline(x, y + 1, y + height - 2, _color);
- vline(x + 1, y, y + height - 1, _color);
+ int16 colorA = inverted ? _shadowcolor : _color;
+ int16 colorB = inverted ? _color : _shadowcolor;
- hline(x + 1, y + height - 2, x + width - 1, _shadowcolor);
- hline(x + 1, y + height - 1, x + width - 2, _shadowcolor);
- vline(x + width - 1, y + 1, y + height - 2, _shadowcolor);
- vline(x + width - 2, y + 1, y + height - 1, _shadowcolor);
+ hline(x + 1, y, x + width - 2, colorA);
+ hline(x, y + 1, x + width - 1, colorA);
+ vline(x, y + 1, y + height - 2, colorA);
+ vline(x + 1, y, y + height - 1, colorA);
+
+ hline(x + 1, y + height - 2, x + width - 1, colorB);
+ hline(x + 1, y + height - 1, x + width - 2, colorB);
+ vline(x + width - 1, y + 1, y + height - 2, colorB);
+ vline(x + width - 2, y + 1, y + height - 1, colorB);
}
void NewGui::line(int x, int y, int x2, int y2, int16 color)
Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- newgui.h 16 Oct 2002 17:37:29 -0000 1.14
+++ newgui.h 19 Oct 2002 01:22:41 -0000 1.15
@@ -119,7 +119,7 @@
// Drawing primitives
int16 *getBasePtr(int x, int y);
- void box(int x, int y, int width, int height);
+ void box(int x, int y, int width, int height, bool inverted = false);
void line(int x, int y, int x2, int y2, int16 color);
void blendRect(int x, int y, int w, int h, int16 color);
void fillRect(int x, int y, int w, int h, int16 color);
Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- widget.cpp 12 Oct 2002 00:26:24 -0000 1.7
+++ widget.cpp 19 Oct 2002 01:22:41 -0000 1.8
@@ -26,9 +26,7 @@
#ifdef _MSC_VER
-
# pragma warning( disable : 4068 ) // unknown pragma
-
#endif
@@ -59,7 +57,7 @@
// Draw border
if (_flags & WIDGET_BORDER) {
- gui->box(_x, _y, _w, _h);
+ gui->box(_x, _y, _w, _h, (_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER);
_x += 4;
_y += 4;
_w -= 8;
@@ -111,9 +109,10 @@
ButtonWidget::ButtonWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
- : StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss), _cmd(cmd), _hotkey(hotkey)
+ : StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss),
+ _cmd(cmd), _hotkey(hotkey)
{
- _flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG ;
+ _flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
_type = kButtonWidget;
}
@@ -131,6 +130,27 @@
hilite ? gui->_textcolorhi : gui->_textcolor, _align);
}
+
+#pragma mark -
+
+
+PushButtonWidget::PushButtonWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
+ : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _state(false)
+{
+ _flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
+ _type = kButtonWidget;
+}
+
+void PushButtonWidget::setState(bool state)
+{
+ if (_state != state) {
+ _state = state;
+ _flags ^= WIDGET_INV_BORDER;
+ draw();
+ }
+}
+
+
#pragma mark -
@@ -147,17 +167,16 @@
};
CheckboxWidget::CheckboxWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
- : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _state(false)
+ : PushButtonWidget(boss, x, y, w, h, label, cmd, hotkey)
{
_flags = WIDGET_ENABLED;
_type = kCheckboxWidget;
}
-void CheckboxWidget::handleMouseDown(int x, int y, int button, int clickCount)
+void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount)
{
- if (isEnabled()) {
- _state = !_state;
- draw();
+ if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) {
+ toggleState();
sendCommand(_cmd, 0);
}
}
Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- widget.h 16 Oct 2002 20:32:12 -0000 1.7
+++ widget.h 19 Oct 2002 01:22:41 -0000 1.8
@@ -31,10 +31,11 @@
WIDGET_INVISIBLE = 1 << 1,
WIDGET_HILITED = 1 << 2,
WIDGET_BORDER = 1 << 3,
- WIDGET_CLEARBG = 1 << 4,
- WIDGET_WANT_TICKLE = 1 << 5,
- WIDGET_TRACK_MOUSE = 1 << 6,
- WIDGET_RETAIN_FOCUS = 1 << 7 // Retain focus on mouse up. By default widgets lose focus on mouseup, but some widgets might want to retain it - widgets where you enter text, for instance
+ WIDGET_INV_BORDER = 1 << 4,
+ WIDGET_CLEARBG = 1 << 5,
+ WIDGET_WANT_TICKLE = 1 << 7,
+ WIDGET_TRACK_MOUSE = 1 << 8,
+ WIDGET_RETAIN_FOCUS = 1 << 9 // Retain focus on mouse up. By default widgets lose focus on mouseup, but some widgets might want to retain it - widgets where you enter text, for instance
};
@@ -152,8 +153,8 @@
class ButtonWidget : public StaticTextWidget, public CommandSender {
friend class Dialog; // Needed for the hotkey handling
protected:
- uint32 _cmd;
- uint8 _hotkey;
+ uint32 _cmd;
+ uint8 _hotkey;
public:
ButtonWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0);
@@ -168,16 +169,25 @@
void drawWidget(bool hilite);
};
-/* CheckboxWidget */
-class CheckboxWidget : public ButtonWidget {
+/* PushButtonWidget */
+class PushButtonWidget : public ButtonWidget {
protected:
bool _state;
public:
- CheckboxWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0);
- void setState(bool state) { _state = state; }
+ PushButtonWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0);
+
+ void setState(bool state);
+ void toggleState() { setState(!_state); }
bool getState() const { return _state; }
+};
- void handleMouseDown(int x, int y, int button, int clickCount);
+/* CheckboxWidget */
+class CheckboxWidget : public PushButtonWidget {
+protected:
+public:
+ CheckboxWidget(Dialog *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0);
+
+ void handleMouseUp(int x, int y, int button, int clickCount);
virtual void handleMouseEntered(int button) {}
virtual void handleMouseLeft(int button) {}
More information about the Scummvm-git-logs
mailing list