DISTRHO Plugin Framework
Base.hpp
1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any purpose with
6  * or without fee is hereby granted, provided that the above copyright notice and this
7  * permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10  * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef DGL_BASE_HPP_INCLUDED
18 #define DGL_BASE_HPP_INCLUDED
19 
20 #include "../distrho/extra/LeakDetector.hpp"
21 #include "../distrho/extra/ScopedPointer.hpp"
22 
23 // --------------------------------------------------------------------------------------------------------------------
24 // Define namespace
25 
26 #ifndef DGL_NAMESPACE
27 # define DGL_NAMESPACE DGL
28 #endif
29 
30 #define START_NAMESPACE_DGL namespace DGL_NAMESPACE {
31 #define END_NAMESPACE_DGL }
32 #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;
33 
34 START_NAMESPACE_DGL
35 
36 // --------------------------------------------------------------------------------------------------------------------
37 // Base DGL enums
38 
39 /**
40  Keyboard modifier flags.
41  */
42 enum Modifier {
43  kModifierShift = 1u << 0u, ///< Shift key
44  kModifierControl = 1u << 1u, ///< Control key
45  kModifierAlt = 1u << 2u, ///< Alt/Option key
46  kModifierSuper = 1u << 3u ///< Mod4/Command/Windows key
47 };
48 
49 /**
50  Keyboard key codepoints.
51 
52  All keys are identified by a Unicode code point in PuglEventKey::key. This
53  enumeration defines constants for special keys that do not have a standard
54  code point, and some convenience constants for control characters. Note
55  that all keys are handled in the same way, this enumeration is just for
56  convenience when writing hard-coded key bindings.
57 
58  Keys that do not have a standard code point use values in the Private Use
59  Area in the Basic Multilingual Plane (`U+E000` to `U+F8FF`). Applications
60  must take care to not interpret these values beyond key detection, the
61  mapping used here is arbitrary and specific to DPF.
62  */
63 enum Key {
64  // Convenience symbols for ASCII control characters
65  kKeyBackspace = 0x08,
66  kKeyEscape = 0x1B,
67  kKeyDelete = 0x7F,
68 
69  // Backwards compatibility with old DPF
70  kCharBackspace DISTRHO_DEPRECATED_BY("kKeyBackspace") = kKeyBackspace,
71  kCharEscape DISTRHO_DEPRECATED_BY("kKeyEscape") = kKeyEscape,
72  kCharDelete DISTRHO_DEPRECATED_BY("kKeyDelete") = kKeyDelete,
73 
74  // Unicode Private Use Area
75  kKeyF1 = 0xE000,
76  kKeyF2,
77  kKeyF3,
78  kKeyF4,
79  kKeyF5,
80  kKeyF6,
81  kKeyF7,
82  kKeyF8,
83  kKeyF9,
84  kKeyF10,
85  kKeyF11,
86  kKeyF12,
87  kKeyLeft,
88  kKeyUp,
89  kKeyRight,
90  kKeyDown,
91  kKeyPageUp,
92  kKeyPageDown,
93  kKeyHome,
94  kKeyEnd,
95  kKeyInsert,
96  kKeyShift,
97  kKeyShiftL = kKeyShift,
98  kKeyShiftR,
99  kKeyControl,
100  kKeyControlL = kKeyControl,
101  kKeyControlR,
102  kKeyAlt,
103  kKeyAltL = kKeyAlt,
104  kKeyAltR,
105  kKeySuper,
106  kKeySuperL = kKeySuper,
107  kKeySuperR,
108  kKeyMenu,
109  kKeyCapsLock,
110  kKeyScrollLock,
111  kKeyNumLock,
112  kKeyPrintScreen,
113  kKeyPause
114 };
115 
116 /**
117  Common flags for all events.
118  */
119 enum Flag {
120  kFlagSendEvent = 1, ///< Event is synthetic
121  kFlagIsHint = 2 ///< Event is a hint (not direct user input)
122 };
123 
124 /**
125  Reason for a crossing event.
126  */
127 enum CrossingMode {
128  kCrossingNormal, ///< Crossing due to pointer motion
129  kCrossingGrab, ///< Crossing due to a grab
130  kCrossingUngrab ///< Crossing due to a grab release
131 };
132 
133 /**
134  Scroll direction.
135 
136  Describes the direction of a scroll event along with whether the scroll is a "smooth" scroll.
137  The discrete directions are for devices like mouse wheels with constrained axes,
138  while a smooth scroll is for those with arbitrary scroll direction freedom, like some touchpads.
139 */
140 enum ScrollDirection {
141  kScrollUp, ///< Scroll up
142  kScrollDown, ///< Scroll down
143  kScrollLeft, ///< Scroll left
144  kScrollRight, ///< Scroll right
145  kScrollSmooth ///< Smooth scroll in any direction
146 };
147 
148 // --------------------------------------------------------------------------------------------------------------------
149 // Base DGL classes
150 
151 /**
152  Graphics context, definition depends on build type.
153  */
154 struct GraphicsContext {};
155 
156 /**
157  Idle callback.
158  */
160 {
161  virtual ~IdleCallback() {}
162  virtual void idleCallback() = 0;
163 };
164 
165 // --------------------------------------------------------------------------------------------------------------------
166 
167 END_NAMESPACE_DGL
168 
169 #ifndef DONT_SET_USING_DGL_NAMESPACE
170  // If your code uses a lot of DGL classes, then this will obviously save you
171  // a lot of typing, but can be disabled by setting DONT_SET_USING_DGL_NAMESPACE.
172  using namespace DGL_NAMESPACE;
173 #endif
174 
175 // --------------------------------------------------------------------------------------------------------------------
176 
177 #endif // DGL_BASE_HPP_INCLUDED
GraphicsContext
Definition: Base.hpp:154
IdleCallback
Definition: Base.hpp:159