summaryrefslogtreecommitdiff
path: root/platform/gl
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-09-23 14:28:02 +0200
committerTor Andersson <tor.andersson@artifex.com>2015-10-06 11:21:23 +0200
commitcca539d70b69231408e35b0032b3b349237835bf (patch)
treecc61b40c026b0564c2a869771b25c2f442db8707 /platform/gl
parent17abfbce18df0d2a9c85687fc31afeb45c215ded (diff)
downloadmupdf-cca539d70b69231408e35b0032b3b349237835bf.tar.xz
gl: Add scroll wheel support.
Diffstat (limited to 'platform/gl')
-rw-r--r--platform/gl/gl-app.h1
-rw-r--r--platform/gl/gl-main.c21
2 files changed, 21 insertions, 1 deletions
diff --git a/platform/gl/gl-app.h b/platform/gl/gl-app.h
index fc9bbfbd..df6a2f96 100644
--- a/platform/gl/gl-app.h
+++ b/platform/gl/gl-app.h
@@ -54,6 +54,7 @@ struct ui
{
int x, y;
int down, middle, right;
+ int scroll_x, scroll_y;
int key, mod;
void *hot, *active, *focus;
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index 96d2ff6d..fb1c286c 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -481,6 +481,7 @@ static void do_outline(fz_outline *node, int outline_w)
if (ui.x >= 0 && ui.x < outline_w && ui.y >= 0 && ui.y < outline_h)
{
+ ui.hot = id;
if (!ui.active && ui.middle)
{
ui.active = id;
@@ -492,6 +493,9 @@ static void do_outline(fz_outline *node, int outline_w)
if (ui.active == id)
outline_scroll_y = saved_outline_scroll_y + (saved_ui_y - ui.y) * 5;
+ if (ui.hot == id)
+ outline_scroll_y -= ui.scroll_y * ui.lineheight * 3;
+
ui_scrollbar(outline_w, 0, outline_w+ui.lineheight, outline_h, &outline_scroll_y, outline_h, total_h);
glScissor(0, 0, outline_w, outline_h);
@@ -909,6 +913,12 @@ static void do_canvas(void)
}
}
+ if (ui.hot == doc)
+ {
+ scroll_x -= ui.scroll_x * ui.lineheight * 3;
+ scroll_y -= ui.scroll_y * ui.lineheight * 3;
+ }
+
if (ui.active == doc)
{
scroll_x = saved_scroll_x + saved_ui_x - ui.x;
@@ -1149,6 +1159,14 @@ static void on_mouse_motion(GLFWwindow *window, double x, double y)
ui_needs_update = 1;
}
+static void on_scroll(GLFWwindow *window, double x, double y)
+{
+ ui.scroll_x = x;
+ ui.scroll_y = y;
+ run_main_loop();
+ ui.scroll_x = ui.scroll_y = 0;
+}
+
static void on_reshape(GLFWwindow *window, int w, int h)
{
screen_w = w;
@@ -1244,9 +1262,10 @@ int main(int argc, char **argv)
update_title();
shrinkwrap();
+ glfwSetFramebufferSizeCallback(window, on_reshape);
glfwSetCursorPosCallback(window, on_mouse_motion);
glfwSetMouseButtonCallback(window, on_mouse_button);
- glfwSetFramebufferSizeCallback(window, on_reshape);
+ glfwSetScrollCallback(window, on_scroll);
glfwSetCharModsCallback(window, on_char);
glfwSetKeyCallback(window, on_key);
glfwSetWindowRefreshCallback(window, on_display);