1 /**
2 Copyright: Copyright (c) 2013-2014 Andrey Penechko.
3 License: a$(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
4 Authors: Andrey Penechko.
5 */
6 
7 module anchovy.gui.events;
8 
9 import anchovy.gui;
10 
11 abstract class Event
12 {
13 	/++
14 	 + If this flag is set-
15 	 + event propagates
16 	 + from root widget to target widget, otherwise
17 	 + it is bubbling from target to root.
18 	 +/
19 	bool	sinking = true;
20 
21 	/// Pseudo flag for convenience.
22 	/// Opposite to sinking.
23 	bool bubbling() @property
24 	{
25 		return !sinking;
26 	}
27 	/// ditto
28 	bool bubbling(bool newBubbling) @property
29 	{
30 		return sinking = !newBubbling;
31 	}
32 
33 	/// Specifies if event was already handled.
34 	/// Useful for checking if any child has handled this event.
35 	/// Set automatically by EventPropagator
36 	bool handled;
37 
38 	/// Reference to GuiContext class, used to obtain some global information.
39 	GuiContext context;
40 }
41 
42 abstract class PointerEvent : Event
43 {
44 	this(ivec2 pointerPosition)
45 	{
46 		this.pointerPosition = pointerPosition;
47 	}
48 	ivec2 pointerPosition;
49 }
50 
51 abstract class PointerButtonEvent : PointerEvent
52 {
53 	this(ivec2 pointerPosition, PointerButton button)
54 	{
55 		super(pointerPosition);
56 		this.button = button;
57 	}
58 	PointerButton button;
59 }
60 
61 // Pointer button
62 
63 class PointerPressEvent : PointerButtonEvent
64 {
65 	this(ivec2 pointerPosition, PointerButton button)
66 	{
67 		super(pointerPosition, button);
68 	}
69 }
70 
71 class PointerReleaseEvent : PointerButtonEvent
72 {
73 	this(ivec2 pointerPosition, PointerButton button)
74 	{
75 		super(pointerPosition, button);
76 	}
77 }
78 
79 class PointerClickEvent : PointerButtonEvent
80 {
81 	this(ivec2 pointerPosition, PointerButton button)
82 	{
83 		super(pointerPosition, button);
84 	}
85 }
86 
87 class PointerDoubleClickEvent : PointerButtonEvent
88 {
89 	this(ivec2 pointerPosition, PointerButton button)
90 	{
91 		super(pointerPosition, button);
92 	}
93 }
94 
95 class PointerMoveEvent : PointerEvent
96 {
97 	this(ivec2 newPointerPosition, ivec2 delta)
98 	{
99 		super(newPointerPosition);
100 		this.delta = delta;
101 	}
102 	ivec2 delta;
103 }
104 
105 class DragEvent : PointerMoveEvent
106 {
107 	this(ivec2 newPointerPosition, ivec2 delta, ivec2 dragOffset, Widget target)
108 	{
109 		super(newPointerPosition, delta);
110 		this.target = target;
111 		this.dragOffset = dragOffset;
112 	}
113 
114 	Widget target;
115 	ivec2 dragOffset;
116 }
117 
118 class DragEndEvent : DragEvent
119 {
120 	this(ivec2 newPointerPosition, ivec2 delta, ivec2 dragOffset, Widget target)
121 	{
122 		super(newPointerPosition, delta, dragOffset, target);
123 	}
124 }
125 
126 // Keyboard
127 
128 class CharEnterEvent : Event
129 {
130 	this(dchar character)
131 	{
132 		this.character = character;
133 	}
134 	dchar character;
135 }
136 
137 abstract class KeyEvent : Event
138 {
139 	this(uint keyCode, uint modifiers)
140 	{
141 		this.keyCode = keyCode;
142 		this.modifiers = modifiers;
143 	}
144 	uint keyCode;
145 	uint modifiers;
146 }
147 
148 class KeyPressEvent : KeyEvent
149 {
150 	this(uint keyCode, uint modifiers)
151 	{
152 		super(keyCode, modifiers);
153 	}
154 }
155 
156 class KeyReleaseEvent : KeyEvent
157 {
158 	this(uint keyCode, uint modifiers)
159 	{
160 		super(keyCode, modifiers);
161 	}
162 }
163 
164 // Hovering
165 
166 class PointerEnterEvent : Event
167 {
168 }
169 
170 class PointerLeaveEvent : Event
171 {
172 }
173 
174 // Focus
175 
176 class FocusGainEvent : Event
177 {
178 }
179 
180 class FocusLoseEvent : Event
181 {
182 }
183 
184 // Layout
185 
186 class ExpandLayoutEvent : Event
187 {
188 }
189 
190 class MinimizeLayoutEvent : Event
191 {
192 }
193 
194 // Misc
195 
196 class DrawEvent : Event
197 {
198 	this(IGuiRenderer guiRenderer)
199 	{
200 		this.guiRenderer = guiRenderer;
201 	}
202 	IGuiRenderer guiRenderer;
203 }
204 
205 class UpdatePositionEvent : Event
206 {
207 }
208 
209 class GroupSelectionEvent : Event
210 {
211 	this(Widget selected)
212 	{
213 		this.selected = selected;
214 	}
215 
216 	Widget selected;
217 }