2023-04-11 16:05:24 +02:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fyne.io/fyne/v2"
|
|
|
|
"fyne.io/fyne/v2/container"
|
|
|
|
"fyne.io/fyne/v2/widget"
|
2023-05-12 09:10:24 +02:00
|
|
|
"gitea.mmo.to/ppForge/ppforge/packet"
|
2023-04-11 16:05:24 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type PacketFieldEditor struct {
|
|
|
|
Representation *fyne.Container
|
|
|
|
Value *widget.Entry
|
|
|
|
|
|
|
|
Reference *packet.FieldValue
|
|
|
|
|
|
|
|
GlobalIndex int
|
2023-04-12 15:14:19 +02:00
|
|
|
LayerIndex int
|
2023-04-11 16:05:24 +02:00
|
|
|
Index int
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreatePacketFieldEditor(
|
|
|
|
ed *PacketEditor,
|
|
|
|
gblidx int,
|
|
|
|
lyridx int,
|
|
|
|
index int,
|
|
|
|
ref *packet.FieldValue,
|
|
|
|
) *PacketFieldEditor {
|
|
|
|
pfe := &PacketFieldEditor{}
|
|
|
|
pfe.Reference = ref
|
|
|
|
pfe.Index = index
|
2023-04-12 15:14:19 +02:00
|
|
|
pfe.LayerIndex = lyridx
|
2023-04-11 16:05:24 +02:00
|
|
|
pfe.GlobalIndex = gblidx
|
|
|
|
|
|
|
|
setfunc := func(s string) {
|
|
|
|
//todo
|
2023-10-30 22:51:13 +01:00
|
|
|
//ed.Reference.UpdateField(&ed.Reference.Layers[lyridx], index, packet.NewFieldValue(s))
|
2023-04-11 16:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
elements := []fyne.CanvasObject{}
|
|
|
|
|
2023-09-17 12:49:41 +02:00
|
|
|
elements = append(elements, widget.NewLabel("TODO"))
|
2023-04-11 16:05:24 +02:00
|
|
|
if ed.ShowShortHints {
|
2023-09-17 12:49:41 +02:00
|
|
|
elements = append(elements, widget.NewLabel("TODO")) // todo: implement real shorthints if feasible
|
2023-04-11 16:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// depending on the input stuff, entry for now
|
|
|
|
pfe.Value = widget.NewEntry()
|
|
|
|
pfe.Value.OnChanged = setfunc
|
|
|
|
|
|
|
|
elements = append(elements, pfe.Value)
|
|
|
|
|
|
|
|
pfe.Representation = container.NewHBox(elements...)
|
|
|
|
return pfe
|
|
|
|
}
|