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
|
||||
}
|
||||
|
||||
49
main.go
49
main.go
@@ -24,7 +24,7 @@ type MyMainWindow struct {
|
||||
|
||||
const (
|
||||
AppName string = "BeadImager"
|
||||
Version string = "0.0.8"
|
||||
Version string = "0.0.9"
|
||||
CopyRight string = "©2022 Jan Lerking"
|
||||
STD_MESS string = "Ready"
|
||||
UserPath string = "C:\\Users\\janle\\BeadImager"
|
||||
@@ -44,9 +44,10 @@ func main() {
|
||||
log.Println("MainWindow created")
|
||||
CreatePallette(mw)
|
||||
log.Println("Pallette created: ", mw.pallette)
|
||||
//LoadBeads(mw)
|
||||
//log.Println("Beads loaded: ", mw.beads)
|
||||
mw.brand_model = CreateBrandsList(mw)
|
||||
pallette_trigged := false
|
||||
serie_trigged := false
|
||||
pegboard_trigged := false
|
||||
|
||||
DD_Pallette := Composite{
|
||||
Layout: HBox{MarginsZero: true},
|
||||
@@ -58,12 +59,16 @@ func main() {
|
||||
AssignTo: &mw.pallette_combo,
|
||||
Model: mw.brand_model,
|
||||
OnCurrentIndexChanged: func() {
|
||||
log.Println("Pallette changed to: ", mw.pallette_combo.Text())
|
||||
mw.serie_model = CreateSeriesList(mw)
|
||||
mw.serie_combo.SetModel(mw.serie_model)
|
||||
mw.serie_combo.SetEnabled(true)
|
||||
if !pallette_trigged {
|
||||
log.Println("Pallette changed to: ", mw.pallette_combo.Text())
|
||||
mw.serie_model = CreateSeriesList(mw)
|
||||
mw.serie_combo.SetModel(mw.serie_model)
|
||||
mw.serie_combo.SetEnabled(true)
|
||||
}
|
||||
pallette_trigged = true
|
||||
},
|
||||
},
|
||||
HSpacer{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -77,17 +82,21 @@ func main() {
|
||||
AssignTo: &mw.serie_combo,
|
||||
Enabled: false,
|
||||
OnCurrentIndexChanged: func() {
|
||||
log.Println("Serie changed to: ", mw.serie_combo.Text())
|
||||
mw.pegboard_model = CreatePegboardsList(mw)
|
||||
mw.pegboard_combo.SetModel(mw.pegboard_model)
|
||||
mw.pegboard_combo.SetEnabled(true)
|
||||
if !serie_trigged {
|
||||
log.Println("Serie changed to: ", mw.serie_combo.Text())
|
||||
LoadBeads(mw)
|
||||
log.Println("Beads loaded: ", mw.beads)
|
||||
mw.pegboard_model = CreatePegboardsList(mw)
|
||||
mw.pegboard_combo.SetModel(mw.pegboard_model)
|
||||
mw.pegboard_combo.SetEnabled(true)
|
||||
}
|
||||
serie_trigged = true
|
||||
},
|
||||
},
|
||||
HSpacer{},
|
||||
},
|
||||
}
|
||||
|
||||
//pegboard_model := CreatePegboardsList(mw)
|
||||
|
||||
DD_Pegboard := Composite{
|
||||
Layout: HBox{MarginsZero: true},
|
||||
Children: []Widget{
|
||||
@@ -98,9 +107,13 @@ func main() {
|
||||
AssignTo: &mw.pegboard_combo,
|
||||
Enabled: false,
|
||||
OnCurrentIndexChanged: func() {
|
||||
log.Println("Pegboard changed to: ", mw.pegboard_combo.Text())
|
||||
if !pegboard_trigged {
|
||||
log.Println("Pegboard changed to: ", mw.pegboard_combo.Text())
|
||||
}
|
||||
pegboard_trigged = true
|
||||
},
|
||||
},
|
||||
HSpacer{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -121,8 +134,12 @@ func main() {
|
||||
DD_Serie,
|
||||
DD_Pegboard,
|
||||
PushButton{
|
||||
Text: "Edit Animal",
|
||||
OnClicked: func() {},
|
||||
Text: "Select all colors",
|
||||
OnClicked: func() {
|
||||
for _, c := range mw.beads {
|
||||
c.Checkbox.SetChecked(true)
|
||||
}
|
||||
},
|
||||
},
|
||||
ScrollView{
|
||||
AssignTo: &mw.colors,
|
||||
|
||||
Reference in New Issue
Block a user