summaryrefslogtreecommitdiffstats
path: root/src/livecode/input.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/livecode/input.h')
-rw-r--r--src/livecode/input.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/livecode/input.h b/src/livecode/input.h
new file mode 100644
index 000000000..0b9977af8
--- /dev/null
+++ b/src/livecode/input.h
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef INK_LIVECODE_INPUT_H
+#define INK_LIVECODE_INPUT_H
+
+/*
+ * Input state keeper for the livecoding tool
+ *
+ * Authors:
+ * Sol Bekic <s+inkscape@s-ol.nu>
+ * Copyright (C) 2019 Authors
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#include <gdk/gdk.h>
+#include <2geom/point.h>
+#include <2geom/geom.h>
+
+
+namespace Inkscape {
+namespace Livecode {
+
+class API;
+
+enum InputState {
+ INPUTSTATE_NONE,
+ INPUTSTATE_HOVER,
+ INPUTSTATE_PRESSED,
+ INPUTSTATE_HELD,
+ INPUTSTATE_RELEASED,
+};
+
+class Mouse {
+public:
+ Geom::Point pos() const;
+ Geom::Point delta() const;
+
+ Geom::Point ui_pos() const;
+ Geom::Point ui_delta() const;
+
+ InputState event(guint button = 1) const;
+ bool pressed(guint button = 1) const;
+ bool held(guint button = 1) const;
+ bool released(guint button = 1) const;
+
+private:
+ API& api;
+
+ guint last_mask, prev_mask;
+ Geom::Point last_pos, prev_pos;
+
+ Mouse(API &api);
+
+ void push_event(GdkEvent *event);
+ void finish_frame();
+
+ friend class API;
+};
+
+}
+}
+
+#endif // INK_LIVECODE_INPUT_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :