package ui import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" ) type NewObjectDialog struct { representation *fyne.Container // views selection *fyne.Container // 4buttons grid protocolChooser *container.AppTabs packetChooser *fyne.Container } var pnod *NewObjectDialog func CreateNewObjectDialog() *NewObjectDialog { if pnod == nil { pnod = &NewObjectDialog{} pnod.representation = container.NewMax(nil) // representation // grid layout 100x100px elements in a center layout, 4 buttons, new Protocol, edit protocol, new Packet, edit Packet buttons := []widget.Button{} buttons = append(buttons, *widget.NewButton("New protocol", func() { PPF.NewProtocolFile() })) buttons = append(buttons, *widget.NewButton("Open/Edit protocol", func() { pnod.representation.RemoveAll() pnod.representation.Add(pnod.protocolChooser) })) buttons = append(buttons, *widget.NewButton("New packet", func() { PPF.NewPacketFile() })) buttons = append(buttons, *widget.NewButton("Open/Edit packet", func() { pnod.representation.RemoveAll() pnod.representation.Add(pnod.packetChooser) })) selectgrid := container.NewGridWithColumns(2, nil) for _, v := range buttons { selectgrid.Add(&v) } pnod.selection = container.NewMax(selectgrid) pnod.representation.Add(pnod.selection) // add selection per default // generate protocol chooser view // App Tabs or vertical Accordion (doesnt exist yet) pnod.protocolChooser = container.NewAppTabs(nil) // first tab -> official protocol repo, for viewing and editing/improvement // file chooser embedded // second tab -> own protocols, in a folder somewhere. // file chooser embedded // generate packet chooser view // Just a file chooser embedded. // data } return pnod } func (nod *NewObjectDialog) Representation() *fyne.Container { return nod.representation } func (nod *NewObjectDialog) Refresh() { }