0.3.4 Added dialog for adding beads. /JL
This commit is contained in:
11
color.go
11
color.go
@@ -129,6 +129,17 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, b
|
||||
}
|
||||
img, _ := walk.NewImageFromFileForDPI("images/plus_alpha.png", 96)
|
||||
color.add.SetImage(img)
|
||||
color.add.MouseDown().Attach(func(x, y int, button walk.MouseButton) {
|
||||
var data Serie
|
||||
if button == walk.LeftButton {
|
||||
for _, s := range color.Series {
|
||||
if s.Name == mw.serie_combo.Text() {
|
||||
data = *s
|
||||
}
|
||||
}
|
||||
mw.addBeads(name, data, color.ColorID, color.backgroundColor)
|
||||
}
|
||||
})
|
||||
color.info, err = walk.NewImageView(cm)
|
||||
if err != nil {
|
||||
log.Println("Error creating info image view: ", err)
|
||||
|
||||
25
dialog.go
25
dialog.go
@@ -2,10 +2,35 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"github.com/lxn/walk"
|
||||
)
|
||||
|
||||
func (mv *MyMainWindow) addBeads(name string, data Serie, id int, bg walk.Brush) error {
|
||||
log.Println("Adding beads...")
|
||||
dlg, err := walk.NewDialog(mv.MainWindow)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dlg.SetTitle("Add Beads")
|
||||
dlg.SetLayout(walk.NewVBoxLayout())
|
||||
dlg.SetSize(walk.Size{Width: 300, Height: 200})
|
||||
dlg.SetMinMaxSize(walk.Size{Width: 300, Height: 200}, walk.Size{Width: 300, Height: 200})
|
||||
dlg.SetX(mv.MainWindow.X() + 100)
|
||||
dlg.SetY(mv.MainWindow.Y() + 100)
|
||||
cmp, _ := walk.NewComposite(dlg)
|
||||
cmp.SetLayout(walk.NewVBoxLayout())
|
||||
cmp.Layout().SetMargins(walk.Margins{0, 0, 0, 0})
|
||||
lbl, _ := walk.NewTextLabel(cmp)
|
||||
lbl.SetText(name + " - " + strconv.Itoa(id))
|
||||
lbl.SetAlignment(walk.AlignHCenterVCenter)
|
||||
cmp.SetBackground(bg)
|
||||
|
||||
dlg.Show()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mw *MyMainWindow) openImage() error {
|
||||
dlg := new(walk.FileDialog)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user