diff options
| author | Eugene Sandulenko | 2018-07-08 23:17:19 +0200 | 
|---|---|---|
| committer | Eugene Sandulenko | 2018-07-11 22:45:36 +0200 | 
| commit | ddfe6c3bce672086d28363c1c90ee4be279f5539 (patch) | |
| tree | 101ed4d7c916293ede5353800945a2f1dd29804e /graphics/macgui/macwindowmanager.cpp | |
| parent | 468d9d09f0d013d8f897acd2ee3df258e84688e3 (diff) | |
| download | scummvm-rg350-ddfe6c3bce672086d28363c1c90ee4be279f5539.tar.gz scummvm-rg350-ddfe6c3bce672086d28363c1c90ee4be279f5539.tar.bz2 scummvm-rg350-ddfe6c3bce672086d28363c1c90ee4be279f5539.zip  | |
GRAPHICS: MACGUI: Implemented autohide menus
Diffstat (limited to 'graphics/macgui/macwindowmanager.cpp')
| -rw-r--r-- | graphics/macgui/macwindowmanager.cpp | 59 | 
1 files changed, 49 insertions, 10 deletions
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; +			}  		}  	}  | 
