aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-29 18:10:46 +0000
committerDavid Robillard <d@drobilla.net>2012-04-29 18:10:46 +0000
commitd9732fbc106a6ac228912078888fbac65e78d26d (patch)
treed0b8c8f11c7cdcf8d117f853d680e4fa706d2a99 /pugl
parentd4b2829de83ca5f0efd3d1ee2683ee400e63ffe2 (diff)
downloadpugl-d9732fbc106a6ac228912078888fbac65e78d26d.tar.gz
pugl-d9732fbc106a6ac228912078888fbac65e78d26d.tar.bz2
pugl-d9732fbc106a6ac228912078888fbac65e78d26d.zip
Scroll support on Windows.
Diffstat (limited to 'pugl')
-rw-r--r--pugl/pugl.h2
-rw-r--r--pugl/pugl_win.cpp16
-rw-r--r--pugl/pugl_x11.c10
3 files changed, 22 insertions, 6 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h
index f173525..e5021f3 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -55,7 +55,7 @@ typedef void (*PuglMouseFunc)(PuglWindow* handle,
int button, bool down,
int x, int y);
typedef void (*PuglReshapeFunc)(PuglWindow* handle, int width, int height);
-typedef void (*PuglScrollFunc)(PuglWindow* handle, int dx, int dy);
+typedef void (*PuglScrollFunc)(PuglWindow* handle, float dx, float dy);
/**
Create a new GL window.
diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp
index 5441409..a3354bf 100644
--- a/pugl/pugl_win.cpp
+++ b/pugl/pugl_win.cpp
@@ -39,6 +39,10 @@ wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
case WM_DESTROY:
return 0;
+ case WM_MOUSEWHEEL:
+ case WM_MOUSEHWHEEL:
+ PostMessage(hwnd, message, wParam, lParam);
+ return 0;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
@@ -201,6 +205,18 @@ puglProcessEvents(PuglWindow* win)
case WM_RBUTTONUP:
processMouseEvent(win, 3, false, msg.lParam);
break;
+ case WM_MOUSEWHEEL:
+ if (win->scrollFunc) {
+ win->scrollFunc(
+ win, 0, (int16_t)HIWORD(msg.wParam) / (float)WHEEL_DELTA);
+ }
+ break;
+ case WM_MOUSEHWHEEL:
+ if (win->scrollFunc) {
+ win->scrollFunc(
+ win, (int16_t)HIWORD(msg.wParam) / float(WHEEL_DELTA), 0);
+ }
+ break;
case WM_KEYDOWN:
case WM_KEYUP:
if (win->keyboardFunc) {
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index 735cdb1..c6cc2b5 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -240,12 +240,12 @@ puglProcessEvents(PuglWindow* win)
case ButtonPress:
if (event.xbutton.button >= 4 && event.xbutton.button <= 7) {
if (win->scrollFunc) {
- int dx = 0, dy = 0;
+ float dx = 0, dy = 0;
switch (event.xbutton.button) {
- case 4: dy = 1; break;
- case 5: dy = -1; break;
- case 6: dx = -1; break;
- case 7: dx = 1; break;
+ case 4: dy = 1.0f; break;
+ case 5: dy = -1.0f; break;
+ case 6: dx = -1.0f; break;
+ case 7: dx = 1.0f; break;
}
win->scrollFunc(win, dx, dy);
}