0.5.0 Added beads config. /JL
This commit is contained in:
@@ -122,7 +122,7 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, b
|
|||||||
cm, _ := walk.NewComposite(mw.colors)
|
cm, _ := walk.NewComposite(mw.colors)
|
||||||
cm.SetAlignment(walk.AlignHNearVCenter)
|
cm.SetAlignment(walk.AlignHNearVCenter)
|
||||||
hb := walk.NewHBoxLayout()
|
hb := walk.NewHBoxLayout()
|
||||||
hb.SetMargins(walk.Margins{5, 0, 20, 0})
|
hb.SetMargins(walk.Margins{5, 5, 20, 5})
|
||||||
cm.SetLayout(hb)
|
cm.SetLayout(hb)
|
||||||
color := new(BeadColor)
|
color := new(BeadColor)
|
||||||
color.Color = cm
|
color.Color = cm
|
||||||
|
|||||||
@@ -54,6 +54,27 @@ func SetConfigScale(s string) {
|
|||||||
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetConfigShowAll(s string) {
|
||||||
|
log.Printf("Setting showall to: %s\n", s)
|
||||||
|
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||||
|
Config.Set("beads", "showall", s)
|
||||||
|
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetConfigGreyscale(s string) {
|
||||||
|
log.Printf("Setting greyscale to: %s\n", s)
|
||||||
|
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||||
|
Config.Set("beads", "greyscale", s)
|
||||||
|
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetConfigInStock(s string) {
|
||||||
|
log.Printf("Setting instock to: %s\n", s)
|
||||||
|
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||||
|
Config.Set("beads", "instock", s)
|
||||||
|
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||||
|
}
|
||||||
|
|
||||||
func ReadConfig() {
|
func ReadConfig() {
|
||||||
log.Printf("Reading config file: %s\n", ConfigFile)
|
log.Printf("Reading config file: %s\n", ConfigFile)
|
||||||
Config, _ = configparser.Parse(UserPath + Sep + ConfigFile)
|
Config, _ = configparser.Parse(UserPath + Sep + ConfigFile)
|
||||||
@@ -65,6 +86,9 @@ func ReadConfig() {
|
|||||||
ConfogGridColor, _ = Config.Get("canvas", "gridcolor")
|
ConfogGridColor, _ = Config.Get("canvas", "gridcolor")
|
||||||
ConfigShowBeads, _ = Config.Get("canvas", "showbeads")
|
ConfigShowBeads, _ = Config.Get("canvas", "showbeads")
|
||||||
ConfigBackgroundColor, _ = Config.Get("canvas", "backgroundcolor")
|
ConfigBackgroundColor, _ = Config.Get("canvas", "backgroundcolor")
|
||||||
|
ConfigShowAll, _ = Config.Get("beads", "showall")
|
||||||
|
ConfigGreyscale, _ = Config.Get("beads", "greyscale")
|
||||||
|
ConfigInStock, _ = Config.Get("beads", "instock")
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckConfigFile() bool {
|
func CheckConfigFile() bool {
|
||||||
@@ -89,5 +113,9 @@ func CreateDefaultConfig() {
|
|||||||
Config.Set("canvas", "gridcolor", "#00ff00")
|
Config.Set("canvas", "gridcolor", "#00ff00")
|
||||||
Config.Set("canvas", "showbeads", "false")
|
Config.Set("canvas", "showbeads", "false")
|
||||||
Config.Set("canvas", "backgroundcolor", "#ffffff")
|
Config.Set("canvas", "backgroundcolor", "#ffffff")
|
||||||
|
Config.AddSection("beads")
|
||||||
|
Config.Set("beads", "showall", "true")
|
||||||
|
Config.Set("beads", "greyscale", "false")
|
||||||
|
Config.Set("beads", "instock", "false")
|
||||||
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ type MyMainWindow struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AppName string = "BeadImager"
|
AppName string = "BeadImager"
|
||||||
Version string = "0.4.5"
|
Version string = "0.5.0"
|
||||||
CopyRight string = "©2022 Jan Lerking"
|
CopyRight string = "©2022 Jan Lerking"
|
||||||
STD_MESS string = "Ready"
|
STD_MESS string = "Ready"
|
||||||
LogFile string = "BeadImager.log"
|
LogFile string = "BeadImager.log"
|
||||||
@@ -49,6 +49,9 @@ var (
|
|||||||
ConfogGridColor string
|
ConfogGridColor string
|
||||||
ConfigShowBeads string
|
ConfigShowBeads string
|
||||||
ConfigBackgroundColor string
|
ConfigBackgroundColor string
|
||||||
|
ConfigShowAll string
|
||||||
|
ConfigGreyscale string
|
||||||
|
ConfigInStock string
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetupMainWindow(mw *MyMainWindow) {
|
func SetupMainWindow(mw *MyMainWindow) {
|
||||||
|
|||||||
+150
@@ -13,6 +13,7 @@ type (
|
|||||||
propColor *PropColor
|
propColor *PropColor
|
||||||
propScale *PropScale
|
propScale *PropScale
|
||||||
propCanvas *PropCanvas
|
propCanvas *PropCanvas
|
||||||
|
propBeads *PropBeads
|
||||||
}
|
}
|
||||||
|
|
||||||
PropColor struct {
|
PropColor struct {
|
||||||
@@ -28,6 +29,14 @@ type (
|
|||||||
property *walk.Composite
|
property *walk.Composite
|
||||||
visible bool
|
visible bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PropBeads struct {
|
||||||
|
property *walk.Composite
|
||||||
|
showAll *walk.RadioButton
|
||||||
|
greyScale *walk.RadioButton
|
||||||
|
inStock *walk.CheckBox
|
||||||
|
visible bool
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateProperties(mw *MyMainWindow) {
|
func CreateProperties(mw *MyMainWindow) {
|
||||||
@@ -35,6 +44,7 @@ func CreateProperties(mw *MyMainWindow) {
|
|||||||
mw.properties.propColor = new(PropColor)
|
mw.properties.propColor = new(PropColor)
|
||||||
mw.properties.propScale = new(PropScale)
|
mw.properties.propScale = new(PropScale)
|
||||||
mw.properties.propCanvas = new(PropCanvas)
|
mw.properties.propCanvas = new(PropCanvas)
|
||||||
|
mw.properties.propBeads = new(PropBeads)
|
||||||
CreateSettingsGroup(mw)
|
CreateSettingsGroup(mw)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +98,7 @@ func CreateSettingsGroup(mw *MyMainWindow) {
|
|||||||
CreateColorProperties(mw)
|
CreateColorProperties(mw)
|
||||||
CreateScaleProperties(mw)
|
CreateScaleProperties(mw)
|
||||||
CreateCanvasProperties(mw)
|
CreateCanvasProperties(mw)
|
||||||
|
CreateBeadsProperties(mw)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateColorProperties(mw *MyMainWindow) {
|
func CreateColorProperties(mw *MyMainWindow) {
|
||||||
@@ -342,3 +353,142 @@ func CreateCanvasProperties(mw *MyMainWindow) {
|
|||||||
}
|
}
|
||||||
mw.properties.propCanvas.property.SetBackground(bg)
|
mw.properties.propCanvas.property.SetBackground(bg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateBeadsProperties(mw *MyMainWindow) {
|
||||||
|
var err error
|
||||||
|
mw.properties.propBeads.property, err = walk.NewComposite(mw.propScroll)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error creating beads property: ", err)
|
||||||
|
}
|
||||||
|
err = mw.properties.propBeads.property.SetAlignment(walk.AlignHNearVNear)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting beads property alignment: ", err)
|
||||||
|
}
|
||||||
|
vb := walk.NewVBoxLayout()
|
||||||
|
err = mw.properties.propBeads.property.SetLayout(vb)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting beads property layout: ", err)
|
||||||
|
}
|
||||||
|
lbl, err := walk.NewTextLabel(mw.properties.propBeads.property)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error creating beads label: ", err)
|
||||||
|
}
|
||||||
|
err = lbl.SetText("Beads: ")
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting beads label text: ", err)
|
||||||
|
}
|
||||||
|
grcom, err := walk.NewComposite(mw.properties.propBeads.property)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error creating beads group: ", err)
|
||||||
|
}
|
||||||
|
err = grcom.SetAlignment(walk.AlignHNearVNear)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting beads group alignment: ", err)
|
||||||
|
}
|
||||||
|
hb := walk.NewHBoxLayout()
|
||||||
|
err = hb.SetMargins(walk.Margins{0, 0, 0, 0})
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting beads group margins: ", err)
|
||||||
|
}
|
||||||
|
err = grcom.SetLayout(hb)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting beads group layout: ", err)
|
||||||
|
}
|
||||||
|
mw.properties.propBeads.showAll, err = walk.NewRadioButton(grcom)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error creating beads checkbox: ", err)
|
||||||
|
}
|
||||||
|
err = mw.properties.propBeads.showAll.SetAlignment(walk.AlignHNearVNear)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting beads checkbox alignment: ", err)
|
||||||
|
}
|
||||||
|
err = mw.properties.propBeads.showAll.SetText("Show all")
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting beads checkbox text: ", err)
|
||||||
|
}
|
||||||
|
switch ConfigShowAll {
|
||||||
|
case "true":
|
||||||
|
mw.properties.propBeads.showAll.SetChecked(true)
|
||||||
|
case "false":
|
||||||
|
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 {
|
||||||
|
SetConfigShowAll("true")
|
||||||
|
mw.properties.propBeads.greyScale.SetChecked(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
walk.NewHSpacer(grcom)
|
||||||
|
mw.properties.propBeads.greyScale, err = walk.NewRadioButton(grcom)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error creating pixels checkbox: ", err)
|
||||||
|
}
|
||||||
|
err = mw.properties.propBeads.greyScale.SetAlignment(walk.AlignHNearVNear)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting pixels checkbox alignment: ", err)
|
||||||
|
}
|
||||||
|
err = mw.properties.propBeads.greyScale.SetText("Greyscale")
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting pixels checkbox text: ", err)
|
||||||
|
}
|
||||||
|
switch ConfigGreyscale {
|
||||||
|
case "true":
|
||||||
|
mw.properties.propBeads.greyScale.SetChecked(true)
|
||||||
|
case "false":
|
||||||
|
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 {
|
||||||
|
SetConfigGreyscale("true")
|
||||||
|
mw.properties.propBeads.showAll.SetChecked(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
mw.properties.propBeads.inStock, err = walk.NewCheckBox(mw.properties.propBeads.property)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error creating pixels checkbox: ", err)
|
||||||
|
}
|
||||||
|
err = mw.properties.propBeads.inStock.SetAlignment(walk.AlignHNearVNear)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting pixels checkbox alignment: ", err)
|
||||||
|
}
|
||||||
|
err = mw.properties.propBeads.inStock.SetText("Show only beads in stock")
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error setting pixels checkbox text: ", err)
|
||||||
|
}
|
||||||
|
switch ConfigInStock {
|
||||||
|
case "true":
|
||||||
|
mw.properties.propBeads.inStock.SetChecked(true)
|
||||||
|
case "false":
|
||||||
|
mw.properties.propBeads.inStock.SetChecked(false)
|
||||||
|
}
|
||||||
|
mw.properties.propBeads.inStock.CheckedChanged().Attach(func() {
|
||||||
|
log.Println("In stock changed")
|
||||||
|
if mw.properties.propBeads.showAll.Checked() && mw.properties.propBeads.greyScale.Checked() {
|
||||||
|
mw.properties.propBeads.greyScale.SetChecked(false)
|
||||||
|
}
|
||||||
|
if mw.properties.propBeads.inStock.Checked() {
|
||||||
|
SetConfigInStock("true")
|
||||||
|
} else {
|
||||||
|
SetConfigInStock("false")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
bg, err := walk.NewSolidColorBrush(walk.RGB(255, 255, 255))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error creating beads brush: ", err)
|
||||||
|
}
|
||||||
|
mw.properties.propBeads.property.SetBackground(bg)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user