zntg/ui/event.go
Sander Schobers cdfb863ab0 Added SDL backend.
Added Action{,s}. List of actions that can be used to defer cleanup code (see NewRenderer implementations).
Added TextInputEvent (replaces the old KeyPressEvent) and added to new events KeyDown & KeyUp.
Added VSync to NewRendererOptions.
Removed IconScale from button.
Added ImageSource interface that replaces the Image/Texture method on the Texture interface. This makes converting back a texture to an image optional (since this is atypical for a hardware texture for instance).
Added new KeyModifier: OSCommand (Windows/Command key).
Added KeyState that can keep the state of keys (pressed or not).
Added KeyEnter, representing the Enter key.
Changed signatures of CreateTexture methods in Renderer.
Changed signatures of icon related method (removed factories).
Basic example now depends on sdlgui.
2020-05-15 09:20:44 +02:00

96 lines
1.3 KiB
Go

package ui
import "opslag.de/schobers/geom"
type DisplayCloseEvent struct {
EventBase
}
type DisplayResizeEvent struct {
EventBase
Bounds geom.RectangleF32
}
type Event interface {
Stamp() float64
}
type EventBase struct {
StampInSeconds float64
}
func (e *EventBase) Stamp() float64 {
return e.StampInSeconds
}
type KeyModifier int
const (
KeyModifierNone KeyModifier = 0
KeyModifierShift = 1 << iota
KeyModifierControl
KeyModifierAlt
KeyModifierOSCommand
)
type KeyDownEvent struct {
EventBase
Key Key
Modifiers KeyModifier
}
type KeyUpEvent struct {
EventBase
Key Key
Modifiers KeyModifier
}
type MouseButton int
const (
MouseButtonLeft MouseButton = 1
MouseButtonRight MouseButton = 2
MouseButtonMiddle MouseButton = 3
)
type MouseButtonDownEvent struct {
MouseEvent
Button MouseButton
}
type MouseButtonUpEvent struct {
MouseEvent
Button MouseButton
}
type MouseEnterEvent struct {
MouseEvent
}
type MouseEvent struct {
EventBase
X, Y float32
}
func (e *MouseEvent) Pos() geom.PointF32 {
return geom.PtF32(e.X, e.Y)
}
type MouseLeaveEvent struct {
MouseEvent
}
type MouseMoveEvent struct {
MouseEvent
MouseWheel float32
}
type RefreshEvent struct {
EventBase
}
type TextInputEvent struct {
EventBase
Character rune
}