2
0
mirror of https://github.com/OrbTools/OrbBind synced 2024-10-31 03:20:26 +00:00
OrbBind/orbbind.go

55 lines
1.5 KiB
Go
Raw Normal View History

package main
import (
2021-02-10 01:13:44 +00:00
"reflect"
"fyne.io/fyne"
"fyne.io/fyne/app"
"fyne.io/fyne/dialog"
2021-02-10 01:13:44 +00:00
"github.com/OrbTools/OrbBind/ui/mui"
2021-02-09 22:02:50 +00:00
"github.com/OrbTools/OrbCommon/devices/orbweaver"
)
func main() {
ap := app.NewWithID("com.minizbot2012.orbbind")
window := ap.NewWindow("Orbweaver Rebinding")
2020-05-01 05:39:07 +00:00
window.SetMaster()
2020-12-08 05:35:41 +00:00
omap := new(orbweaver.PKM)
2021-02-10 01:13:44 +00:00
//pages := make(map[string]baseui.PageWithBindings)
//pages["main"] = mainpage.NewMainPage(window, omap)
//pages["side"] = sidepage.NewSidePage(window, omap)
tabs, setter := mui.Generate(orbweaver.GUI, window, reflect.ValueOf(omap))
//tabs := widget.NewTabContainer(pages["main"].Create(), pages["side"].Create())
2020-05-01 05:39:07 +00:00
tabs.Resize(fyne.NewSize(640, 480))
2020-05-09 04:29:30 +00:00
main := tabs
2020-05-01 05:39:07 +00:00
window.Resize(fyne.NewSize(640, 500))
2020-05-09 04:29:30 +00:00
mainMenu := fyne.NewMainMenu(fyne.NewMenu("File", fyne.NewMenuItem("Save", func() {
2020-06-06 13:04:48 +00:00
dialog.ShowFileSave(func(writer fyne.URIWriteCloser, err error) {
2020-05-01 05:39:07 +00:00
if err != nil {
dialog.ShowError(err, window)
return
}
2020-05-09 04:35:59 +00:00
if writer != nil {
2021-02-09 22:02:50 +00:00
orbweaver.SavePKMKeymap(omap, writer)
2020-05-09 04:35:59 +00:00
}
}, window)
}), fyne.NewMenuItem("Load", func() {
2020-06-06 13:04:48 +00:00
dialog.ShowFileOpen(func(reader fyne.URIReadCloser, err error) {
2020-05-01 05:39:07 +00:00
if err != nil {
dialog.ShowError(err, window)
return
}
2020-05-09 04:35:59 +00:00
if reader != nil {
2021-02-10 01:13:44 +00:00
setter(reflect.ValueOf(orbweaver.LoadPKMKeymap(reader)))
// pages["main"].SetBindings(omap)
// pages["side"].SetBindings(omap)
2020-05-09 04:35:59 +00:00
}
}, window)
2020-05-01 05:39:07 +00:00
})))
window.SetMainMenu(mainMenu)
2020-05-09 04:29:30 +00:00
2020-05-01 05:39:07 +00:00
window.SetContent(main)
window.ShowAndRun()
}