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:
+5
-12
@@ -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() }
|
||||
|
||||
Reference in New Issue
Block a user