aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2017-08-22 09:31:38 +0200
committerEugene Sandulenko2017-08-22 10:25:00 +0200
commit8458630e50d428ce6154aa303c24367abb34c9e9 (patch)
treeb37e0b0478ab96e7b5f7e0ab93b9a3e80de05096
parenta7dbacb5c32b04ca5ffe59667ba12e5f76a5ec59 (diff)
downloadscummvm-rg350-8458630e50d428ce6154aa303c24367abb34c9e9.tar.gz
scummvm-rg350-8458630e50d428ce6154aa303c24367abb34c9e9.tar.bz2
scummvm-rg350-8458630e50d428ce6154aa303c24367abb34c9e9.zip
GRAPHICS: MACGUI: Added support for scrolling with mouse wheel
-rw-r--r--graphics/macgui/mactextwindow.cpp35
-rw-r--r--graphics/macgui/mactextwindow.h2
2 files changed, 25 insertions, 12 deletions
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index 4818b5b4aa..c05468c2e3 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -313,6 +313,16 @@ bool MacTextWindow::processEvent(Common::Event &event) {
if (hasAllFocus())
return MacWindow::processEvent(event); // Pass it to upstream
+ if (event.type == Common::EVENT_WHEELUP) {
+ scroll(-2);
+ return true;
+ }
+
+ if (event.type == Common::EVENT_WHEELDOWN) {
+ scroll(2);
+ return true;
+ }
+
if (click == kBorderScrollUp || click == kBorderScrollDown) {
if (event.type == Common::EVENT_LBUTTONDOWN) {
int consoleHeight = getInnerDimensions().height();
@@ -324,22 +334,12 @@ bool MacTextWindow::processEvent(Common::Event &event) {
return true;
} else if (event.type == Common::EVENT_LBUTTONUP) {
- int oldScrollPos = _scrollPos;
-
switch (click) {
case kBorderScrollUp:
- _scrollPos = MAX<int>(0, _scrollPos - kConScrollStep);
- undrawCursor();
- _cursorY -= (_scrollPos - oldScrollPos);
- _contentIsDirty = true;
- _borderIsDirty = true;
+ scroll(-1);
break;
case kBorderScrollDown:
- _scrollPos = MIN<int>(_mactext->getTextHeight() - kConScrollStep, _scrollPos + kConScrollStep);
- undrawCursor();
- _cursorY -= (_scrollPos - oldScrollPos);
- _contentIsDirty = true;
- _borderIsDirty = true;
+ scroll(1);
break;
default:
return false;
@@ -389,6 +389,17 @@ bool MacTextWindow::processEvent(Common::Event &event) {
return MacWindow::processEvent(event);
}
+void MacTextWindow::scroll(int delta) {
+ int oldScrollPos = _scrollPos;
+
+ _scrollPos += delta * kConScrollStep;
+ _scrollPos = CLIP<int>(_scrollPos, 0, _mactext->getTextHeight() - kConScrollStep);
+ undrawCursor();
+ _cursorY -= (_scrollPos - oldScrollPos);
+ _contentIsDirty = true;
+ _borderIsDirty = true;
+}
+
void MacTextWindow::startMarking(int x, int y) {
x -= getInnerDimensions().left - 2;
y -= getInnerDimensions().top;
diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h
index 6dd464e9af..5791da3496 100644
--- a/graphics/macgui/mactextwindow.h
+++ b/graphics/macgui/mactextwindow.h
@@ -77,6 +77,8 @@ public:
private:
bool isCutAllowed();
+ void scroll(int delta);
+
void undrawInput();
void drawInput();
void drawSelection();