0.5.1 Beads properties work. /JL

This commit is contained in:
2023-01-05 19:35:55 +01:00
parent b14275687d
commit 260b56d830
3 changed files with 103 additions and 22 deletions

View File

@@ -28,6 +28,7 @@ type (
Green byte
Blue byte
TextColor walk.Color
GreyScale bool
}
Serie struct {
@@ -96,7 +97,7 @@ func LoadBeads(mw *MyMainWindow) {
if brand.BrandName == mw.brand_combo.Text() {
for _, bead := range brand.Colors {
if !bead.Disabled {
bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.Red, bead.Green, bead.Blue)
bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.Red, bead.Green, bead.Blue, bead.IsGrayscale)
for _, s := range bead.Series.Serie {
se := new(Serie)
se.Name = s.Name
@@ -117,7 +118,7 @@ func LoadBeads(mw *MyMainWindow) {
}
}
func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, blue byte) *BeadColor {
func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, blue byte, greyscale bool) *BeadColor {
var err error
cm, _ := walk.NewComposite(mw.colors)
cm.SetAlignment(walk.AlignHNearVCenter)
@@ -128,6 +129,7 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, b
color.Color = cm
color.SetBackgroundColor(walk.RGB(red, green, blue))
color.SetColor(red, green, blue)
color.SetGreyscale(greyscale)
color.SetTextColor()
lbl, _ := walk.NewLabel(cm)
lbl.SetTextColor(color.TextColor)
@@ -243,6 +245,10 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, b
return color
}
func (bc *BeadColor) SetGreyscale(grey bool) {
bc.GreyScale = grey
}
func (bc *BeadColor) SetBackgroundColor(col walk.Color) {
bc.backgroundColor, _ = walk.NewSolidColorBrush(col)
}

20
main.go
View File

@@ -32,8 +32,8 @@ type MyMainWindow struct {
const (
AppName string = "BeadImager"
Version string = "0.5.0"
CopyRight string = "©2022 Jan Lerking"
Version string = "0.5.1"
CopyRight string = "©2022-'23 Jan Lerking"
STD_MESS string = "Ready"
LogFile string = "BeadImager.log"
Sep string = "\\"
@@ -108,6 +108,22 @@ func main() {
mw.brand_model = CreateBrandsList(mw)
CreatePalletteGroup(mw)
CreateBeadsGroup(mw)
switch ConfigShowAll {
case "true":
//ShowAll(mw)
case "false":
//ShowGreyscale(mw)
}
switch ConfigGreyscale {
case "true":
//ShowGreyscale(mw)
case "false":
//ShowAll(mw)
}
switch ConfigInStock {
case "true":
//ShowInStock(mw)
}
CreateCanvasGroup(mw)
CreateProperties(mw)

View File

@@ -39,6 +39,72 @@ type (
}
)
func ShowInStock(mw *MyMainWindow) {
for _, bead := range mw.beads {
for _, s := range bead.Series {
if s.Name == mw.serie_combo.Text() {
if s.inStock {
bead.Color.SetVisible(true)
} else {
bead.Color.SetVisible(false)
}
break
}
break
}
}
}
func ShowGreyscale(mw *MyMainWindow) {
mw.properties.propBeads.showAll.SetChecked(false)
mw.properties.propBeads.greyScale.SetChecked(true)
for _, bead := range mw.beads {
if bead.GreyScale {
if mw.properties.propBeads.inStock.Checked() {
for _, s := range bead.Series {
if s.Name == mw.serie_combo.Text() {
if s.inStock {
bead.Color.SetVisible(true)
} else {
bead.Color.SetVisible(false)
}
break
}
break
}
break
} else {
bead.Color.SetVisible(true)
}
} else {
bead.Color.SetVisible(false)
}
}
}
func ShowAll(mw *MyMainWindow) {
mw.properties.propBeads.showAll.SetChecked(true)
mw.properties.propBeads.greyScale.SetChecked(false)
for _, bead := range mw.beads {
if mw.properties.propBeads.inStock.Checked() {
for _, s := range bead.Series {
if s.Name == mw.serie_combo.Text() {
if s.inStock {
bead.Color.SetVisible(true)
} else {
bead.Color.SetVisible(false)
}
break
}
break
}
break
} else {
bead.Color.SetVisible(true)
}
}
}
func CreateProperties(mw *MyMainWindow) {
mw.properties = new(properties)
mw.properties.propColor = new(PropColor)
@@ -413,16 +479,12 @@ func CreateBeadsProperties(mw *MyMainWindow) {
mw.properties.propBeads.showAll.SetChecked(false)
}
mw.properties.propBeads.showAll.CheckedChanged().Attach(func() {
log.Println("Show all changed")
if mw.properties.propBeads.showAll.Checked() && mw.properties.propBeads.greyScale.Checked() {
mw.properties.propBeads.greyScale.SetChecked(false)
}
if !mw.properties.propBeads.showAll.Checked() {
SetConfigShowAll("false")
mw.properties.propBeads.greyScale.SetChecked(true)
} else {
log.Println("Show all checkbox changed")
if mw.properties.propBeads.showAll.Checked() {
SetConfigShowAll("true")
mw.properties.propBeads.greyScale.SetChecked(false)
SetConfigGreyscale("false")
mw.properties.propBeads.greyScale.SetChecked(!mw.properties.propBeads.showAll.Checked())
//ShowAll(mw)
}
})
walk.NewHSpacer(grcom)
@@ -445,16 +507,12 @@ func CreateBeadsProperties(mw *MyMainWindow) {
mw.properties.propBeads.greyScale.SetChecked(false)
}
mw.properties.propBeads.greyScale.CheckedChanged().Attach(func() {
log.Println("Greyscale changed")
if mw.properties.propBeads.showAll.Checked() && mw.properties.propBeads.greyScale.Checked() {
mw.properties.propBeads.showAll.SetChecked(false)
}
if !mw.properties.propBeads.greyScale.Checked() {
SetConfigGreyscale("false")
mw.properties.propBeads.showAll.SetChecked(true)
} else {
log.Println("Greyscale checkbox changed")
if mw.properties.propBeads.greyScale.Checked() {
SetConfigGreyscale("true")
mw.properties.propBeads.showAll.SetChecked(false)
SetConfigShowAll("false")
mw.properties.propBeads.showAll.SetChecked(!mw.properties.propBeads.greyScale.Checked())
//ShowGreyscale(mw)
}
})
mw.properties.propBeads.inStock, err = walk.NewCheckBox(mw.properties.propBeads.property)
@@ -481,6 +539,7 @@ func CreateBeadsProperties(mw *MyMainWindow) {
mw.properties.propBeads.greyScale.SetChecked(false)
}
if mw.properties.propBeads.inStock.Checked() {
//ShowInStock(mw)
SetConfigInStock("true")
} else {
SetConfigInStock("false")