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

This commit is contained in:
Trevor Slocum 2021-06-06 20:44:56 -07:00
parent ca75748dff
commit 652afb9875
2 changed files with 20 additions and 5 deletions

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)

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