1 /**
2  * Events module for dcell.
3  *
4  * Copyright: Copyright 2022 Garrett D'Amore
5  * Authors: Garrett D'Amore
6  * License:
7  *   Distributed under the Boost Software License, Version 1.0.
8  *   (See accompanying file LICENSE or https://www.boost.org/LICENSE_1_0.txt)
9  *   SPDX-License-Identifier: BSL-1.0
10  */
11 module dcell.event;
12 
13 import core.time;
14 
15 import dcell.key;
16 import dcell.mouse;
17 
18 enum EventType
19 {
20     none = 0,
21     closed, /// input queue is closed (no more events will be received)
22     error, /// an error condition
23     key, /// a keyboard press
24     mouse, /// a mouse event
25     paste, /// a paste event
26     resize, /// window was resized
27 }
28 
29 /**
30  * Event is the abstract from of an event.  We use structs because
31  * these will be sent by value over the message box.  Other event
32  * types should "derive" from this by using it as their first member
33  * and using alias this.
34  */
35 struct Event
36 {
37     EventType type;
38     MonoTime when;
39     union
40     {
41         MouseEvent mouse;
42         KeyEvent key;
43         ResizeEvent resize;
44         PasteEvent paste;
45     }
46 }
47 
48 /**
49  * Resize is fired when a window resize event has occurred.
50  * It is something the application should use to determine
51  * when it needs to update layouts, etc.
52  */
53 struct ResizeEvent
54 {
55 }
56 
57 /**
58  * Paste start or stop.
59  */
60 struct PasteEvent
61 {
62     dstring content;
63 }