0.0.9 Added bead colors. /JL
This commit is contained in:
50
color.go
50
color.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/lxn/walk"
|
||||
@@ -9,6 +10,8 @@ import (
|
||||
type (
|
||||
BeadColor struct {
|
||||
Brand string
|
||||
Series string
|
||||
ColorID int
|
||||
Checkbox *walk.CheckBox
|
||||
backgroundColor walk.Brush
|
||||
Red byte
|
||||
@@ -19,39 +22,54 @@ type (
|
||||
|
||||
func LoadBeads(mw *MyMainWindow) {
|
||||
for _, brand := range mw.pallette.Brands.Brand {
|
||||
log.Println("Loading beads for brand: " + brand.BrandName + " ...")
|
||||
for _, series := range brand.Series.Serie {
|
||||
for _, bead := range series.Beads.Color {
|
||||
log.Println("Loading bead: " + bead.ColorName + " ...")
|
||||
if !bead.Disabled {
|
||||
bc := NewBeadColor(mw, bead.ColorName, bead.Red, bead.Green, bead.Blue)
|
||||
bc.Brand = brand.BrandName
|
||||
bc.Red = bead.Red
|
||||
bc.Green = bead.Green
|
||||
bc.Blue = bead.Blue
|
||||
mw.beads = append(mw.beads, bc)
|
||||
if brand.BrandName == mw.pallette_combo.Text() {
|
||||
log.Println("Loading beads for brand: " + brand.BrandName + " ...")
|
||||
for _, series := range brand.Series.Serie {
|
||||
if series.SerieName == mw.serie_combo.Text() {
|
||||
log.Println("Loading beads for serie: " + series.SerieName + " ...")
|
||||
for _, bead := range series.Beads.Color {
|
||||
log.Println("Loading bead: " + bead.ColorName + " ...")
|
||||
if !bead.Disabled {
|
||||
bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.Red, bead.Green, bead.Blue)
|
||||
bc.Brand = brand.BrandName
|
||||
bc.Series = series.SerieName
|
||||
bc.ColorID = bead.ColorIndex
|
||||
bc.Red = bead.Red
|
||||
bc.Green = bead.Green
|
||||
bc.Blue = bead.Blue
|
||||
mw.beads = append(mw.beads, bc)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func NewBeadColor(mw *MyMainWindow, name string, 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)
|
||||
cm.SetAlignment(walk.AlignHNearVCenter)
|
||||
hb := walk.NewHBoxLayout()
|
||||
hb.SetMargins(walk.Margins{0, 0, 0, 0})
|
||||
cm.SetLayout(hb)
|
||||
color := new(BeadColor)
|
||||
log.Println("Bead color struct: ", color)
|
||||
//color.SetBackgroundColor(walk.RGB(red, green, blue))
|
||||
color.SetBackgroundColor(walk.RGB(red, green, blue))
|
||||
lbl, _ := walk.NewLabel(cm)
|
||||
lbl.SetText(fmt.Sprint("Color ID: ", id))
|
||||
log.Println("Creating checkbox")
|
||||
color.Checkbox, err = walk.NewCheckBox(mw.colors)
|
||||
color.Checkbox, err = walk.NewCheckBox(cm)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
log.Println("Checkbox created")
|
||||
log.Println("Setting checkbox name")
|
||||
color.Checkbox.SetName(name)
|
||||
color.Checkbox.SetText(name)
|
||||
log.Println("Checkbox name set")
|
||||
//color.Checkbox.SetBackground(color.backgroundColor)
|
||||
walk.NewHSpacer(cm)
|
||||
cm.SetBackground(color.backgroundColor)
|
||||
|
||||
return color
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user