Preserve order of panels when updating panel

Closes !12.
This commit is contained in:
Trevor Slocum 2021-01-05 14:53:36 -08:00
parent 7db7653746
commit 3bd98fd55f
2 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,7 @@
v1.5.3 (WIP)
- Document how to prevent screen artifacts when using SetBackgroundTransparent
- Fix incorrect TabbedPanels colors
- Preserve order of panels when updating panel
v1.5.2 (2020-12-04)
- Handle input events before executing queued update functions

View File

@ -75,13 +75,17 @@ func (p *Panels) AddPanel(name string, item Primitive, resize, visible bool) {
p.Lock()
defer p.Unlock()
for index, pg := range p.panels {
var added bool
for i, pg := range p.panels {
if pg.Name == name {
p.panels = append(p.panels[:index], p.panels[index+1:]...)
p.panels[i] = &panel{Item: item, Name: name, Resize: resize, Visible: visible}
added = true
break
}
}
p.panels = append(p.panels, &panel{Item: item, Name: name, Resize: resize, Visible: visible})
if !added {
p.panels = append(p.panels, &panel{Item: item, Name: name, Resize: resize, Visible: visible})
}
if p.changed != nil {
p.Unlock()
p.changed()