mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-20 22:14:35 -04:00
feat(tracker/gioui): right click resets knobs instead of doubleclick
This commit is contained in:
parent
4138c34574
commit
0ce79978d5
@ -27,7 +27,6 @@ type (
|
|||||||
dragStartPt f32.Point // used to calculate the drag amount
|
dragStartPt f32.Point // used to calculate the drag amount
|
||||||
dragStartVal int
|
dragStartVal int
|
||||||
tipArea TipArea
|
tipArea TipArea
|
||||||
click gesture.Click
|
|
||||||
clickable Clickable
|
clickable Clickable
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,15 +183,6 @@ func (s *ParamState) update(gtx C, param tracker.Parameter, scroll bool) {
|
|||||||
s.tipArea.Appear(gtx.Now)
|
s.tipArea.Appear(gtx.Now)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for {
|
|
||||||
g, ok := s.click.Update(gtx.Source)
|
|
||||||
if !ok {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if g.Kind == gesture.KindClick && g.NumClicks > 1 {
|
|
||||||
param.Reset()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for scroll {
|
for scroll {
|
||||||
e, ok := gtx.Event(pointer.Filter{
|
e, ok := gtx.Event(pointer.Filter{
|
||||||
Target: s,
|
Target: s,
|
||||||
@ -229,6 +219,16 @@ func Knob(v tracker.Parameter, th *Theme, state *ParamState, hint string, scroll
|
|||||||
|
|
||||||
func (k *KnobWidget) Layout(gtx C) D {
|
func (k *KnobWidget) Layout(gtx C) D {
|
||||||
k.State.update(gtx, k.Value, k.Scroll)
|
k.State.update(gtx, k.Value, k.Scroll)
|
||||||
|
for k.Scroll {
|
||||||
|
ev, ok := gtx.Event(pointer.Filter{Target: k.State, Kinds: pointer.Press})
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if pe, ok := ev.(pointer.Event); ok && pe.Kind == pointer.Press && pe.Buttons == pointer.ButtonSecondary {
|
||||||
|
k.Value.Reset()
|
||||||
|
k.State.tipArea.Appear(gtx.Now)
|
||||||
|
}
|
||||||
|
}
|
||||||
knob := func(gtx C) D {
|
knob := func(gtx C) D {
|
||||||
m := k.Value.Range()
|
m := k.Value.Range()
|
||||||
amount := float32(k.Value.Value()-m.Min) / float32(m.Max-m.Min)
|
amount := float32(k.Value.Value()-m.Min) / float32(m.Max-m.Min)
|
||||||
@ -237,7 +237,6 @@ func (k *KnobWidget) Layout(gtx C) D {
|
|||||||
defer clip.Rect(image.Rectangle{Max: image.Pt(d, d)}).Push(gtx.Ops).Pop()
|
defer clip.Rect(image.Rectangle{Max: image.Pt(d, d)}).Push(gtx.Ops).Pop()
|
||||||
event.Op(gtx.Ops, k.State)
|
event.Op(gtx.Ops, k.State)
|
||||||
k.State.drag.Add(gtx.Ops)
|
k.State.drag.Add(gtx.Ops)
|
||||||
k.State.click.Add(gtx.Ops)
|
|
||||||
middle := float32(k.Value.Neutral()-m.Min) / float32(m.Max-m.Min)
|
middle := float32(k.Value.Neutral()-m.Min) / float32(m.Max-m.Min)
|
||||||
pos := max(amount, middle)
|
pos := max(amount, middle)
|
||||||
neg := min(amount, middle)
|
neg := min(amount, middle)
|
||||||
@ -401,7 +400,6 @@ func (s *SwitchWidget) Layout(gtx C) D {
|
|||||||
defer clip.Rect(image.Rectangle{Max: image.Pt(width, height)}).Push(gtx.Ops).Pop()
|
defer clip.Rect(image.Rectangle{Max: image.Pt(width, height)}).Push(gtx.Ops).Pop()
|
||||||
event.Op(gtx.Ops, s.State)
|
event.Op(gtx.Ops, s.State)
|
||||||
s.State.drag.Add(gtx.Ops)
|
s.State.drag.Add(gtx.Ops)
|
||||||
s.State.click.Add(gtx.Ops)
|
|
||||||
icon := icons.NavigationClose
|
icon := icons.NavigationClose
|
||||||
if s.Value.Range().Min < 0 {
|
if s.Value.Range().Min < 0 {
|
||||||
if s.Value.Value() < 0 {
|
if s.Value.Value() < 0 {
|
||||||
|
Reference in New Issue
Block a user