ppforge/fieldcreator.go

57 lines
1.4 KiB
Go
Raw Normal View History

2022-11-25 11:36:29 +01:00
package ppf
2022-11-23 20:33:07 +01:00
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
)
type FieldCreator struct {
Representation *fyne.Container
NameValue *widget.Entry
DescValue *widget.Entry
RegExValue *widget.Entry
2022-11-24 21:49:10 +01:00
SizeLabel *widget.Label
SizeValue *widget.Entry
SizeInBits bool
2022-11-23 20:33:07 +01:00
// to be filled with needed things
}
func CreateFieldCreator() *FieldCreator {
fc := &FieldCreator{}
2022-11-24 21:49:10 +01:00
fc.Representation = container.New(layout.NewFormLayout())
fc.Representation.Add(widget.NewLabel(""))
fc.Representation.Add(widget.NewLabel("Field Values"))
2022-11-23 20:33:07 +01:00
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()
2022-11-24 21:49:10 +01:00
fc.DescValue.MultiLine = true
fc.DescValue.SetMinRowsVisible(3)
2022-11-23 20:33:07 +01:00
fc.Representation.Add(fc.DescValue)
fc.Representation.Add(widget.NewLabel("RegEx"))
fc.RegExValue = widget.NewEntry()
fc.Representation.Add(fc.RegExValue)
2022-11-24 21:49:10 +01:00
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)
2022-11-23 20:33:07 +01:00
return fc
}