aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure/gui.cpp
diff options
context:
space:
mode:
authorBorja Lorente2016-07-10 18:56:05 +0200
committerBorja Lorente2016-08-14 18:50:20 +0200
commitb6acfe868ce4b614bfdc9d510e10e35923a7fed6 (patch)
tree5c3bea270cc248d6086a16b85e45a2f98ba6787b /engines/macventure/gui.cpp
parentfdd949bb00d5d3b5bda54ef85f8fde3682dc2c27 (diff)
downloadscummvm-rg350-b6acfe868ce4b614bfdc9d510e10e35923a7fed6.tar.gz
scummvm-rg350-b6acfe868ce4b614bfdc9d510e10e35923a7fed6.tar.bz2
scummvm-rg350-b6acfe868ce4b614bfdc9d510e10e35923a7fed6.zip
MACVENTURE: Fix click-through and refactor
Diffstat (limited to 'engines/macventure/gui.cpp')
-rw-r--r--engines/macventure/gui.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 5a26482e9d..880ec286d0 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -906,13 +906,20 @@ WindowReference Gui::findObjWindow(ObjID objID) {
return kNoWindow;
}
-void Gui::checkSelect(ObjID obj, const Common::Event &event, const Common::Rect & clickRect, WindowReference ref) {
- if (_engine->isObjVisible(obj) &&
- _engine->isObjClickable(obj) &&
- isRectInsideObject(clickRect, obj))
- {
- selectDraggable(obj, ref, event.mouse);
+bool Gui::canBeSelected(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) {
+ return (_engine->isObjVisible(obj) &&
+ _engine->isObjClickable(obj) &&
+ isRectInsideObject(clickRect, obj));
+}
+
+void Gui::checkSelect(const WindowData &data, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) {
+ ObjID child;
+ for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
+ if (canBeSelected((*it).obj, event, clickRect, ref)) {
+ child = (*it).obj;
+ }
}
+ if (child != 0) selectDraggable(child, ref, event.mouse);
}
bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) {
@@ -1182,14 +1189,11 @@ bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & e
if (click == kBorderInner && event.type == Common::EVENT_LBUTTONDOWN) {
WindowData &data = findWindowData(kMainGameWindow);
- ObjID child;
+ ObjID child = 0;
Common::Point pos;
// Click rect to local coordinates. We assume the click is inside the window ^
Common::Rect clickRect = calculateClickRect(event.mouse, _mainGameWindow->getDimensions());
- for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
- child = (*it).obj;
- checkSelect(child, event, clickRect, kMainGameWindow);
- }
+ checkSelect(data, event, clickRect, kMainGameWindow);
}
return false;
}
@@ -1262,10 +1266,8 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) {
Common::Point pos;
// Click rect to local coordinates. We assume the click is inside the window ^
Common::Rect clickRect = calculateClickRect(event.mouse, win->getDimensions());
- for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
- child = (*it).obj;
- checkSelect(child, event, clickRect, (WindowReference)ref);
- }
+ checkSelect(data, event, clickRect, (WindowReference)ref);
+
}
return true;
}