Browse Source

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

textarea
Trevor Slocum 1 year ago
parent
commit
652afb9875
  1. 3
      CHANGELOG
  2. 22
      application.go

3
CHANGELOG

@ -6,7 +6,8 @@ v1.5.6 (WIP) @@ -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)

22
application.go

@ -862,12 +862,26 @@ func (a *Application) QueueUpdate(f func()) { @@ -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