canvas.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package fyne
  2. import "image"
  3. // Canvas defines a graphical canvas to which a CanvasObject or Container can be added.
  4. // Each canvas has a scale which is automatically applied during the render process.
  5. type Canvas interface {
  6. Content() CanvasObject
  7. SetContent(CanvasObject)
  8. Refresh(CanvasObject)
  9. // Focus makes the provided item focused.
  10. // The item has to be added to the contents of the canvas before calling this.
  11. Focus(Focusable)
  12. // FocusNext focuses the next focusable item.
  13. // If no item is currently focused, the first focusable item is focused.
  14. // If the last focusable item is currently focused, the first focusable item is focused.
  15. //
  16. // Since: 2.0
  17. FocusNext()
  18. // FocusPrevious focuses the previous focusable item.
  19. // If no item is currently focused, the last focusable item is focused.
  20. // If the first focusable item is currently focused, the last focusable item is focused.
  21. //
  22. // Since: 2.0
  23. FocusPrevious()
  24. Unfocus()
  25. Focused() Focusable
  26. // Size returns the current size of this canvas
  27. Size() Size
  28. // Scale returns the current scale (multiplication factor) this canvas uses to render
  29. // The pixel size of a CanvasObject can be found by multiplying by this value.
  30. Scale() float32
  31. // Overlays returns the overlay stack.
  32. Overlays() OverlayStack
  33. OnTypedRune() func(rune)
  34. SetOnTypedRune(func(rune))
  35. OnTypedKey() func(*KeyEvent)
  36. SetOnTypedKey(func(*KeyEvent))
  37. AddShortcut(shortcut Shortcut, handler func(shortcut Shortcut))
  38. RemoveShortcut(shortcut Shortcut)
  39. Capture() image.Image
  40. // PixelCoordinateForPosition returns the x and y pixel coordinate for a given position on this canvas.
  41. // This can be used to find absolute pixel positions or pixel offsets relative to an object top left.
  42. PixelCoordinateForPosition(Position) (int, int)
  43. // InteractiveArea returns the position and size of the central interactive area.
  44. // Operating system elements may overlap the portions outside this area and widgets should avoid being outside.
  45. //
  46. // Since: 1.4
  47. InteractiveArea() (Position, Size)
  48. }