Write central application struct
After prototyping phase of the editor parts it's now time to build up the app properly.
This commit is contained in:
parent
755be5f962
commit
de7306b8f0
110
app.go
110
app.go
|
@ -4,53 +4,119 @@ import (
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/layout"
|
||||||
|
"fyne.io/fyne/v2/theme"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var fyneApp fyne.App
|
||||||
|
|
||||||
func Appmain() {
|
func Appmain() {
|
||||||
a := app.New()
|
fyneApp := app.New()
|
||||||
w := a.NewWindow("ProtocolPacketForger")
|
w := fyneApp.NewWindow("ProtocolPacketForger")
|
||||||
w.Resize(fyne.NewSize(800, 600))
|
w.Resize(fyne.NewSize(800, 600))
|
||||||
|
|
||||||
hello := widget.NewLabel("Hello Fyne!")
|
w.SetContent(CreateApp())
|
||||||
w.SetContent(container.NewBorder(
|
|
||||||
hello,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
container.NewVScroll(GetProtocolEditor().Representation),
|
|
||||||
// widget.NewButton("Hi!", func() {
|
|
||||||
// hello.SetText("Welcome :)")
|
|
||||||
// }),
|
|
||||||
))
|
|
||||||
|
|
||||||
w.ShowAndRun()
|
w.ShowAndRun()
|
||||||
}
|
}
|
||||||
|
|
||||||
type ppfApp struct {
|
type ppfApp struct {
|
||||||
Toolbar *fyne.Container
|
// Container for the borderlayout
|
||||||
|
Toolbar fyne.CanvasObject
|
||||||
Metadata *fyne.Container
|
Metadata *fyne.Container
|
||||||
Extensions *fyne.Container
|
Extensions *fyne.Container
|
||||||
ContextBar *fyne.Container
|
ContextBar *fyne.Container
|
||||||
Workarea *fyne.Container
|
Workarea *fyne.Container
|
||||||
|
// Once initialized metadata containers for swapping
|
||||||
|
ProtocolMeta *fyne.Container
|
||||||
|
PacketMeta *fyne.Container
|
||||||
|
// Global important stuff
|
||||||
Settings map[string]string
|
Settings map[string]string
|
||||||
ProtocolForging bool
|
ProtocolForging bool
|
||||||
|
// Once initialized instances of the editor views
|
||||||
|
EditorPacket *PacketEditor
|
||||||
|
EditorProtocol *ProtocolEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
var application ppfApp
|
var ppf ppfApp
|
||||||
|
|
||||||
func CreateApp() *fyne.Container {
|
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(
|
return container.NewBorder(
|
||||||
application.Toolbar,
|
ppf.Toolbar,
|
||||||
application.Metadata,
|
ppf.Metadata,
|
||||||
application.ContextBar,
|
ppf.ContextBar,
|
||||||
application.Extensions,
|
ppf.Extensions,
|
||||||
container.NewVScroll(application.Workarea),
|
container.NewVScroll(ppf.Workarea),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateToolbar() *fyne.Container {
|
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() {
|
||||||
|
|
||||||
return nil
|
}))
|
||||||
|
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 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
|
||||||
}
|
}
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -6,6 +6,7 @@ require fyne.io/fyne/v2 v2.2.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93 // indirect
|
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93 // indirect
|
||||||
|
fyne.io/x/fyne v0.0.0-20221121180555-92e65f302337 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3 // indirect
|
github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||||
|
|
7
go.sum
7
go.sum
|
@ -41,6 +41,9 @@ fyne.io/fyne/v2 v2.2.4 h1:izyiDUjJYAB7B/MST7M9GDs+mQ0CwDgRZTiVJZQoEe4=
|
||||||
fyne.io/fyne/v2 v2.2.4/go.mod h1:MBoGuHzLLSXdQOWFAwWhIhYTEMp33zqtGCReSWhaQTA=
|
fyne.io/fyne/v2 v2.2.4/go.mod h1:MBoGuHzLLSXdQOWFAwWhIhYTEMp33zqtGCReSWhaQTA=
|
||||||
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93 h1:V2IC9t0Zj9Ur6qDbfhUuzVmIvXKFyxZXRJyigUvovs4=
|
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93 h1:V2IC9t0Zj9Ur6qDbfhUuzVmIvXKFyxZXRJyigUvovs4=
|
||||||
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93/go.mod h1:oM2AQqGJ1AMo4nNqZFYU8xYygSBZkW2hmdJ7n4yjedE=
|
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93/go.mod h1:oM2AQqGJ1AMo4nNqZFYU8xYygSBZkW2hmdJ7n4yjedE=
|
||||||
|
fyne.io/x/fyne v0.0.0-20221121180555-92e65f302337 h1:pmI4fpk16hb9sZWlO9FUmtixQ8t8bKShYxn7HJLMlpA=
|
||||||
|
fyne.io/x/fyne v0.0.0-20221121180555-92e65f302337/go.mod h1:tInTkLEiYNhEYq8s4UbnpINBg/W6mqU0ArbuuJszd3s=
|
||||||
|
github.com/Andrew-M-C/go.jsonvalue v1.1.2-0.20211223013816-e873b56b4a84/go.mod h1:oTJGG91FhtsxvUFVwHSvr6zuaTcAuroj/ToxfT7Ox8U=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
|
@ -66,6 +69,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
|
@ -166,6 +170,7 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20211219123610-ec9572f70e60/go.mod h1:cz9oNYuRUWGdHmLF2IodMLkAhcPtXeULvcBNagUrxTI=
|
github.com/gopherjs/gopherjs v0.0.0-20211219123610-ec9572f70e60/go.mod h1:cz9oNYuRUWGdHmLF2IodMLkAhcPtXeULvcBNagUrxTI=
|
||||||
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
|
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
|
||||||
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
|
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
|
||||||
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/goxjs/gl v0.0.0-20210104184919-e3fafc6f8f2a/go.mod h1:dy/f2gjY09hwVfIyATps4G2ai7/hLwLkc5TrPqONuXY=
|
github.com/goxjs/gl v0.0.0-20210104184919-e3fafc6f8f2a/go.mod h1:dy/f2gjY09hwVfIyATps4G2ai7/hLwLkc5TrPqONuXY=
|
||||||
github.com/goxjs/glfw v0.0.0-20191126052801-d2efb5f20838/go.mod h1:oS8P8gVOT4ywTcjV6wZlOU4GuVFQ8F5328KY3MJ79CY=
|
github.com/goxjs/glfw v0.0.0-20191126052801-d2efb5f20838/go.mod h1:oS8P8gVOT4ywTcjV6wZlOU4GuVFQ8F5328KY3MJ79CY=
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||||
|
@ -274,6 +279,7 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69
|
||||||
github.com/tevino/abool v1.2.0 h1:heAkClL8H6w+mK5md9dzsuohKeXHUpY7Vw0ZCKW+huA=
|
github.com/tevino/abool v1.2.0 h1:heAkClL8H6w+mK5md9dzsuohKeXHUpY7Vw0ZCKW+huA=
|
||||||
github.com/tevino/abool v1.2.0/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg=
|
github.com/tevino/abool v1.2.0/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg=
|
||||||
github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg=
|
github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg=
|
||||||
|
github.com/wagslane/go-password-validator v0.3.0/go.mod h1:TI1XJ6T5fRdRnHqHt14pvy1tNVnrwe7m3/f1f2fDphQ=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
@ -363,6 +369,7 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
|
Loading…
Reference in New Issue