From 46a9cbee3cd7fa9d7559f005a08ac0a1f42c279c Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 19 Dec 2022 12:40:10 +0100 Subject: [PATCH] 0.2.3 Pallette updating working. /JL --- color.go | 57 ++++++++++++++++++++++++++++------------------------- main.go | 2 +- pallette.go | 16 ++------------- 3 files changed, 33 insertions(+), 42 deletions(-) diff --git a/color.go b/color.go index ffd2705..e096e29 100644 --- a/color.go +++ b/color.go @@ -29,6 +29,18 @@ type ( } ) +func ShowBeads(mw *MyMainWindow, serie string) { + log.Println("Showing beads...") + for _, bead := range mw.beads { + bead.Color.SetVisible(false) + for _, s := range bead.Series { + if s == serie { + bead.Color.SetVisible(true) + } + } + } +} + func CreateBeadsGroup(mw *MyMainWindow) { gb, _ := walk.NewGroupBox(mw.leftPanel) gb.SetTitle("Beads") @@ -46,38 +58,29 @@ func CreateBeadsGroup(mw *MyMainWindow) { } func LoadBeads(mw *MyMainWindow) { - var located bool - for _, brand := range mw.pallette.Brand { if brand.BrandName == mw.brand_combo.Text() { log.Println("Loading beads for brand: " + brand.BrandName + " ...") log.Println("Loading beads for serie: " + mw.serie_combo.Text() + " ...") for _, bead := range brand.Colors { - for _, serie := range bead.Series.Serie { - if serie == mw.serie_combo.Text() { - located = true - } - } - if located { - log.Println("Loading bead: " + bead.ColorName + " ...") - if !bead.Disabled { - bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.OnHand, bead.Red, bead.Green, bead.Blue) - bc.Series = bead.Series.Serie - bc.Brand = brand.BrandName - bc.Name = bead.ColorName - bc.ColorID = bead.ColorIndex - bc.Red = bead.Red - bc.Green = bead.Green - bc.Blue = bead.Blue - bc.inStock = bead.InStock - mw.beads = append(mw.beads, bc) - if bead.OnHand <= 200 { - bc.warning.SetVisible(true) - bc.info.SetVisible(false) - } else { - bc.warning.SetVisible(false) - bc.info.SetVisible(true) - } + log.Println("Loading bead: " + bead.ColorName + " ...") + if !bead.Disabled { + bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.OnHand, bead.Red, bead.Green, bead.Blue) + bc.Series = bead.Series.Serie + bc.Brand = brand.BrandName + bc.Name = bead.ColorName + bc.ColorID = bead.ColorIndex + bc.Red = bead.Red + bc.Green = bead.Green + bc.Blue = bead.Blue + bc.inStock = bead.InStock + mw.beads = append(mw.beads, bc) + if bead.OnHand <= 200 { + bc.warning.SetVisible(true) + bc.info.SetVisible(false) + } else { + bc.warning.SetVisible(false) + bc.info.SetVisible(true) } } } diff --git a/main.go b/main.go index addd8c8..63ad392 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ type MyMainWindow struct { const ( AppName string = "BeadImager" - Version string = "0.2.2" + Version string = "0.2.3" CopyRight string = "©2022 Jan Lerking" STD_MESS string = "Ready" LogFile string = "BeadImager.log" diff --git a/pallette.go b/pallette.go index 8f52a6d..05c4b91 100644 --- a/pallette.go +++ b/pallette.go @@ -100,20 +100,7 @@ func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox { mw.serie_combo.SetText(ConfigSerie) mw.serie_combo.CurrentIndexChanged().Attach(func() { log.Println("Serie triggered: ", mw.serie_combo.Text()) - for _, color := range mw.beads { - for _, serie := range color.Series { - if serie != mw.serie_combo.Text() { - Disable = true - } else { - Disable = false - } - } - if Disable { - color.Color.SetVisible(false) - } else { - color.Color.SetVisible(true) - } - } + ShowBeads(mw, mw.serie_combo.Text()) for _, model := range mw.Pegboards.Boards { if model.brand == mw.brand_combo.Text() && model.serie == mw.serie_combo.Text() { mw.pegboard_combo.SetText("") @@ -135,6 +122,7 @@ func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox { } } mw.pegboard_combo.SetText(ConfigPegboard) + ShowBeads(mw, mw.serie_combo.Text()) return pallette_group }