Got rid of GuiManager::clearDragWidget instead handle it via a new widget flag WIDGET_IGNORE_DRAG.
svn-id: r35662
This commit is contained in:
parent
e6b9a3e476
commit
e7bf64744b
5 changed files with 25 additions and 23 deletions
|
@ -358,7 +358,7 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
|
||||||
|
|
||||||
PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth)
|
PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth)
|
||||||
: Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(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;
|
_type = kPopUpWidget;
|
||||||
|
|
||||||
_selectedItem = -1;
|
_selectedItem = -1;
|
||||||
|
@ -375,7 +375,6 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) {
|
||||||
_selectedItem = newSel;
|
_selectedItem = newSel;
|
||||||
sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
|
sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
|
||||||
}
|
}
|
||||||
g_gui.clearDragWidget();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,8 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
|
||||||
|
|
||||||
w = findWidget(x, y);
|
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
|
// If the click occured inside a widget which is not the currently
|
||||||
// focused one, change the focus to that widget.
|
// 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)
|
if (w)
|
||||||
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
|
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
|
||||||
|
|
|
@ -394,11 +394,6 @@ void GuiManager::animateCursor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiManager::clearDragWidget() {
|
|
||||||
if (!_dialogStack.empty())
|
|
||||||
_dialogStack.top()->_dragWidget = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GuiManager::checkScreenChange() {
|
bool GuiManager::checkScreenChange() {
|
||||||
int tmpScreenChangeID = _system->getScreenChangeID();
|
int tmpScreenChangeID = _system->getScreenChangeID();
|
||||||
if (_lastScreenChangeID != tmpScreenChangeID) {
|
if (_lastScreenChangeID != tmpScreenChangeID) {
|
||||||
|
|
|
@ -82,11 +82,6 @@ public:
|
||||||
int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
|
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); }
|
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.
|
* Tell the GuiManager to check whether the screen resolution has changed.
|
||||||
* If that is the case, the GuiManager will reload/refresh the active theme.
|
* If that is the case, the GuiManager will reload/refresh the active theme.
|
||||||
|
|
27
gui/widget.h
27
gui/widget.h
|
@ -37,15 +37,24 @@ namespace GUI {
|
||||||
class Dialog;
|
class Dialog;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
WIDGET_ENABLED = 1 << 0,
|
WIDGET_ENABLED = 1 << 0,
|
||||||
WIDGET_INVISIBLE = 1 << 1,
|
WIDGET_INVISIBLE = 1 << 1,
|
||||||
WIDGET_HILITED = 1 << 2,
|
WIDGET_HILITED = 1 << 2,
|
||||||
WIDGET_BORDER = 1 << 3,
|
WIDGET_BORDER = 1 << 3,
|
||||||
//WIDGET_INV_BORDER = 1 << 4,
|
//WIDGET_INV_BORDER = 1 << 4,
|
||||||
WIDGET_CLEARBG = 1 << 5,
|
WIDGET_CLEARBG = 1 << 5,
|
||||||
WIDGET_WANT_TICKLE = 1 << 7,
|
WIDGET_WANT_TICKLE = 1 << 7,
|
||||||
WIDGET_TRACK_MOUSE = 1 << 8,
|
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
|
// 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 {
|
enum {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue