mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
perf(tracker/gioui): use pointer receivers in numericupdown to avoid garbage
This commit is contained in:
parent
1a256b1f01
commit
4899b027ff
@ -76,14 +76,14 @@ func NumericUpDown(th *material.Theme, number *NumberInput, min, max int, toolti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s NumericUpDownStyle) Layout(gtx C) D {
|
func (s *NumericUpDownStyle) Layout(gtx C) D {
|
||||||
if s.Tooltip.Text.Text != "" {
|
if s.Tooltip.Text.Text != "" {
|
||||||
return s.NumberInput.tipArea.Layout(gtx, s.Tooltip, s.actualLayout)
|
return s.NumberInput.tipArea.Layout(gtx, s.Tooltip, s.actualLayout)
|
||||||
}
|
}
|
||||||
return s.actualLayout(gtx)
|
return s.actualLayout(gtx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s NumericUpDownStyle) actualLayout(gtx C) D {
|
func (s *NumericUpDownStyle) actualLayout(gtx C) D {
|
||||||
size := image.Pt(gtx.Dp(s.Width), gtx.Dp(s.Height))
|
size := image.Pt(gtx.Dp(s.Width), gtx.Dp(s.Height))
|
||||||
gtx.Constraints.Min = size
|
gtx.Constraints.Min = size
|
||||||
rr := gtx.Dp(s.CornerRadius)
|
rr := gtx.Dp(s.CornerRadius)
|
||||||
@ -115,7 +115,7 @@ func (s NumericUpDownStyle) actualLayout(gtx C) D {
|
|||||||
return layout.Dimensions{Size: size}
|
return layout.Dimensions{Size: size}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s NumericUpDownStyle) button(height int, icon *widget.Icon, delta int, click *gesture.Click) layout.Widget {
|
func (s *NumericUpDownStyle) button(height int, icon *widget.Icon, delta int, click *gesture.Click) layout.Widget {
|
||||||
return func(gtx C) D {
|
return func(gtx C) D {
|
||||||
btnWidth := gtx.Dp(s.ButtonWidth)
|
btnWidth := gtx.Dp(s.ButtonWidth)
|
||||||
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
|
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
|
||||||
@ -148,7 +148,7 @@ func (s NumericUpDownStyle) button(height int, icon *widget.Icon, delta int, cli
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s NumericUpDownStyle) layoutText(gtx C) D {
|
func (s *NumericUpDownStyle) layoutText(gtx C) D {
|
||||||
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
|
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
|
||||||
layout.Stacked(func(gtx C) D {
|
layout.Stacked(func(gtx C) D {
|
||||||
paint.FillShape(gtx.Ops, s.BackgroundColor, clip.Rect(image.Rect(0, 0, gtx.Constraints.Max.X, gtx.Constraints.Max.Y)).Op())
|
paint.FillShape(gtx.Ops, s.BackgroundColor, clip.Rect(image.Rect(0, 0, gtx.Constraints.Max.X, gtx.Constraints.Max.Y)).Op())
|
||||||
@ -162,7 +162,7 @@ func (s NumericUpDownStyle) layoutText(gtx C) D {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s NumericUpDownStyle) layoutDrag(gtx layout.Context) layout.Dimensions {
|
func (s *NumericUpDownStyle) layoutDrag(gtx layout.Context) layout.Dimensions {
|
||||||
{ // handle dragging
|
{ // handle dragging
|
||||||
pxPerStep := float32(gtx.Dp(s.UnitsPerStep))
|
pxPerStep := float32(gtx.Dp(s.UnitsPerStep))
|
||||||
for _, ev := range gtx.Events(s.NumberInput) {
|
for _, ev := range gtx.Events(s.NumberInput) {
|
||||||
@ -195,7 +195,7 @@ func (s NumericUpDownStyle) layoutDrag(gtx layout.Context) layout.Dimensions {
|
|||||||
return layout.Dimensions{Size: gtx.Constraints.Min}
|
return layout.Dimensions{Size: gtx.Constraints.Min}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s NumericUpDownStyle) layoutClick(gtx layout.Context, delta int, click *gesture.Click) layout.Dimensions {
|
func (s *NumericUpDownStyle) layoutClick(gtx layout.Context, delta int, click *gesture.Click) layout.Dimensions {
|
||||||
// handle clicking
|
// handle clicking
|
||||||
for _, e := range click.Events(gtx) {
|
for _, e := range click.Events(gtx) {
|
||||||
switch e.Type {
|
switch e.Type {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user