widget.go 1.4 KB

123456789101112131415161718192021222324252627282930313233
  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 a hook that is called when the renderer is being destroyed.
  16. // This happens at some time after the widget is no longer visible, and
  17. // once destroyed a renderer will not be reused.
  18. // Renderers should dispose and clean up any related resources, if necessary.
  19. Destroy()
  20. // Layout is a hook that is called if the widget needs to be laid out.
  21. // This should never call Refresh.
  22. Layout(Size)
  23. // MinSize returns the minimum size of the widget that is rendered by this renderer.
  24. MinSize() Size
  25. // Objects returns all objects that should be drawn.
  26. Objects() []CanvasObject
  27. // Refresh is a hook that is called if the widget has updated and needs to be redrawn.
  28. // This might trigger a Layout.
  29. Refresh()
  30. }