aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMatthew Hoops2012-05-04 23:32:29 -0400
committerMatthew Hoops2012-05-04 23:32:29 -0400
commite80d622fa5b3a834faff22ac777838388c0cdf10 (patch)
treef19d5a4b8725796a8bad28dad9b29c7313e5c2ff /gui
parent68438a2919df2756942193d9b1b77496828fd45a (diff)
parente5808c740a62cb87a1ceeef7873af3b21e912c73 (diff)
downloadscummvm-rg350-e80d622fa5b3a834faff22ac777838388c0cdf10.tar.gz
scummvm-rg350-e80d622fa5b3a834faff22ac777838388c0cdf10.tar.bz2
scummvm-rg350-e80d622fa5b3a834faff22ac777838388c0cdf10.zip
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'gui')
-rw-r--r--gui/ThemeEngine.cpp5
-rw-r--r--gui/ThemeEngine.h6
-rw-r--r--gui/dialog.cpp13
-rw-r--r--gui/dialog.h7
-rw-r--r--gui/gui-manager.cpp13
-rw-r--r--gui/launcher.cpp1
-rw-r--r--gui/predictivedialog.cpp288
-rw-r--r--gui/predictivedialog.h9
-rw-r--r--gui/themes/default.inc11
-rw-r--r--gui/themes/scummclassic.zipbin93076 -> 93390 bytes
-rw-r--r--gui/themes/scummclassic/THEMERC2
-rw-r--r--gui/themes/scummclassic/classic_gfx.stx13
-rw-r--r--gui/themes/scummmodern.zipbin1449403 -> 1449894 bytes
-rw-r--r--gui/themes/scummmodern/THEMERC2
-rw-r--r--gui/themes/scummmodern/scummmodern_gfx.stx21
-rw-r--r--gui/widget.cpp58
-rw-r--r--gui/widget.h18
17 files changed, 338 insertions, 129 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index fdd7750af9..be0a5db601 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -175,6 +175,7 @@ static const DrawDataInfo kDrawDataDefaults[] = {
{kDDButtonIdle, "button_idle", true, kDDWidgetBackgroundSlider},
{kDDButtonHover, "button_hover", false, kDDButtonIdle},
{kDDButtonDisabled, "button_disabled", true, kDDNone},
+ {kDDButtonPressed, "button_pressed", false, kDDButtonIdle},
{kDDSliderFull, "slider_full", false, kDDNone},
{kDDSliderHover, "slider_hover", false, kDDNone},
@@ -877,6 +878,8 @@ void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, W
dd = kDDButtonHover;
else if (state == kStateDisabled)
dd = kDDButtonDisabled;
+ else if (state == kStatePressed)
+ dd = kDDButtonPressed;
queueDD(dd, r, 0, hints & WIDGET_CLEARBG);
queueDDText(getTextData(dd), getTextColor(dd), r, str, false, true, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
@@ -1125,6 +1128,7 @@ void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, Wid
break;
case kStateEnabled:
+ case kStatePressed:
colorId = kTextColorNormal;
break;
}
@@ -1145,6 +1149,7 @@ void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, Wid
break;
case kStateEnabled:
+ case kStatePressed:
colorId = kTextColorAlternative;
break;
}
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index 0495a85c88..acded085f5 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -35,7 +35,7 @@
#include "graphics/pixelformat.h"
-#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.11"
+#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.12"
class OSystem;
@@ -81,6 +81,7 @@ enum DrawData {
kDDButtonIdle,
kDDButtonHover,
kDDButtonDisabled,
+ kDDButtonPressed,
kDDSliderFull,
kDDSliderHover,
@@ -178,7 +179,8 @@ public:
enum State {
kStateDisabled, ///< Indicates that the widget is disabled, that does NOT include that it is invisible
kStateEnabled, ///< Indicates that the widget is enabled
- kStateHighlight ///< Indicates that the widget is highlighted by the user
+ kStateHighlight, ///< Indicates that the widget is highlighted by the user
+ kStatePressed ///< Indicates that the widget is pressed, currently works for buttons
};
typedef State WidgetStateInfo;
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 2201e83ca5..ffca15bbc8 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -42,7 +42,7 @@ namespace GUI {
Dialog::Dialog(int x, int y, int w, int h)
: GuiObject(x, y, w, h),
- _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false),
+ _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _tickleWidget(0), _visible(false),
_backgroundType(GUI::ThemeEngine::kDialogBackgroundDefault) {
// Some dialogs like LauncherDialog use internally a fixed size, even though
// their widgets rely on the layout to be initialized correctly by the theme.
@@ -54,7 +54,7 @@ Dialog::Dialog(int x, int y, int w, int h)
Dialog::Dialog(const Common::String &name)
: GuiObject(name),
- _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false),
+ _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _tickleWidget(0), _visible(false),
_backgroundType(GUI::ThemeEngine::kDialogBackgroundDefault) {
// It may happen that we have 3x scaler in launcher (960xY) and then 640x480
@@ -117,6 +117,12 @@ void Dialog::reflowLayout() {
GuiObject::reflowLayout();
}
+void Dialog::lostFocus() {
+ if (_tickleWidget) {
+ _tickleWidget->lostFocus();
+ }
+}
+
void Dialog::setFocusWidget(Widget *widget) {
// The focus will change. Tell the old focused widget (if any)
// that it lost the focus.
@@ -308,6 +314,9 @@ void Dialog::handleTickle() {
// Focused widget receives tickle notifications
if (_focusedWidget && _focusedWidget->getFlags() & WIDGET_WANT_TICKLE)
_focusedWidget->handleTickle();
+
+ if (_tickleWidget && _tickleWidget->getFlags() & WIDGET_WANT_TICKLE)
+ _tickleWidget->handleTickle();
}
void Dialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
diff --git a/gui/dialog.h b/gui/dialog.h
index f5a5f94a68..1773c6633e 100644
--- a/gui/dialog.h
+++ b/gui/dialog.h
@@ -52,6 +52,7 @@ protected:
Widget *_mouseWidget;
Widget *_focusedWidget;
Widget *_dragWidget;
+ Widget *_tickleWidget;
bool _visible;
ThemeEngine::DialogBackground _backgroundType;
@@ -71,7 +72,13 @@ public:
void setFocusWidget(Widget *widget);
Widget *getFocusWidget() { return _focusedWidget; }
+ void setTickleWidget(Widget *widget) { _tickleWidget = widget; }
+ void unSetTickleWidget() { _tickleWidget = NULL; }
+ Widget *getTickleWidget() { return _tickleWidget; }
+
virtual void reflowLayout();
+ virtual void lostFocus();
+ virtual void receivedFocus() {}
protected:
virtual void open();
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index ffecd928bc..abd781e1a3 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -381,7 +381,7 @@ void GuiManager::runLoop() {
if (tooltipCheck && _lastMousePosition.time + kTooltipDelay < _system->getMillis()) {
Widget *wdg = activeDialog->findWidget(_lastMousePosition.x, _lastMousePosition.y);
- if (wdg && wdg->getTooltip()) {
+ if (wdg && wdg->getTooltip() && !(wdg->getFlags() & WIDGET_PRESSED)) {
Tooltip *tooltip = new Tooltip();
tooltip->setup(activeDialog, wdg, _lastMousePosition.x, _lastMousePosition.y);
tooltip->runModal();
@@ -441,6 +441,11 @@ void GuiManager::restoreState() {
}
void GuiManager::openDialog(Dialog *dialog) {
+ dialog->receivedFocus();
+
+ if (!_dialogStack.empty())
+ getTopDialog()->lostFocus();
+
_dialogStack.push(dialog);
if (_redrawStatus != kRedrawFull)
_redrawStatus = kRedrawOpenDialog;
@@ -458,7 +463,11 @@ void GuiManager::closeTopDialog() {
return;
// Remove the dialog from the stack
- _dialogStack.pop();
+ _dialogStack.pop()->lostFocus();
+
+ if (!_dialogStack.empty())
+ getTopDialog()->receivedFocus();
+
if (_redrawStatus != kRedrawFull)
_redrawStatus = kRedrawCloseDialog;
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index a86a98f819..c8ed3126c4 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -663,7 +663,6 @@ LauncherDialog::LauncherDialog()
_list->setEditable(false);
_list->setNumberingMode(kListNumberingOff);
-
// Populate the list
updateListing();
diff --git a/gui/predictivedialog.cpp b/gui/predictivedialog.cpp
index 9cd18b81ba..b827d49416 100644
--- a/gui/predictivedialog.cpp
+++ b/gui/predictivedialog.cpp
@@ -69,31 +69,33 @@ enum {
PredictiveDialog::PredictiveDialog() : Dialog("Predictive") {
new StaticTextWidget(this, "Predictive.Headline", "Enter Text");
- new ButtonWidget(this, "Predictive.Cancel" , _("Cancel"), 0, kCancelCmd);
- new ButtonWidget(this, "Predictive.OK" , _("Ok") , 0, kOkCmd);
- new ButtonWidget(this, "Predictive.Button1", "1 `-.&" , 0, kBut1Cmd);
- new ButtonWidget(this, "Predictive.Button2", "2 abc" , 0, kBut2Cmd);
- new ButtonWidget(this, "Predictive.Button3", "3 def" , 0, kBut3Cmd);
- new ButtonWidget(this, "Predictive.Button4", "4 ghi" , 0, kBut4Cmd);
- new ButtonWidget(this, "Predictive.Button5", "5 jkl" , 0, kBut5Cmd);
- new ButtonWidget(this, "Predictive.Button6", "6 mno" , 0, kBut6Cmd);
- new ButtonWidget(this, "Predictive.Button7", "7 pqrs" , 0, kBut7Cmd);
- new ButtonWidget(this, "Predictive.Button8", "8 tuv" , 0, kBut8Cmd);
- new ButtonWidget(this, "Predictive.Button9", "9 wxyz" , 0, kBut9Cmd);
- new ButtonWidget(this, "Predictive.Button0", "0" , 0, kBut0Cmd);
- // I18N: You must leave "#" as is, only word 'next' is translatable
- new ButtonWidget(this, "Predictive.Next" , _("# next"), 0, kNextCmd);
- _addBtn = new ButtonWidget(this, "Predictive.Add", _("add"), 0, kAddCmd);
- _addBtn->setEnabled(false);
-
-#ifndef DISABLE_FANCY_THEMES
- _delbtn = new PicButtonWidget(this, "Predictive.Delete", _("Delete char"), kDelCmd);
- ((PicButtonWidget *)_delbtn)->useThemeTransparency(true);
- ((PicButtonWidget *)_delbtn)->setGfx(g_gui.theme()->getImageSurface(ThemeEngine::kImageDelbtn));
-#endif
- _delbtn = new ButtonWidget(this, "Predictive.Delete" , _("<"), 0, kDelCmd);
- // I18N: Pre means 'Predictive', leave '*' as is
- _modebutton = new ButtonWidget(this, "Predictive.Pre", _("* Pre"), 0, kModeCmd);
+ _btns = (ButtonWidget **)calloc(1, sizeof(ButtonWidget *) * 16);
+
+ _btns[kCancelAct] = new ButtonWidget(this, "Predictive.Cancel", _("Cancel") , 0, kCancelCmd);
+ _btns[kOkAct] = new ButtonWidget(this, "Predictive.OK", _("Ok") , 0, kOkCmd);
+ _btns[kBtn1Act] = new ButtonWidget(this, "Predictive.Button1", "1 `-.&" , 0, kBut1Cmd);
+ _btns[kBtn2Act] = new ButtonWidget(this, "Predictive.Button2", "2 abc" , 0, kBut2Cmd);
+ _btns[kBtn3Act] = new ButtonWidget(this, "Predictive.Button3", "3 def" , 0, kBut3Cmd);
+ _btns[kBtn4Act] = new ButtonWidget(this, "Predictive.Button4", "4 ghi" , 0, kBut4Cmd);
+ _btns[kBtn5Act] = new ButtonWidget(this, "Predictive.Button5", "5 jkl" , 0, kBut5Cmd);
+ _btns[kBtn6Act] = new ButtonWidget(this, "Predictive.Button6", "6 mno" , 0, kBut6Cmd);
+ _btns[kBtn7Act] = new ButtonWidget(this, "Predictive.Button7", "7 pqrs" , 0, kBut7Cmd);
+ _btns[kBtn8Act] = new ButtonWidget(this, "Predictive.Button8", "8 tuv" , 0, kBut8Cmd);
+ _btns[kBtn9Act] = new ButtonWidget(this, "Predictive.Button9", "9 wxyz" , 0, kBut9Cmd);
+ _btns[kBtn0Act] = new ButtonWidget(this, "Predictive.Button0", "0" , 0, kBut0Cmd);
+ // I18N: You must leave "#" as is, only word 'next' is translatable
+ _btns[kNextAct] = new ButtonWidget(this, "Predictive.Next", _("# next") , 0, kNextCmd);
+ _btns[kAddAct] = new ButtonWidget(this, "Predictive.Add", _("add") , 0, kAddCmd);
+ _btns[kAddAct]->setEnabled(false);
+
+ #ifndef DISABLE_FANCY_THEMES
+ _btns[kDelAct] = new PicButtonWidget(this, "Predictive.Delete", _("Delete char"), kDelCmd);
+ ((PicButtonWidget *)_btns[kDelAct])->useThemeTransparency(true);
+ ((PicButtonWidget *)_btns[kDelAct])->setGfx(g_gui.theme()->getImageSurface(ThemeEngine::kImageDelbtn));
+ #endif
+ _btns[kDelAct] = new ButtonWidget(this, "Predictive.Delete" , _("<") , 0, kDelCmd);
+ // I18N: Pre means 'Predictive', leave '*' as is
+ _btns[kModeAct] = new ButtonWidget(this, "Predictive.Pre", _("* Pre"), 0, kModeCmd);
_edittext = new EditTextWidget(this, "Predictive.Word", _search, 0, 0, 0);
_userDictHasChanged = false;
@@ -164,6 +166,8 @@ PredictiveDialog::~PredictiveDialog() {
free(_userDict.dictLine);
free(_predictiveDict.dictLine);
free(_unitedDict.dictLine);
+
+ free(_btns);
}
void PredictiveDialog::saveUserDictToFile() {
@@ -182,11 +186,23 @@ void PredictiveDialog::saveUserDictToFile() {
}
}
+void PredictiveDialog::handleKeyUp(Common::KeyState state) {
+ if (_currBtn != kNoAct && !_needRefresh) {
+ _btns[_currBtn]->startAnimatePressedState();
+ processBtnActive(_currBtn);
+ }
+}
+
void PredictiveDialog::handleKeyDown(Common::KeyState state) {
- ButtonId act = kNoAct;
+ _currBtn = kNoAct;
+ _needRefresh = false;
if (getFocusWidget() == _edittext) {
- setFocusWidget(_addBtn);
+ setFocusWidget(_btns[kAddAct]);
+ }
+
+ if (_lastbutton == kNoAct) {
+ _lastbutton = kBtn5Act;
}
switch (state.keycode) {
@@ -197,96 +213,126 @@ void PredictiveDialog::handleKeyDown(Common::KeyState state) {
case Common::KEYCODE_LEFT:
_navigationwithkeys = true;
if (_lastbutton == kBtn1Act || _lastbutton == kBtn4Act || _lastbutton == kBtn7Act)
- act = ButtonId(_lastbutton + 2);
+ _currBtn = ButtonId(_lastbutton + 2);
+ else if (_lastbutton == kDelAct)
+ _currBtn = kBtn1Act;
+ else if (_lastbutton == kModeAct)
+ _currBtn = kNextAct;
else if (_lastbutton == kNextAct)
- act = kBtn0Act;
- else if (_lastbutton == kDelAct)
- act = kDelAct;
+ _currBtn = kBtn0Act;
+ else if (_lastbutton == kAddAct)
+ _currBtn = kOkAct;
else if (_lastbutton == kCancelAct)
- act = kOkAct;
- else if (_lastbutton == kModeAct)
- act = kAddAct;
+ _currBtn = kAddAct;
else
- act = ButtonId(_lastbutton - 1);
- _lastbutton = act;
- //needRefresh = true;
+ _currBtn = ButtonId(_lastbutton - 1);
+
+
+ if (_mode != kModeAbc && _lastbutton == kCancelAct)
+ _currBtn = kOkAct;
+
+ _needRefresh = true;
break;
case Common::KEYCODE_RIGHT:
_navigationwithkeys = true;
- if (_lastbutton == kBtn3Act || _lastbutton == kBtn6Act || _lastbutton == kBtn9Act)
- act = ButtonId(_lastbutton - 2);
+ if (_lastbutton == kBtn3Act || _lastbutton == kBtn6Act || _lastbutton == kBtn9Act || _lastbutton == kOkAct)
+ _currBtn = ButtonId(_lastbutton - 2);
+ else if (_lastbutton == kDelAct)
+ _currBtn = kBtn3Act;
+ else if (_lastbutton == kBtn0Act)
+ _currBtn = kNextAct;
+ else if (_lastbutton == kNextAct)
+ _currBtn = kModeAct;
else if (_lastbutton == kAddAct)
- act = kModeAct;
- else if (_lastbutton == kDelAct)
- act = kDelAct;
+ _currBtn = kCancelAct;
else if (_lastbutton == kOkAct)
- act = kCancelAct;
- else if (_lastbutton == kBtn0Act)
- act = kNextAct;
+ _currBtn = kAddAct;
else
- act = ButtonId(_lastbutton + 1);
- _lastbutton = act;
- //needRefresh = true;
+ _currBtn = ButtonId(_lastbutton + 1);
+
+ if (_mode != kModeAbc && _lastbutton == kOkAct)
+ _currBtn = kCancelAct;
+ _needRefresh = true;
break;
case Common::KEYCODE_UP:
_navigationwithkeys = true;
if (_lastbutton <= kBtn3Act)
- act = kDelAct;
- else if (_lastbutton == kNextAct || _lastbutton == kAddAct)
- act = ButtonId(_lastbutton - 2);
+ _currBtn = kDelAct;
else if (_lastbutton == kDelAct)
- act = kOkAct;
- else if (_lastbutton == kModeAct)
- act = kBtn9Act;
+ _currBtn = kOkAct;
+ else if (_lastbutton == kModeAct)
+ _currBtn = kBtn7Act;
else if (_lastbutton == kBtn0Act)
- act = kBtn7Act;
+ _currBtn = kBtn8Act;
+ else if (_lastbutton == kNextAct)
+ _currBtn = kBtn9Act;
+ else if (_lastbutton == kAddAct)
+ _currBtn = kModeAct;
+ else if (_lastbutton == kCancelAct)
+ _currBtn = kBtn0Act;
+ else if (_lastbutton == kOkAct)
+ _currBtn = kNextAct;
else
- act = ButtonId(_lastbutton - 3);
- _lastbutton = act;
- //needRefresh = true;
+ _currBtn = ButtonId(_lastbutton - 3);
+ _needRefresh = true;
break;
case Common::KEYCODE_DOWN:
_navigationwithkeys = true;
- if (_lastbutton == kBtn7Act)
- act = kBtn0Act;
- else if (_lastbutton == kBtn8Act || _lastbutton == kBtn9Act)
- act = ButtonId(_lastbutton + 2);
- else if (_lastbutton == kDelAct)
- act = kBtn1Act;
- else if (_lastbutton == kCancelAct || _lastbutton == kOkAct)
- act = kDelAct;
- else if (_lastbutton == kModeAct || _lastbutton == kBtn0Act)
- act = ButtonId(_lastbutton - 2);
+ if (_lastbutton == kDelAct)
+ _currBtn = kBtn3Act;
+ else if (_lastbutton == kBtn7Act)
+ _currBtn = kModeAct;
+ else if (_lastbutton == kBtn8Act)
+ _currBtn = kBtn0Act;
+ else if (_lastbutton == kBtn9Act)
+ _currBtn = kNextAct;
+ else if (_lastbutton == kModeAct)
+ _currBtn = kAddAct;
+ else if (_lastbutton == kBtn0Act)
+ _currBtn = kCancelAct;
+ else if (_lastbutton == kNextAct)
+ _currBtn = kOkAct;
+ else if (_lastbutton == kAddAct || _lastbutton == kCancelAct || _lastbutton == kOkAct)
+ _currBtn = kDelAct;
else
- act = ButtonId(_lastbutton + 3);
- _lastbutton = act;
- //needRefresh = true;
+ _currBtn = ButtonId(_lastbutton + 3);
+
+ if (_mode != kModeAbc && _lastbutton == kModeAct)
+ _currBtn = kCancelAct;
+
+ _needRefresh = true;
break;
case Common::KEYCODE_KP_ENTER:
+ case Common::KEYCODE_RETURN:
+ if (state.flags & Common::KBD_CTRL) {
+ _currBtn = kOkAct;
+ break;
+ }
if (_navigationwithkeys) {
// when the user has utilized arrow key navigation,
- // interpret enter as 'click' on the act button
- act = _lastbutton;
+ // interpret enter as 'click' on the _currBtn button
+ _currBtn = _lastbutton;
+ _needRefresh = false;
} else {
// else it is a shortcut for 'Ok'
- act = kOkAct;
+ _currBtn = kOkAct;
}
break;
case Common::KEYCODE_KP_PLUS:
- act = kAddAct;
+ _currBtn = kAddAct;
break;
case Common::KEYCODE_BACKSPACE:
case Common::KEYCODE_KP_MINUS:
- act = kDelAct;
+ _currBtn = kDelAct;
break;
case Common::KEYCODE_KP_DIVIDE:
- act = kNextAct;
+ _currBtn = kNextAct;
break;
case Common::KEYCODE_KP_MULTIPLY:
- act = kModeAct;
+ _currBtn = kModeAct;
break;
case Common::KEYCODE_KP0:
- act = kBtn0Act;
+ _currBtn = kBtn0Act;
break;
case Common::KEYCODE_KP1:
case Common::KEYCODE_KP2:
@@ -297,78 +343,93 @@ void PredictiveDialog::handleKeyDown(Common::KeyState state) {
case Common::KEYCODE_KP7:
case Common::KEYCODE_KP8:
case Common::KEYCODE_KP9:
- act = ButtonId(state.keycode - Common::KEYCODE_KP1);
+ _currBtn = ButtonId(state.keycode - Common::KEYCODE_KP1);
break;
default:
Dialog::handleKeyDown(state);
}
- if (act != kNoAct) {
- processBtnActive(act);
+ if (_lastbutton != _currBtn)
+ _btns[_lastbutton]->stopAnimatePressedState();
+
+ if (_currBtn != kNoAct && !_needRefresh)
+ _btns[_currBtn]->setPressedState();
+ else
+ updateHighLightedButton(_currBtn);
+}
+
+void PredictiveDialog::updateHighLightedButton(ButtonId act) {
+ if (_currBtn != kNoAct) {
+ _btns[_lastbutton]->setHighLighted(false);
+ _lastbutton = act;
+ _btns[_lastbutton]->setHighLighted(true);
}
}
void PredictiveDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
- ButtonId act = kNoAct;
+ _currBtn = kNoAct;
_navigationwithkeys = false;
+ if (_lastbutton != kNoAct)
+ _btns[_lastbutton]->setHighLighted(false);
+
switch (cmd) {
case kDelCmd:
- act = kDelAct;
+ _currBtn = kDelAct;
break;
case kNextCmd:
- act = kNextAct;
+ _currBtn = kNextAct;
break;
case kAddCmd:
- act = kAddAct;
+ _currBtn = kAddAct;
break;
case kModeCmd:
- act = kModeAct;
+ _currBtn = kModeAct;
break;
case kBut1Cmd:
- act = kBtn1Act;
+ _currBtn = kBtn1Act;
break;
case kBut2Cmd:
- act = kBtn2Act;
+ _currBtn = kBtn2Act;
break;
case kBut3Cmd:
- act = kBtn3Act;
+ _currBtn = kBtn3Act;
break;
case kBut4Cmd:
- act = kBtn4Act;
+ _currBtn = kBtn4Act;
break;
case kBut5Cmd:
- act = kBtn5Act;
+ _currBtn = kBtn5Act;
break;
case kBut6Cmd:
- act = kBtn6Act;
+ _currBtn = kBtn6Act;
break;
case kBut7Cmd:
- act = kBtn7Act;
+ _currBtn = kBtn7Act;
break;
case kBut8Cmd:
- act = kBtn8Act;
+ _currBtn = kBtn8Act;
break;
case kBut9Cmd:
- act = kBtn9Act;
+ _currBtn = kBtn9Act;
break;
case kBut0Cmd:
- act = kBtn0Act;
+ _currBtn = kBtn0Act;
break;
case kCancelCmd:
saveUserDictToFile();
close();
return;
case kOkCmd:
- act = kOkAct;
+ _currBtn = kOkAct;
break;
default:
Dialog::handleCommand(sender, cmd, data);
}
- if (act != kNoAct) {
- processBtnActive(act);
+ if (_currBtn != kNoAct) {
+ processBtnActive(_currBtn);
}
}
@@ -500,18 +561,18 @@ void PredictiveDialog::processBtnActive(ButtonId button) {
bringWordtoTop(_unitedDict.dictActLine, _wordNumber);
} else if (button == kModeAct) { // Mode
_mode++;
- _addBtn->setEnabled(false);
+ _btns[kAddAct]->setEnabled(false);
if (_mode > kModeAbc) {
_mode = kModePre;
// I18N: Pre means 'Predictive', leave '*' as is
- _modebutton->setLabel("* Pre");
+ _btns[kModeAct]->setLabel("* Pre");
} else if (_mode == kModeNum) {
// I18N: 'Num' means Numbers
- _modebutton->setLabel("* Num");
+ _btns[kModeAct]->setLabel("* Num");
} else {
// I18N: 'Abc' means Latin alphabet input
- _modebutton->setLabel("* Abc");
- _addBtn->setEnabled(true);
+ _btns[kModeAct]->setLabel("* Abc");
+ _btns[kAddAct]->setEnabled(true);
}
// truncate current input at mode change
@@ -532,18 +593,23 @@ void PredictiveDialog::processBtnActive(ButtonId button) {
if (button == kOkAct)
close();
+
+ if (button == kCancelAct) {
+ saveUserDictToFile();
+ close();
+ }
}
void PredictiveDialog::handleTickle() {
- // TODO/FIXME: This code does not seem to make any sense. It is only
- // triggered when _lastTime is zero and sets _lastTime to zero again
- // under some condition. This should really be a nop. Probably this
- // code intends to check "_lastTime" instead of "!_lastTime".
- if (!_lastTime) {
+ if (_lastTime) {
if ((_curTime - _lastTime) > kRepeatDelay) {
_lastTime = 0;
}
}
+
+ if (getTickleWidget()) {
+ getTickleWidget()->handleTickle();
+ }
}
void PredictiveDialog::mergeDicts() {
@@ -664,7 +730,7 @@ bool PredictiveDialog::matchWord() {
// The entries in the dictionary consist of a code, a space, and then
// a space-separated list of words matching this code.
- // To exactly match a code, we therefore match the code plus the trailing
+ // To ex_currBtnly match a code, we therefore match the code plus the trailing
// space in the dictionary.
Common::String code = _currentCode + " ";
diff --git a/gui/predictivedialog.h b/gui/predictivedialog.h
index 32de36d5f2..0e3d2967c0 100644
--- a/gui/predictivedialog.h
+++ b/gui/predictivedialog.h
@@ -68,6 +68,7 @@ public:
~PredictiveDialog();
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
+ virtual void handleKeyUp(Common::KeyState state);
virtual void handleKeyDown(Common::KeyState state);
virtual void handleTickle();
@@ -98,6 +99,8 @@ private:
void saveUserDictToFile();
void mergeDicts();
+
+ void updateHighLightedButton(ButtonId active);
private:
Dict _unitedDict;
Dict _predictiveDict;
@@ -118,6 +121,7 @@ private:
uint32 _curTime, _lastTime;
ButtonId _lastPressBtn;
+ ButtonId _currBtn;
char _temp[kMaxWordLen + 1];
int _repeatcount[kMaxWordLen];
@@ -128,11 +132,10 @@ private:
Common::String _search;
bool _navigationwithkeys;
+ bool _needRefresh;
private:
EditTextWidget *_edittext;
- ButtonWidget *_modebutton;
- ButtonWidget *_delbtn;
- ButtonWidget *_addBtn;
+ ButtonWidget **_btns;
};
} // namespace GUI
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index 542f776dbd..5ee9b9202a 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -460,6 +460,17 @@
"bevel='2' "
"/> "
"</drawdata> "
+"<drawdata id='button_pressed' cache='false'> "
+"<text font='text_button' "
+"text_color='color_alternative_inverted' "
+"vertical_align='center' "
+"horizontal_align='center' "
+"/> "
+"<drawstep func='square' "
+"fill='foreground' "
+"fg_color='green' "
+"/> "
+"</drawdata> "
"<drawdata id='button_idle' cache='false'> "
"<text font='text_button' "
"text_color='color_button' "
diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip
index eb5ac2d9f7..ec1728b778 100644
--- a/gui/themes/scummclassic.zip
+++ b/gui/themes/scummclassic.zip
Binary files differ
diff --git a/gui/themes/scummclassic/THEMERC b/gui/themes/scummclassic/THEMERC
index b808aee32f..7cbed97e40 100644
--- a/gui/themes/scummclassic/THEMERC
+++ b/gui/themes/scummclassic/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.8.11:ScummVM Classic Theme:No Author]
+[SCUMMVM_STX0.8.12:ScummVM Classic Theme:No Author]
diff --git a/gui/themes/scummclassic/classic_gfx.stx b/gui/themes/scummclassic/classic_gfx.stx
index f07499ce79..49ecea2e11 100644
--- a/gui/themes/scummclassic/classic_gfx.stx
+++ b/gui/themes/scummclassic/classic_gfx.stx
@@ -541,6 +541,19 @@
/>
</drawdata>
+ <!-- Pressed button -->
+ <drawdata id = 'button_pressed' cache = 'false'>
+ <text font = 'text_button'
+ text_color = 'color_alternative_inverted'
+ vertical_align = 'center'
+ horizontal_align = 'center'
+ />
+ <drawstep func = 'square'
+ fill = 'foreground'
+ fg_color = 'green'
+ />
+ </drawdata>
+
<drawdata id = 'button_idle' cache = 'false'>
<text font = 'text_button'
text_color = 'color_button'
diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
index 94f7cd8f6e..deae315e30 100644
--- a/gui/themes/scummmodern.zip
+++ b/gui/themes/scummmodern.zip
Binary files differ
diff --git a/gui/themes/scummmodern/THEMERC b/gui/themes/scummmodern/THEMERC
index e6c441d543..326993e98d 100644
--- a/gui/themes/scummmodern/THEMERC
+++ b/gui/themes/scummmodern/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.8.11:ScummVM Modern Theme:No Author]
+[SCUMMVM_STX0.8.12:ScummVM Modern Theme:No Author]
diff --git a/gui/themes/scummmodern/scummmodern_gfx.stx b/gui/themes/scummmodern/scummmodern_gfx.stx
index 403f636fd0..970d78a5ae 100644
--- a/gui/themes/scummmodern/scummmodern_gfx.stx
+++ b/gui/themes/scummmodern/scummmodern_gfx.stx
@@ -740,6 +740,27 @@
/>
</drawdata>
+ <!-- Pressed button -->
+ <drawdata id = 'button_pressed' cache = 'false'>
+ <text font = 'text_button'
+ text_color = 'color_button'
+ vertical_align = 'center'
+ horizontal_align = 'center'
+ />
+ <drawstep func = 'roundedsq'
+ radius = '5'
+ stroke = '1'
+ fill = 'foreground'
+ shadow = '0'
+ factor = '0'
+ fg_color = '120, 40, 16'
+ gradient_start = '255, 0, 0'
+ gradient_end = '255, 0, 0'
+ bevel = '1'
+ bevel_color = 'black'
+ />
+ </drawdata>
+
<!-- Idle button -->
<drawdata id = 'button_idle' cache = 'false'>
<text font = 'text_button'
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 0e2fd248b1..6ae4e5cee5 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -30,6 +30,8 @@
#include "gui/ThemeEval.h"
+#include "gui/dialog.h"
+
namespace GUI {
Widget::Widget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip)
@@ -77,6 +79,8 @@ void Widget::updateState(int oldFlags, int newFlags) {
_state = ThemeEngine::kStateEnabled;
if (newFlags & WIDGET_HILITED)
_state = ThemeEngine::kStateHighlight;
+ if (newFlags & WIDGET_PRESSED)
+ _state = ThemeEngine::kStatePressed;
} else {
_state = ThemeEngine::kStateDisabled;
}
@@ -272,27 +276,33 @@ void StaticTextWidget::drawWidget() {
ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, const char *tooltip, uint32 cmd, uint8 hotkey)
: StaticTextWidget(boss, x, y, w, h, cleanupHotkey(label), Graphics::kTextAlignCenter, tooltip), CommandSender(boss),
- _cmd(cmd), _hotkey(hotkey) {
+ _cmd(cmd), _hotkey(hotkey), _lastTime(0) {
if (hotkey == 0)
_hotkey = parseHotkey(label);
- setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
+ setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG | WIDGET_WANT_TICKLE);
_type = kButtonWidget;
}
ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Common::String &label, const char *tooltip, uint32 cmd, uint8 hotkey)
: StaticTextWidget(boss, name, cleanupHotkey(label), tooltip), CommandSender(boss),
- _cmd(cmd) {
+ _cmd(cmd), _lastTime(0) {
if (hotkey == 0)
_hotkey = parseHotkey(label);
- setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
+ setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG | WIDGET_WANT_TICKLE);
_type = kButtonWidget;
}
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
- if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h)
+ if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) {
sendCommand(_cmd, 0);
+ startAnimatePressedState();
+ }
+}
+
+void ButtonWidget::handleMouseDown(int x, int y, int button, int clickCount) {
+ setPressedState();
}
void ButtonWidget::drawWidget() {
@@ -324,6 +334,44 @@ ButtonWidget *addClearButton(GuiObject *boss, const Common::String &name, uint32
return button;
}
+void ButtonWidget::setHighLighted(bool enable) {
+ (enable) ? setFlags(WIDGET_HILITED) : clearFlags(WIDGET_HILITED);
+ draw();
+}
+
+void ButtonWidget::handleTickle() {
+ if (_lastTime) {
+ uint32 curTime = g_system->getMillis();
+ if (curTime - _lastTime > kPressedButtonTime) {
+ stopAnimatePressedState();
+ }
+ }
+}
+
+void ButtonWidget::setPressedState() {
+ wantTickle(true);
+ setFlags(WIDGET_PRESSED);
+ draw();
+}
+
+void ButtonWidget::stopAnimatePressedState() {
+ wantTickle(false);
+ _lastTime = 0;
+ clearFlags(WIDGET_PRESSED);
+ draw();
+}
+
+void ButtonWidget::startAnimatePressedState() {
+ _lastTime = g_system->getMillis();
+}
+
+void ButtonWidget::wantTickle(bool tickled) {
+ if (tickled)
+ ((GUI::Dialog *)_boss)->setTickleWidget(this);
+ else
+ ((GUI::Dialog *)_boss)->unSetTickleWidget();
+}
+
#pragma mark -
PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey)
diff --git a/gui/widget.h b/gui/widget.h
index 789fc09231..6a6c67ced9 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -38,6 +38,7 @@ enum {
WIDGET_INVISIBLE = 1 << 1,
WIDGET_HILITED = 1 << 2,
WIDGET_BORDER = 1 << 3,
+ WIDGET_PRESSED = 1 << 4,
//WIDGET_INV_BORDER = 1 << 4,
WIDGET_CLEARBG = 1 << 5,
WIDGET_WANT_TICKLE = 1 << 7,
@@ -73,6 +74,10 @@ enum {
kCaretBlinkTime = 300
};
+enum {
+ kPressedButtonTime = 200
+};
+
/* Widget */
class Widget : public GuiObject {
friend class Dialog;
@@ -189,11 +194,22 @@ public:
void setLabel(const Common::String &label);
void handleMouseUp(int x, int y, int button, int clickCount);
+ void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); }
- void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); }
+ void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED | WIDGET_PRESSED); draw(); }
+ void handleTickle();
+
+ void setHighLighted(bool enable);
+ void setPressedState();
+ void startAnimatePressedState();
+ void stopAnimatePressedState();
+ void lostFocusWidget() { stopAnimatePressedState(); }
protected:
void drawWidget();
+ void wantTickle(bool tickled);
+private:
+ uint32 _lastTime;
};
/* PicButtonWidget */