Added Maximized flag to new display options.
Added display resize & orientation event.
This commit is contained in:
parent
ab5572018d
commit
e8ff8c35fe
@ -19,6 +19,7 @@ type NewDisplayOptions struct {
|
||||
Fullscreen bool
|
||||
Resizable bool
|
||||
Windowed bool
|
||||
Maximized bool
|
||||
}
|
||||
|
||||
// NewDisplay creates a display
|
||||
@ -33,6 +34,9 @@ func NewDisplay(options NewDisplayOptions) (*Display, error) {
|
||||
}
|
||||
if options.Resizable {
|
||||
flags |= C.ALLEGRO_RESIZABLE
|
||||
if options.Maximized {
|
||||
flags |= C.ALLEGRO_MAXIMIZED
|
||||
}
|
||||
}
|
||||
C.al_set_new_display_flags(flags)
|
||||
d := C.al_create_display(C.int(options.Width), C.int(options.Height))
|
||||
|
@ -28,6 +28,48 @@ type DisplayCloseEvent struct {
|
||||
EventBase
|
||||
}
|
||||
|
||||
type DisplayResizeEvent struct {
|
||||
EventBase
|
||||
X, Y int
|
||||
Width int
|
||||
Height int
|
||||
}
|
||||
|
||||
type DisplayOrientation int
|
||||
|
||||
const (
|
||||
DisplayOrientation0Degrees DisplayOrientation = iota
|
||||
DisplayOrientation90Degrees
|
||||
DisplayOrientation180Degrees
|
||||
DisplayOrientation270Degrees
|
||||
DisplayOrientationFaceUp
|
||||
DisplayOrientationFaceDown
|
||||
)
|
||||
|
||||
func toDisplayOrientation(o C.int) DisplayOrientation {
|
||||
switch o {
|
||||
case C.ALLEGRO_DISPLAY_ORIENTATION_0_DEGREES:
|
||||
return DisplayOrientation0Degrees
|
||||
case C.ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES:
|
||||
return DisplayOrientation90Degrees
|
||||
case C.ALLEGRO_DISPLAY_ORIENTATION_180_DEGREES:
|
||||
return DisplayOrientation180Degrees
|
||||
case C.ALLEGRO_DISPLAY_ORIENTATION_270_DEGREES:
|
||||
return DisplayOrientation270Degrees
|
||||
case C.ALLEGRO_DISPLAY_ORIENTATION_FACE_UP:
|
||||
return DisplayOrientationFaceUp
|
||||
case C.ALLEGRO_DISPLAY_ORIENTATION_FACE_DOWN:
|
||||
return DisplayOrientationFaceDown
|
||||
default:
|
||||
panic("not supported")
|
||||
}
|
||||
}
|
||||
|
||||
type DisplayOrientationEvent struct {
|
||||
EventBase
|
||||
Orientation DisplayOrientation
|
||||
}
|
||||
|
||||
type KeyEvent struct {
|
||||
EventBase
|
||||
KeyCode int
|
||||
@ -104,7 +146,13 @@ func (eq *EventQueue) mapEvent(e *C.ALLEGRO_EVENT) Event {
|
||||
eb := EventBase{float64(any.timestamp)}
|
||||
switch any._type {
|
||||
case C.ALLEGRO_EVENT_DISPLAY_CLOSE:
|
||||
return &DisplayCloseEvent{EventBase{float64(any.timestamp)}}
|
||||
return &DisplayCloseEvent{eb}
|
||||
case C.ALLEGRO_EVENT_DISPLAY_ORIENTATION:
|
||||
display := (*C.ALLEGRO_DISPLAY_EVENT)(unsafe.Pointer(e))
|
||||
return &DisplayOrientationEvent{eb, toDisplayOrientation(display.orientation)}
|
||||
case C.ALLEGRO_EVENT_DISPLAY_RESIZE:
|
||||
display := (*C.ALLEGRO_DISPLAY_EVENT)(unsafe.Pointer(e))
|
||||
return &DisplayResizeEvent{eb, int(display.x), int(display.y), int(display.width), int(display.height)}
|
||||
case C.ALLEGRO_EVENT_MOUSE_AXES:
|
||||
mouse := (*C.ALLEGRO_MOUSE_EVENT)(unsafe.Pointer(e))
|
||||
return &MouseMoveEvent{MouseEvent{eb, int(mouse.x), int(mouse.y), int(mouse.z), int(mouse.w), nil}, int(mouse.dx), int(mouse.dy), int(mouse.dz), int(mouse.dw), float32(mouse.pressure)}
|
||||
|
Loading…
Reference in New Issue
Block a user