116 lines
2.7 KiB
Go
116 lines
2.7 KiB
Go
package tomo
|
|
|
|
import "image"
|
|
import "image/color"
|
|
import "golang.org/x/image/font"
|
|
import "git.tebibyte.media/tomo/tomo/data"
|
|
import "git.tebibyte.media/tomo/tomo/event"
|
|
import "git.tebibyte.media/tomo/tomo/input"
|
|
import "git.tebibyte.media/tomo/tomo/canvas"
|
|
|
|
type Inset [4]int
|
|
type Gap image.Point
|
|
|
|
type Border struct {
|
|
Width Inset
|
|
Color [4]color.Color
|
|
}
|
|
|
|
type Align int; const (
|
|
AlignStart Align = iota // similar to left-aligned text
|
|
AlignMiddle // similar to center-aligned text
|
|
AlignEnd // similar to right-aligned text
|
|
AlignEven // similar to justified text
|
|
)
|
|
|
|
type Object interface {
|
|
Box () Box
|
|
}
|
|
|
|
type Box interface {
|
|
Object
|
|
Bounds () image.Rectangle
|
|
InnerBounds () image.Rectangle
|
|
SetBounds (image.Rectangle)
|
|
SetColor (color.Color)
|
|
SetBorder (...Border)
|
|
SetMinimumSize (int, int)
|
|
SetPadding (Inset)
|
|
|
|
SetDNDData (data.Data)
|
|
SetDNDAccept (...data.Mime)
|
|
SetFocused (bool)
|
|
SetFocusable (bool)
|
|
|
|
Focused () bool
|
|
Modifiers (func ()) input.Modifiers
|
|
MousePosition (func ()) image.Point
|
|
|
|
OnFocusEnter (func ()) event.Cookie
|
|
OnFocusLeave (func ()) event.Cookie
|
|
OnDNDEnter (func ()) event.Cookie
|
|
OnDNDLeave (func ()) event.Cookie
|
|
OnDNDDrop (func (data.Data)) event.Cookie
|
|
OnMouseEnter (func ()) event.Cookie
|
|
OnMouseLeave (func ()) event.Cookie
|
|
OnMouseMove (func ()) event.Cookie
|
|
OnMouseDown (func (input.Button)) event.Cookie
|
|
OnMouseUp (func (input.Button)) event.Cookie
|
|
OnScroll (func (deltaX, deltaY float64)) event.Cookie
|
|
OnKeyDown (func (key input.Key, numberPad bool)) event.Cookie
|
|
OnKeyUp (func (key input.Key, numberPad bool)) event.Cookie
|
|
|
|
ContentBounds () image.Rectangle
|
|
ScrollTo (image.Point)
|
|
OnContentBoundsChange (func ()) event.Cookie
|
|
}
|
|
|
|
type TextBox interface {
|
|
Box
|
|
SetTextColor (color.Color)
|
|
SetFace (font.Face)
|
|
SetHAlign (Align)
|
|
SetVAlign (Align)
|
|
}
|
|
|
|
type CanvasBox interface {
|
|
Box
|
|
SetDrawer (canvas.Drawer)
|
|
Invalidate ()
|
|
}
|
|
|
|
type ContainerBox interface {
|
|
Box
|
|
SetGap (Gap)
|
|
Add (Object)
|
|
Delete (Object)
|
|
Insert (child Object, before Object)
|
|
Clear ()
|
|
Length () int
|
|
At (int) Object
|
|
SetLayout (Layout)
|
|
}
|
|
|
|
type Window interface {
|
|
SetRoot (Object)
|
|
SetIcon (sizes []image.Image)
|
|
NewMenu (image.Rectangle) (Window, error)
|
|
NewModal (image.Rectangle) (Window, error)
|
|
Widget () (Window, error)
|
|
Copy (data.Data)
|
|
Paste (callback func (data.Data, error), accept ...data.Mime)
|
|
Close ()
|
|
Show ()
|
|
Hide ()
|
|
OnClose (func ()) event.Cookie
|
|
}
|
|
|
|
type MainWindow interface {
|
|
Window
|
|
NewChild (image.Rectangle) (Window, error)
|
|
}
|
|
|
|
type Layout interface {
|
|
Arrange (image.Rectangle, Gap, []Box)
|
|
}
|