zntg/ui/control.go

52 lines
1.0 KiB
Go
Raw Normal View History

package ui
import (
"opslag.de/schobers/geom"
)
type Control interface {
Arrange(Context, geom.RectangleF32, geom.PointF32, Control)
DesiredSize(Context, geom.PointF32) geom.PointF32
Handle(Context, Event) bool
Render(Context)
Bounds() geom.RectangleF32
BoundsUnclipped(Context, ControlPath) geom.RectangleF32
2020-05-16 11:46:07 +00:00
Disable()
Enable()
IsDisabled() bool
IsInBounds(p geom.PointF32) bool
IsOver() bool
Offset() geom.PointF32
ScrollIntoView(Context, ControlPath)
Self() Control
SetSelf(Control)
Parent() Control
}
type ControlPath []Control
func (p ControlPath) BoundsUnclipped(ctx Context, c Control) geom.RectangleF32 {
if len(p) == 0 {
return c.Bounds()
}
// switch next := p[0].(type) {
// case *ContainerBase:
// return next.BoundsUnclipped(ctx, p[1:])
// case *StackPanel:
// return next.BoundsUnclipped(ctx, p[1:])
// }
return p[0].BoundsUnclipped(ctx, p[1:])
}
func (p ControlPath) Prepend(control Control) ControlPath {
return append(ControlPath{control}, p...)
}
type RootControl interface {
Control
2019-05-01 07:40:59 +00:00
Init(Context) error
}