GRAPHICS: MACGUI: add intersection check with macmenu and macwindow

This commit is contained in:
ysj1173886760 2021-05-18 22:14:04 +08:00 committed by Eugene Sandulenko
parent 1b211371cf
commit 60d9b79c0f
3 changed files with 24 additions and 1 deletions

View file

@ -1038,6 +1038,15 @@ bool MacMenu::keyEvent(Common::Event &event) {
return false;
}
bool MacMenu::checkIntersects(Common::Rect &rect) {
if (_bbox.intersects(rect))
return true;
for (uint i = 0; i < _menustack.size(); i++)
if (_menustack[i]->bbox.intersects(rect))
return true;
return false;
}
bool MacMenu::mouseClick(int x, int y) {
if (_bbox.contains(x, y)) {
for (uint i = 0; i < _items.size(); i++) {

View file

@ -95,6 +95,8 @@ public:
void closeMenu();
bool checkIntersects(Common::Rect &rect);
Common::Rect _bbox;
private:

View file

@ -657,7 +657,19 @@ void MacWindowManager::draw() {
// Menu is drawn on top of everything and always
if (_menu && !(_mode & kWMModeFullscreen)) {
_menu->draw(_screen, _fullRefresh);
if (_fullRefresh)
_menu->draw(_screen, _fullRefresh);
else {
// add intersection check with menu
bool menuRedraw = false;
for (Common::Array<Common::Rect>::iterator dirty = dirtyRects.begin(); dirty != dirtyRects.end(); dirty++) {
if (_menu->checkIntersects(*dirty)) {
menuRedraw = true;
break;
}
}
_menu->draw(_screen, menuRedraw);
}
}
_fullRefresh = false;