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
|
|
|
*/
|
|
|
|
|
2009-01-18 14:48:24 +00:00
|
|
|
#ifndef GUIMANAGER_H
|
|
|
|
#define GUIMANAGER_H
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2003-08-01 12:21:04 +00:00
|
|
|
#include "common/scummsys.h"
|
2003-11-02 02:18:16 +00:00
|
|
|
#include "common/singleton.h"
|
2004-03-29 22:29:30 +00:00
|
|
|
#include "common/stack.h"
|
2002-09-26 11:44:02 +00:00
|
|
|
#include "common/str.h"
|
2017-03-10 02:02:58 +00:00
|
|
|
#include "common/list.h"
|
2022-06-28 00:09:47 +00:00
|
|
|
#include "common/mutex.h"
|
2009-01-02 20:03:45 +00:00
|
|
|
|
2008-09-02 17:51:08 +00:00
|
|
|
#include "gui/ThemeEngine.h"
|
2021-06-18 11:27:36 +00:00
|
|
|
#include "gui/widget.h"
|
2008-08-15 11:05:25 +00:00
|
|
|
|
2005-01-10 22:06:49 +00:00
|
|
|
class OSystem;
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
namespace Graphics {
|
|
|
|
class Font;
|
2023-09-27 09:56:06 +00:00
|
|
|
class MacWindowManager;
|
2011-04-24 08:34:27 +00:00
|
|
|
}
|
|
|
|
|
2013-05-16 21:18:09 +00:00
|
|
|
namespace Common {
|
|
|
|
struct Event;
|
2020-01-23 09:50:52 +00:00
|
|
|
class Keymap;
|
2013-05-16 21:18:09 +00:00
|
|
|
}
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2023-10-11 18:33:03 +00:00
|
|
|
enum {
|
|
|
|
kActionEnd,
|
2023-10-28 19:01:01 +00:00
|
|
|
kActionShiftEnd,
|
2023-10-11 18:33:03 +00:00
|
|
|
kActionHome,
|
2023-10-28 19:01:01 +00:00
|
|
|
kActionShiftHome,
|
2023-10-11 18:33:03 +00:00
|
|
|
kActionCopy,
|
|
|
|
kActionCut,
|
|
|
|
kActionPaste,
|
|
|
|
};
|
|
|
|
|
2022-06-28 00:17:06 +00:00
|
|
|
enum {
|
|
|
|
kIconsSetLoadedCmd = 'icns'
|
|
|
|
};
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
class Dialog;
|
2008-08-05 09:54:36 +00:00
|
|
|
class ThemeEval;
|
2017-03-10 02:02:58 +00:00
|
|
|
class GuiObject;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2008-12-25 23:55:36 +00:00
|
|
|
#define g_gui (GUI::GuiManager::instance())
|
2003-11-02 02:18:16 +00:00
|
|
|
|
|
|
|
|
2004-03-13 13:03:25 +00:00
|
|
|
// Height of a single text line
|
2005-01-06 22:48:42 +00:00
|
|
|
#define kLineHeight (g_gui.getFontHeight() + 2)
|
2004-03-13 13:03:25 +00:00
|
|
|
|
2002-07-27 00:36:09 +00:00
|
|
|
|
2004-03-21 21:20:25 +00:00
|
|
|
|
2004-03-29 22:29:30 +00:00
|
|
|
// Simple dialog stack class
|
|
|
|
// Anybody nesting dialogs deeper than 4 is mad anyway
|
2004-05-05 01:19:42 +00:00
|
|
|
typedef Common::FixedStack<Dialog *> DialogStack;
|
2004-03-29 22:29:30 +00:00
|
|
|
|
2002-07-07 21:46:53 +00:00
|
|
|
|
2003-11-19 23:46:39 +00:00
|
|
|
/**
|
|
|
|
* GUI manager singleton.
|
2005-01-06 19:09:34 +00:00
|
|
|
*/
|
2022-06-28 00:17:06 +00:00
|
|
|
class GuiManager : public Common::Singleton<GuiManager>, public CommandSender {
|
2003-11-02 02:18:16 +00:00
|
|
|
friend class Dialog;
|
2005-01-06 18:38:34 +00:00
|
|
|
friend class Common::Singleton<SingletonBaseType>;
|
2008-12-25 23:55:36 +00:00
|
|
|
GuiManager();
|
2020-01-05 16:48:04 +00:00
|
|
|
~GuiManager() override;
|
2002-07-05 16:56:53 +00:00
|
|
|
public:
|
|
|
|
|
2002-09-22 04:03:45 +00:00
|
|
|
// Main entry for the GUI: this will start an event loop that keeps running
|
|
|
|
// until no dialogs are active anymore.
|
|
|
|
void runLoop();
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2020-09-06 05:01:06 +00:00
|
|
|
// If the GUI loop is running close all the dialogs causing the loop to finish.
|
|
|
|
// Typically you may want to use it after setting the ConfMan active domain to
|
|
|
|
// a game domain to cause the game to start.
|
|
|
|
void exitLoop();
|
|
|
|
|
2013-05-16 21:18:09 +00:00
|
|
|
void processEvent(const Common::Event &event, Dialog *const activeDialog);
|
2020-01-23 09:50:52 +00:00
|
|
|
Common::Keymap *getKeymap() const;
|
2018-01-06 15:13:29 +00:00
|
|
|
void scheduleTopDialogRedraw();
|
2023-05-11 21:53:17 +00:00
|
|
|
void scheduleFullRedraw();
|
2013-05-16 21:18:09 +00:00
|
|
|
|
2005-01-06 22:48:42 +00:00
|
|
|
bool isActive() const { return ! _dialogStack.empty(); }
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2010-06-15 10:44:51 +00:00
|
|
|
bool loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx = ThemeEngine::kGfxDisabled, bool force = false);
|
2008-11-09 12:38:30 +00:00
|
|
|
ThemeEngine *theme() { return _theme; }
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-10-12 22:25:35 +00:00
|
|
|
ThemeEval *xmlEval() { return _theme->getEvaluator(); }
|
2006-01-27 15:43:23 +00:00
|
|
|
|
2022-06-29 18:27:27 +00:00
|
|
|
void lockIconsSet() { _iconsMutex.lock(); }
|
|
|
|
void unlockIconsSet() { _iconsMutex.unlock(); }
|
|
|
|
Common::SearchSet &getIconsSet() { return _iconsSet; }
|
2021-11-12 13:14:03 +00:00
|
|
|
|
2021-03-31 21:50:40 +00:00
|
|
|
int16 getGUIWidth() const { return _baseWidth; }
|
|
|
|
int16 getGUIHeight() const { return _baseHeight; }
|
2020-10-26 22:11:25 +00:00
|
|
|
float getScaleFactor() const { return _scaleFactor; }
|
2021-04-17 17:35:08 +00:00
|
|
|
void computeScaleFactor();
|
2020-10-26 17:27:06 +00:00
|
|
|
|
2023-10-03 22:41:14 +00:00
|
|
|
bool useLowResGUI() const { return _baseWidth <= 320; }
|
|
|
|
|
2020-05-07 21:21:22 +00:00
|
|
|
bool useRTL() const { return _useRTL; }
|
2020-05-30 11:46:23 +00:00
|
|
|
void setLanguageRTL();
|
|
|
|
|
2020-05-14 00:12:19 +00:00
|
|
|
void setDialogPaddings(int l, int r);
|
|
|
|
int getOverlayOffset() { return _topDialogRightPadding - _topDialogLeftPadding; }
|
2020-05-07 21:21:22 +00:00
|
|
|
|
2008-11-10 11:24:55 +00:00
|
|
|
const Graphics::Font &getFont(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return *(_theme->getFont(style)); }
|
|
|
|
int getFontHeight(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getFontHeight(style); }
|
|
|
|
int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
|
2020-06-10 20:41:20 +00:00
|
|
|
int getStringWidth(const Common::U32String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
|
2022-07-28 22:46:16 +00:00
|
|
|
int getCharWidth(uint32 c, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getCharWidth(c, style); }
|
|
|
|
int getKerningOffset(uint32 left, uint32 right, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold) const { return _theme->getKerningOffset(left, right, font); }
|
2006-01-27 15:43:23 +00:00
|
|
|
|
2009-01-01 21:41:55 +00:00
|
|
|
/**
|
|
|
|
* Tell the GuiManager to check whether the screen resolution has changed.
|
|
|
|
* If that is the case, the GuiManager will reload/refresh the active theme.
|
|
|
|
*
|
|
|
|
* @return true if the a screen change indeed occurred, false otherwise
|
|
|
|
*/
|
|
|
|
bool checkScreenChange();
|
2010-06-15 10:52:35 +00:00
|
|
|
|
2017-03-10 02:02:58 +00:00
|
|
|
/**
|
|
|
|
* Tell the GuiManager to delete the given GuiObject later. If a parent
|
|
|
|
* dialog is provided and is present in the DialogStack, the object will
|
|
|
|
* only be deleted when that dialog is the top level dialog.
|
|
|
|
*/
|
2020-01-05 16:48:04 +00:00
|
|
|
void addToTrash(GuiObject*, Dialog* parent = nullptr);
|
2019-07-23 14:40:08 +00:00
|
|
|
void initTextToSpeech();
|
2017-03-10 02:02:58 +00:00
|
|
|
|
2015-11-11 20:36:27 +00:00
|
|
|
bool _launched;
|
|
|
|
|
2019-10-06 22:11:48 +00:00
|
|
|
void redrawFull();
|
|
|
|
|
2021-11-19 23:46:47 +00:00
|
|
|
void initIconsSet();
|
|
|
|
|
2022-10-01 14:57:03 +00:00
|
|
|
void displayTopDialogOnly(bool mode);
|
|
|
|
|
2023-09-27 09:56:06 +00:00
|
|
|
Graphics::MacWindowManager *getWM();
|
|
|
|
|
2009-01-01 21:41:55 +00:00
|
|
|
protected:
|
2008-07-17 21:58:43 +00:00
|
|
|
enum RedrawStatus {
|
|
|
|
kRedrawDisabled = 0,
|
2009-02-06 23:28:08 +00:00
|
|
|
kRedrawOpenDialog,
|
|
|
|
kRedrawCloseDialog,
|
|
|
|
kRedrawTopDialog,
|
2008-07-17 21:58:43 +00:00
|
|
|
kRedrawFull
|
|
|
|
};
|
|
|
|
|
2005-01-06 19:09:34 +00:00
|
|
|
OSystem *_system;
|
2006-01-27 15:43:23 +00:00
|
|
|
|
2008-11-09 12:38:30 +00:00
|
|
|
ThemeEngine *_theme;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2008-07-17 21:58:43 +00:00
|
|
|
// bool _needRedraw;
|
|
|
|
RedrawStatus _redrawStatus;
|
2006-08-04 18:01:43 +00:00
|
|
|
int _lastScreenChangeID;
|
2020-10-26 17:27:06 +00:00
|
|
|
int16 _baseWidth, _baseHeight;
|
2020-10-26 22:11:25 +00:00
|
|
|
float _scaleFactor;
|
2002-07-07 21:46:53 +00:00
|
|
|
DialogStack _dialogStack;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-10-16 17:37:30 +00:00
|
|
|
bool _stateIsSaved;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-10-08 20:37:39 +00:00
|
|
|
bool _useStdCursor;
|
|
|
|
|
2020-05-07 21:21:22 +00:00
|
|
|
bool _useRTL;
|
2020-05-11 22:07:40 +00:00
|
|
|
|
2020-05-14 00:12:19 +00:00
|
|
|
int _topDialogLeftPadding;
|
|
|
|
int _topDialogRightPadding;
|
2020-05-07 21:21:22 +00:00
|
|
|
|
2022-10-01 14:57:03 +00:00
|
|
|
bool _displayTopDialogOnly;
|
|
|
|
|
2022-06-28 00:09:47 +00:00
|
|
|
Common::Mutex _iconsMutex;
|
2021-11-12 13:14:03 +00:00
|
|
|
Common::SearchSet _iconsSet;
|
2022-06-28 00:17:06 +00:00
|
|
|
bool _iconsSetChanged;
|
2021-11-12 13:14:03 +00:00
|
|
|
|
2023-09-27 09:56:06 +00:00
|
|
|
Graphics::MacWindowManager *_wm = nullptr;
|
|
|
|
|
2002-07-27 14:16:14 +00:00
|
|
|
// position and time of last mouse click (used to detect double clicks)
|
2016-04-06 14:22:02 +00:00
|
|
|
struct MousePos {
|
|
|
|
MousePos() : x(-1), y(-1), count(0) { time = 0; }
|
2010-06-15 12:33:20 +00:00
|
|
|
int16 x, y; // Position of mouse when the click occurred
|
2002-07-27 14:16:14 +00:00
|
|
|
uint32 time; // Time
|
|
|
|
int count; // How often was it already pressed?
|
2016-04-06 14:22:02 +00:00
|
|
|
} _lastClick, _lastMousePosition, _globalMousePosition;
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2021-06-18 11:27:36 +00:00
|
|
|
struct TooltipData {
|
|
|
|
TooltipData() : x(-1), y(-1) { time = 0; wdg = nullptr; }
|
|
|
|
uint32 time; // Time
|
|
|
|
Widget *wdg; // Widget that had its tooltip shown
|
|
|
|
int16 x, y; // Position of mouse before tooltip was focused
|
|
|
|
} _lastTooltipShown;
|
|
|
|
|
2002-09-19 23:06:54 +00:00
|
|
|
// mouse cursor state
|
2023-08-07 14:53:39 +00:00
|
|
|
uint32 _cursorAnimateCounter;
|
|
|
|
uint32 _cursorAnimateTimer;
|
2009-07-05 14:11:54 +00:00
|
|
|
byte _cursor[2048];
|
2006-10-08 18:22:28 +00:00
|
|
|
|
2017-03-10 02:02:58 +00:00
|
|
|
// delayed deletion of GuiObject
|
|
|
|
struct GuiObjectTrashItem {
|
|
|
|
GuiObject* object;
|
|
|
|
Dialog* parent;
|
|
|
|
};
|
|
|
|
Common::List<GuiObjectTrashItem> _guiObjectTrash;
|
|
|
|
|
2009-05-10 22:05:04 +00:00
|
|
|
void initKeymap();
|
2017-08-13 15:04:45 +00:00
|
|
|
void enableKeymap(bool enabled);
|
2009-05-10 22:05:04 +00:00
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
void saveState();
|
|
|
|
void restoreState();
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2002-07-07 21:46:53 +00:00
|
|
|
void openDialog(Dialog *dialog);
|
2023-05-01 01:33:35 +00:00
|
|
|
void closeTopDialog();
|
2005-01-06 19:09:34 +00:00
|
|
|
|
2006-06-03 10:48:37 +00:00
|
|
|
void redraw();
|
2023-05-08 08:09:52 +00:00
|
|
|
void redrawInternalTopDialogOnly();
|
|
|
|
void redrawInternal();
|
2006-06-03 10:48:37 +00:00
|
|
|
|
2006-10-08 18:22:28 +00:00
|
|
|
void setupCursor();
|
2002-09-19 23:06:54 +00:00
|
|
|
void animateCursor();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-12-27 22:51:14 +00:00
|
|
|
Dialog *getTopDialog() const;
|
2009-01-01 21:41:55 +00:00
|
|
|
|
|
|
|
void screenChange();
|
2016-04-06 14:22:02 +00:00
|
|
|
|
|
|
|
void giveFocusToDialog(Dialog *dialog);
|
|
|
|
void setLastMousePos(int16 x, int16 y);
|
2002-07-05 16:56:53 +00:00
|
|
|
};
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
} // End of namespace GUI
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
#endif
|