[Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.6,1.7 ListWidget.h,1.5,1.6 dialog.cpp,1.15,1.16 dialog.h,1.6,1.7 launcher.cpp,1.3,1.4 launcher.h,1.2,1.3 widget.cpp,1.5,1.6 widget.h,1.4,1.5
Max Horn
fingolfin at users.sourceforge.net
Tue Oct 1 16:12:20 CEST 2002
Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv1307
Modified Files:
ListWidget.cpp ListWidget.h dialog.cpp dialog.h launcher.cpp
launcher.h widget.cpp widget.h
Log Message:
fixed ListWidget drawin/behaviour if there are less items than fit on one page; enhanced launcher dialog to disable start button if nothing is selected
Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ListWidget.cpp 30 Sep 2002 12:56:59 -0000 1.6
+++ ListWidget.cpp 1 Oct 2002 23:11:19 -0000 1.7
@@ -58,15 +58,19 @@
void ListWidget::handleMouseDown(int x, int y, int button, int clickCount)
{
- int oldSelectedItem = _selectedItem;
-
- if (_flags & WIDGET_ENABLED) {
+ if (isEnabled()) {
+ int oldSelectedItem = _selectedItem;
_selectedItem = (y - 1) / kLineHeight + _currentPos;
+ if (_selectedItem > _list.size() - 1)
+ _selectedItem = -1;
- if (_editMode && oldSelectedItem != _selectedItem) {
- // undo any changes made
- _list[oldSelectedItem] = _backupString;
- _editMode = false;
+ if (oldSelectedItem != _selectedItem) {
+ if (_editMode) {
+ // undo any changes made
+ _list[oldSelectedItem] = _backupString;
+ _editMode = false;
+ }
+ sendCommand(kListSelectionChangedCmd, _selectedItem);
}
draw();
}
@@ -96,7 +100,7 @@
// enter, confirm edit and exit editmode
_editMode = false;
dirty = true;
- sendCommand(kListItemChangedCmd, _selectedItem);
+ sendCommand(kListItemActivatedCmd, _selectedItem);
} else if (key == 27) {
// ESC, abort edit and exit editmode
_editMode = false;
@@ -172,6 +176,7 @@
draw();
if (_selectedItem != oldSelectedItem) {
+ sendCommand(kListSelectionChangedCmd, _selectedItem);
// also draw scrollbar
_scrollBar->draw();
}
Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ListWidget.h 30 Sep 2002 12:56:59 -0000 1.5
+++ ListWidget.h 1 Oct 2002 23:11:19 -0000 1.6
@@ -34,8 +34,9 @@
// Some special commands
enum {
- kListItemDoubleClickedCmd = 'LIdb', // 'data' will be item index
- kListItemChangedCmd = 'LIch', // 'data' will be item index
+ kListItemDoubleClickedCmd = 'LIdb', // double click on item - 'data' will be item index
+ kListItemActivatedCmd = 'LIac', // item activated by return/enter - 'data' will be item index
+ kListSelectionChangedCmd = 'Lsch', // selection changed - 'data' will be item index
};
/* ListWidget */
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- dialog.cpp 28 Sep 2002 19:25:09 -0000 1.15
+++ dialog.cpp 1 Oct 2002 23:11:19 -0000 1.16
@@ -243,8 +243,8 @@
return w;
}
-void Dialog::addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey)
+Widget *Dialog::addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey)
{
- new ButtonWidget(this, x, y, w, h, label, cmd, hotkey);
+ return new ButtonWidget(this, x, y, w, h, label, cmd, hotkey);
}
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 28 Sep 2002 19:25:09 -0000 1.6
+++ dialog.h 1 Oct 2002 23:11:19 -0000 1.7
@@ -70,7 +70,7 @@
protected:
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
- void addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey);
+ Widget* addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey);
};
#endif
Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- launcher.cpp 30 Sep 2002 12:56:59 -0000 1.3
+++ launcher.cpp 1 Oct 2002 23:11:19 -0000 1.4
@@ -50,7 +50,8 @@
// Add three buttons at the bottom
addButton(1*(_w - 54)/6, _h - 24, 54, 16, "Quit", kQuitCmd, 'Q');
addButton(3*(_w - 54)/6, _h - 24, 54, 16, "Options", kOptionsCmd, 'O');
- addButton(5*(_w - 54)/6, _h - 24, 54, 16, "Start", kStartCmd, 'S');
+ _startButton = addButton(5*(_w - 54)/6, _h - 24, 54, 16, "Start", kStartCmd, 'S');
+ _startButton->setEnabled(false);
// Add list with game titles
_list = new ListWidget(this, 10, 10, 300, 112);
@@ -83,14 +84,13 @@
case kListItemDoubleClickedCmd:
// Print out what was selected
item = _list->getSelected();
- if (item >= 0) {
- printf("Selected game: %s\n", _filenames[item].c_str());
- _detector.setGame(_filenames[item].c_str());
- close();
- } else {
- // TODO - beep or so ?
- // Ideally, the start button should be disabled if no game is selected
- }
+ assert(item >= 0);
+ _detector.setGame(_filenames[item].c_str());
+ close();
+ break;
+ case kListSelectionChangedCmd:
+ _startButton->setEnabled(_list->getSelected() >= 0);
+ _startButton->draw();
break;
case kQuitCmd:
g_system->quit();
Index: launcher.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- launcher.h 30 Sep 2002 00:55:47 -0000 1.2
+++ launcher.h 1 Oct 2002 23:11:19 -0000 1.3
@@ -38,6 +38,7 @@
protected:
ListWidget *_list;
+ Widget *_startButton;
StringList _filenames;
GameDetector &_detector;
};
Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- widget.cpp 22 Sep 2002 03:53:52 -0000 1.5
+++ widget.cpp 1 Oct 2002 23:11:19 -0000 1.6
@@ -21,11 +21,16 @@
#include "stdafx.h"
#include "widget.h"
#include "dialog.h"
-#include "newgui.h"
-
-#ifdef _MSC_VER
-# pragma warning( disable : 4068 ) // unknown pragma
-#endif
+#include "newgui.h"
+
+
+
+#ifdef _MSC_VER
+
+# pragma warning( disable : 4068 ) // unknown pragma
+
+#endif
+
Widget::Widget (Dialog *boss, int x, int y, int w, int h)
@@ -98,7 +103,9 @@
void StaticTextWidget::drawWidget(bool hilite)
{
NewGui *gui = _boss->getGui();
- gui->drawString(_label.c_str(), _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor, _align);
+ gui->drawString(_label.c_str(), _x, _y, _w,
+ !isEnabled() ? gui->_color :
+ hilite ? gui->_textcolorhi : gui->_textcolor, _align);
}
@@ -114,7 +121,7 @@
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount)
{
- if (_flags & WIDGET_ENABLED && x >= 0 && x < _w && y >= 0 && y < _h)
+ if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h)
sendCommand(_cmd, 0);
}
@@ -142,7 +149,7 @@
void CheckboxWidget::handleMouseDown(int x, int y, int button, int clickCount)
{
- if (_flags & WIDGET_ENABLED) {
+ if (isEnabled()) {
_state = !_state;
draw();
sendCommand(_cmd, 0);
@@ -177,7 +184,7 @@
}
void SliderWidget::handleMouseMoved(int x, int y, int button) {
- if ((_flags & WIDGET_ENABLED) && _isDragging) {
+ if (isEnabled() && _isDragging) {
int newValue = posToValue(x);
if (newValue < _valueMin)
@@ -195,7 +202,7 @@
void SliderWidget::handleMouseDown(int x, int y, int button, int clickCount) {
- if (_flags & WIDGET_ENABLED) {
+ if (isEnabled()) {
int barx;
barx = valueToPos(_value);
@@ -208,7 +215,7 @@
void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount) {
- if ((_flags & WIDGET_ENABLED) && _isDragging) {
+ if (isEnabled() && _isDragging) {
sendCommand(_cmd, _value);
}
Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- widget.h 8 Sep 2002 16:00:13 -0000 1.4
+++ widget.h 1 Oct 2002 23:11:19 -0000 1.5
@@ -108,7 +108,9 @@
void clearFlags(int flags) { _flags &= ~flags; }
int getFlags() const { return _flags; }
- bool isVisible() const { return !(_flags & WIDGET_INVISIBLE); }
+ 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); }
protected:
virtual void drawWidget(bool hilite) {}
More information about the Scummvm-git-logs
mailing list