diff --git a/color.go b/color.go index 446984c..d2b9895 100644 --- a/color.go +++ b/color.go @@ -9,13 +9,15 @@ import ( type ( BeadColor struct { - Brand string - Series string - Name string - ColorID int Checkbox *walk.CheckBox backgroundColor walk.Brush tooltip walk.ToolTip + warning *walk.ImageView + Brand string + Series string + Weight int + Name string + ColorID int Red byte Green byte Blue byte @@ -37,6 +39,7 @@ func LoadBeads(mw *MyMainWindow) { bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.Red, bead.Green, bead.Blue) bc.Brand = brand.BrandName bc.Series = series.SerieName + bc.Weight = series.Weight bc.Name = bead.ColorName bc.ColorID = bead.ColorIndex bc.Red = bead.Red @@ -73,6 +76,12 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, b log.Println("Setting checkbox name") color.Checkbox.SetText(name) log.Println("Checkbox name set") + color.warning, err = walk.NewImageView(cm) + if err != nil { + log.Println("Error creating image view: ", err) + } + color.warning.SetImage(walk.IconInformation()) + color.warning.SetVisible(false) walk.NewHSpacer(cm) lbl, _ := walk.NewLabel(cm) lbl.SetText(fmt.Sprint("Color ID: ", id)) @@ -89,6 +98,19 @@ func (bc *BeadColor) GetOnHand() int { return bc.onHand } -func (bc *BeadColor) SetOnHand(onHand int) { - bc.onHand = onHand +func (bc *BeadColor) GetInStock() bool { + return bc.inStock +} + +func (bc *BeadColor) SetInStock(inStock bool) { + bc.inStock = inStock +} + +func (bc *BeadColor) GetColorID() int { + return bc.ColorID +} + +func (bc *BeadColor) AddOnHand(grams int) { + addbeads := bc.Weight * grams / 1000 + bc.onHand += int(addbeads) } diff --git a/main.go b/main.go index 72e0dfd..a4a72e6 100644 --- a/main.go +++ b/main.go @@ -28,7 +28,7 @@ type MyMainWindow struct { const ( AppName string = "BeadImager" - Version string = "0.0.22" + Version string = "0.0.23" CopyRight string = "©2022 Jan Lerking" STD_MESS string = "Ready" LogFile string = "BeadImager.log" @@ -172,7 +172,7 @@ func main() { Children: []Widget{ Composite{ Layout: VBox{MarginsZero: true}, - MaxSize: Size{220, 0}, + MaxSize: Size{260, 0}, Children: []Widget{ DD_Pallette, DD_Beads, @@ -199,7 +199,7 @@ func main() { GroupBox{ Title: "Settings", Layout: VBox{}, - MaxSize: Size{220, 0}, + MaxSize: Size{260, 0}, Children: []Widget{ ScrollView{ AssignTo: &mw.propScroll, diff --git a/pallette.go b/pallette.go index 8d2eabb..ae1f0ce 100644 --- a/pallette.go +++ b/pallette.go @@ -32,6 +32,7 @@ type ( Seriestruct struct { XMLName xml.Name `xml:"serie"` SerieName string `xml:"seriename"` + Weight int `xml:"weightPerThousand"` Pegboards Pegboardsstruct `xml:"pegboards"` Beads Beadsstruct `xml:"beads"` } diff --git a/pallettes/pallette.xml b/pallettes/pallette.xml index cc295ad..1d8ddff 100644 --- a/pallettes/pallette.xml +++ b/pallettes/pallette.xml @@ -11,6 +11,7 @@ Midi + // Weight is per 1000 beads in grams 60