127 lines
3.1 KiB
Go
127 lines
3.1 KiB
Go
package app
|
|
|
|
import (
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/app"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/layout"
|
|
"fyne.io/fyne/v2/theme"
|
|
"fyne.io/fyne/v2/widget"
|
|
|
|
"gitea.mmo.to/ProtocolPacketForger/ppf/internal/ui"
|
|
)
|
|
|
|
var fyneApp fyne.App
|
|
var w fyne.Window
|
|
|
|
func Appmain() {
|
|
fyneApp = app.New()
|
|
w = fyneApp.NewWindow("ProtocolPacketForger")
|
|
w.Resize(fyne.NewSize(800, 600))
|
|
|
|
w.SetContent(CreateApp())
|
|
|
|
w.ShowAndRun()
|
|
}
|
|
|
|
type ppfApp struct {
|
|
// Container for the borderlayout
|
|
Toolbar fyne.CanvasObject
|
|
Metadata *fyne.Container
|
|
Extensions *fyne.Container
|
|
ContextBar *fyne.Container
|
|
ContentTabs *fyne.Container
|
|
Workarea *fyne.Container
|
|
// Once initialized metadata containers for swapping
|
|
ProtocolMeta *fyne.Container
|
|
PacketMeta *fyne.Container
|
|
// Global important stuff
|
|
Settings map[string]string
|
|
ProtocolForging bool
|
|
// Once initialized instances of the editor views
|
|
EditorPacket *ui.PacketEditor
|
|
EditorProtocol *ui.ProtocolEditor
|
|
}
|
|
|
|
var ppf ppfApp
|
|
|
|
func CreateApp() *fyne.Container {
|
|
ppf.Toolbar = CreateToolbar()
|
|
ppf.Workarea = CreateWorkarea()
|
|
ppf.Extensions = container.NewCenter()
|
|
ppf.Metadata = container.NewCenter()
|
|
ppf.ContextBar = container.NewCenter()
|
|
|
|
return container.NewBorder(
|
|
ppf.Toolbar,
|
|
ppf.Metadata,
|
|
ppf.ContextBar,
|
|
ppf.Extensions,
|
|
container.NewVScroll(ppf.Workarea),
|
|
)
|
|
}
|
|
|
|
func CreateToolbar() fyne.CanvasObject {
|
|
toolbar := widget.NewToolbar()
|
|
toolbar.Append(widget.NewToolbarAction(theme.StorageIcon(), func() {
|
|
ppf.ProtocolForging = !ppf.ProtocolForging
|
|
//TODO: implement the switch
|
|
}))
|
|
toolbar.Append(widget.NewToolbarSeparator())
|
|
toolbar.Append(widget.NewToolbarAction(theme.FolderNewIcon(), func() {
|
|
|
|
}))
|
|
toolbar.Append(widget.NewToolbarAction(theme.FolderOpenIcon(), func() {
|
|
|
|
}))
|
|
toolbar.Append(widget.NewToolbarAction(theme.DocumentSaveIcon(), func() {
|
|
|
|
}))
|
|
toolbar.Append(widget.NewToolbarAction(theme.SettingsIcon(), func() {
|
|
|
|
}))
|
|
toolbar.Append(widget.NewToolbarSpacer())
|
|
toolbar.Append(widget.NewToolbarAction(theme.LogoutIcon(), func() {
|
|
fyneApp.Quit()
|
|
}))
|
|
|
|
return toolbar
|
|
}
|
|
|
|
func CreateWorkarea() *fyne.Container {
|
|
return ui.GetProtocolEditor().Representation
|
|
}
|
|
|
|
func CreateMetadataProtocol() *fyne.Container {
|
|
vbox := container.NewVBox()
|
|
vbox.Add(widget.NewLabel("Protocol Metadata"))
|
|
form := container.New(layout.NewFormLayout())
|
|
form.Add(widget.NewLabel("Name:"))
|
|
form.Add(widget.NewEntry())
|
|
form.Add(widget.NewLabel("Version:"))
|
|
form.Add(widget.NewEntry())
|
|
form.Add(widget.NewLabel("Extends:"))
|
|
form.Add(widget.NewEntry())
|
|
vbox.Add(form)
|
|
vbox.Add(widget.NewLabel("Description"))
|
|
multiline := widget.NewMultiLineEntry()
|
|
multiline.SetMinRowsVisible(3)
|
|
vbox.Add(multiline)
|
|
|
|
return vbox
|
|
}
|
|
|
|
func CreateMetadataPacket() *fyne.Container {
|
|
vbox := container.NewVBox()
|
|
vbox.Add(widget.NewLabel("Packet Metadata"))
|
|
form := container.New(layout.NewFormLayout())
|
|
form.Add(widget.NewLabel("Name:"))
|
|
form.Add(widget.NewEntry())
|
|
vbox.Add(form)
|
|
vbox.Add(widget.NewLabel("Description:"))
|
|
multiline := widget.NewMultiLineEntry()
|
|
multiline.SetMinRowsVisible(3)
|
|
vbox.Add(multiline)
|
|
return vbox
|
|
}
|