0.2.4 Updated pallette. /JL
This commit is contained in:
70
color.go
70
color.go
@@ -17,15 +17,19 @@ type (
|
||||
info *walk.ImageView
|
||||
warning *walk.ImageView
|
||||
Brand string
|
||||
Series []string
|
||||
Series []*Serie
|
||||
Weight []int
|
||||
Name string
|
||||
ColorID int
|
||||
Red byte
|
||||
Green byte
|
||||
Blue byte
|
||||
inStock bool
|
||||
onHand int
|
||||
}
|
||||
|
||||
Serie struct {
|
||||
Name string
|
||||
inStock bool
|
||||
onHand int
|
||||
}
|
||||
)
|
||||
|
||||
@@ -34,7 +38,7 @@ func ShowBeads(mw *MyMainWindow, serie string) {
|
||||
for _, bead := range mw.beads {
|
||||
bead.Color.SetVisible(false)
|
||||
for _, s := range bead.Series {
|
||||
if s == serie {
|
||||
if s.Name == serie {
|
||||
bead.Color.SetVisible(true)
|
||||
}
|
||||
}
|
||||
@@ -65,30 +69,37 @@ func LoadBeads(mw *MyMainWindow) {
|
||||
for _, bead := range brand.Colors {
|
||||
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 := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.Red, bead.Green, bead.Blue)
|
||||
for _, s := range bead.Series.Serie {
|
||||
se := new(Serie)
|
||||
se.Name = s.Name
|
||||
se.inStock = s.InStock
|
||||
se.onHand = s.OnHand
|
||||
bc.Series = append(bc.Series, se)
|
||||
bc.InfoTooltip.SetText(bc.info, "Approx. "+fmt.Sprint(se.onHand)+" left on hand")
|
||||
bc.WarningTooltip.SetText(bc.warning, "Only "+fmt.Sprint(se.onHand)+" left on hand")
|
||||
if se.onHand <= 200 {
|
||||
bc.warning.SetVisible(true)
|
||||
bc.info.SetVisible(false)
|
||||
} else {
|
||||
bc.warning.SetVisible(false)
|
||||
bc.info.SetVisible(true)
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func NewBeadColor(mw *MyMainWindow, name string, id int, onhand int, red byte, green byte, blue byte) *BeadColor {
|
||||
func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, blue byte) *BeadColor {
|
||||
var err error
|
||||
log.Println("Creating bead color: " + name + " ...")
|
||||
cm, _ := walk.NewComposite(mw.colors)
|
||||
@@ -100,7 +111,6 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, onhand int, red byte, g
|
||||
color.Color = cm
|
||||
log.Println("Bead color struct: ", color)
|
||||
color.SetBackgroundColor(walk.RGB(red, green, blue))
|
||||
color.onHand = onhand
|
||||
log.Println("Creating checkbox")
|
||||
color.Checkbox, err = walk.NewCheckBox(cm)
|
||||
if err != nil {
|
||||
@@ -120,7 +130,6 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, onhand int, red byte, g
|
||||
color.InfoTooltip.SetInfoTitle(name + " - " + fmt.Sprint(id))
|
||||
color.info.SetImage(walk.IconInformation())
|
||||
color.InfoTooltip.AddTool(color.info)
|
||||
color.InfoTooltip.SetText(color.info, "Approx. "+fmt.Sprint(color.onHand)+" left on hand")
|
||||
color.info.SetVisible(false)
|
||||
color.warning, err = walk.NewImageView(cm)
|
||||
if err != nil {
|
||||
@@ -131,7 +140,6 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, onhand int, red byte, g
|
||||
color.WarningTooltip.SetWarningTitle(name + " - " + fmt.Sprint(id))
|
||||
color.warning.SetImage(walk.IconWarning())
|
||||
color.WarningTooltip.AddTool(color.warning)
|
||||
color.WarningTooltip.SetText(color.warning, "Only "+fmt.Sprint(color.onHand)+" left on hand")
|
||||
color.warning.SetVisible(false)
|
||||
|
||||
lbl, _ := walk.NewLabel(cm)
|
||||
@@ -145,16 +153,30 @@ func (bc *BeadColor) SetBackgroundColor(col walk.Color) {
|
||||
bc.backgroundColor, _ = walk.NewSolidColorBrush(col)
|
||||
}
|
||||
|
||||
func (bc *BeadColor) GetOnHand() int {
|
||||
return bc.onHand
|
||||
func (bc *BeadColor) GetOnHand(serie string) int {
|
||||
for _, s := range bc.Series {
|
||||
if s.Name == serie {
|
||||
return s.onHand
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (bc *BeadColor) GetInStock() bool {
|
||||
return bc.inStock
|
||||
func (bc *BeadColor) GetInStock(serie string) bool {
|
||||
for _, s := range bc.Series {
|
||||
if s.Name == serie {
|
||||
return s.inStock
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (bc *BeadColor) SetInStock(inStock bool) {
|
||||
bc.inStock = inStock
|
||||
func (bc *BeadColor) SetInStock(serie string, inStock bool) {
|
||||
for _, s := range bc.Series {
|
||||
if s.Name == serie {
|
||||
s.inStock = inStock
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (bc *BeadColor) GetColorID() int {
|
||||
|
||||
Reference in New Issue
Block a user