Files
AynaLivePlayer/gui/config_layout.go
Aynakeya 5cc5948a85 Merge 1.0.x branch (#8)
* rewrite

* update submodule

* make width height configurable

* update dependency

* update

* update file

* update dep

* fix basic config layout

* update plugin management

* more stuff

* add blacklist

* fix todo

* fix windows gethandle

* update windows update guide

* update windows build guide

* include go mod tidy in script

* update todo

* fix source session

* fix text output

* add plugin play duration control

* fix id diange not working

* update todo

* update version number
2024-04-22 21:21:02 -07:00

55 lines
1.4 KiB
Go

package gui
import (
"AynaLivePlayer/gui/component"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
var ConfigList = []ConfigLayout{
&bascicConfig{},
}
type ConfigLayout interface {
Title() string
Description() string
CreatePanel() fyne.CanvasObject
}
func AddConfigLayout(cfgs ...ConfigLayout) {
ConfigList = append(ConfigList, cfgs...)
}
func createConfigLayout() fyne.CanvasObject {
// initialize config panels
for _, c := range ConfigList {
c.CreatePanel()
}
content := container.NewMax()
entryList := widget.NewList(
func() int {
return len(ConfigList)
},
func() fyne.CanvasObject {
return widget.NewLabel("")
},
func(id widget.ListItemID, object fyne.CanvasObject) {
object.(*widget.Label).SetText(ConfigList[id].Title())
})
entryList.OnSelected = func(id widget.ListItemID) {
desc := widget.NewRichTextFromMarkdown("## " + ConfigList[id].Title() + " \n\n" + ConfigList[id].Description())
for i := range desc.Segments {
if seg, ok := desc.Segments[i].(*widget.TextSegment); ok {
seg.Style.Alignment = fyne.TextAlignCenter
}
}
content.Objects = []fyne.CanvasObject{
container.NewVScroll(container.NewBorder(container.NewVBox(desc, widget.NewSeparator()), nil, nil, nil, ConfigList[id].CreatePanel())),
}
content.Refresh()
}
return component.NewFixedSplitContainer(entryList, content, true, 0.23)
}