aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pugl/pugl.h6
-rw-r--r--pugl/pugl_osx.m5
-rw-r--r--pugl/pugl_win.cpp6
-rw-r--r--pugl/pugl_x11.c4
-rw-r--r--pugl_test.c6
-rw-r--r--wscript2
6 files changed, 20 insertions, 9 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h
index 7f68351..8d82016 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -199,7 +199,11 @@ typedef void (*PuglReshapeFunc)(PuglView* view, int width, int height);
@param dx The scroll x distance.
@param dx The scroll y distance.
*/
-typedef void (*PuglScrollFunc)(PuglView* view, float dx, float dy);
+typedef void (*PuglScrollFunc)(PuglView* view,
+ int x,
+ int y,
+ float dx,
+ float dy);
/**
A function called when a special key is pressed or released.
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m
index a9bbd24..c318d91 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/pugl_osx.m
@@ -273,8 +273,11 @@ getModifiers(PuglView* view, NSEvent* ev)
- (void) scrollWheel:(NSEvent*)event
{
if (puglview->scrollFunc) {
+ NSPoint loc = [event locationInWindow];
puglview->mods = getModifiers(puglview, event);
- puglview->scrollFunc(puglview, [event deltaX], [event deltaY]);
+ puglview->scrollFunc(puglview,
+ loc.x, puglview->height - loc.y,
+ [event deltaX], [event deltaY]);
}
[self updateTrackingAreas];
}
diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp
index 780752b..c95a2d2 100644
--- a/pugl/pugl_win.cpp
+++ b/pugl/pugl_win.cpp
@@ -286,13 +286,15 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSEWHEEL:
if (view->scrollFunc) {
view->scrollFunc(
- view, 0, (int16_t)HIWORD(wParam) / (float)WHEEL_DELTA);
+ view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
+ (int16_t)HIWORD(wParam) / (float)WHEEL_DELTA);
}
break;
case WM_MOUSEHWHEEL:
if (view->scrollFunc) {
view->scrollFunc(
- view, (int16_t)HIWORD(wParam) / float(WHEEL_DELTA), 0);
+ view, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
+ (int16_t)HIWORD(wParam) / float(WHEEL_DELTA), 0);
}
break;
case WM_KEYDOWN:
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index d9fccf2..bd29074 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -296,7 +296,9 @@ puglProcessEvents(PuglView* view)
case 6: dx = -1.0f; break;
case 7: dx = 1.0f; break;
}
- view->scrollFunc(view, dx, dy);
+ view->scrollFunc(view,
+ event.xbutton.x, event.xbutton.y,
+ dx, dy);
}
break;
}
diff --git a/pugl_test.c b/pugl_test.c
index 8338d51..b9a54f5 100644
--- a/pugl_test.c
+++ b/pugl_test.c
@@ -138,9 +138,9 @@ onMouse(PuglView* view, int button, bool press, int x, int y)
}
static void
-onScroll(PuglView* view, float dx, float dy)
+onScroll(PuglView* view, int x, int y, float dx, float dy)
{
- fprintf(stderr, "Scroll %f %f ", dx, dy);
+ fprintf(stderr, "Scroll %d %d %f %f ", x, y, dx, dy);
printModifiers(view);
dist += dy / 4.0f;
puglPostRedisplay(view);
@@ -173,7 +173,7 @@ main(int argc, char** argv)
}
}
- PuglView* view = puglCreate(0, "Pugl Test", 512, 512, resizable);
+ PuglView* view = puglCreate(0, "Pugl Test", 512, 512, resizable, true);
puglIgnoreKeyRepeat(view, ignoreKeyRepeat);
puglSetKeyboardFunc(view, onKeyboard);
puglSetMotionFunc(view, onMotion);
diff --git a/wscript b/wscript
index b27f6f9..3682d14 100644
--- a/wscript
+++ b/wscript
@@ -7,7 +7,7 @@ from waflib.extras import autowaf as autowaf
import waflib.Logs as Logs, waflib.Options as Options
# Version of this package (even if built as a child)
-PUGL_VERSION = '0.1.0'
+PUGL_VERSION = '0.2.0'
PUGL_MAJOR_VERSION = '0'
# Library version (UNIX style major, minor, micro)