aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2009-01-02 01:31:46 +0000
committerJohannes Schickel2009-01-02 01:31:46 +0000
commite7bf64744b13b86cce707cc4de3516cd8723c90e (patch)
tree3b85753e33e1efca6ce5788520ec609753f08960 /gui
parente6b9a3e4763f7802cbc5b7f7c12f12c5995ee23c (diff)
downloadscummvm-rg350-e7bf64744b13b86cce707cc4de3516cd8723c90e.tar.gz
scummvm-rg350-e7bf64744b13b86cce707cc4de3516cd8723c90e.tar.bz2
scummvm-rg350-e7bf64744b13b86cce707cc4de3516cd8723c90e.zip
Got rid of GuiManager::clearDragWidget instead handle it via a new widget flag WIDGET_IGNORE_DRAG.
svn-id: r35662
Diffstat (limited to 'gui')
-rw-r--r--gui/PopUpWidget.cpp3
-rw-r--r--gui/dialog.cpp8
-rw-r--r--gui/newgui.cpp5
-rw-r--r--gui/newgui.h5
-rw-r--r--gui/widget.h27
5 files changed, 25 insertions, 23 deletions
diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp
index 4c9dd8d81a..60f36247d5 100644
--- a/gui/PopUpWidget.cpp
+++ b/gui/PopUpWidget.cpp
@@ -358,7 +358,7 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth)
: Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(labelWidth) {
- setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS);
+ setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG);
_type = kPopUpWidget;
_selectedItem = -1;
@@ -375,7 +375,6 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) {
_selectedItem = newSel;
sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
}
- g_gui.clearDragWidget();
}
}
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index ebfdb9d634..9fd9d19fac 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -152,7 +152,8 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
w = findWidget(x, y);
- _dragWidget = w;
+ if (w && !(w->getFlags() & WIDGET_IGNORE_DRAG))
+ _dragWidget = w;
// If the click occured inside a widget which is not the currently
// focused one, change the focus to that widget.
@@ -184,7 +185,10 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
}
}
- w = _dragWidget;
+ if (_dragWidget)
+ w = _dragWidget;
+ else
+ w = findWidget(x, y);
if (w)
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index cf29d44ce0..b6c8f549ab 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -394,11 +394,6 @@ void GuiManager::animateCursor() {
}
}
-void GuiManager::clearDragWidget() {
- if (!_dialogStack.empty())
- _dialogStack.top()->_dragWidget = 0;
-}
-
bool GuiManager::checkScreenChange() {
int tmpScreenChangeID = _system->getScreenChangeID();
if (_lastScreenChangeID != tmpScreenChangeID) {
diff --git a/gui/newgui.h b/gui/newgui.h
index c6313feedd..c2ec61dd34 100644
--- a/gui/newgui.h
+++ b/gui/newgui.h
@@ -82,11 +82,6 @@ public:
int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
int getCharWidth(byte c, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getCharWidth(c, style); }
- // FIXME: clearDragWidget is apparently there for the sake of PopUpWidget::handleMouseDown.
- // This seems to be an ugly hack. At the very least, it should be thoroughly documented.
- // Better would be to replace it with a proper solution.
- void clearDragWidget();
-
/**
* Tell the GuiManager to check whether the screen resolution has changed.
* If that is the case, the GuiManager will reload/refresh the active theme.
diff --git a/gui/widget.h b/gui/widget.h
index 6140e03a26..3f4b4c04ae 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -37,15 +37,24 @@ namespace GUI {
class Dialog;
enum {
- WIDGET_ENABLED = 1 << 0,
- WIDGET_INVISIBLE = 1 << 1,
- WIDGET_HILITED = 1 << 2,
- WIDGET_BORDER = 1 << 3,
- //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
+ WIDGET_ENABLED = 1 << 0,
+ WIDGET_INVISIBLE = 1 << 1,
+ WIDGET_HILITED = 1 << 2,
+ WIDGET_BORDER = 1 << 3,
+ //WIDGET_INV_BORDER = 1 << 4,
+ WIDGET_CLEARBG = 1 << 5,
+ WIDGET_WANT_TICKLE = 1 << 7,
+ WIDGET_TRACK_MOUSE = 1 << 8,
+ // 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_RETAIN_FOCUS = 1 << 9,
+ // Usually widgets would lock mouse input when the user pressed the
+ // left mouse button till the user releases it.
+ // The PopUpWidget for example does not want this behavior, since the
+ // mouse down will open up a new dialog which silently eats the mouse
+ // up event for its own purposes.
+ WIDGET_IGNORE_DRAG = 1 << 10
};
enum {