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

View File

@@ -11,6 +11,7 @@ import (
type MyMainWindow struct {
*walk.MainWindow
leftPanel *walk.Composite
colors *walk.ScrollView
canvasScroll *walk.ScrollView
drawWidget *walk.CustomWidget
@@ -28,7 +29,7 @@ type MyMainWindow struct {
const (
AppName string = "BeadImager"
Version string = "0.0.28"
Version string = "0.1.0"
CopyRight string = "©2022 Jan Lerking"
STD_MESS string = "Ready"
LogFile string = "BeadImager.log"
@@ -188,7 +189,8 @@ func main() {
Layout: VBox{MarginsZero: true},
Children: []Widget{
Composite{
Layout: HBox{},
AssignTo: &mw.leftPanel,
Layout: HBox{},
Children: []Widget{
Composite{
Layout: VBox{MarginsZero: true},

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 {