diff --git a/go.mod b/go.mod index 2b2ff02..a6faeec 100644 --- a/go.mod +++ b/go.mod @@ -2,14 +2,10 @@ module gitea.mmo.to/ProtocolPacketForger/ppf go 1.19 -require ( - fyne.io/fyne/v2 v2.2.4 - github.com/spf13/viper v1.10.1 -) +require fyne.io/fyne/v2 v2.2.4 require ( 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/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect @@ -30,7 +26,7 @@ require ( github.com/yuin/goldmark v1.4.0 // indirect golang.org/x/image v0.0.0-20220601225756-64ec528b34cd // indirect golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect - golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d // indirect + golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect golang.org/x/text v0.3.7 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index a16dfb0..00fdfc8 100644 --- a/go.sum +++ b/go.sum @@ -41,9 +41,6 @@ fyne.io/fyne/v2 v2.2.4 h1:izyiDUjJYAB7B/MST7M9GDs+mQ0CwDgRZTiVJZQoEe4= 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/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 v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -69,7 +66,6 @@ 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.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 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.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -170,7 +166,6 @@ 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 v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g= 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/glfw v0.0.0-20191126052801-d2efb5f20838/go.mod h1:oS8P8gVOT4ywTcjV6wZlOU4GuVFQ8F5328KY3MJ79CY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= @@ -279,7 +274,6 @@ 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/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg= 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.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -369,7 +363,6 @@ 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-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-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-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= @@ -385,8 +378,9 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d h1:20cMwl2fHAzkJMEA+8J4JgqBQcQGzbisXo31MIeenXI= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/internal/app/app.go b/internal/app/app.go index e0a6e63..e2b2dc9 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -12,10 +12,11 @@ import ( ) var fyneApp fyne.App +var w fyne.Window func Appmain() { - fyneApp := app.New() - w := fyneApp.NewWindow("ProtocolPacketForger") + fyneApp = app.New() + w = fyneApp.NewWindow("ProtocolPacketForger") w.Resize(fyne.NewSize(800, 600)) w.SetContent(CreateApp()) @@ -25,11 +26,12 @@ func Appmain() { type ppfApp struct { // Container for the borderlayout - Toolbar fyne.CanvasObject - Metadata *fyne.Container - Extensions *fyne.Container - ContextBar *fyne.Container - Workarea *fyne.Container + 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 diff --git a/internal/ui/fieldadd.go b/internal/ui/fieldadd.go index b24bb80..a2d998c 100644 --- a/internal/ui/fieldadd.go +++ b/internal/ui/fieldadd.go @@ -4,13 +4,9 @@ import ( "fyne.io/fyne/v2/widget" ) -var fieldAdder *widget.Button - -func GetAdder() *widget.Button { - if fieldAdder == nil { - fieldAdder = widget.NewButton("Add Field", func() { - protocolEditor.AddFieldCreator(CreateFieldCreator()) - }) - } +func GetAdder(pEd *ProtocolEditor) *widget.Button { + fieldAdder := widget.NewButton("Add Field", func() { + pEd.AddFieldCreator(CreateFieldEditor()) + }) return fieldAdder } diff --git a/internal/ui/fieldcreator.go b/internal/ui/fieldeditor.go similarity index 88% rename from internal/ui/fieldcreator.go rename to internal/ui/fieldeditor.go index b8add78..34edf89 100644 --- a/internal/ui/fieldcreator.go +++ b/internal/ui/fieldeditor.go @@ -5,9 +5,10 @@ import ( "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/widget" + "gitea.mmo.to/ProtocolPacketForger/ppf/protocol" ) -type FieldCreator struct { +type FieldEditor struct { Representation *fyne.Container NameValue *widget.Entry DescValue *widget.Entry @@ -16,10 +17,12 @@ type FieldCreator struct { SizeValue *widget.Entry SizeInBits bool // to be filled with needed things + + Reference *protocol.Field } -func CreateFieldCreator() *FieldCreator { - fc := &FieldCreator{} +func CreateFieldEditor() *FieldEditor { + fc := &FieldEditor{} fc.Representation = container.New(layout.NewFormLayout()) fc.Representation.Add(widget.NewLabel("")) diff --git a/internal/ui/protocoleditor.go b/internal/ui/protocoleditor.go index 5add203..5ab4d1b 100644 --- a/internal/ui/protocoleditor.go +++ b/internal/ui/protocoleditor.go @@ -3,33 +3,33 @@ package ui import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" + "gitea.mmo.to/ProtocolPacketForger/ppf/protocol" + "gitea.mmo.to/ProtocolPacketForger/ppf/protocolctl" ) type ProtocolEditor struct { Representation *fyne.Container - Creators []*FieldCreator + Fields []*FieldEditor + + Reference *protocol.ProtocolStructure } -var protocolEditor *ProtocolEditor - func GetProtocolEditor() *ProtocolEditor { - if protocolEditor == nil { - container := container.NewGridWrap(fyne.NewSize(300, 300)) - protocolEditor = &ProtocolEditor{container, []*FieldCreator{}} - container.Add(GetAdder()) - } + container := container.NewGridWrap(fyne.NewSize(300, 300)) + protocolEditor := &ProtocolEditor{container, []*FieldEditor{}, protocolctl.NewProtocolStructure()} + container.Add(GetAdder(protocolEditor)) return protocolEditor } -func (ed *ProtocolEditor) AddFieldCreator(fieldCreator *FieldCreator) { - ed.Creators = append(protocolEditor.Creators, fieldCreator) +func (ed *ProtocolEditor) AddFieldCreator(fieldCreator *FieldEditor) { + ed.Fields = append(ed.Fields, fieldCreator) ed.Redraw() } func (ed *ProtocolEditor) Redraw() { ed.Representation.RemoveAll() - for _, v := range ed.Creators { + for _, v := range ed.Fields { ed.Representation.Add(v.Representation) } - ed.Representation.Add(GetAdder()) + ed.Representation.Add(GetAdder(ed)) }