aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure/gui.cpp
diff options
context:
space:
mode:
authorBorja Lorente2016-07-26 11:42:58 +0200
committerBorja Lorente2016-08-14 19:00:35 +0200
commit518d336e5a5e266c2b443a9cacfa88abd541fe28 (patch)
treeb3a2e2991791792a0b549f2955105069ceb6936c /engines/macventure/gui.cpp
parentb02185432716e9a6a9d163318a0ebf817750a167 (diff)
downloadscummvm-rg350-518d336e5a5e266c2b443a9cacfa88abd541fe28.tar.gz
scummvm-rg350-518d336e5a5e266c2b443a9cacfa88abd541fe28.tar.bz2
scummvm-rg350-518d336e5a5e266c2b443a9cacfa88abd541fe28.zip
MACVENTURE: Fix item selection on scroll
Diffstat (limited to 'engines/macventure/gui.cpp')
-rw-r--r--engines/macventure/gui.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index ed9bad6720..738ea900af 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -683,7 +683,9 @@ void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface *
// For test
if (MACVENTURE_DEBUG_GUI) {
- surface->frameRect(_engine->getObjBounds(child), kColorGreen);
+ Common::Rect testBounds = _engine->getObjBounds(child);
+ testBounds.translate(-data.scrollPos.x, -data.scrollPos.y);
+ surface->frameRect(testBounds, kColorGreen);
}
}
@@ -982,7 +984,7 @@ void Gui::checkSelect(const WindowData &data, const Common::Event &event, const
child = (*it).obj;
}
}
- if (child != 0) selectDraggable(child, ref, event.mouse);
+ if (child != 0) selectDraggable(child, ref, event.mouse, data.scrollPos);
}
bool Gui::canBeSelected(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) {
@@ -1004,12 +1006,12 @@ bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) {
return _assets[obj]->isRectInside(intersection);
}
-void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point click) {
+void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point click, Common::Point scroll) {
if (_engine->isObjClickable(child) && _draggedObj.id == 0) {
_draggedObj.hasMoved = false;
_draggedObj.id = child;
_draggedObj.startWin = origin;
- _draggedObj.mouseOffset = (_engine->getObjPosition(child) + getWindowSurfacePos(origin)) - click;
+ _draggedObj.mouseOffset = (_engine->getObjPosition(child) + getWindowSurfacePos(origin)) - click - scroll;
_draggedObj.pos = click + _draggedObj.mouseOffset;
_draggedObj.startPos = _draggedObj.pos;
}
@@ -1263,7 +1265,7 @@ bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & e
WindowData &data = findWindowData(kMainGameWindow);
Common::Point pos;
// Click rect to local coordinates. We assume the click is inside the window ^
- Common::Rect clickRect = calculateClickRect(event.mouse, _mainGameWindow->getDimensions());
+ Common::Rect clickRect = calculateClickRect(event.mouse + data.scrollPos, _mainGameWindow->getDimensions());
checkSelect(data, event, clickRect, kMainGameWindow);
}
return false;
@@ -1371,7 +1373,7 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) {
if (click == kBorderInner) {
Common::Point pos;
// Click rect to local coordinates. We assume the click is inside the window ^
- Common::Rect clickRect = calculateClickRect(event.mouse, win->getDimensions());
+ Common::Rect clickRect = calculateClickRect(event.mouse + data.scrollPos, win->getDimensions());
checkSelect(data, event, clickRect, (WindowReference)ref);
}
}