kemoforge/internal/KFEditor/Templates/CustomLayout/CustomLayout.got

39 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2024-06-26 01:08:19 +00:00
package CustomLayout
import (
"log"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"g.r-io.lu/shynd/kemoforge/pkg/KFData"
"g.r-io.lu/shynd/kemoforge/pkg/KFData/KFObjects/KFLayout"
)
// Import is a function used to allow importing of the custom layout package
// while still allowing the package to be used normally and not be yelled at by the compiler
func Import() {}
func init() {
log.Printf("Registering ExampleLayouts")
customLayout := KFLayout.Layout{
Type: "ExampleLayout",
RequiredArgs: KFData.NewNFInterfaceMap(),
OptionalArgs: KFData.NewNFInterfaceMap(),
}
customLayout.Register(ExampleLayoutHandler)
}
func ExampleLayoutHandler(window fyne.Window, _ *KFData.NFInterfaceMap, l *KFLayout.Layout) (fyne.CanvasObject, error) {
vbox := container.NewVBox()
vbox.Add(widget.NewLabel("Example Layout"))
for _, child := range l.Children {
parsedChild, err := child.Parse(window)
if err != nil {
return nil, err
}
vbox.Add(parsedChild)
}
return vbox, nil
}