2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-07-05 16:56:53 +00:00
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2002-07-05 16:56:53 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2002-07-05 16:56:53 +00:00
|
|
|
*/
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/rect.h"
|
2012-02-23 00:30:47 +00:00
|
|
|
|
2010-11-16 10:19:01 +00:00
|
|
|
#include "gui/gui-manager.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "gui/dialog.h"
|
2019-12-28 09:43:58 +00:00
|
|
|
#include "gui/ThemeEval.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "gui/widget.h"
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2002-07-28 20:10:39 +00:00
|
|
|
/*
|
|
|
|
* TODO list
|
2005-01-06 19:09:34 +00:00
|
|
|
* - add some sense of the window being "active" (i.e. in front) or not. If it
|
2002-08-04 01:18:06 +00:00
|
|
|
* was inactive and just became active, reset certain vars (like who is focused).
|
|
|
|
* Maybe we should just add lostFocus and receivedFocus methods to Dialog, just
|
|
|
|
* like we have for class Widget?
|
2002-07-28 20:10:39 +00:00
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
|
2023-03-23 21:04:50 +00:00
|
|
|
Dialog::Dialog(int x, int y, int w, int h, bool scale)
|
|
|
|
: GuiObject(x, y, w, h, scale),
|
2020-01-05 16:48:04 +00:00
|
|
|
_mouseWidget(nullptr), _focusedWidget(nullptr), _dragWidget(nullptr), _tickleWidget(nullptr), _visible(false),
|
2023-04-12 22:34:10 +00:00
|
|
|
_backgroundType(GUI::ThemeEngine::kDialogBackgroundDefault), _handlingMouseWheel(false) {
|
2009-01-02 22:10:00 +00:00
|
|
|
// Some dialogs like LauncherDialog use internally a fixed size, even though
|
|
|
|
// their widgets rely on the layout to be initialized correctly by the theme.
|
|
|
|
// Thus we need to catch screen changes here too. If we do not do that, it
|
|
|
|
// will for example crash after returning to the launcher when the user
|
|
|
|
// started a 640x480 game with a non 1x scaler.
|
|
|
|
g_gui.checkScreenChange();
|
2016-06-01 10:10:33 +00:00
|
|
|
|
2021-06-18 11:27:36 +00:00
|
|
|
_mouseUpdatedOnFocus = true;
|
2016-06-01 10:10:33 +00:00
|
|
|
_result = -1;
|
2009-01-02 22:10:00 +00:00
|
|
|
}
|
2006-03-07 19:02:42 +00:00
|
|
|
|
2008-08-13 17:46:00 +00:00
|
|
|
Dialog::Dialog(const Common::String &name)
|
2006-03-07 19:02:42 +00:00
|
|
|
: GuiObject(name),
|
2020-01-05 16:48:04 +00:00
|
|
|
_mouseWidget(nullptr), _focusedWidget(nullptr), _dragWidget(nullptr), _tickleWidget(nullptr), _visible(false),
|
2023-04-12 22:34:10 +00:00
|
|
|
_backgroundType(GUI::ThemeEngine::kDialogBackgroundDefault), _handlingMouseWheel(false) {
|
2006-12-27 00:47:57 +00:00
|
|
|
|
|
|
|
// It may happen that we have 3x scaler in launcher (960xY) and then 640x480
|
|
|
|
// game will be forced to 1x. At this stage GUI will not be aware of
|
|
|
|
// resolution change, so widgets will be off screen. This forces it to
|
|
|
|
// recompute
|
|
|
|
//
|
2021-02-28 09:28:23 +00:00
|
|
|
// Fixes bug #2892: "HE: When 3x graphics are choosen, F5 crashes game"
|
|
|
|
// and bug #2903: "SCUMM: F5 crashes game (640x480)"
|
2009-01-01 21:41:55 +00:00
|
|
|
g_gui.checkScreenChange();
|
2016-06-01 10:10:33 +00:00
|
|
|
|
2021-06-18 11:27:36 +00:00
|
|
|
_mouseUpdatedOnFocus = true;
|
2016-06-01 10:10:33 +00:00
|
|
|
_result = -1;
|
2004-12-25 23:20:37 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
int Dialog::runModal() {
|
2002-10-16 17:37:30 +00:00
|
|
|
// Open up
|
|
|
|
open();
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-10-16 17:37:30 +00:00
|
|
|
// Start processing events
|
2003-11-02 02:18:16 +00:00
|
|
|
g_gui.runLoop();
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-11-19 01:36:47 +00:00
|
|
|
// Return the result code
|
|
|
|
return _result;
|
2002-10-16 17:37:30 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Dialog::open() {
|
2002-11-19 01:36:47 +00:00
|
|
|
_result = 0;
|
2002-09-08 16:00:13 +00:00
|
|
|
_visible = true;
|
2003-11-02 02:18:16 +00:00
|
|
|
g_gui.openDialog(this);
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2017-06-13 05:18:33 +00:00
|
|
|
setDefaultFocusedWidget();
|
2002-07-26 20:38:55 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Dialog::close() {
|
2002-09-08 16:00:13 +00:00
|
|
|
_visible = false;
|
|
|
|
|
2002-07-26 20:38:55 +00:00
|
|
|
if (_mouseWidget) {
|
|
|
|
_mouseWidget->handleMouseLeft(0);
|
2020-01-05 16:48:04 +00:00
|
|
|
_mouseWidget = nullptr;
|
2002-07-26 20:38:55 +00:00
|
|
|
}
|
2002-11-21 15:20:52 +00:00
|
|
|
releaseFocus();
|
2009-05-18 21:02:52 +00:00
|
|
|
g_gui.closeTopDialog();
|
2002-11-21 15:20:52 +00:00
|
|
|
}
|
|
|
|
|
2006-08-04 13:55:53 +00:00
|
|
|
void Dialog::reflowLayout() {
|
2006-01-27 15:43:23 +00:00
|
|
|
// The screen has changed. That means the screen visual may also have
|
|
|
|
// changed, so any cached image may be invalid. The subsequent redraw
|
|
|
|
// should be treated as the very first draw.
|
|
|
|
|
2019-12-28 09:43:58 +00:00
|
|
|
if (!_name.empty()) {
|
|
|
|
g_gui.xmlEval()->reflowDialogLayout(_name, _firstWidget);
|
|
|
|
}
|
|
|
|
|
2016-06-23 16:54:07 +00:00
|
|
|
GuiObject::reflowLayout();
|
|
|
|
|
2006-01-27 15:43:23 +00:00
|
|
|
Widget *w = _firstWidget;
|
|
|
|
while (w) {
|
2006-08-04 13:55:53 +00:00
|
|
|
w->reflowLayout();
|
2006-01-27 15:43:23 +00:00
|
|
|
w = w->_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-03 16:32:08 +00:00
|
|
|
void Dialog::lostFocus() {
|
2020-01-05 16:48:04 +00:00
|
|
|
_dragWidget = nullptr;
|
2016-04-06 14:22:02 +00:00
|
|
|
|
2012-05-03 16:32:08 +00:00
|
|
|
if (_tickleWidget) {
|
|
|
|
_tickleWidget->lostFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-06 23:22:48 +00:00
|
|
|
void Dialog::setFocusWidget(Widget *widget) {
|
|
|
|
// The focus will change. Tell the old focused widget (if any)
|
|
|
|
// that it lost the focus.
|
|
|
|
releaseFocus();
|
|
|
|
|
|
|
|
// Tell the new focused widget (if any) that it just gained the focus.
|
|
|
|
if (widget)
|
|
|
|
widget->receivedFocus();
|
|
|
|
|
|
|
|
_focusedWidget = widget;
|
|
|
|
}
|
|
|
|
|
2017-06-13 05:18:33 +00:00
|
|
|
void Dialog::setDefaultFocusedWidget() {
|
|
|
|
Widget *w = _firstWidget;
|
|
|
|
// Search for the first objects that wantsFocus() (if any) and give it the focus
|
|
|
|
while (w && !w->wantsFocus()) {
|
|
|
|
w = w->_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
setFocusWidget(w);
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Dialog::releaseFocus() {
|
2002-07-26 20:38:55 +00:00
|
|
|
if (_focusedWidget) {
|
|
|
|
_focusedWidget->lostFocus();
|
2020-01-05 16:48:04 +00:00
|
|
|
_focusedWidget = nullptr;
|
2002-07-26 20:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-06 13:40:02 +00:00
|
|
|
void Dialog::markWidgetsAsDirty() {
|
|
|
|
Widget *w = _firstWidget;
|
|
|
|
while (w) {
|
|
|
|
w->markAsDirty();
|
|
|
|
w = w->_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-07 09:39:22 +00:00
|
|
|
void Dialog::drawDialog(DrawLayer layerToDraw) {
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-09-08 16:00:13 +00:00
|
|
|
if (!isVisible())
|
|
|
|
return;
|
2002-07-07 13:14:34 +00:00
|
|
|
|
2019-08-27 06:07:14 +00:00
|
|
|
g_gui.theme()->disableClipRect();
|
2018-01-07 09:39:22 +00:00
|
|
|
g_gui.theme()->_layerToDraw = layerToDraw;
|
2018-01-27 07:59:53 +00:00
|
|
|
g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _backgroundType);
|
2002-07-07 13:14:34 +00:00
|
|
|
|
2018-01-06 13:40:02 +00:00
|
|
|
markWidgetsAsDirty();
|
2021-11-21 18:39:38 +00:00
|
|
|
|
|
|
|
#ifdef LAYOUT_DEBUG_DIALOG
|
|
|
|
return;
|
|
|
|
#endif
|
2018-01-06 13:40:02 +00:00
|
|
|
drawWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog::drawWidgets() {
|
|
|
|
|
|
|
|
if (!isVisible())
|
|
|
|
return;
|
|
|
|
|
2003-11-02 22:31:20 +00:00
|
|
|
// Draw all children
|
|
|
|
Widget *w = _firstWidget;
|
2002-07-05 16:56:53 +00:00
|
|
|
while (w) {
|
2008-12-22 11:22:15 +00:00
|
|
|
//if (w->_debugVisible)
|
2008-08-07 10:53:33 +00:00
|
|
|
w->draw();
|
2002-07-05 16:56:53 +00:00
|
|
|
w = w->_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
|
2002-07-16 10:52:48 +00:00
|
|
|
Widget *w;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-07-16 10:52:48 +00:00
|
|
|
w = findWidget(x, y);
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2009-01-02 01:31:46 +00:00
|
|
|
if (w && !(w->getFlags() & WIDGET_IGNORE_DRAG))
|
|
|
|
_dragWidget = w;
|
2002-07-13 18:32:09 +00:00
|
|
|
|
2010-06-15 12:33:20 +00:00
|
|
|
// If the click occurred inside a widget which is not the currently
|
2002-09-08 16:00:13 +00:00
|
|
|
// focused one, change the focus to that widget.
|
2004-12-25 23:20:37 +00:00
|
|
|
if (w && w != _focusedWidget && w->wantsFocus()) {
|
2009-06-06 23:22:48 +00:00
|
|
|
setFocusWidget(w);
|
2002-07-13 22:41:29 +00:00
|
|
|
}
|
2002-07-16 10:52:48 +00:00
|
|
|
|
2004-12-25 23:20:37 +00:00
|
|
|
if (w)
|
|
|
|
w->handleMouseDown(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
|
2002-07-13 18:32:09 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
|
2002-07-13 22:41:29 +00:00
|
|
|
Widget *w;
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-07-13 22:41:29 +00:00
|
|
|
if (_focusedWidget) {
|
2004-12-25 23:20:37 +00:00
|
|
|
//w = _focusedWidget;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-07-13 22:41:29 +00:00
|
|
|
// Lose focus on mouseup unless the widget requested to retain the focus
|
2002-07-16 10:52:48 +00:00
|
|
|
if (! (_focusedWidget->getFlags() & WIDGET_RETAIN_FOCUS )) {
|
2002-11-21 15:20:52 +00:00
|
|
|
releaseFocus();
|
2002-07-16 10:52:48 +00:00
|
|
|
}
|
2002-07-13 22:41:29 +00:00
|
|
|
}
|
|
|
|
|
2009-01-02 01:31:46 +00:00
|
|
|
if (_dragWidget)
|
|
|
|
w = _dragWidget;
|
|
|
|
else
|
|
|
|
w = findWidget(x, y);
|
2004-12-28 21:07:34 +00:00
|
|
|
|
|
|
|
if (w)
|
2003-11-02 17:41:01 +00:00
|
|
|
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
|
2004-12-25 23:20:37 +00:00
|
|
|
|
2023-06-11 18:48:52 +00:00
|
|
|
if (_dragWidget) {
|
|
|
|
_dragWidget = nullptr;
|
|
|
|
// Fake a mouse move to refresh now hovered widget
|
|
|
|
handleMouseMoved(x, y, button);
|
|
|
|
}
|
2002-07-05 16:56:53 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Dialog::handleMouseWheel(int x, int y, int direction) {
|
2023-04-12 22:34:10 +00:00
|
|
|
// Guard against recursive call.
|
|
|
|
// This can happen as we call handleMouseWheel() on the widget under the mouse,
|
|
|
|
// and the default implementation of Widget::handleMouseWheel() is to call it
|
|
|
|
// for the widget boss, which can be this dialog.
|
|
|
|
if (_handlingMouseWheel)
|
|
|
|
return;
|
|
|
|
_handlingMouseWheel = true;
|
2002-10-16 20:32:12 +00:00
|
|
|
|
|
|
|
// This may look a bit backwards, but I think it makes more sense for
|
|
|
|
// the mouse wheel to primarily affect the widget the mouse is at than
|
|
|
|
// the widget that happens to be focused.
|
2023-04-12 22:34:10 +00:00
|
|
|
Widget *w = findWidget(x, y);
|
2002-10-16 20:32:12 +00:00
|
|
|
if (!w)
|
|
|
|
w = _focusedWidget;
|
|
|
|
if (w)
|
2015-03-21 16:35:47 +00:00
|
|
|
w->handleMouseWheel(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), direction);
|
2023-04-12 22:34:10 +00:00
|
|
|
|
|
|
|
_handlingMouseWheel = false;
|
2002-10-16 20:32:12 +00:00
|
|
|
}
|
|
|
|
|
2007-06-30 12:26:59 +00:00
|
|
|
void Dialog::handleKeyDown(Common::KeyState state) {
|
2002-07-13 22:41:29 +00:00
|
|
|
if (_focusedWidget) {
|
2007-06-30 12:26:59 +00:00
|
|
|
if (_focusedWidget->handleKeyDown(state))
|
2002-07-27 14:16:14 +00:00
|
|
|
return;
|
2003-07-22 16:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hotkey handling
|
2021-08-17 20:40:42 +00:00
|
|
|
|
|
|
|
// Convert keypad Enter to Return key
|
|
|
|
if (state.keycode == Common::KEYCODE_KP_ENTER) {
|
|
|
|
state.ascii = Common::ASCII_RETURN;
|
|
|
|
}
|
2007-06-30 12:26:59 +00:00
|
|
|
if (state.ascii != 0) {
|
2003-07-23 16:44:15 +00:00
|
|
|
Widget *w = _firstWidget;
|
2007-06-30 12:26:59 +00:00
|
|
|
state.ascii = toupper(state.ascii);
|
2003-07-23 16:44:15 +00:00
|
|
|
while (w) {
|
2007-06-30 12:26:59 +00:00
|
|
|
if (w->_type == kButtonWidget && state.ascii == toupper(((ButtonWidget *)w)->_hotkey)) {
|
2003-07-23 16:44:15 +00:00
|
|
|
// The hotkey for widget w was pressed. We fake a mouse click into the
|
|
|
|
// button by invoking the appropriate methods.
|
|
|
|
w->handleMouseDown(0, 0, 1, 1);
|
|
|
|
w->handleMouseUp(0, 0, 1, 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
w = w->_next;
|
2002-07-08 00:29:47 +00:00
|
|
|
}
|
|
|
|
}
|
2002-07-27 14:16:14 +00:00
|
|
|
|
|
|
|
// ESC closes all dialogs by default
|
2007-06-30 12:26:59 +00:00
|
|
|
if (state.keycode == Common::KEYCODE_ESCAPE) {
|
2003-12-06 13:55:50 +00:00
|
|
|
setResult(-1);
|
2002-07-27 14:16:14 +00:00
|
|
|
close();
|
2003-12-06 13:55:50 +00:00
|
|
|
}
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2014-03-31 05:43:54 +00:00
|
|
|
if (state.keycode == Common::KEYCODE_TAB) {
|
|
|
|
// TODO: Maybe add Tab behaviours for all widgets too.
|
|
|
|
// searches through widgets on screen for tab widget
|
|
|
|
Widget *w = _firstWidget;
|
|
|
|
while (w) {
|
|
|
|
if (w->_type == kTabWidget)
|
|
|
|
if (w->handleKeyDown(state))
|
|
|
|
return;
|
|
|
|
|
|
|
|
w = w->_next;
|
|
|
|
}
|
|
|
|
}
|
2002-07-08 00:29:47 +00:00
|
|
|
}
|
|
|
|
|
2007-06-30 12:26:59 +00:00
|
|
|
void Dialog::handleKeyUp(Common::KeyState state) {
|
2003-11-07 02:31:44 +00:00
|
|
|
// Focused widget receives keyup events
|
2002-07-13 22:41:29 +00:00
|
|
|
if (_focusedWidget)
|
2007-06-30 12:26:59 +00:00
|
|
|
_focusedWidget->handleKeyUp(state);
|
2002-07-13 18:32:09 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Dialog::handleMouseMoved(int x, int y, int button) {
|
2002-07-13 22:41:29 +00:00
|
|
|
Widget *w;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2004-12-28 21:07:34 +00:00
|
|
|
if (_focusedWidget && !_dragWidget) {
|
2002-07-13 22:41:29 +00:00
|
|
|
w = _focusedWidget;
|
2003-11-02 17:41:01 +00:00
|
|
|
int wx = w->getAbsX() - _x;
|
|
|
|
int wy = w->getAbsY() - _y;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-07-13 22:41:29 +00:00
|
|
|
// We still send mouseEntered/Left messages to the focused item
|
|
|
|
// (but to no other items).
|
2003-11-02 17:41:01 +00:00
|
|
|
bool mouseInFocusedWidget = (x >= wx && x < wx + w->_w && y >= wy && y < wy + w->_h);
|
2002-07-13 22:41:29 +00:00
|
|
|
if (mouseInFocusedWidget && _mouseWidget != w) {
|
2004-12-25 23:20:37 +00:00
|
|
|
if (_mouseWidget)
|
|
|
|
_mouseWidget->handleMouseLeft(button);
|
2002-07-13 22:41:29 +00:00
|
|
|
_mouseWidget = w;
|
|
|
|
w->handleMouseEntered(button);
|
|
|
|
} else if (!mouseInFocusedWidget && _mouseWidget == w) {
|
2020-01-05 16:48:04 +00:00
|
|
|
_mouseWidget = nullptr;
|
2002-07-13 22:41:29 +00:00
|
|
|
w->handleMouseLeft(button);
|
|
|
|
}
|
|
|
|
|
2009-01-02 02:48:06 +00:00
|
|
|
if (w->getFlags() & WIDGET_TRACK_MOUSE)
|
|
|
|
w->handleMouseMoved(x - wx, y - wy, button);
|
2002-08-04 01:18:06 +00:00
|
|
|
}
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2009-01-02 02:48:06 +00:00
|
|
|
// We process mouseEntered/Left events if we don't have any
|
|
|
|
// currently active dragged widget or if the currently dragged widget
|
|
|
|
// does not want to be informed about the mouse mouse events.
|
|
|
|
if (!_dragWidget || !(_dragWidget->getFlags() & WIDGET_TRACK_MOUSE))
|
2004-12-28 21:07:34 +00:00
|
|
|
w = findWidget(x, y);
|
2009-01-02 02:48:06 +00:00
|
|
|
else
|
|
|
|
w = _dragWidget;
|
2002-08-04 01:18:06 +00:00
|
|
|
|
|
|
|
if (_mouseWidget != w) {
|
|
|
|
if (_mouseWidget)
|
|
|
|
_mouseWidget->handleMouseLeft(button);
|
2009-01-02 02:48:06 +00:00
|
|
|
|
|
|
|
// If we have a widget in drag mode we prevent mouseEntered
|
|
|
|
// events from being sent to other widgets.
|
|
|
|
if (_dragWidget && w != _dragWidget)
|
2020-01-05 16:48:04 +00:00
|
|
|
w = nullptr;
|
2009-01-02 02:48:06 +00:00
|
|
|
|
2002-08-04 01:18:06 +00:00
|
|
|
if (w)
|
|
|
|
w->handleMouseEntered(button);
|
|
|
|
_mouseWidget = w;
|
2005-01-06 19:09:34 +00:00
|
|
|
}
|
2002-08-04 01:18:06 +00:00
|
|
|
|
2009-01-02 03:03:06 +00:00
|
|
|
// We only sent mouse move events when the widget requests to be informed about them.
|
2009-01-02 02:48:06 +00:00
|
|
|
if (w && (w->getFlags() & WIDGET_TRACK_MOUSE))
|
2004-12-25 23:20:37 +00:00
|
|
|
w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
|
2002-07-06 12:57:51 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Dialog::handleTickle() {
|
2003-11-07 02:31:44 +00:00
|
|
|
// Focused widget receives tickle notifications
|
2007-11-04 03:38:30 +00:00
|
|
|
if (_focusedWidget && _focusedWidget->getFlags() & WIDGET_WANT_TICKLE)
|
2002-07-13 22:41:29 +00:00
|
|
|
_focusedWidget->handleTickle();
|
2012-05-03 16:32:08 +00:00
|
|
|
|
|
|
|
if (_tickleWidget && _tickleWidget->getFlags() & WIDGET_WANT_TICKLE)
|
|
|
|
_tickleWidget->handleTickle();
|
2002-07-13 22:41:29 +00:00
|
|
|
}
|
2002-07-06 12:57:51 +00:00
|
|
|
|
2023-10-11 18:33:03 +00:00
|
|
|
void Dialog::handleOtherEvent(const Common::Event &evt) {
|
|
|
|
if (_focusedWidget)
|
|
|
|
_focusedWidget->handleOtherEvent(evt);
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Dialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
2002-07-07 22:44:30 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case kCloseCmd:
|
|
|
|
close();
|
|
|
|
break;
|
2020-03-22 14:19:56 +00:00
|
|
|
case kCloseWithResultCmd:
|
|
|
|
setResult(data);
|
|
|
|
close();
|
|
|
|
break;
|
2019-10-03 05:03:46 +00:00
|
|
|
default:
|
|
|
|
break;
|
2002-07-07 22:44:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
/*
|
|
|
|
* Determine the widget at location (x,y) if any. Assumes the coordinates are
|
|
|
|
* in the local coordinate system, i.e. relative to the top left of the dialog.
|
|
|
|
*/
|
2003-03-06 19:52:54 +00:00
|
|
|
Widget *Dialog::findWidget(int x, int y) {
|
2003-11-02 18:57:20 +00:00
|
|
|
return Widget::findWidgetInChain(_firstWidget, x, y);
|
2002-07-05 16:56:53 +00:00
|
|
|
}
|
|
|
|
|
2006-04-19 01:05:28 +00:00
|
|
|
Widget *Dialog::findWidget(const char *name) {
|
|
|
|
return Widget::findWidgetInChain(_firstWidget, name);
|
|
|
|
}
|
|
|
|
|
2007-03-16 20:47:41 +00:00
|
|
|
void Dialog::removeWidget(Widget *del) {
|
2017-04-06 20:52:55 +00:00
|
|
|
if (del == _mouseWidget || del->containsWidget(_mouseWidget))
|
2020-01-05 16:48:04 +00:00
|
|
|
_mouseWidget = nullptr;
|
2017-04-06 20:52:55 +00:00
|
|
|
if (del == _focusedWidget || del->containsWidget(_focusedWidget))
|
2020-01-05 16:48:04 +00:00
|
|
|
_focusedWidget = nullptr;
|
2017-04-06 20:52:55 +00:00
|
|
|
if (del == _dragWidget || del->containsWidget(_dragWidget))
|
2020-01-05 16:48:04 +00:00
|
|
|
_dragWidget = nullptr;
|
2006-06-02 15:20:48 +00:00
|
|
|
|
2012-02-24 21:20:50 +00:00
|
|
|
GuiObject::removeWidget(del);
|
2006-04-19 01:05:28 +00:00
|
|
|
}
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
} // End of namespace GUI
|