aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBorja Lorente2016-08-04 16:02:51 +0200
committerBorja Lorente2016-08-14 19:01:00 +0200
commit409a665867d5c310bf335436d05bf728c26c2f4a (patch)
tree7708767c9cf89af5a206d56b1b42ac729d3dae09
parent0aef29a8c5f364e53f6bef57fee890005bcda129 (diff)
downloadscummvm-rg350-409a665867d5c310bf335436d05bf728c26c2f4a.tar.gz
scummvm-rg350-409a665867d5c310bf335436d05bf728c26c2f4a.tar.bz2
scummvm-rg350-409a665867d5c310bf335436d05bf728c26c2f4a.zip
MACVENTURE: Adapt dragging to new click detection
-rw-r--r--engines/macventure/gui.cpp39
-rw-r--r--engines/macventure/gui.h10
2 files changed, 26 insertions, 23 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 327a2e8b7f..24f7031629 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -963,22 +963,22 @@ WindowReference Gui::findObjWindow(ObjID objID) {
return kNoWindow;
}
-void Gui::checkSelect(const WindowData &data, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) {
+void Gui::checkSelect(const WindowData &data, Common::Point pos, const Common::Rect &clickRect, WindowReference ref) {
ObjID child = 0;
for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
- if (canBeSelected((*it).obj, event, clickRect, ref)) {
+ if (canBeSelected((*it).obj, clickRect, ref)) {
child = (*it).obj;
}
}
if (child != 0) {
- selectDraggable(child, ref, event.mouse, data.scrollPos);
+ selectDraggable(child, ref, pos, data.scrollPos);
bringToFront(ref);
}
}
-bool Gui::canBeSelected(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) {
+bool Gui::canBeSelected(ObjID obj, const Common::Rect &clickRect, WindowReference ref) {
return (_engine->isObjClickable(obj) &&
- isRectInsideObject(clickRect, obj));
+ isRectInsideObject(clickRect, obj));
}
bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) {
@@ -1007,6 +1007,7 @@ void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point cli
}
void Gui::handleDragRelease(Common::Point pos, bool shiftPressed, bool isDoubleClick) {
+
if (_draggedObj.id != 0) {
WindowReference destinationWindow = findWindowAtPoint(pos);
if (destinationWindow == kNoWindow) return;
@@ -1250,13 +1251,6 @@ bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & e
if (_engine->needsClickToContinue())
return true;
- if (click == kBorderInner && event.type == Common::EVENT_LBUTTONDOWN) {
- 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 + data.scrollPos, _mainGameWindow->getDimensions());
- checkSelect(data, event, clickRect, kMainGameWindow);
- }
return false;
}
@@ -1342,8 +1336,7 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) {
// Find the appropriate window
WindowReference ref = findWindowAtPoint(event.mouse);
if (ref == kNoWindow) return false;
-
- Graphics::MacWindow *win = findWindow(ref);
+
WindowData &data = findWindowData((WindowReference) ref);
if (click == kBorderScrollUp) {
@@ -1358,17 +1351,21 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) {
if (click == kBorderScrollRight) {
data.scrollPos.x += kScrollAmount;
}
-
- 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 + data.scrollPos, win->getDimensions());
- checkSelect(data, event, clickRect, (WindowReference)ref);
- }
}
return true;
}
+void Gui::selectForDrag(Common::Point pos) {
+ WindowReference ref = findWindowAtPoint(pos);
+ if (ref == kNoWindow) return;
+
+ Graphics::MacWindow *win = findWindow(ref);
+ WindowData &data = findWindowData((WindowReference) ref);
+
+ Common::Rect clickRect = calculateClickRect(pos + data.scrollPos, win->getDimensions());
+ checkSelect(data, pos, clickRect, (WindowReference)ref);
+}
+
void Gui::handleSingleClick(Common::Point pos) {
debug("Single Click");
// HACK THERE HAS TO BE A MORE ELEGANT WAY
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index bc9ca14643..8155fb50d1 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -130,6 +130,7 @@ public:
const Graphics::Font& getCurrentFont();
// Clicks
+ void selectForDrag(Common::Point pos);
void handleSingleClick(Common::Point pos);
void handleDoubleClick(Common::Point pos);
@@ -231,8 +232,8 @@ private: // Methods
Graphics::MacWindow *findWindow(WindowReference reference);
// Utils
- bool canBeSelected(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref);
- void checkSelect(const WindowData &data, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref);
+ void checkSelect(const WindowData &data, Common::Point pos, const Common::Rect &clickRect, WindowReference ref);
+ bool canBeSelected(ObjID obj, const Common::Rect &clickRect, WindowReference ref);
bool isRectInsideObject(Common::Rect target, ObjID obj);
void selectDraggable(ObjID child, WindowReference origin, Common::Point startPos, Common::Point scroll);
void handleDragRelease(Common::Point pos, bool shiftPressed, bool isDoubleClick);
@@ -308,6 +309,10 @@ public:
return _pos;
}
+ bool canSelectDraggable() {
+ return _state == kCursorSCDrag;
+ }
+
private:
void changeState(CursorInput input) {
@@ -323,6 +328,7 @@ private:
switch (_state) {
case kCursorSCStart:
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 300000, this, "macVentureCursor");
+ _gui->selectForDrag(_pos);
break;
case kCursorDCStart:
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 300000, this, "macVentureCursor");