60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package ui
|
|
|
|
import (
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/layout"
|
|
"fyne.io/fyne/v2/widget"
|
|
"gitea.mmo.to/ProtocolPacketForger/ppf/protocol"
|
|
)
|
|
|
|
type FieldEditor struct {
|
|
Representation *fyne.Container
|
|
NameValue *widget.Entry
|
|
DescValue *widget.Entry
|
|
RegExValue *widget.Entry
|
|
SizeLabel *widget.Label
|
|
SizeValue *widget.Entry
|
|
SizeInBits bool
|
|
// to be filled with needed things
|
|
|
|
Reference *protocol.Field
|
|
}
|
|
|
|
func CreateFieldEditor() *FieldEditor {
|
|
fc := &FieldEditor{}
|
|
fc.Representation = container.New(layout.NewFormLayout())
|
|
|
|
fc.Representation.Add(widget.NewLabel(""))
|
|
fc.Representation.Add(widget.NewLabel("Field Values"))
|
|
|
|
fc.Representation.Add(widget.NewLabel("Name"))
|
|
fc.NameValue = widget.NewEntry()
|
|
fc.Representation.Add(fc.NameValue)
|
|
|
|
fc.Representation.Add(widget.NewLabel("Description"))
|
|
fc.DescValue = widget.NewEntry()
|
|
fc.DescValue.MultiLine = true
|
|
fc.DescValue.SetMinRowsVisible(3)
|
|
fc.Representation.Add(fc.DescValue)
|
|
|
|
fc.Representation.Add(widget.NewLabel("RegEx"))
|
|
fc.RegExValue = widget.NewEntry()
|
|
fc.Representation.Add(fc.RegExValue)
|
|
|
|
fc.SizeLabel = widget.NewLabel("Bytes")
|
|
|
|
toggleBtn := widget.NewButton("T", func() {
|
|
if fc.SizeInBits {
|
|
fc.SizeLabel.SetText("Bytes")
|
|
} else {
|
|
fc.SizeLabel.SetText("Bits")
|
|
}
|
|
fc.SizeInBits = !fc.SizeInBits
|
|
})
|
|
fc.Representation.Add(container.NewHBox(toggleBtn, fc.SizeLabel))
|
|
fc.SizeValue = widget.NewEntry()
|
|
fc.Representation.Add(fc.SizeValue)
|
|
return fc
|
|
}
|