48 lines
855 B
Go
48 lines
855 B
Go
package appwindow
|
|
|
|
import (
|
|
"context"
|
|
"image"
|
|
)
|
|
|
|
type ViewerFrame struct {
|
|
Image image.Image
|
|
Tag uint64
|
|
shape viewerShape
|
|
}
|
|
|
|
type viewerShape struct {
|
|
outline image.Rectangle
|
|
caption image.Rectangle
|
|
radius image.Point
|
|
}
|
|
|
|
type ViewerEventKind uint8
|
|
|
|
const (
|
|
ViewerFocus ViewerEventKind = iota + 1
|
|
ViewerClose
|
|
ViewerMouseMove
|
|
ViewerMouseButton
|
|
ViewerMouseWheel
|
|
ViewerKey
|
|
)
|
|
|
|
type ViewerEvent struct {
|
|
Kind ViewerEventKind
|
|
FrameTag uint64
|
|
X, Y int
|
|
Width, Height int
|
|
Button int // 0 = left, 1 = right, 2 = middle
|
|
Delta int // 120 units per wheel detent
|
|
VirtualKey uint32
|
|
Down bool
|
|
}
|
|
|
|
type ViewerOptions struct {
|
|
Title string
|
|
Initial ViewerFrame
|
|
Frame func(context.Context) (ViewerFrame, error)
|
|
Input func(ViewerEvent) // Runs on the window thread and must return promptly.
|
|
}
|