2023-01-03 13:34:32 +01:00
|
|
|
package ui
|
2022-11-24 21:49:10 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fyne.io/fyne/v2"
|
|
|
|
"fyne.io/fyne/v2/container"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ProtocolEditor struct {
|
|
|
|
Representation *fyne.Container
|
|
|
|
Creators []*FieldCreator
|
|
|
|
}
|
|
|
|
|
|
|
|
var protocolEditor *ProtocolEditor
|
|
|
|
|
|
|
|
func GetProtocolEditor() *ProtocolEditor {
|
|
|
|
if protocolEditor == nil {
|
|
|
|
container := container.NewGridWrap(fyne.NewSize(300, 300))
|
|
|
|
protocolEditor = &ProtocolEditor{container, []*FieldCreator{}}
|
|
|
|
container.Add(GetAdder())
|
|
|
|
}
|
|
|
|
return protocolEditor
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ed *ProtocolEditor) AddFieldCreator(fieldCreator *FieldCreator) {
|
|
|
|
ed.Creators = append(protocolEditor.Creators, fieldCreator)
|
|
|
|
ed.Redraw()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ed *ProtocolEditor) Redraw() {
|
|
|
|
ed.Representation.RemoveAll()
|
|
|
|
for _, v := range ed.Creators {
|
|
|
|
ed.Representation.Add(v.Representation)
|
|
|
|
}
|
|
|
|
ed.Representation.Add(GetAdder())
|
|
|
|
}
|