2019-03-05 20:52:18 +00:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"opslag.de/schobers/geom"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Control interface {
|
2019-04-11 21:38:32 +00:00
|
|
|
Arrange(Context, geom.RectangleF32, geom.PointF32, Control)
|
2020-05-16 13:37:53 +00:00
|
|
|
DesiredSize(Context, geom.PointF32) geom.PointF32
|
2020-05-15 17:00:43 +00:00
|
|
|
Handle(Context, Event) bool
|
2019-03-05 20:52:18 +00:00
|
|
|
Render(Context)
|
|
|
|
|
|
|
|
Bounds() geom.RectangleF32
|
2021-08-19 10:27:34 +00:00
|
|
|
BoundsUnclipped(Context, ControlPath) geom.RectangleF32
|
2020-05-16 11:46:07 +00:00
|
|
|
Disable()
|
|
|
|
Enable()
|
|
|
|
IsDisabled() bool
|
2019-04-11 21:38:32 +00:00
|
|
|
IsInBounds(p geom.PointF32) bool
|
|
|
|
IsOver() bool
|
2019-03-05 21:42:57 +00:00
|
|
|
Offset() geom.PointF32
|
2021-08-19 10:27:34 +00:00
|
|
|
ScrollIntoView(Context, ControlPath)
|
2020-05-15 17:00:43 +00:00
|
|
|
|
2021-08-19 10:27:34 +00:00
|
|
|
Self() Control
|
|
|
|
SetSelf(Control)
|
2019-04-11 21:38:32 +00:00
|
|
|
Parent() Control
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|
|
|
|
|
2021-08-19 10:27:34 +00:00
|
|
|
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...)
|
|
|
|
}
|
|
|
|
|
2019-03-05 20:52:18 +00:00
|
|
|
type RootControl interface {
|
|
|
|
Control
|
|
|
|
|
2019-05-01 07:40:59 +00:00
|
|
|
Init(Context) error
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|