[Scummvm-cvs-logs] scummvm master -> e74a8ba619df3befc3c59ae32de5d5f06377fd20

sev- sev at scummvm.org
Thu Apr 21 11:04:00 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e74a8ba619 WAGE: Moved console text selection to callbacks


Commit: e74a8ba619df3befc3c59ae32de5d5f06377fd20
    https://github.com/scummvm/scummvm/commit/e74a8ba619df3befc3c59ae32de5d5f06377fd20
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-21T11:03:58+02:00

Commit Message:
WAGE: Moved console text selection to callbacks

Changed paths:
    engines/wage/gui.cpp
    engines/wage/gui.h
    engines/wage/macwindow.cpp
    engines/wage/macwindow.h



diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index d670378..7e703b1 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -143,8 +143,8 @@ static void cursorTimerHandler(void *refCon) {
 	gui->_cursorDirty = true;
 }
 
-static void sceneWindowCallback(WindowClick click, Common::Event &event, void *gui);
-static void consoleWindowCallback(WindowClick click, Common::Event &event, void *gui);
+static bool sceneWindowCallback(WindowClick click, Common::Event &event, void *gui);
+static bool consoleWindowCallback(WindowClick click, Common::Event &event, void *gui);
 
 Gui::Gui(WageEngine *engine) {
 	_engine = engine;
@@ -315,18 +315,29 @@ void Gui::drawScene() {
 	_consoleTextArea.setHeight(_scene->_textBounds->height() - 2 * kBorderWidth);
 }
 
-static void sceneWindowCallback(WindowClick click, Common::Event &event, void *g) {
+static bool sceneWindowCallback(WindowClick click, Common::Event &event, void *g) {
 	Gui *gui = (Gui *)g;
 
+	return gui->processSceneEvents(click, event);
+}
+
+bool Gui::processSceneEvents(WindowClick click, Common::Event &event) {
+	if (_cursorIsArrow == false) {
+		CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+		_cursorIsArrow = true;
+	}
+
 	if (click == kBorderInner && event.type == Common::EVENT_LBUTTONUP) {
-		Designed *obj = gui->_scene->lookUpEntity(event.mouse.x - gui->_sceneWindow->getDimensions().left,
-												  event.mouse.y - gui->_sceneWindow->getDimensions().top);
+		Designed *obj = _scene->lookUpEntity(event.mouse.x - _sceneWindow->getDimensions().left,
+												  event.mouse.y - _sceneWindow->getDimensions().top);
 
 		if (obj != nullptr)
-			gui->_engine->processTurn(NULL, obj);
+			_engine->processTurn(NULL, obj);
 
-		return;
+		return true;
 	}
+
+	return false;
 }
 
 // Render console
@@ -339,13 +350,18 @@ void Gui::drawConsole() {
 	_consoleWindow->setDirty(true);
 }
 
-static void consoleWindowCallback(WindowClick click, Common::Event &event, void *g) {
+static bool consoleWindowCallback(WindowClick click, Common::Event &event, void *g) {
 	Gui *gui = (Gui *)g;
 
-	gui->processConsoleEvents(click, event);
+	return gui->processConsoleEvents(click, event);
 }
 
-void Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
+bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
+	if (click != kBorderInner && _cursorIsArrow == false) {
+		CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+		_cursorIsArrow = true;
+	}
+
 	if (click == kBorderScrollUp || click == kBorderScrollDown) {
 		if (event.type == Common::EVENT_LBUTTONDOWN) {
 			int textFullSize = _lines.size() * _consoleLineHeight + _consoleTextArea.height();
@@ -376,8 +392,49 @@ void Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
 			}
 		}
 
-		return;
+		return true;
 	}
+
+	if (click == kBorderInner) {
+		if (event.type == Common::EVENT_LBUTTONDOWN) {
+			startMarking(event.mouse.x, event.mouse.y);
+		} else if (event.type == Common::EVENT_LBUTTONUP) {
+			if (_inTextSelection) {
+				_inTextSelection = false;
+
+				if (_selectionEndY == -1 ||
+						(_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) {
+					_selectionStartY = _selectionEndY = -1;
+					_consoleFullRedraw = true;
+					_menu->enableCommand(kMenuEdit, kMenuActionCopy, false);
+				} else {
+					_menu->enableCommand(kMenuEdit, kMenuActionCopy, true);
+
+					bool cutAllowed = false;
+
+					if (_selectionStartY == _selectionEndY && _selectionStartY == (int)_lines.size() - 1)
+						cutAllowed = true;
+
+					_menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed);
+					_menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed);
+				}
+			}
+		} else if (event.type == Common::EVENT_MOUSEMOVE) {
+			if (_inTextSelection) {
+				updateTextSelection(event.mouse.x, event.mouse.y);
+				return true;
+			}
+
+			if (_cursorIsArrow) {
+				CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
+				_cursorIsArrow = false;
+			}
+		}
+
+		return true;
+	}
+
+	return false;
 }
 
 void Gui::loadFonts() {
@@ -443,21 +500,6 @@ void Gui::mouseMove(int x, int y) {
 
 		return;
 	}
-
-	if (_inTextSelection) {
-		updateTextSelection(x, y);
-		return;
-	}
-
-	if (_consoleTextArea.contains(x, 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;
-	}
 }
 
 void Gui::pushArrowCursor() {
@@ -502,35 +544,12 @@ void Gui::mouseUp(int x, int y) {
 		return;
 	}
 
-	if (_inTextSelection) {
-		_inTextSelection = false;
-
-		if (_selectionEndY == -1 ||
-				(_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) {
-			_selectionStartY = _selectionEndY = -1;
-			_consoleFullRedraw = true;
-			_menu->enableCommand(kMenuEdit, kMenuActionCopy, false);
-		} else {
-			_menu->enableCommand(kMenuEdit, kMenuActionCopy, true);
-
-			bool cutAllowed = false;
-
-			if (_selectionStartY == _selectionEndY && _selectionStartY == (int)_lines.size() - 1)
-				cutAllowed = true;
-
-			_menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed);
-			_menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed);
-		}
-	}
-
 	return;
 }
 
 void Gui::mouseDown(int x, int y) {
 	if (_menu->mouseClick(x, y)) {
 		_menuDirty = true;
-	} else if (_consoleTextArea.contains(x, y)) {
-		startMarking(x, y);
 	}
 }
 
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 1420851..6783b2e 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -114,7 +114,8 @@ public:
 
 	bool builtInFonts() { return _builtInFonts; }
 
-	void processConsoleEvents(WindowClick click, Common::Event &event);
+	bool processSceneEvents(WindowClick click, Common::Event &event);
+	bool processConsoleEvents(WindowClick click, Common::Event &event);
 
 private:
 	void drawScene();
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index f629e3e..01767d7 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -291,42 +291,22 @@ static WindowClick isInBorder(Common::Rect &rect, int x, int y) {
 }
 
 bool MacWindow::processEvent(Common::Event &event) {
+	WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
+
 	switch (event.type) {
 	case Common::EVENT_MOUSEMOVE:
-		//mouseMove(event.mouse.x, event.mouse.y);
 		break;
 	case Common::EVENT_LBUTTONDOWN:
-		mouseDown(event);
+		setHighlight(click);
 		break;
-	case Common::EVENT_LBUTTONUP: {
-			setHighlight(kBorderNone);
-
-			WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
-			(*_callback)(click, event, _dataPtr);
-		}
+	case Common::EVENT_LBUTTONUP:
+		setHighlight(kBorderNone);
 		break;
-
 	default:
 		return false;
 	}
 
-	return true;
-}
-
-void MacWindow::mouseDown(Common::Event &event) {
-	WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
-
-	if (click == kBorderNone)
-		return;
-
-	setHighlight(click);
-
-	if (click == kBorderScrollUp || click == kBorderScrollDown || click == kBorderInner) {
-		if (!_callback)
-			return;
-
-		(*_callback)(click, event, _dataPtr);
-	}
+	return (*_callback)(click, event, _dataPtr);
 }
 
 } // End of namespace Wage
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index d82807d..27ec196 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -86,7 +86,7 @@ public:
 	void setDirty(bool dirty) { _contentIsDirty = dirty; }
 	int getId() { return _id; }
 	bool processEvent(Common::Event &event);
-	void setCallback(void (*callback)(WindowClick, Common::Event &, void *), void *data) { _callback = callback; _dataPtr = data; }
+	void setCallback(bool (*callback)(WindowClick, Common::Event &, void *), void *data) { _callback = callback; _dataPtr = data; }
 
 private:
 	void drawBorder();
@@ -95,8 +95,6 @@ private:
 	const Graphics::Font *getTitleFont();
 	bool builtInFonts();
 
-	void mouseDown(Common::Event &event);
-
 private:
 	Graphics::ManagedSurface _surface;
 	Graphics::ManagedSurface _borderSurface;
@@ -115,7 +113,7 @@ private:
 
 	Common::String _title;
 
-	void (*_callback)(WindowClick, Common::Event &, void *);
+	bool (*_callback)(WindowClick, Common::Event &, void *);
 	void *_dataPtr;
 };
 






More information about the Scummvm-git-logs mailing list