summaryrefslogtreecommitdiff
path: root/gui/input.h
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-18 01:45:24 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-18 01:49:20 -0300
commit07a60ddc211856fc7693cdd3654f53ee3da2be59 (patch)
treec608d41df89c68a3608454be3e5e3ee91aada7df /gui/input.h
parent30d665115a8f7d72f659a1e77b6eb14e727fbe57 (diff)
downloadeeshow-07a60ddc211856fc7693cdd3654f53ee3da2be59.tar.gz
eeshow-07a60ddc211856fc7693cdd3654f53ee3da2be59.tar.bz2
eeshow-07a60ddc211856fc7693cdd3654f53ee3da2be59.zip
eeshow/gui/gui.c: begin moving input (mouse, keyboard) handling to input.c (WIP)
We had input state scattered all over the place. This cleans things up. We also merge the functions of left and (previously) middle button. This breaks history panning.
Diffstat (limited to 'gui/input.h')
-rw-r--r--gui/input.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/gui/input.h b/gui/input.h
new file mode 100644
index 0000000..7e32df6
--- /dev/null
+++ b/gui/input.h
@@ -0,0 +1,52 @@
+/*
+ * gui/input.h - Input operations
+ *
+ * Written 2016 by Werner Almesberger
+ * Copyright 2016 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef GUI_INPUT_H
+#define GUI_NPUT_H
+
+#include <stdbool.h>
+
+#include <gtk/gtk.h>
+
+
+/*
+ * All members of input_ops are optional, i.e., can be NULL.
+ *
+ * hover_begin and drag_begin must not call input_push or input_pop.
+ */
+
+struct input_ops {
+ bool (*click)(void *user, int x, int y);
+
+ bool (*hover_begin)(void *user, int x, int y);
+ bool (*hover_update)(void *user, int x, int y);
+ bool (*hover_click)(void *user, int x, int y);
+ void (*hover_end)(void *user);
+
+ bool (*drag_begin)(void *user, int x, int y);
+ void (*drag_move)(void *user, int dx, int dy);
+ void (*drag_end)(void *user);
+
+ void (*scroll)(void *user, int x, int y, int dy);
+ /* down = 1, up = -1 */
+
+ void (*key)(void *user, int x, int y, int keyval);
+};
+
+
+bool input_accept(void *user, int x, int y);
+
+void input_push(const struct input_ops *ops, void *user);
+void input_pop(void);
+void input_setup(GtkWidget *da);
+
+#endif /* !GUI_INPUT_H */