Working on Layout Stuff

This commit is contained in:
2025-10-16 11:39:06 -05:00
parent f823a24fe8
commit 6aaaa68228
5 changed files with 222 additions and 74 deletions

View File

@@ -328,6 +328,14 @@ func (w *LinearLayout) IndexOf(n Widget) int {
return -1
}
func (w *LinearLayout) FindById(id string) Widget {
for i := range w.widgets {
if w.widgets[i].Id() == id {
return w.widgets[i]
}
}
return nil
}
func (w *LinearLayout) Contains(n Widget) bool {
return w.IndexOf(n) >= 0
}
@@ -344,6 +352,13 @@ func (w *LinearLayout) Replace(n, with Widget) {
w.layoutFlags[with], w.layoutWeights[with] = pFlags, pWeight
}
func (w *LinearLayout) AddAll(n Widget, more ...Widget) {
w.Add(n)
for i := range more {
w.Add(more[i])
}
}
func (w *LinearLayout) Add(n Widget) {
if w.Contains(n) {
// If the widget is already in the layout, move it to the end