ProgressSpinners.swift 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. extension BackendFeatures {
  2. /// Backend methods for progress spinners.
  3. ///
  4. /// These are used by ``ProgressView`` when initialized without a `Progress`
  5. /// instance.
  6. @MainActor
  7. public protocol ProgressSpinners: Core {
  8. /// Creates an indeterminate progress spinner.
  9. ///
  10. /// - Returns: A progress spinner.
  11. func createProgressSpinner() -> Widget
  12. /// Sets the size of a progress spinner.
  13. ///
  14. /// This method exists because AppKitBackend requires special handling to resize progress spinners.
  15. ///
  16. /// The default implementation forwards to ``BackendFeatures/Widgets/setSize(of:to:)``.
  17. func setSize(
  18. ofProgressSpinner widget: Widget,
  19. to size: SIMD2<Int>
  20. )
  21. }
  22. }
  23. // MARK: Default Implementations
  24. extension BackendFeatures.ProgressSpinners {
  25. public func setSize(
  26. ofProgressSpinner widget: Widget,
  27. to size: SIMD2<Int>
  28. ) {
  29. setSize(of: widget, to: size)
  30. }
  31. }