Skip to content

Commit

Permalink
don't show mode chooser if only one mode!
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Nov 5, 2024
1 parent 35a3b6d commit 2cda37d
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions egui/loopctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,29 @@ func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Stacks) {
stepChoose.SetCurrentValue(cur)
}

tree.AddAt(p, "loop-mode", func(w *core.Switches) {
w.SetType(core.SwitchSegmentedButton)
w.Mutex = true
w.SetEnums(modes...)
w.SelectValue(curMode)
w.FinalStyler(func(s *styles.Style) {
s.Grow.Set(0, 0)
})
w.OnChange(func(e events.Event) {
curMode = w.SelectedItem().Value.(enums.Enum)
st := loops.Stacks[curMode]
if st != nil {
curStep = st.StepLevel
}
updateSteps()
stepChoose.Update()
stepN := st.Loops[curStep].StepCount
stepNSpin.SetValue(float32(stepN))
stepNSpin.Update()
if len(modes) > 1 {
tree.AddAt(p, "loop-mode", func(w *core.Switches) {
w.SetType(core.SwitchSegmentedButton)
w.Mutex = true
w.SetEnums(modes...)
w.SelectValue(curMode)
w.FinalStyler(func(s *styles.Style) {
s.Grow.Set(0, 0)
})
w.OnChange(func(e events.Event) {
curMode = w.SelectedItem().Value.(enums.Enum)
st := loops.Stacks[curMode]
if st != nil {
curStep = st.StepLevel
}
updateSteps()
stepChoose.Update()
stepN := st.Loops[curStep].StepCount
stepNSpin.SetValue(float32(stepN))
stepNSpin.Update()
})
})
})
}

gui.AddToolbarItem(p, ToolbarItem{Label: "Init",
Icon: icons.Update,
Expand Down

0 comments on commit 2cda37d

Please sign in to comment.