Skip to content

Commit

Permalink
feat(tracker/gioui): clicking a parameter slider (etc.) selects it
Browse files Browse the repository at this point in the history
Closes #112.
  • Loading branch information
vsariola committed Sep 8, 2024
1 parent 6924b63 commit e49f699
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased
### Added
- Clicking the parameter slider also selects that parameter ([#112][i112])
- The vertical and horizontal split bars indicate with a cursor that they can be
resized ([#145][i145])

Expand Down
6 changes: 4 additions & 2 deletions tracker/gioui/unit_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ func (p ParameterStyle) Layout(gtx C) D {
sliderStyle := material.Slider(p.Theme, &p.w.floatWidget)
sliderStyle.Color = p.Theme.Fg
r := image.Rectangle{Max: gtx.Constraints.Min}
area := clip.Rect(r).Push(gtx.Ops)
defer clip.Rect(r).Push(gtx.Ops).Pop()
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
if p.Focus {
event.Op(gtx.Ops, &p.w.floatWidget)
}
dims := sliderStyle.Layout(gtx)
area.Pop()
tracker.Int{IntData: p.w.Parameter}.Set(int(p.w.floatWidget.Value*float32(ra.Max-ra.Min) + float32(ra.Min) + 0.5))
return dims
case tracker.BoolParameter:
Expand All @@ -279,6 +279,7 @@ func (p ParameterStyle) Layout(gtx C) D {
boolStyle := material.Switch(p.Theme, &p.w.boolWidget, "Toggle boolean parameter")
boolStyle.Color.Disabled = p.Theme.Fg
boolStyle.Color.Enabled = white
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
dims := layout.Center.Layout(gtx, boolStyle.Layout)
if p.w.boolWidget.Value {
tracker.Int{IntData: p.w.Parameter}.Set(ra.Max)
Expand Down Expand Up @@ -320,6 +321,7 @@ func (p ParameterStyle) Layout(gtx C) D {
})
}
}
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
layout.Rigid(p.tracker.layoutMenu(gtx, instrName, &p.w.instrBtn, &p.w.instrMenu, unit.Dp(200),
instrItems...,
Expand Down

0 comments on commit e49f699

Please sign in to comment.