widget.go 1.2 KB

123456789101112131415161718192021222324252627282930
  1. package fyne
  2. // Widget defines the standard behaviours of any widget. This extends the
  3. // CanvasObject - a widget behaves in the same basic way but will encapsulate
  4. // many child objects to create the rendered widget.
  5. type Widget interface {
  6. CanvasObject
  7. // CreateRenderer returns a new WidgetRenderer for this widget.
  8. // This should not be called by regular code, it is used internally to render a widget.
  9. CreateRenderer() WidgetRenderer
  10. }
  11. // WidgetRenderer defines the behaviour of a widget's implementation.
  12. // This is returned from a widget's declarative object through the CreateRenderer()
  13. // function and should be exactly one instance per widget in memory.
  14. type WidgetRenderer interface {
  15. // Destroy is for internal use.
  16. Destroy()
  17. // Layout is a hook that is called if the widget needs to be laid out.
  18. // This should never call Refresh.
  19. Layout(Size)
  20. // MinSize returns the minimum size of the widget that is rendered by this renderer.
  21. MinSize() Size
  22. // Objects returns all objects that should be drawn.
  23. Objects() []CanvasObject
  24. // Refresh is a hook that is called if the widget has updated and needs to be redrawn.
  25. // This might trigger a Layout.
  26. Refresh()
  27. }