[Scummvm-cvs-logs] CVS: scummvm/gui EditTextWidget.cpp,1.26,1.26.2.1 EditTextWidget.h,1.14,1.14.4.1 TabWidget.cpp,1.12,1.12.2.1 about.cpp,1.13.2.3,1.13.2.4 credits.h,1.1.2.3,1.1.2.4 dialog.cpp,1.43,1.43.4.1 dialog.h,1.28,1.28.2.1 launcher.cpp,1.102,1.102.2.1 widget.cpp,1.38,1.38.2.1
Max Horn
fingolfin at users.sourceforge.net
Thu Dec 30 05:15:12 CET 2004
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13483/gui
Modified Files:
Tag: branch-0-7-0
EditTextWidget.cpp EditTextWidget.h TabWidget.cpp about.cpp
credits.h dialog.cpp dialog.h launcher.cpp widget.cpp
Log Message:
Backporting some changes to the 0.7.x branch, just in case
Index: EditTextWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/EditTextWidget.cpp,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -u -d -r1.26 -r1.26.2.1
--- EditTextWidget.cpp 28 Sep 2004 20:19:26 -0000 1.26
+++ EditTextWidget.cpp 30 Dec 2004 13:14:03 -0000 1.26.2.1
@@ -71,6 +71,14 @@
draw();
}
+bool EditTextWidget::tryInsertChar(char c, int pos) {
+ if (isprint(c)) {
+ _label.insertChar(c, pos);
+ return true;
+ }
+ return false;
+}
+
bool EditTextWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
bool handled = true;
bool dirty = false;
@@ -126,9 +134,8 @@
dirty = adjustOffset();
break;
default:
- if (isprint((char)ascii)) {
- _label.insertChar((char)ascii, _pos++);
- //_label += (char)ascii;
+ if (tryInsertChar((char)ascii, _pos)) {
+ _pos++;
dirty = true;
} else {
handled = false;
Index: EditTextWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/EditTextWidget.h,v
retrieving revision 1.14
retrieving revision 1.14.4.1
diff -u -d -r1.14 -r1.14.4.1
--- EditTextWidget.h 5 Feb 2004 00:19:54 -0000 1.14
+++ EditTextWidget.h 30 Dec 2004 13:14:03 -0000 1.14.4.1
@@ -28,6 +28,7 @@
/* EditTextWidget */
class EditTextWidget : public StaticTextWidget {
+public:
typedef Common::StringList StringList;
typedef Common::String String;
protected:
@@ -52,6 +53,8 @@
int getCaretPos() const;
bool adjustOffset();
+
+ virtual bool tryInsertChar(char c, int pos);
};
} // End of namespace GUI
Index: TabWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/TabWidget.cpp,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -d -r1.12 -r1.12.2.1
--- TabWidget.cpp 28 Feb 2004 12:57:53 -0000 1.12
+++ TabWidget.cpp 30 Dec 2004 13:14:03 -0000 1.12.2.1
@@ -118,29 +118,52 @@
return Widget::handleKeyDown(ascii, keycode, modifiers);
}
+static void box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB, bool omitBottom) {
+ NewGui &gui = g_gui;
+
+ gui.hLine(x + 1, y, x + width - 2, colorA);
+ gui.hLine(x, y + 1, x + width - 1, colorA);
+ gui.vLine(x, y + 1, y + height - (omitBottom ? 1 : 2), colorA);
+ gui.vLine(x + 1, y, y + height - (omitBottom ? 2 : 1), colorA);
+
+ if (!omitBottom) {
+ gui.hLine(x + 1, y + height - 2, x + width - 1, colorB);
+ gui.hLine(x + 1, y + height - 1, x + width - 2, colorB);
+ }
+ gui.vLine(x + width - 1, y + 1, y + height - (omitBottom ? 1 : 2), colorB);
+ gui.vLine(x + width - 2, y + 1, y + height - (omitBottom ? 2 : 1), colorB);
+}
+
+
void TabWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
+ const int left1 = _x + 1;
+ const int right1 = _x + kTabLeftOffset + _activeTab * (_tabWidth + kTabSpacing);
+ const int left2 = right1 + _tabWidth;
+ const int right2 = _x + _w - 2;
+
// Draw horizontal line
- gui->hLine(_x + 1, _y + kTabHeight - 2, _x + _w - 2, gui->_shadowcolor);
+ gui->hLine(left1, _y + kTabHeight - 2, right1, gui->_shadowcolor);
+ gui->hLine(left2, _y + kTabHeight - 2, right2, gui->_shadowcolor);
// Iterate over all tabs and draw them
int i, x = _x + kTabLeftOffset;
for (i = 0; i < (int)_tabs.size(); ++i) {
OverlayColor color = (i == _activeTab) ? gui->_color : gui->_shadowcolor;
int yOffset = (i == _activeTab) ? 0 : 2;
- gui->box(x, _y + yOffset, _tabWidth, kTabHeight - yOffset, color, color);
+ box(x, _y + yOffset, _tabWidth, kTabHeight - yOffset, color, color, (i == _activeTab));
gui->drawString(_tabs[i].title, x + kTabPadding, _y + yOffset / 2 + (kTabHeight - kLineHeight - 1), _tabWidth - 2 * kTabPadding, gui->_textcolor, kTextAlignCenter);
x += _tabWidth + kTabSpacing;
}
// Draw more horizontal lines
- gui->hLine(_x+1, _y + kTabHeight - 1, _x + _w - 2, gui->_color);
+ gui->hLine(left1, _y + kTabHeight - 1, right1, gui->_color);
+ gui->hLine(left2, _y + kTabHeight - 1, right2, gui->_color);
gui->hLine(_x+1, _y + _h - 2, _x + _w - 2, gui->_shadowcolor);
gui->hLine(_x+1, _y + _h - 1, _x + _w - 2, gui->_color);
}
-
Widget *TabWidget::findWidget(int x, int y) {
if (y < kTabHeight) {
// Click was in the tab area
Index: about.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/about.cpp,v
retrieving revision 1.13.2.3
retrieving revision 1.13.2.4
diff -u -d -r1.13.2.3 -r1.13.2.4
--- about.cpp 22 Dec 2004 01:07:30 -0000 1.13.2.3
+++ about.cpp 30 Dec 2004 13:14:03 -0000 1.13.2.4
@@ -35,9 +35,6 @@
kYOff = 2
};
-// TODO: Probably should display something regarding GPL
-// We could just list our full credits section here now...
-//
// The following commands can be put at the start of a line (all subject to change):
// \C, \L, \R -- set center/left/right alignment
// \c0 - \c4 -- set a custom color:
@@ -57,6 +54,26 @@
"\\C""Broken Sword Games (C) Revolution",
"\\C""Flight of the Amazon Queen (C) John Passfield",
"\\C""and Steve Stamatiadis",
+"\\C""",
+"\\C""This program is free software; you can",
+"\\C""redistribute it and/or modify it under the",
+"\\C""terms of the GNU General Public License as",
+"\\C""published by the Free Software Foundation;",
+"\\C""either version 2 of the License, or (at your",
+"\\C""option) any later version.",
+"\\C""",
+"\\C""This program is distributed in the hope that",
+"\\C""it will be useful, but WITHOUT ANY WARRANTY;",
+"\\C""without even the implied warranty of",
+"\\C""MERCHANTABILITY or FITNESS FOR A PARTICULAR",
+"\\C""PURPOSE. See the GNU General Public License",
+"\\C""for more details.",
+"\\C""",
+"\\C""You should have received a copy of the GNU",
+"\\C""General Public License along with this",
+"\\C""program; if not, write to the Free Software",
+"\\C""Foundation, Inc., 59 Temple Place - Suite 330,",
+"\\C""Boston, MA 02111-1307, USA.",
"\\C"""
};
Index: credits.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/credits.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- credits.h 22 Dec 2004 19:07:42 -0000 1.1.2.3
+++ credits.h 30 Dec 2004 13:14:03 -0000 1.1.2.4
@@ -6,26 +6,28 @@
"\\L\\c0"" Max Horn",
"\\L\\c2"" Lead developer",
"\\L\\c0"" Torbjorn Andersson",
-"\\L\\c2"" Engine: SCUMM, Broken Sword II",
+"\\L\\c2"" Engine: SCUMM, Broken Sword II, SAGA",
"\\L\\c0"" David Eriksson",
"\\L\\c2"" Engine: Flight of the Amazon Queen",
"\\L\\c0"" Robert Goeffringmann",
"\\L\\c2"" Engine: Beneath a Steel Sky, Broken Sword I",
"\\L\\c0"" Jonathan Gray",
-"\\L\\c2"" Engine: SCUMM, Broken Sword II",
+"\\L\\c2"" Engine: SCUMM, HE, Broken Sword II",
"\\L\\c0"" Travis Howell",
-"\\L\\c2"" Engine: SCUMM, Simon the Sorcerer",
+"\\L\\c2"" Engine: SCUMM, HE, Simon the Sorcerer",
"\\L\\c0"" Oliver Kiehl",
"\\L\\c2"" Engine: Beneath a Steel Sky, Simon",
"\\L\\c0"" Pawel Kolodziejski",
"\\L\\c2"" Engine: SCUMM (Codecs, iMUSE, Smush, etc.)",
+"\\L\\c0"" Andrew Kurushin",
+"\\L\\c2"" Engine: SAGA",
"\\L\\c0"" Gregory Montoir",
-"\\L\\c2"" Engine: Flight of the Amazon Queen",
+"\\L\\c2"" Engine: Flight of the Amazon Queen, HE",
"\\L\\c0"" Joost Peters",
"\\L\\c2"" Engine: Beneath a Steel Sky, Flight of the",
"\\L\\c2"" Amazon Queen",
"\\L\\c0"" Eugene Sandulenko",
-"\\L\\c2"" Engine: SCUMM (FT INSANE, bugfixes)",
+"\\L\\c2"" Engine: SCUMM (FT INSANE), HE, SAGA",
"\\L\\c0"" Chris Apers",
"\\L\\c2"" Port: PalmOS",
"\\L\\c0"" Nicolas Bacca",
@@ -129,6 +131,11 @@
"\\L\\c0""Flight of the Amazon Queen and also being",
"\\L\\c0""incredibly supportive.",
"\\L\\c0""",
+"\\L\\c0""Joe Pearce from The Wyrmkeep Entertainment",
+"\\L\\c0""Co. for sharing the source of their famous",
+"\\L\\c0""title Inherit the Earth and always prompt",
+"\\L\\c0""replies to our questions.",
+"\\L\\c0""",
"\\L\\c0""Aric Wilmunder, Ron Gilbert, David Fox, Vince",
"\\L\\c0""Lee, and all those at LucasFilm/LucasArts who",
"\\L\\c0""made SCUMM the insane mess to reimplement",
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.43
retrieving revision 1.43.4.1
diff -u -d -r1.43 -r1.43.4.1
--- dialog.cpp 6 Jan 2004 12:45:29 -0000 1.43
+++ dialog.cpp 30 Dec 2004 13:14:03 -0000 1.43.4.1
@@ -36,6 +36,11 @@
* ...
*/
+Dialog::Dialog(int x, int y, int w, int h)
+ : GuiObject(x, y, w, h),
+ _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false) {
+}
+
Dialog::~Dialog() {
delete _firstWidget;
_firstWidget = 0;
@@ -114,15 +119,12 @@
void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
Widget *w;
w = findWidget(x, y);
+
+ _dragWidget = w;
// If the click occured inside a widget which is not the currently
// focused one, change the focus to that widget.
- // TODO: use the wantsFocus() method to objects, so that only fields
- // that want it get the focus (like edit fields, list field...)
- // However, right now we "abuse" the focus also for the click&drag
- // behaviour of buttons. This should probably be changed by adding
- // a nother field, e.g. _clickedWidget or _dragWidget.
- if (w && w != _focusedWidget) {
+ if (w && w != _focusedWidget && w->wantsFocus()) {
// The focus will change. Tell the old focused widget (if any)
// that it lost the focus.
releaseFocus();
@@ -134,27 +136,28 @@
_focusedWidget = w;
}
- if (w && w == _focusedWidget)
- _focusedWidget->handleMouseDown(x - (_focusedWidget->getAbsX() - _x), y - (_focusedWidget->getAbsY() - _y), button, clickCount);
+ if (w)
+ w->handleMouseDown(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
}
void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
Widget *w;
if (_focusedWidget) {
- w = _focusedWidget;
+ //w = _focusedWidget;
// Lose focus on mouseup unless the widget requested to retain the focus
if (! (_focusedWidget->getFlags() & WIDGET_RETAIN_FOCUS )) {
releaseFocus();
}
-
- } else {
- w = findWidget(x, y);
}
+ w = _dragWidget;
+
if (w)
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
+
+ _dragWidget = 0;
}
void Dialog::handleMouseWheel(int x, int y, int direction) {
@@ -211,7 +214,10 @@
void Dialog::handleMouseMoved(int x, int y, int button) {
Widget *w;
- if (_focusedWidget) {
+ //if (!button)
+ // _dragWidget = 0;
+
+ if (_focusedWidget && !_dragWidget) {
w = _focusedWidget;
int wx = w->getAbsX() - _x;
int wy = w->getAbsY() - _y;
@@ -220,6 +226,8 @@
// (but to no other items).
bool mouseInFocusedWidget = (x >= wx && x < wx + w->_w && y >= wy && y < wy + w->_h);
if (mouseInFocusedWidget && _mouseWidget != w) {
+ if (_mouseWidget)
+ _mouseWidget->handleMouseLeft(button);
_mouseWidget = w;
w->handleMouseEntered(button);
} else if (!mouseInFocusedWidget && _mouseWidget == w) {
@@ -229,8 +237,13 @@
w->handleMouseMoved(x - wx, y - wy, button);
}
-
- w = findWidget(x, y);
+
+ // While a "drag" is in process (i.e. mouse is moved while a button is pressed),
+ // only deal with the widget in which the click originated.
+ if (_dragWidget)
+ w = _dragWidget;
+ else
+ w = findWidget(x, y);
if (_mouseWidget != w) {
if (_mouseWidget)
@@ -240,11 +253,9 @@
_mouseWidget = w;
}
- if (!w || !(w->getFlags() & WIDGET_TRACK_MOUSE)) {
- return;
+ if (w && (w->getFlags() & WIDGET_TRACK_MOUSE)) {
+ w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
}
-
- w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
}
void Dialog::handleTickle() {
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.28
retrieving revision 1.28.2.1
diff -u -d -r1.28 -r1.28.2.1
--- dialog.h 13 Mar 2004 13:03:25 -0000 1.28
+++ dialog.h 30 Dec 2004 13:14:04 -0000 1.28.2.1
@@ -41,16 +41,14 @@
protected:
Widget *_mouseWidget;
Widget *_focusedWidget;
+ Widget *_dragWidget;
bool _visible;
private:
int _result;
public:
- Dialog(int x, int y, int w, int h)
- : GuiObject(x, y, w, h),
- _mouseWidget(0), _focusedWidget(0), _visible(false) {
- }
+ Dialog(int x, int y, int w, int h);
virtual ~Dialog();
virtual int runModal();
Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.102
retrieving revision 1.102.2.1
diff -u -d -r1.102 -r1.102.2.1
--- launcher.cpp 9 Dec 2004 15:06:42 -0000 1.102
+++ launcher.cpp 30 Dec 2004 13:14:04 -0000 1.102.2.1
@@ -69,6 +69,27 @@
};
/*
+ * TODO: Clean up this ugly design: we subclass EditTextWidget to perform
+ * input validation. It would be much more elegant to use a decorator pattern,
+ * or a validation callback, or something like that.
+ */
+class DomainEditTextWidget : public EditTextWidget {
+public:
+ DomainEditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text)
+ : EditTextWidget(boss, x, y, w, h, text) {
+ }
+
+protected:
+ bool tryInsertChar(char c, int pos) {
+ if (isalnum(c) || c == '-' || c == '_') {
+ _label.insertChar(c, pos);
+ return true;
+ }
+ return false;
+ }
+};
+
+/*
* A dialog that allows the user to edit a config game entry.
* TODO: add widgets for some/all of the following
* - Maybe scaler/graphics mode. But there are two problems:
@@ -96,7 +117,7 @@
protected:
EditTextWidget *_descriptionWidget;
- EditTextWidget *_domainWidget;
+ DomainEditTextWidget *_domainWidget;
StaticTextWidget *_gamePathWidget;
StaticTextWidget *_extraPathWidget;
@@ -141,7 +162,7 @@
// GUI: Label & edit widget for the game ID
new StaticTextWidget(tab, x, yoffset + 2, labelWidth, kLineHeight, "ID: ", kTextAlignRight);
- _domainWidget = new EditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10, kLineHeight, _domain);
+ _domainWidget = new DomainEditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10, kLineHeight, _domain);
yoffset += 16;
// GUI: Label & edit widget for the description
@@ -487,7 +508,10 @@
}
}
+ const int oldSel = _list->getSelected();
_list->setList(l);
+ if (oldSel < (int)l.size())
+ _list->setSelected(oldSel); // Restore the old selection
updateButtons();
}
@@ -673,8 +697,8 @@
updateButtons();
break;
case kQuitCmd:
+ setResult(-1);
close();
- g_system->quit();
break;
default:
Dialog::handleCommand(sender, cmd, data);
Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.38
retrieving revision 1.38.2.1
diff -u -d -r1.38 -r1.38.2.1
--- widget.cpp 13 Mar 2004 13:03:25 -0000 1.38
+++ widget.cpp 30 Dec 2004 13:14:04 -0000 1.38.2.1
@@ -201,15 +201,13 @@
SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint labelWidth, uint32 cmd, uint8 hotkey)
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
- _value(0), _oldValue(0),_valueMin(0), _valueMax(100), _isDragging(false),
+ _value(0), _oldValue(0), _valueMin(0), _valueMax(100), _isDragging(false),
_labelWidth(labelWidth) {
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
_type = kSliderWidget;
}
void SliderWidget::handleMouseMoved(int x, int y, int button) {
- // TODO: when the mouse is dragged outside the widget, the slider should
- // snap back to the old value.
if (isEnabled() && _isDragging && x >= (int)_labelWidth) {
int newValue = posToValue(x - _labelWidth);
if (newValue < _valueMin)
More information about the Scummvm-git-logs
mailing list