Manager.Set and Manager.All
ci/woodpecker/push/woodpecker Pipeline was successful

Set is the deliberate overwrite: it replaces a registered entry in place,
keeping its position in the insertion order, and falls back to Register
when the name is new. Register keeps panicking on duplicates.

All returns every entry in insertion order; orderedWidgets is now just
that call, and reversedWidgets builds on it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-30 09:50:28 +02:00
co-authored by Claude Opus 5
parent f9745e4266
commit 08f15a7e3d
3 changed files with 33 additions and 12 deletions
+5 -12
View File
@@ -7,20 +7,13 @@ type UIManager = Manager[Widget]
// order — used by the engine for top-down input dispatch (the widget
// drawn on top gets the click first).
func reversedWidgets(m *UIManager) []Widget {
names := m.Names()
out := make([]Widget, len(names))
for i, n := range names {
out[len(names)-1-i] = m.MustGet(n)
all := m.All()
out := make([]Widget, len(all))
for i, w := range all {
out[len(all)-1-i] = w
}
return out
}
// orderedWidgets iterates in registration order — bottom-up draw.
func orderedWidgets(m *UIManager) []Widget {
names := m.Names()
out := make([]Widget, len(names))
for i, n := range names {
out[i] = m.MustGet(n)
}
return out
}
func orderedWidgets(m *UIManager) []Widget { return m.All() }