mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
GRAPHICS: MACGUI: Implement lockable widgets
Lockable widgets are those which takes in all input and if set then no other widget can take any input its same as them being inactive, no buttons, animations etc will work. This is implemented to support `modal` property of window, which requires a window to take all input and prevent all others from having any actions.
This commit is contained in:
parent
dd72dd09ca
commit
797803d515
@ -164,6 +164,8 @@ MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns, Common::L
|
||||
_needsRemoval = false;
|
||||
|
||||
_activeWidget = nullptr;
|
||||
_lockedWidget = nullptr;
|
||||
|
||||
_mouseDown = false;
|
||||
_hoveredWidget = nullptr;
|
||||
|
||||
@ -337,6 +339,13 @@ void MacWindowManager::setActiveWidget(MacWidget *widget) {
|
||||
_activeWidget->setActive(true);
|
||||
}
|
||||
|
||||
void MacWindowManager::setLockedWidget(MacWidget *widget) {
|
||||
if (_lockedWidget == widget)
|
||||
return;
|
||||
|
||||
_lockedWidget = widget;
|
||||
}
|
||||
|
||||
void MacWindowManager::clearWidgetRefs(MacWidget *widget) {
|
||||
if (widget == _hoveredWidget)
|
||||
_hoveredWidget = nullptr;
|
||||
@ -1024,7 +1033,8 @@ bool MacWindowManager::processEvent(Common::Event &event) {
|
||||
for (Common::List<BaseMacWindow *>::const_iterator it = _windowStack.end(); it != _windowStack.begin();) {
|
||||
it--;
|
||||
BaseMacWindow *w = *it;
|
||||
|
||||
if (_lockedWidget != nullptr && w != _lockedWidget)
|
||||
continue;
|
||||
if (w->hasAllFocus() || (w->isEditable() && event.type == Common::EVENT_KEYDOWN) ||
|
||||
w->getDimensions().contains(event.mouse.x, event.mouse.y)) {
|
||||
if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP)
|
||||
|
@ -292,9 +292,18 @@ public:
|
||||
*/
|
||||
void setActiveWidget(MacWidget *widget);
|
||||
|
||||
/**
|
||||
* Similar to setActiveWidget but in this case no action including animation
|
||||
* hover, etc can work until a window is locked.
|
||||
* Anything outside this window will not respond to user.
|
||||
* @param widget Pointer to the widget to lock, nullptr for no widget
|
||||
*/
|
||||
void setLockedWidget(MacWidget *widget);
|
||||
|
||||
MacPatterns &getBuiltinPatterns() { return _builtinPatterns; }
|
||||
|
||||
MacWidget *getActiveWidget() { return _activeWidget; }
|
||||
MacWidget *getLockedWidget() { return _lockedWidget; }
|
||||
|
||||
Common::Rect getScreenBounds() { return _screen ? _screen->getBounds() : _screenDims; }
|
||||
|
||||
@ -446,6 +455,7 @@ private:
|
||||
Cursor *_cursor;
|
||||
|
||||
MacWidget *_activeWidget;
|
||||
MacWidget *_lockedWidget;
|
||||
|
||||
PauseToken *_screenCopyPauseToken;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user