initial options bug fixed

See
424f62327b

Thanks a lot for the fast support, amazing!
This commit is contained in:
2024-06-08 20:06:02 +02:00
parent 3c992a00c6
commit 4f7cf4c419
4 changed files with 16 additions and 5 deletions

View File

@@ -82,35 +82,36 @@ func (scene *SceneOptions) Init() {
rowContainer := NewRowContainer("Options")
pause := NewCheckbox("Pause",
scene.Config.Paused,
func(args *widget.CheckboxChangedEventArgs) {
scene.Config.TogglePaused()
})
debugging := NewCheckbox("Debugging",
scene.Config.Debug,
func(args *widget.CheckboxChangedEventArgs) {
scene.Config.ToggleDebugging()
})
scene.SetInitialValue(debugging, scene.Config.Debug)
gridlines := NewCheckbox("Show grid lines",
scene.Config.ShowGrid,
func(args *widget.CheckboxChangedEventArgs) {
fmt.Println("CHECKBOX CALLED")
repr.Println(args.State)
scene.Config.ToggleGridlines()
})
scene.SetInitialValue(gridlines, scene.Config.ShowGrid)
evolution := NewCheckbox("Show evolution traces",
scene.Config.ShowEvolution,
func(args *widget.CheckboxChangedEventArgs) {
scene.Config.ToggleEvolution()
})
scene.SetInitialValue(evolution, scene.Config.ShowEvolution)
wrap := NewCheckbox("Wrap around edges",
scene.Config.Wrap,
func(args *widget.CheckboxChangedEventArgs) {
scene.Config.ToggleWrap()
})
scene.SetInitialValue(wrap, scene.Config.Wrap)
themes := NewCombobox(
[]string{"dark", "light"},
@@ -118,6 +119,7 @@ func (scene *SceneOptions) Init() {
func(args *widget.ListComboButtonEntrySelectedEventArgs) {
scene.Config.SwitchTheme(args.Entry.(ListEntry).Name)
})
themelabel := NewLabel("Themes")
combocontainer := NewColumnContainer()
combocontainer.AddChild(themes)

View File

@@ -42,11 +42,17 @@ func NewMenuButton(
func NewCheckbox(
text string,
initialvalue bool,
action func(args *widget.CheckboxChangedEventArgs)) *widget.LabeledCheckbox {
checkboxImage, _ := LoadCheckboxImage()
buttonImage, _ := LoadButtonImage()
var state widget.WidgetState
if initialvalue {
state = widget.WidgetChecked
}
return widget.NewLabeledCheckbox(
widget.LabeledCheckboxOpts.CheckboxOpts(
widget.CheckboxOpts.ButtonOpts(
@@ -54,6 +60,7 @@ func NewCheckbox(
),
widget.CheckboxOpts.Image(checkboxImage),
widget.CheckboxOpts.StateChangedHandler(action),
widget.CheckboxOpts.InitialState(state),
),
widget.LabeledCheckboxOpts.LabelOpts(
widget.LabelOpts.Text(text, *FontRenderer.FontSmall,