2
0
mirror of https://github.com/OrbTools/OrbBind synced 2024-11-15 12:13:00 +00:00
OrbBind/orbbind.go

57 lines
1.5 KiB
Go
Raw Normal View History

//go:generate boxy
package main
import (
"fyne.io/fyne"
"fyne.io/fyne/app"
"fyne.io/fyne/dialog"
"fyne.io/fyne/widget"
2020-03-26 22:59:43 +00:00
"github.com/minizbot2012/orbbind/keymap/orbweaver"
2020-05-01 05:39:07 +00:00
"github.com/minizbot2012/orbbind/ui/baseui"
2020-03-26 22:59:43 +00:00
"github.com/minizbot2012/orbbind/ui/mainpage"
2020-04-15 22:56:04 +00:00
"github.com/minizbot2012/orbbind/ui/sidepage"
)
func main() {
ap := app.NewWithID("com.minizbot2012.orbbind")
window := ap.NewWindow("Orbweaver Rebinding")
2020-05-01 05:39:07 +00:00
window.SetMaster()
omap := &orbweaver.PKM{}
2020-05-01 05:39:07 +00:00
pages := make(map[string]baseui.PageWithBindings)
pages["main"] = mainpage.NewMainPage(window, omap)
pages["side"] = sidepage.NewSidePage(window, omap)
tabs := widget.NewTabContainer(pages["main"].Create(), pages["side"].Create())
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-05-01 05:39:07 +00:00
dialog.ShowFileSave(func(writer fyne.FileWriteCloser, err error) {
if err != nil {
dialog.ShowError(err, window)
return
}
2020-05-09 04:35:59 +00:00
if writer != nil {
orbweaver.SaveIntoKeymap(omap, writer)
}
}, window)
}), fyne.NewMenuItem("Load", func() {
2020-05-01 05:39:07 +00:00
dialog.ShowFileOpen(func(reader fyne.FileReadCloser, err error) {
if err != nil {
dialog.ShowError(err, window)
return
}
2020-05-09 04:35:59 +00:00
if reader != nil {
omap = orbweaver.LoadFile(reader)
pages["main"].SetBindings(omap)
pages["side"].SetBindings(omap)
}
}, 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()
}