2023-01-03 13:34:32 +01:00
|
|
|
package app
|
2022-11-23 20:33:07 +01:00
|
|
|
|
|
|
|
import (
|
2022-11-24 21:49:10 +01:00
|
|
|
"fyne.io/fyne/v2"
|
2022-11-23 20:33:07 +01:00
|
|
|
"fyne.io/fyne/v2/app"
|
|
|
|
"fyne.io/fyne/v2/container"
|
2022-11-25 14:35:51 +01:00
|
|
|
"fyne.io/fyne/v2/layout"
|
|
|
|
"fyne.io/fyne/v2/theme"
|
2022-11-23 20:33:07 +01:00
|
|
|
"fyne.io/fyne/v2/widget"
|
2023-01-03 13:34:32 +01:00
|
|
|
|
|
|
|
"gitea.mmo.to/ProtocolPacketForger/ppf/internal/ui"
|
2022-11-23 20:33:07 +01:00
|
|
|
)
|
|
|
|
|
2022-11-25 14:35:51 +01:00
|
|
|
var fyneApp fyne.App
|
2023-01-03 15:44:52 +01:00
|
|
|
var w fyne.Window
|
2022-11-25 14:35:51 +01:00
|
|
|
|
2022-11-23 20:33:07 +01:00
|
|
|
func Appmain() {
|
2023-01-03 15:44:52 +01:00
|
|
|
fyneApp = app.New()
|
|
|
|
w = fyneApp.NewWindow("ProtocolPacketForger")
|
2022-11-24 21:49:10 +01:00
|
|
|
w.Resize(fyne.NewSize(800, 600))
|
2022-11-23 20:33:07 +01:00
|
|
|
|
2022-11-25 14:35:51 +01:00
|
|
|
w.SetContent(CreateApp())
|
2022-11-23 20:33:07 +01:00
|
|
|
|
|
|
|
w.ShowAndRun()
|
|
|
|
}
|
2022-11-25 11:36:29 +01:00
|
|
|
|
|
|
|
type ppfApp struct {
|
2022-11-25 14:35:51 +01:00
|
|
|
// Container for the borderlayout
|
2023-01-03 15:44:52 +01:00
|
|
|
Toolbar fyne.CanvasObject
|
|
|
|
Metadata *fyne.Container
|
|
|
|
Extensions *fyne.Container
|
|
|
|
ContextBar *fyne.Container
|
|
|
|
ContentTabs *fyne.Container
|
|
|
|
Workarea *fyne.Container
|
2022-11-25 14:35:51 +01:00
|
|
|
// Once initialized metadata containers for swapping
|
|
|
|
ProtocolMeta *fyne.Container
|
|
|
|
PacketMeta *fyne.Container
|
|
|
|
// Global important stuff
|
2022-11-25 11:36:29 +01:00
|
|
|
Settings map[string]string
|
|
|
|
ProtocolForging bool
|
2022-11-25 14:35:51 +01:00
|
|
|
// Once initialized instances of the editor views
|
2023-01-03 13:34:32 +01:00
|
|
|
EditorPacket *ui.PacketEditor
|
|
|
|
EditorProtocol *ui.ProtocolEditor
|
2022-11-25 11:36:29 +01:00
|
|
|
}
|
|
|
|
|
2022-11-25 14:35:51 +01:00
|
|
|
var ppf ppfApp
|
2022-11-25 11:36:29 +01:00
|
|
|
|
|
|
|
func CreateApp() *fyne.Container {
|
2022-11-25 14:35:51 +01:00
|
|
|
ppf.Toolbar = CreateToolbar()
|
|
|
|
ppf.Workarea = CreateWorkarea()
|
|
|
|
ppf.Extensions = container.NewCenter()
|
|
|
|
ppf.Metadata = container.NewCenter()
|
|
|
|
ppf.ContextBar = container.NewCenter()
|
2022-11-25 11:36:29 +01:00
|
|
|
|
|
|
|
return container.NewBorder(
|
2022-11-25 14:35:51 +01:00
|
|
|
ppf.Toolbar,
|
|
|
|
ppf.Metadata,
|
|
|
|
ppf.ContextBar,
|
|
|
|
ppf.Extensions,
|
|
|
|
container.NewVScroll(ppf.Workarea),
|
2022-11-25 11:36:29 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-11-25 14:35:51 +01:00
|
|
|
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 {
|
2023-01-03 13:34:32 +01:00
|
|
|
return ui.GetProtocolEditor().Representation
|
2022-11-25 14:35:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2022-11-25 11:36:29 +01:00
|
|
|
|
2022-11-25 14:35:51 +01:00
|
|
|
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
|
2022-11-25 11:36:29 +01:00
|
|
|
}
|