Browse Source

Update Application.QueueUpdateDraw to accept one or more primitives to draw instead of the whole screen

master
Trevor Slocum 5 days ago
parent
commit
652afb9875
2 changed files with 20 additions and 5 deletions
  1. +2
    -1
      CHANGELOG
  2. +18
    -4
      application.go

+ 2
- 1
CHANGELOG View File

@ -6,7 +6,8 @@ v1.5.6 (WIP)
- Add DropDown.SetAlwaysDrawDropDownSymbol (DropDown symbols are now shown only when focused by default)
- Add DropDown.SetDropDownOpenSymbolRune
- Draw additional accents when rendering a list divider
- Update Application.Draw to accept one or more primitives to draw instead of the whole screen
- Update Application.Draw and Application.QueueUpdateDraw to accept one or more
primitives to draw instead of the whole screen
- Update List, Table and TreeView to not handle Tab or Backtab
- Allow specifying TabbedPanels switcher height
- Change default colors (fields and buttons are now green)


+ 18
- 4
application.go View File

@ -862,12 +862,26 @@ func (a *Application) QueueUpdate(f func()) {
a.updates <- f
}
// QueueUpdateDraw works like QueueUpdate() except it refreshes the screen
// immediately after executing f.
func (a *Application) QueueUpdateDraw(f func()) {
// QueueUpdateDraw works like QueueUpdate() except, when one or more primitives
// are provided, the primitives are drawn after the provided function returns.
// When no primitives are provided, the entire screen is drawn after the
// provided function returns.
func (a *Application) QueueUpdateDraw(f func(), p ...Primitive) {
a.QueueUpdate(func() {
f()
a.draw()
if len(p) == 0 {
a.draw()
return
}
a.Lock()
if a.screen != nil {
for _, primitive := range p {
primitive.Draw(a.screen)
}
a.screen.Show()
}
a.Unlock()
})
}


Loading…
Cancel
Save