0.0.18 Added color and scale settings. /JL

This commit is contained in:
2022-12-13 21:51:41 +01:00
parent e2c2059e41
commit 5a4b01fde9
3 changed files with 81 additions and 22 deletions

View File

@@ -11,6 +11,7 @@ type (
BeadColor struct {
Brand string
Series string
Name string
ColorID int
Checkbox *walk.CheckBox
backgroundColor walk.Brush
@@ -33,6 +34,7 @@ func LoadBeads(mw *MyMainWindow) {
bc := NewBeadColor(mw, bead.ColorName, bead.ColorIndex, bead.Red, bead.Green, bead.Blue)
bc.Brand = brand.BrandName
bc.Series = series.SerieName
bc.Name = bead.ColorName
bc.ColorID = bead.ColorIndex
bc.Red = bead.Red
bc.Green = bead.Green

View File

@@ -27,7 +27,7 @@ type MyMainWindow struct {
const (
AppName string = "BeadImager"
Version string = "0.0.17"
Version string = "0.0.18"
CopyRight string = "©2022 Jan Lerking"
STD_MESS string = "Ready"
UserPath string = "C:\\Users\\janle\\BeadImager"
@@ -44,8 +44,6 @@ func main() {
walk.ValidationErrorEffect, _ = walk.NewBorderGlowEffect(walk.RGB(255, 0, 0))
})
mw := &MyMainWindow{}
mw.properties = new(properties)
mw.properties.propCanvas = new(PropCanvas)
log.Println("MainWindow created")
CreatePallette(mw)
log.Println("Pallette created: ", mw.pallette)
@@ -152,7 +150,7 @@ func main() {
MinSize: Size{800, 600},
OnSizeChanged: func() {
if !settings_trigged {
mw.properties.propCanvas.newCanvasProperties(mw)
ShowProperties(mw)
settings_trigged = true
}
},

View File

@@ -14,11 +14,11 @@ type (
}
PropColor struct {
*walk.Composite
property *walk.Composite
}
PropScale struct {
*walk.Composite
property *walk.Composite
}
PropCanvas struct {
@@ -26,6 +26,81 @@ type (
}
)
func ShowProperties(mw *MyMainWindow) {
log.Println("Showing properties")
mw.properties = new(properties)
mw.properties.propColor = new(PropColor)
mw.properties.propColor.newColorProperties(mw)
mw.properties.propScale = new(PropScale)
mw.properties.propScale.newScaleProperties(mw)
mw.properties.propCanvas = new(PropCanvas)
mw.properties.propCanvas.newCanvasProperties(mw)
}
func (cp *PropColor) newColorProperties(mw *MyMainWindow) {
var err error
log.Println("Creating color properties...")
cp.property, err = walk.NewComposite(mw.propScroll)
if err != nil {
log.Println("Error creating color properties: ", err)
}
cp.property.SetAlignment(walk.AlignHNearVNear)
vb := walk.NewVBoxLayout()
//vb.SetMargins(walk.Margins{5, 0, 5, 0})
cp.property.SetLayout(vb)
log.Println("Creating color label...")
lbl, _ := walk.NewTextLabel(cp.property)
log.Println("Setting color label text...")
lbl.SetText("Color: ")
log.Println("Creating color background brush...")
bg, _ := walk.NewSolidColorBrush(walk.RGB(167, 45, 234))
log.Println("Setting color background...")
cp.property.SetBackground(bg)
}
func (cp *PropScale) newScaleProperties(mw *MyMainWindow) {
var err error
log.Println("Creating scale properties...")
cp.property, err = walk.NewComposite(mw.propScroll)
if err != nil {
log.Println("Error creating scale properties: ", err)
}
cp.property.SetAlignment(walk.AlignHNearVNear)
vb := walk.NewVBoxLayout()
//vb.SetMargins(walk.Margins{5, 0, 5, 0})
cp.property.SetLayout(vb)
grcom, _ := walk.NewComposite(cp.property)
grcom.SetAlignment(walk.AlignHNearVNear)
hb := walk.NewVBoxLayout()
hb.SetMargins(walk.Margins{0, 0, 0, 0})
grcom.SetLayout(hb)
log.Println("Creating scale label...")
lbl, _ := walk.NewTextLabel(grcom)
log.Println("Setting scale label text...")
lbl.SetText("Scale:")
log.Println("Creating scale slider...")
slider, _ := walk.NewSlider(grcom)
log.Println("Setting scale slider properties...")
slider.SetTracking(true)
slider.SetRange(10, 200)
slider.SetValue(100)
sc, _ := walk.NewNumberEdit(grcom)
slider.ValueChanged().Attach(func() {
log.Println("Scale slider value changed")
nn := float64(slider.Value())
log.Println("Setting scale number edit value to: ", nn)
sc.SetValue(nn)
})
sc.SetWidth(30)
sc.SetDecimals(0)
sc.SetRange(10, 200)
nn := float64(slider.Value())
sc.SetValue(nn)
log.Println("Setting background color...")
bg, _ := walk.NewSolidColorBrush(walk.RGB(255, 255, 255))
cp.property.SetBackground(bg)
}
func (cp *PropCanvas) newCanvasProperties(mw *MyMainWindow) {
var err error
log.Println("Creating canvas properties...")
@@ -66,19 +141,3 @@ func (cp *PropCanvas) newCanvasProperties(mw *MyMainWindow) {
bg, _ := walk.NewSolidColorBrush(walk.RGB(255, 255, 255))
cp.property.SetBackground(bg)
}
func newPropCanvas() *PropCanvas {
return new(PropCanvas)
}
func newPropScale() *PropScale {
return new(PropScale)
}
func newPropColor() *PropColor {
return new(PropColor)
}
func newProperties() *properties {
return new(properties)
}