Browse Source

Preserve order of panels when updating panel

Closes !12.
textarea
Trevor Slocum 11 months ago
parent
commit
3bd98fd55f
  1. 1
      CHANGELOG
  2. 10
      panels.go

1
CHANGELOG

@ -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

10
panels.go

@ -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()

Loading…
Cancel
Save