blobs_linear.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. namespace Ui::Paint {
  11. class LinearBlobs final {
  12. public:
  13. struct BlobData {
  14. int segmentsCount = 0;
  15. float minRadius = 0;
  16. float maxRadius = 0;
  17. float idleRadius = 0;
  18. float speedScale = 0;
  19. float alpha = 0;
  20. float minSpeed = 0;
  21. float maxSpeed = 0;
  22. };
  23. LinearBlobs(
  24. std::vector<BlobData> blobDatas,
  25. float levelDuration,
  26. float maxLevel,
  27. LinearBlob::Direction direction);
  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 paint(QPainter &p, const QBrush &brush, int width);
  34. void updateLevel(crl::time dt);
  35. [[nodiscard]] float maxRadius() const;
  36. [[nodiscard]] int size() const;
  37. [[nodiscard]] float64 currentLevel() const;
  38. static constexpr auto kHideBlobsDuration = 2000;
  39. private:
  40. void init();
  41. const float _maxLevel;
  42. const LinearBlob::Direction _direction;
  43. std::vector<BlobData> _blobDatas;
  44. std::vector<LinearBlob> _blobs;
  45. anim::continuous_value _levelValue;
  46. rpl::lifetime _lifetime;
  47. };
  48. } // namespace Ui::Paint