Got rid of GuiManager::clearDragWidget instead handle it via a new widget flag WIDGET_IGNORE_DRAG.

svn-id: r35662
This commit is contained in:
Johannes Schickel 2009-01-02 01:31:46 +00:00
parent e6b9a3e476
commit e7bf64744b
5 changed files with 25 additions and 23 deletions

View file

@ -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();
}
}

View file

@ -152,6 +152,7 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
w = findWidget(x, y);
if (w && !(w->getFlags() & WIDGET_IGNORE_DRAG))
_dragWidget = w;
// If the click occured inside a widget which is not the currently
@ -184,7 +185,10 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
}
}
if (_dragWidget)
w = _dragWidget;
else
w = findWidget(x, y);
if (w)
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);

View file

@ -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) {

View file

@ -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.

View file

@ -45,7 +45,16 @@ enum {
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
// 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 {