0.0.9 Added bead colors. /JL
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/lxn/walk"
|
"github.com/lxn/walk"
|
||||||
@@ -9,6 +10,8 @@ import (
|
|||||||
type (
|
type (
|
||||||
BeadColor struct {
|
BeadColor struct {
|
||||||
Brand string
|
Brand string
|
||||||
|
Series string
|
||||||
|
ColorID int
|
||||||
Checkbox *walk.CheckBox
|
Checkbox *walk.CheckBox
|
||||||
backgroundColor walk.Brush
|
backgroundColor walk.Brush
|
||||||
Red byte
|
Red byte
|
||||||
@@ -19,13 +22,18 @@ type (
|
|||||||
|
|
||||||
func LoadBeads(mw *MyMainWindow) {
|
func LoadBeads(mw *MyMainWindow) {
|
||||||
for _, brand := range mw.pallette.Brands.Brand {
|
for _, brand := range mw.pallette.Brands.Brand {
|
||||||
|
if brand.BrandName == mw.pallette_combo.Text() {
|
||||||
log.Println("Loading beads for brand: " + brand.BrandName + " ...")
|
log.Println("Loading beads for brand: " + brand.BrandName + " ...")
|
||||||
for _, series := range brand.Series.Serie {
|
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 {
|
for _, bead := range series.Beads.Color {
|
||||||
log.Println("Loading bead: " + bead.ColorName + " ...")
|
log.Println("Loading bead: " + bead.ColorName + " ...")
|
||||||
if !bead.Disabled {
|
if !bead.Disabled {
|
||||||
bc := NewBeadColor(mw, bead.ColorName, bead.Red, bead.Green, bead.Blue)
|
bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.Red, bead.Green, bead.Blue)
|
||||||
bc.Brand = brand.BrandName
|
bc.Brand = brand.BrandName
|
||||||
|
bc.Series = series.SerieName
|
||||||
|
bc.ColorID = bead.ColorIndex
|
||||||
bc.Red = bead.Red
|
bc.Red = bead.Red
|
||||||
bc.Green = bead.Green
|
bc.Green = bead.Green
|
||||||
bc.Blue = bead.Blue
|
bc.Blue = bead.Blue
|
||||||
@@ -34,24 +42,34 @@ func LoadBeads(mw *MyMainWindow) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
var err error
|
||||||
log.Println("Creating bead color: " + name + " ...")
|
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)
|
color := new(BeadColor)
|
||||||
log.Println("Bead color struct: ", color)
|
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")
|
log.Println("Creating checkbox")
|
||||||
color.Checkbox, err = walk.NewCheckBox(mw.colors)
|
color.Checkbox, err = walk.NewCheckBox(cm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
log.Println("Checkbox created")
|
log.Println("Checkbox created")
|
||||||
log.Println("Setting checkbox name")
|
log.Println("Setting checkbox name")
|
||||||
color.Checkbox.SetName(name)
|
color.Checkbox.SetText(name)
|
||||||
log.Println("Checkbox name set")
|
log.Println("Checkbox name set")
|
||||||
//color.Checkbox.SetBackground(color.backgroundColor)
|
walk.NewHSpacer(cm)
|
||||||
|
cm.SetBackground(color.backgroundColor)
|
||||||
|
|
||||||
return color
|
return color
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type MyMainWindow struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AppName string = "BeadImager"
|
AppName string = "BeadImager"
|
||||||
Version string = "0.0.8"
|
Version string = "0.0.9"
|
||||||
CopyRight string = "©2022 Jan Lerking"
|
CopyRight string = "©2022 Jan Lerking"
|
||||||
STD_MESS string = "Ready"
|
STD_MESS string = "Ready"
|
||||||
UserPath string = "C:\\Users\\janle\\BeadImager"
|
UserPath string = "C:\\Users\\janle\\BeadImager"
|
||||||
@@ -44,9 +44,10 @@ func main() {
|
|||||||
log.Println("MainWindow created")
|
log.Println("MainWindow created")
|
||||||
CreatePallette(mw)
|
CreatePallette(mw)
|
||||||
log.Println("Pallette created: ", mw.pallette)
|
log.Println("Pallette created: ", mw.pallette)
|
||||||
//LoadBeads(mw)
|
|
||||||
//log.Println("Beads loaded: ", mw.beads)
|
|
||||||
mw.brand_model = CreateBrandsList(mw)
|
mw.brand_model = CreateBrandsList(mw)
|
||||||
|
pallette_trigged := false
|
||||||
|
serie_trigged := false
|
||||||
|
pegboard_trigged := false
|
||||||
|
|
||||||
DD_Pallette := Composite{
|
DD_Pallette := Composite{
|
||||||
Layout: HBox{MarginsZero: true},
|
Layout: HBox{MarginsZero: true},
|
||||||
@@ -58,12 +59,16 @@ func main() {
|
|||||||
AssignTo: &mw.pallette_combo,
|
AssignTo: &mw.pallette_combo,
|
||||||
Model: mw.brand_model,
|
Model: mw.brand_model,
|
||||||
OnCurrentIndexChanged: func() {
|
OnCurrentIndexChanged: func() {
|
||||||
|
if !pallette_trigged {
|
||||||
log.Println("Pallette changed to: ", mw.pallette_combo.Text())
|
log.Println("Pallette changed to: ", mw.pallette_combo.Text())
|
||||||
mw.serie_model = CreateSeriesList(mw)
|
mw.serie_model = CreateSeriesList(mw)
|
||||||
mw.serie_combo.SetModel(mw.serie_model)
|
mw.serie_combo.SetModel(mw.serie_model)
|
||||||
mw.serie_combo.SetEnabled(true)
|
mw.serie_combo.SetEnabled(true)
|
||||||
|
}
|
||||||
|
pallette_trigged = true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
HSpacer{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,17 +82,21 @@ func main() {
|
|||||||
AssignTo: &mw.serie_combo,
|
AssignTo: &mw.serie_combo,
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
OnCurrentIndexChanged: func() {
|
OnCurrentIndexChanged: func() {
|
||||||
|
if !serie_trigged {
|
||||||
log.Println("Serie changed to: ", mw.serie_combo.Text())
|
log.Println("Serie changed to: ", mw.serie_combo.Text())
|
||||||
|
LoadBeads(mw)
|
||||||
|
log.Println("Beads loaded: ", mw.beads)
|
||||||
mw.pegboard_model = CreatePegboardsList(mw)
|
mw.pegboard_model = CreatePegboardsList(mw)
|
||||||
mw.pegboard_combo.SetModel(mw.pegboard_model)
|
mw.pegboard_combo.SetModel(mw.pegboard_model)
|
||||||
mw.pegboard_combo.SetEnabled(true)
|
mw.pegboard_combo.SetEnabled(true)
|
||||||
|
}
|
||||||
|
serie_trigged = true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
HSpacer{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//pegboard_model := CreatePegboardsList(mw)
|
|
||||||
|
|
||||||
DD_Pegboard := Composite{
|
DD_Pegboard := Composite{
|
||||||
Layout: HBox{MarginsZero: true},
|
Layout: HBox{MarginsZero: true},
|
||||||
Children: []Widget{
|
Children: []Widget{
|
||||||
@@ -98,9 +107,13 @@ func main() {
|
|||||||
AssignTo: &mw.pegboard_combo,
|
AssignTo: &mw.pegboard_combo,
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
OnCurrentIndexChanged: func() {
|
OnCurrentIndexChanged: func() {
|
||||||
|
if !pegboard_trigged {
|
||||||
log.Println("Pegboard changed to: ", mw.pegboard_combo.Text())
|
log.Println("Pegboard changed to: ", mw.pegboard_combo.Text())
|
||||||
|
}
|
||||||
|
pegboard_trigged = true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
HSpacer{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,8 +134,12 @@ func main() {
|
|||||||
DD_Serie,
|
DD_Serie,
|
||||||
DD_Pegboard,
|
DD_Pegboard,
|
||||||
PushButton{
|
PushButton{
|
||||||
Text: "Edit Animal",
|
Text: "Select all colors",
|
||||||
OnClicked: func() {},
|
OnClicked: func() {
|
||||||
|
for _, c := range mw.beads {
|
||||||
|
c.Checkbox.SetChecked(true)
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ScrollView{
|
ScrollView{
|
||||||
AssignTo: &mw.colors,
|
AssignTo: &mw.colors,
|
||||||
|
|||||||
Reference in New Issue
Block a user