blobs.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #pragma once
  8. #include "ui/effects/animation_value.h"
  9. #include "ui/paint/blob.h"
  10. class Painter;
  11. namespace Ui::Paint {
  12. class Blobs final {
  13. public:
  14. struct BlobData {
  15. int segmentsCount = 0;
  16. float minScale = 0;
  17. float minRadius = 0;
  18. float maxRadius = 0;
  19. float speedScale = 0;
  20. float alpha = 0;
  21. float minSpeed = 0;
  22. float maxSpeed = 0;
  23. };
  24. Blobs(
  25. std::vector<BlobData> blobDatas,
  26. float levelDuration,
  27. float maxLevel);
  28. void setRadiusesAt(
  29. rpl::producer<Blob::Radiuses> &&radiuses,
  30. int index);
  31. Blob::Radiuses radiusesAt(int index);
  32. void setLevel(float value);
  33. void resetLevel();
  34. void paint(QPainter &p, const QBrush &brush, float outerScale = 1.);
  35. void updateLevel(crl::time dt);
  36. [[nodiscard]] float maxRadius() const;
  37. [[nodiscard]] int size() const;
  38. [[nodiscard]] float64 currentLevel() const;
  39. static constexpr auto kHideBlobsDuration = 2000;
  40. private:
  41. void init();
  42. const float _maxLevel;
  43. std::vector<BlobData> _blobDatas;
  44. std::vector<RadialBlob> _blobs;
  45. anim::continuous_value _levelValue;
  46. rpl::lifetime _lifetime;
  47. };
  48. } // namespace Ui::Paint