canvas.go 674 B

1234567891011121314151617181920212223242526272829
  1. package canvas
  2. import "fyne.io/fyne/v2"
  3. // Refresh instructs the containing canvas to refresh the specified obj.
  4. func Refresh(obj fyne.CanvasObject) {
  5. if fyne.CurrentApp() == nil || fyne.CurrentApp().Driver() == nil {
  6. return
  7. }
  8. c := fyne.CurrentApp().Driver().CanvasForObject(obj)
  9. if c != nil {
  10. c.Refresh(obj)
  11. }
  12. }
  13. // repaint instructs the containing canvas to redraw, even if nothing changed.
  14. func repaint(obj fyne.CanvasObject) {
  15. if fyne.CurrentApp() == nil || fyne.CurrentApp().Driver() == nil {
  16. return
  17. }
  18. c := fyne.CurrentApp().Driver().CanvasForObject(obj)
  19. if c != nil {
  20. if paint, ok := c.(interface{ SetDirty() }); ok {
  21. paint.SetDirty()
  22. }
  23. }
  24. }