aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorEugene Sandulenko2018-07-08 23:17:19 +0200
committerEugene Sandulenko2018-07-11 22:45:36 +0200
commitddfe6c3bce672086d28363c1c90ee4be279f5539 (patch)
tree101ed4d7c916293ede5353800945a2f1dd29804e /graphics
parent468d9d09f0d013d8f897acd2ee3df258e84688e3 (diff)
downloadscummvm-rg350-ddfe6c3bce672086d28363c1c90ee4be279f5539.tar.gz
scummvm-rg350-ddfe6c3bce672086d28363c1c90ee4be279f5539.tar.bz2
scummvm-rg350-ddfe6c3bce672086d28363c1c90ee4be279f5539.zip
GRAPHICS: MACGUI: Implemented autohide menus
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/macmenu.cpp12
-rw-r--r--graphics/macgui/macmenu.h4
-rw-r--r--graphics/macgui/macwindowmanager.cpp59
-rw-r--r--graphics/macgui/macwindowmanager.h11
4 files changed, 73 insertions, 13 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index cecdcabcea..0d25ea7a41 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -90,6 +90,12 @@ MacMenu::MacMenu(int id, const Common::Rect &bounds, MacWindowManager *wm)
_bbox.bottom = kMenuHeight;
_menuActivated = false;
+
+ if (_wm->_mode & kWMModeAutohideMenu)
+ _isVisible = false;
+ else
+ _isVisible = true;
+
_activeItem = -1;
_activeSubItem = -1;
@@ -344,6 +350,9 @@ static void drawFilledRoundRect(ManagedSurface *surface, Common::Rect &rect, int
bool MacMenu::draw(ManagedSurface *g, bool forceRedraw) {
Common::Rect r(_bbox);
+ if (!_isVisible)
+ return false;
+
if (!_contentIsDirty && !forceRedraw)
return false;
@@ -466,6 +475,9 @@ void MacMenu::renderSubmenu(MacMenuItem *menu) {
}
bool MacMenu::processEvent(Common::Event &event) {
+ if (!_isVisible)
+ return false;
+
switch (event.type) {
case Common::EVENT_KEYDOWN:
return keyEvent(event);
diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h
index 8b3e8ff258..08c8f41c23 100644
--- a/graphics/macgui/macmenu.h
+++ b/graphics/macgui/macmenu.h
@@ -65,6 +65,9 @@ public:
void setActive(bool active) { _menuActivated = active; }
bool hasAllFocus() { return _menuActivated; }
+ bool isVisible() { return _isVisible; }
+ void setVisible(bool visible) { _isVisible = visible; }
+
Common::Rect _bbox;
private:
@@ -90,6 +93,7 @@ private:
const Font *_font;
bool _menuActivated;
+ bool _isVisible;
int _activeItem;
int _activeSubItem;
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 6ee92e081e..a7ebf7569f 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -23,6 +23,7 @@
#include "common/events.h"
#include "common/list.h"
#include "common/system.h"
+#include "common/timer.h"
#include "graphics/cursorman.h"
#include "graphics/managed_surface.h"
@@ -144,6 +145,8 @@ static const byte macCursorCrossBar[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
+static void menuTimerHandler(void *refCon);
+
MacWindowManager::MacWindowManager() {
_screen = 0;
_lastId = 0;
@@ -153,6 +156,7 @@ MacWindowManager::MacWindowManager() {
_menu = 0;
_menuDelay = 0;
+ _menuTimerActive = false;
_fullRefresh = true;
@@ -174,6 +178,8 @@ MacWindowManager::~MacWindowManager() {
delete _windows[i];
delete _fontMan;
+
+ g_system->getTimerManager()->removeTimerProc(&menuTimerHandler);
}
MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable, bool editable) {
@@ -210,6 +216,13 @@ MacMenu *MacWindowManager::addMenu() {
return _menu;
}
+void MacWindowManager::activateMenu() {
+ if (!_menu)
+ return;
+
+ _menu->setVisible(true);
+}
+
void MacWindowManager::setActive(int id) {
if (_activeWindow == id)
return;
@@ -306,21 +319,47 @@ void MacWindowManager::draw() {
_fullRefresh = false;
}
+static void menuTimerHandler(void *refCon) {
+ MacWindowManager *wm = (MacWindowManager *)refCon;
+
+ if (wm->_menuHotzone.contains(wm->_lastMousePos))
+ wm->activateMenu();
+
+ wm->_menuTimerActive = false;
+
+ g_system->getTimerManager()->removeTimerProc(&menuTimerHandler);
+}
+
bool MacWindowManager::processEvent(Common::Event &event) {
+ if (event.type == Common::EVENT_MOUSEMOVE)
+ _lastMousePos = event.mouse;
+
+ if (_menu && !_menu->isVisible()) {
+ if ((_mode & kWMModeAutohideMenu) && event.type == Common::EVENT_MOUSEMOVE) {
+ if (!_menuTimerActive && _menuHotzone.contains(event.mouse)) {
+ _menuTimerActive = true;
+
+ g_system->getTimerManager()->installTimerProc(&menuTimerHandler, _menuDelay, this, "menuWindowCursor");
+ }
+ }
+ }
+
// Menu gets events first for shortcuts and menu bar
if (_menu && _menu->processEvent(event))
return true;
- if (_windows[_activeWindow]->isEditable() && _windows[_activeWindow]->getType() == kWindowWindow &&
- ((MacWindow *)_windows[_activeWindow])->getInnerDimensions().contains(event.mouse.x, event.mouse.y)) {
- if (_cursorIsArrow) {
- CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
- _cursorIsArrow = false;
- }
- } else {
- if (_cursorIsArrow == false) {
- CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
- _cursorIsArrow = true;
+ if (_activeWindow != -1) {
+ if (_windows[_activeWindow]->isEditable() && _windows[_activeWindow]->getType() == kWindowWindow &&
+ ((MacWindow *)_windows[_activeWindow])->getInnerDimensions().contains(event.mouse.x, event.mouse.y)) {
+ if (_cursorIsArrow) {
+ CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
+ _cursorIsArrow = false;
+ }
+ } else {
+ if (_cursorIsArrow == false) {
+ CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+ _cursorIsArrow = true;
+ }
}
}
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index d2f89361bb..7db0d019e8 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -140,6 +140,8 @@ public:
*/
MacMenu *addMenu();
+ void activateMenu();
+
/**
* Set hot zone where menu appears (works only with autohide menu)
*/
@@ -208,6 +210,12 @@ public:
public:
MacFontManager *_fontMan;
+ uint32 _mode;
+
+ Common::Point _lastMousePos;
+ Common::Rect _menuHotzone;
+
+ bool _menuTimerActive;
private:
void drawDesktop();
@@ -219,8 +227,6 @@ private:
private:
ManagedSurface *_screen;
- uint32 _mode;
-
Common::List<BaseMacWindow *> _windowStack;
Common::Array<BaseMacWindow *> _windows;
@@ -235,7 +241,6 @@ private:
MacPatterns _patterns;
MacMenu *_menu;
- Common::Rect _menuHotzone;
uint32 _menuDelay;
bool _cursorIsArrow;