diff --git a/ui/checkbox.go b/ui/checkbox.go index 94b099b..82ee165 100644 --- a/ui/checkbox.go +++ b/ui/checkbox.go @@ -4,7 +4,7 @@ import ( "opslag.de/schobers/geom" ) -type SelectedChangedFn func(ctx Context, c Control, selected bool) +type SelectedChangedFn func(selected bool) type Checkbox struct { ControlBase @@ -100,7 +100,7 @@ func (c *Checkbox) Handle(ctx Context, e Event) { c.Selected = !c.Selected onSelectedChanged := c.onSelectedChanged if onSelectedChanged != nil { - onSelectedChanged(ctx, c, c.Selected) + onSelectedChanged(c.Selected) } } } diff --git a/ui/controlbase.go b/ui/controlbase.go index 5f858e3..f430c78 100644 --- a/ui/controlbase.go +++ b/ui/controlbase.go @@ -6,12 +6,12 @@ import ( "opslag.de/schobers/geom" ) -type ClickFn func(ctx Context, c Control, pos geom.PointF32, btn MouseButton) -type DragEndFn func(ctx Context, c Control, start, end geom.PointF32) -type DragMoveFn func(ctx Context, c Control, start, move geom.PointF32) -type DragStartFn func(ctx Context, c Control, start geom.PointF32) -type MouseEnterFn func(ctx Context, c Control) -type MouseLeaveFn func(ctx Context, c Control) +type ClickFn func(pos geom.PointF32, btn MouseButton) +type DragEndFn func(start, end geom.PointF32) +type DragMoveFn func(start, move geom.PointF32) +type DragStartFn func(start geom.PointF32) +type MouseEnterFn func() +type MouseLeaveFn func() var _ Control = &ControlBase{} @@ -66,13 +66,13 @@ func (c *ControlBase) Handle(ctx Context, e Event) { var start = c.ToControlPosition(e.Pos()) c.dragStart = &start if c.onDragStart != nil { - c.onDragStart(ctx, c, start) + c.onDragStart(start) } } else { var start = *c.dragStart var move = c.ToControlPosition(e.Pos()) if c.onDragMove != nil { - c.onDragMove(ctx, c, start, move) + c.onDragMove(start, move) } } } @@ -90,12 +90,12 @@ func (c *ControlBase) Handle(ctx Context, e Event) { var end = c.ToControlPosition(e.Pos()) c.dragStart = nil if c.onDragEnd != nil { - c.onDragEnd(ctx, c, start, end) + c.onDragEnd(start, end) } } if c.pressed { if c.onClick != nil { - c.onClick(ctx, c, c.ToControlPosition(e.Pos()), e.Button) + c.onClick(c.ToControlPosition(e.Pos()), e.Button) } } c.pressed = false diff --git a/ui/scrollbar.go b/ui/scrollbar.go index 27fe8bb..1c9b3fc 100644 --- a/ui/scrollbar.go +++ b/ui/scrollbar.go @@ -18,10 +18,10 @@ type Scrollbar struct { func BuildScrollbar(o Orientation, fn func(s *Scrollbar)) *Scrollbar { var s = &Scrollbar{Orientation: o, ContentLength: 0, ContentOffset: 0} - s.handle.OnDragStart(func(_ Context, _ Control, _ geom.PointF32) { + s.handle.OnDragStart(func(_ geom.PointF32) { s.startDragOffset = s.ContentOffset }) - s.handle.OnDragMove(func(_ Context, _ Control, start, move geom.PointF32) { + s.handle.OnDragMove(func(start, move geom.PointF32) { var length = s.Orientation.SizeParallel(s.bounds) var handleMaxOffset = length - s.Orientation.SizeParallel(s.handle.bounds) var hidden = s.ContentLength - length