Browse Source

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

textarea
Trevor Slocum 1 year ago
parent
commit
ca75748dff
  1. 1
      CHANGELOG
  2. 29
      application.go

1
CHANGELOG

@ -6,6 +6,7 @@ v1.5.6 (WIP) @@ -6,6 +6,7 @@ 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 List, Table and TreeView to not handle Tab or Backtab
- Allow specifying TabbedPanels switcher height
- Change default colors (fields and buttons are now green)

29
application.go

@ -611,12 +611,31 @@ func (a *Application) Suspend(f func()) bool { @@ -611,12 +611,31 @@ func (a *Application) Suspend(f func()) bool {
return true
}
// Draw refreshes the screen (during the next update cycle). It calls the Draw()
// function of the application's root primitive and then syncs the screen
// buffer.
func (a *Application) Draw() {
// Draw draws the provided primitives on the screen, or when no primitives are
// provided, draws the application's root primitive (i.e. the entire screen).
//
// When one or more primitives are supplied, the Draw functions of the
// primitives are called. Handlers set via BeforeDrawFunc and AfterDrawFunc are
// not called.
//
// When no primitives are provided, the Draw function of the application's root
// primitive is called. This results in drawing the entire screen. Handlers set
// via BeforeDrawFunc and AfterDrawFunc are also called.
func (a *Application) Draw(p ...Primitive) {
a.QueueUpdate(func() {
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