0.1.0 Refactoring from declarative. /JL

This commit is contained in:
2022-12-17 12:39:16 +01:00
parent 8db2458c2d
commit 9b5856ddf1
2 changed files with 47 additions and 2 deletions
+43
View File
@@ -5,6 +5,8 @@ import (
"io"
"log"
"os"
"github.com/lxn/walk"
)
type (
@@ -73,6 +75,47 @@ type (
}
)
func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox {
pallette_group, _ := walk.NewGroupBox(mw.leftPanel)
pallette_group.SetTitle("Pallette")
pallette_group.SetLayout(walk.NewVBoxLayout())
comp, _ := walk.NewComposite(pallette_group)
comp.SetLayout(walk.NewHBoxLayout())
comp.Layout().SetMargins(walk.Margins{0, 0, 0, 0})
lbl, _ := walk.NewLabel(comp)
lbl.SetText("Brand:")
mw.brand_combo, _ = walk.NewComboBox(comp)
mw.brand_combo.SetModel(CreateBrandsList(mw))
mw.brand_combo.SetCurrentIndex(0)
mw.brand_combo.CurrentIndexChanged().Attach(func() {
mw.serie_combo.SetModel(CreateSeriesList(mw))
mw.serie_combo.SetCurrentIndex(0)
mw.pegboard_combo.SetModel(CreatePegboardsList(mw))
mw.pegboard_combo.SetCurrentIndex(0)
})
comp, _ = walk.NewComposite(pallette_group)
comp.SetLayout(walk.NewHBoxLayout())
comp.Layout().SetMargins(walk.Margins{0, 0, 0, 0})
lbl, _ = walk.NewLabel(comp)
lbl.SetText("Serie:")
mw.serie_combo, _ = walk.NewComboBox(comp)
mw.serie_combo.SetModel(CreateSeriesList(mw))
mw.serie_combo.SetCurrentIndex(0)
mw.serie_combo.CurrentIndexChanged().Attach(func() {
mw.pegboard_combo.SetModel(CreatePegboardsList(mw))
mw.pegboard_combo.SetCurrentIndex(0)
})
comp, _ = walk.NewComposite(pallette_group)
comp.SetLayout(walk.NewHBoxLayout())
comp.Layout().SetMargins(walk.Margins{0, 0, 0, 0})
lbl, _ = walk.NewLabel(comp)
lbl.SetText("Pegboard:")
mw.pegboard_combo, _ = walk.NewComboBox(comp)
mw.pegboard_combo.SetModel(CreatePegboardsList(mw))
mw.pegboard_combo.SetCurrentIndex(0)
return pallette_group
}
func CreatePegboardsList(mw *MyMainWindow) []string {
pegboards := make([]string, 0)
for _, brand := range mw.pallette.Brands.Brand {