36 lines
791 B
Go
36 lines
791 B
Go
package ppf
|
|
|
|
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())
|
|
}
|