Gallery: composite demos

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 13:13:47 -04:00
1 parent 215733e3f4
commit 746c776be3
7 files changed
+970 -1

No files matched your search

+12 -1
View File
@@ -33,13 +33,18 @@ type gallery struct {
events []event
scrolls map[string]*ui.ScrollState
overture overtureState
// Composition state lives here so it survives page switches.
cSettings settingsDemo
cFiles filesDemo
cForm formSubmitDemo
}
// densities maps the density control's segments to theme densities.
var densities = []theme.Density{theme.Compact, theme.Default, theme.Comfortable}
func newGallery() *gallery {
g := &gallery{pages: catalog(), byID: map[string]int{}, selected: overtureID, density: 1, scrolls: map[string]*ui.ScrollState{}}
g := &gallery{pages: catalog(), byID: map[string]int{}, selected: overtureID, density: 1, scrolls: map[string]*ui.ScrollState{},
cSettings: newSettingsDemo(), cFiles: newFilesDemo(), cForm: newFormSubmitDemo()}
for i, p := range g.pages {
if _, dup := g.byID[p.ID]; dup {
panic("gallery: duplicate page " + p.ID)
@@ -138,6 +143,12 @@ func (g *gallery) content(c *ui.Context) {
switch g.selected {
case overtureID:
g.overturePage(c)
case settingsID:
g.compositePage(c, settingsID, g.settingsView)
case filesID:
g.compositePage(c, filesID, g.filesView)
case formID:
g.compositePage(c, formID, g.formView)
default:
i, ok := g.byID[g.selected]
if !ok {