123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- package main
- import (
- "fmt"
- "fyne.io/fyne/v2"
- "fyne.io/fyne/v2/app"
- "fyne.io/fyne/v2/container"
- "fyne.io/fyne/v2/dialog"
- "fyne.io/fyne/v2/driver/desktop"
- "fyne.io/fyne/v2/widget"
- )
- var APP fyne.App
- var HOME fyne.Window
- func SetupApp() {
- APP = app.NewWithID("apollox.endless-edit")
- HOME = APP.NewWindow("Endless Edit")
- HOME.CenterOnScreen()
- HOME.Resize(fyne.NewSize(1000, 800))
- }
- func SetupHome() {
- if HOME == nil {
- return
- }
- meta := APP.Metadata()
- // Assign short cuts
- new_short := &desktop.CustomShortcut{
- fyne.KeyN,
- fyne.KeyModifierControl,
- }
- open_short := &desktop.CustomShortcut{
- fyne.KeyO,
- fyne.KeyModifierControl,
- }
- save_short := &desktop.CustomShortcut{
- fyne.KeyS,
- fyne.KeyModifierControl,
- }
- about_short := &desktop.CustomShortcut{
- fyne.KeyH,
- fyne.KeyModifierControl,
- }
- quit_short := &desktop.CustomShortcut{
- fyne.KeyQ,
- fyne.KeyModifierControl,
- }
- // For now most stuff just prints out into the terminal/console what we clicked (except about and quit)
- file_new := fyne.NewMenuItem("New", func() { // CTRL + N
- fmt.Println("File>New")
- })
- file_new.Shortcut = new_short
- file_open := fyne.NewMenuItem("Open", func() { // CTRL + O
- fmt.Println("File>Open")
- })
- file_open.Shortcut = open_short
- file_save := fyne.NewMenuItem("Save", func() { // CTRL + S
- fmt.Println("File>Save")
- })
- file_save.Shortcut = save_short
- showing_about := false
- about := func() {
- d := dialog.NewCustom("About - Endless Edit", "Close", container.NewVBox(
- container.NewGridWithColumns(2,
- widget.NewLabel("Endless Edit"), widget.NewLabel(meta.Version),
- widget.NewLabel("Apollo"), widget.NewLabel("© 2022"),
- ),
- ), HOME)
- d.SetOnClosed(func() {
- if showing_about {
- showing_about = false
- }
- })
- if !showing_about {
- showing_about = true
- d.Show()
- }
- }
- file_about := fyne.NewMenuItem("About", about) // CTRL + H
- file_about.Shortcut = about_short
- file_quit := fyne.NewMenuItem("Quit", func() { // CTRL + Q
- APP.Quit()
- })
- file_quit.Shortcut = quit_short
- file := fyne.NewMenu("File",
- file_new,
- file_open,
- file_save,
- fyne.NewMenuItemSeparator(),
- file_about,
- file_quit,
- )
- HOME.Canvas().AddShortcut(new_short, func(shortcut fyne.Shortcut) {
- fmt.Println("File>New (Via Shortcut)")
- })
- HOME.Canvas().AddShortcut(quit_short, func(shortcut fyne.Shortcut) {
- APP.Quit()
- })
- HOME.Canvas().AddShortcut(open_short, func(shortcut fyne.Shortcut) {
- fmt.Println("File>Open (Via Shortcut)")
- })
- HOME.Canvas().AddShortcut(save_short, func(shortcut fyne.Shortcut) {
- fmt.Println("File>Save (Via Shortcut)")
- })
- HOME.Canvas().AddShortcut(about_short, func(shortcut fyne.Shortcut) {
- about()
- })
- HOME.SetMainMenu(fyne.NewMainMenu(
- file,
- fyne.NewMenu("Edit", // This will most likely become AppTabs instead (as we'll be editing Profile, Account, Conditions and Ships)
- fyne.NewMenuItem("Profile", func() {
- fmt.Println("Edit>Profile")
- }),
- fyne.NewMenuItem("Ships", func() {
- fmt.Println("Edit>Ships")
- }),
- fyne.NewMenuItem("Account", func() {
- fmt.Println("Edit>Account")
- }),
- ),
- ))
- }
|