Browse Source

Preserve order of panels when updating panel

Closes !12.
merge-requests/12/merge
Trevor Slocum 5 months ago
parent
commit
3bd98fd55f
2 changed files with 8 additions and 3 deletions
  1. +1
    -0
      CHANGELOG
  2. +7
    -3
      panels.go

+ 1
- 0
CHANGELOG 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


+ 7
- 3
panels.go 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()


Loading…
Cancel
Save