package ui import ( "fmt" "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" "gitea.mmo.to/ppForge/ppforge/packet" "gitea.mmo.to/ppForge/ppforge/packetctl" ) type PacketEditor struct { Representation *fyne.Container FieldContainer *fyne.Container Metadata *PacketMetadata Fields []*PacketFieldEditor ShowShortHints bool Reference *packet.Packet } func NewPacketEditor(ref *packet.Packet) *PacketEditor { metadata := NewMetadataPacket() fields := container.NewGridWrap(fyne.NewSize(300, 200)) container := container.NewBorder(nil, nil, metadata.Representation, nil, container.NewVScroll(fields)) packetEditor := &PacketEditor{container, fields, metadata, []*PacketFieldEditor{}, false, ref} packetEditor.Redraw() return packetEditor } func (ed *PacketEditor) Redraw() { json := packetctl.ToJson(ed.Reference) fmt.Printf("%s\n", json) ed.FieldContainer.RemoveAll() // existing fields k := 0 for i, v := range ed.Reference.Layers { for j, vv := range v.Values { ed.FieldContainer.Add(CreatePacketFieldEditor(ed, k, i, j, &vv).Representation) k++ } } // metadata //ed.Metadata.SetPacket(ed.Reference) }