diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2019-11-28 22:32:59 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2019-11-28 22:32:59 +0000 |
| commit | e892be093dd86fbdabf7a21f9bfd333bcd0839b7 (patch) | |
| tree | 4123d5e6c9792a4f7a648acf2cb975c20e833520 /src/livecode/input.h | |
| parent | add livecoding tool to toolbar (diff) | |
| download | inkscape-e892be093dd86fbdabf7a21f9bfd333bcd0839b7.tar.gz inkscape-e892be093dd86fbdabf7a21f9bfd333bcd0839b7.zip | |
add api and input modules for the livecoding tool
Diffstat (limited to 'src/livecode/input.h')
| -rw-r--r-- | src/livecode/input.h | 74 |
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 : |
