0.2.0 Refactored pallette. /JL
This commit is contained in:
59
color.go
59
color.go
@@ -33,7 +33,7 @@ func CreateBeadsGroup(mw *MyMainWindow) {
|
||||
gb.SetTitle("Beads")
|
||||
gb.SetLayout(walk.NewVBoxLayout())
|
||||
btn, _ := walk.NewPushButton(gb)
|
||||
btn.SetText("Select all colors")
|
||||
btn.SetText("Select all colors")
|
||||
btn.Clicked().Attach(func() {
|
||||
for _, bead := range mw.beads {
|
||||
bead.Checkbox.SetChecked(true)
|
||||
@@ -45,34 +45,43 @@ func CreateBeadsGroup(mw *MyMainWindow) {
|
||||
}
|
||||
|
||||
func LoadBeads(mw *MyMainWindow) {
|
||||
for _, brand := range mw.pallette.Brands.Brand {
|
||||
var located bool
|
||||
|
||||
for _, brand := range mw.pallette.Brand {
|
||||
if brand.BrandName == mw.brand_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.OnHand, 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
|
||||
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)
|
||||
log.Println("Loading beads for serie: " + mw.serie_combo.Text() + " ...")
|
||||
for _, bead := range brand.Colors {
|
||||
for _, serie := range bead.Series.Serie {
|
||||
if serie == mw.serie_combo.Text() {
|
||||
located = true
|
||||
}
|
||||
}
|
||||
if located {
|
||||
log.Println("Loading bead: " + bead.ColorName + " ...")
|
||||
if !bead.Disabled {
|
||||
bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.OnHand, bead.Red, bead.Green, bead.Blue)
|
||||
for _, series := range brand.Series {
|
||||
if series.Serie == mw.serie_combo.Text() {
|
||||
bc.Series = series.Serie
|
||||
bc.Weight = series.Weight
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func CreateDefaultConfig() {
|
||||
Config.AddSection("pallette")
|
||||
Config.Set("pallette", "brand", "Hama")
|
||||
Config.Set("pallette", "serie", "Midi")
|
||||
Config.Set("pallette", "pegboard", "Large 29x29")
|
||||
Config.Set("pallette", "pegboard", "Square 29x29")
|
||||
Config.AddSection("canvas")
|
||||
Config.Set("canvas", "scale", "100")
|
||||
Config.Set("canvas", "showgrid", "true")
|
||||
|
||||
2
main.go
2
main.go
@@ -30,7 +30,7 @@ type MyMainWindow struct {
|
||||
|
||||
const (
|
||||
AppName string = "BeadImager"
|
||||
Version string = "0.1.3"
|
||||
Version string = "0.2.0"
|
||||
CopyRight string = "©2022 Jan Lerking"
|
||||
STD_MESS string = "Ready"
|
||||
LogFile string = "BeadImager.log"
|
||||
|
||||
105
pallette.go
105
pallette.go
@@ -11,70 +11,54 @@ import (
|
||||
|
||||
type (
|
||||
Pallette struct {
|
||||
XMLName xml.Name `xml:"pallette"`
|
||||
Brands Brandsstruct `xml:"brands"`
|
||||
}
|
||||
|
||||
Brandsstruct struct {
|
||||
XMLName xml.Name `xml:"brands"`
|
||||
XMLName xml.Name `xml:"pallette"`
|
||||
Brand []Brandstruct `xml:"brand"`
|
||||
}
|
||||
|
||||
Brandstruct struct {
|
||||
XMLName xml.Name `xml:"brand"`
|
||||
BrandName string `xml:"brandname"`
|
||||
Series Seriesstruct `xml:"series"`
|
||||
}
|
||||
|
||||
Seriesstruct struct {
|
||||
XMLName xml.Name `xml:"series"`
|
||||
Serie []Seriestruct `xml:"serie"`
|
||||
BrandName string `xml:"name,attr"`
|
||||
Series []Seriestruct `xml:"serie"`
|
||||
Pegboards []Pegboardstruct `xml:"pegboard"`
|
||||
Colors []Colorstruct `xml:"color"`
|
||||
}
|
||||
|
||||
Seriestruct struct {
|
||||
XMLName xml.Name `xml:"serie"`
|
||||
SerieName string `xml:"seriename"`
|
||||
Weight int `xml:"weightPerThousand"`
|
||||
Pegboards Pegboardsstruct `xml:"pegboards"`
|
||||
Beads Beadsstruct `xml:"beads"`
|
||||
}
|
||||
|
||||
Pegboardsstruct struct {
|
||||
XMLName xml.Name `xml:"pegboards"`
|
||||
Pegboard []Pegboardstruct `xml:"pegboard"`
|
||||
Serie string `xml:"name,attr"`
|
||||
Weight int `xml:"weightPerThousand"`
|
||||
}
|
||||
|
||||
Pegboardstruct struct {
|
||||
XMLName xml.Name `xml:"pegboard"`
|
||||
Type string `xml:"type"`
|
||||
Width string `xml:"width"`
|
||||
Height string `xml:"height"`
|
||||
}
|
||||
|
||||
Beadsstruct struct {
|
||||
XMLName xml.Name `xml:"beads"`
|
||||
Color []Colorstruct `xml:"color"`
|
||||
Serie string `xml:"serie,attr"`
|
||||
Type string `xml:"type"`
|
||||
Size string `xml:"size"`
|
||||
}
|
||||
|
||||
Colorstruct struct {
|
||||
XMLName xml.Name `xml:"color"`
|
||||
ColorIndex int `xml:"colorIndex,attr"`
|
||||
ColorName string `xml:"colorname"`
|
||||
ProductCode string `xml:"productCode"`
|
||||
Brand string `xml:"brand"`
|
||||
Red byte `xml:"red"`
|
||||
Green byte `xml:"green"`
|
||||
Blue byte `xml:"blue"`
|
||||
IsPearl bool `xml:"isPearl"`
|
||||
IsTranslucent bool `xml:"isTranslucent"`
|
||||
IsNeutral bool `xml:"isNeutral"`
|
||||
IsGrayscale bool `xml:"isGrayscale"`
|
||||
Disabled bool `xml:"disabled"`
|
||||
InStock bool `xml:"inStock"`
|
||||
OnHand int `xml:"onHand"`
|
||||
Series struct {
|
||||
XMLName xml.Name `xml:"series"`
|
||||
Serie []string `xml:"serie"`
|
||||
}
|
||||
ColorIndex int `xml:"colorIndex,attr"`
|
||||
ColorName string `xml:"colorname"`
|
||||
ProductCode string `xml:"productCode"`
|
||||
Brand string `xml:"brand"`
|
||||
Red byte `xml:"red"`
|
||||
Green byte `xml:"green"`
|
||||
Blue byte `xml:"blue"`
|
||||
IsPearl bool `xml:"isPearl"`
|
||||
IsTranslucent bool `xml:"isTranslucent"`
|
||||
IsNeutral bool `xml:"isNeutral"`
|
||||
IsGrayscale bool `xml:"isGrayscale"`
|
||||
Disabled bool `xml:"disabled"`
|
||||
InStock bool `xml:"inStock"`
|
||||
OnHand int `xml:"onHand"`
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
serie_triggered bool = false
|
||||
)
|
||||
|
||||
func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox {
|
||||
mw.leftPanel, _ = walk.NewComposite(mw.content)
|
||||
vb := walk.NewVBoxLayout()
|
||||
@@ -102,6 +86,13 @@ func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox {
|
||||
mw.serie_combo, _ = walk.NewComboBox(comp)
|
||||
mw.serie_combo.SetModel(CreateSeriesList(mw))
|
||||
mw.serie_combo.SetText(ConfigSerie)
|
||||
mw.serie_combo.CurrentIndexChanged().Attach(func() {
|
||||
if !serie_triggered {
|
||||
mw.colors.Children().Clear()
|
||||
LoadBeads(mw)
|
||||
serie_triggered = true
|
||||
}
|
||||
})
|
||||
comp, _ = walk.NewComposite(pallette_group)
|
||||
comp.SetLayout(walk.NewHBoxLayout())
|
||||
comp.Layout().SetMargins(walk.Margins{0, 0, 0, 0})
|
||||
@@ -115,13 +106,11 @@ func CreatePalletteGroup(mw *MyMainWindow) *walk.GroupBox {
|
||||
|
||||
func CreatePegboardsList(mw *MyMainWindow) []string {
|
||||
pegboards := make([]string, 0)
|
||||
for _, brand := range mw.pallette.Brands.Brand {
|
||||
for _, brand := range mw.pallette.Brand {
|
||||
if brand.BrandName == mw.brand_combo.Text() {
|
||||
for _, serie := range brand.Series.Serie {
|
||||
if serie.SerieName == mw.serie_combo.Text() {
|
||||
for _, pegboard := range serie.Pegboards.Pegboard {
|
||||
pegboards = append(pegboards, pegboard.Type)
|
||||
}
|
||||
for _, pegboard := range brand.Pegboards {
|
||||
if pegboard.Serie == mw.serie_combo.Text() {
|
||||
pegboards = append(pegboards, pegboard.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,10 +120,10 @@ func CreatePegboardsList(mw *MyMainWindow) []string {
|
||||
|
||||
func CreateSeriesList(mw *MyMainWindow) []string {
|
||||
series := make([]string, 0)
|
||||
for _, brand := range mw.pallette.Brands.Brand {
|
||||
for _, brand := range mw.pallette.Brand {
|
||||
if brand.BrandName == mw.brand_combo.Text() {
|
||||
for _, serie := range brand.Series.Serie {
|
||||
series = append(series, serie.SerieName)
|
||||
for _, serie := range brand.Series {
|
||||
series = append(series, serie.Serie)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +132,7 @@ func CreateSeriesList(mw *MyMainWindow) []string {
|
||||
|
||||
func CreateBrandsList(mw *MyMainWindow) []string {
|
||||
brands := make([]string, 0)
|
||||
for _, brand := range mw.pallette.Brands.Brand {
|
||||
for _, brand := range mw.pallette.Brand {
|
||||
brands = append(brands, brand.BrandName)
|
||||
}
|
||||
return brands
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user