-
Notifications
You must be signed in to change notification settings - Fork 11
/
event.go
134 lines (106 loc) · 2.22 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package strife
import (
"github.com/veandco/go-sdl2/sdl"
)
// StrifeEvent wraps an SDL event
type StrifeEvent interface {
sdl.Event
Trigger()
}
// HandleEvent will trigger the given StrifeEvent
func HandleEvent(event StrifeEvent) {
event.Trigger()
}
// BASIC EVENT
// BaseEvent is a simple helper structure
// for events to satisfy sdl2
type BaseEvent struct{}
// GetTimestamp returns the timestamp of the event
// FIXME
func (b *BaseEvent) GetTimestamp() uint32 {
// FIXME
return 0
}
// GetType returns the type of this event
// FIXME
func (b *BaseEvent) GetType() uint32 {
// FIXME
return 0
}
// Trigger is invoked when the event is triggered
func (b *BaseEvent) Trigger() {}
// MOUSE EVENTS
// MouseWheelEvent represents a mouse scroll
// wheel event
type MouseWheelEvent struct {
BaseEvent
X, Y int
}
// MouseMoveEvent represents a mouse movement
// event
type MouseMoveEvent struct {
BaseEvent
X, Y int
}
// KEYBOARD
// KeyUpEvent is invoked when the key is _released_
type KeyUpEvent struct {
BaseEvent
KeyCode int
}
// KeyDownEvent is invoked when a key is pressed and
// held down
type KeyDownEvent struct {
BaseEvent
KeyCode int
}
// WINDOW CLOSE
// CloseEvent is invoked when the window
// requests to close.
type CloseEvent struct {
BaseEvent
}
// WINDOW VISIBILITY
// Visibility of the window, e.g.
// hidden, shown.
type Visibility int
// The types of visibilities available
// for the window.
const (
Shown Visibility = iota
Hidden
Exposed
)
// WindowVisibilityEvent ...
type WindowVisibilityEvent struct {
BaseEvent
Visibility
}
// WINDOW RESIZE
// WindowResizeEvent is invoked when the window
// is resized. contains the new width and height
type WindowResizeEvent struct {
BaseEvent
Width, Height int
}
// WINDOW MOVE
// WindowMoveEvent is invoked when the window is moved
// contains the new x, y position of the window.
type WindowMoveEvent struct {
BaseEvent
X, Y int
}
// WINDOW FOCUS
// Focus represents the state of focus for the window
type Focus int
// Currently two types: focus gained, and focus lost.
// i.e. the window is clicked onto or the window is clicked off of.
const (
FocusGained Focus = iota
FocusLost
)
// WindowFocusEvent ...
type WindowFocusEvent struct {
BaseEvent
Focus
}