premium_graphics.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "ui/effects/round_checkbox.h"
  9. namespace style {
  10. struct PremiumLimits;
  11. } // namespace style
  12. namespace tr {
  13. template <typename ...>
  14. struct phrase;
  15. } // namespace tr
  16. enum lngtag_count : int;
  17. namespace Data {
  18. struct PremiumSubscriptionOption;
  19. } // namespace Data
  20. namespace style {
  21. struct RoundImageCheckbox;
  22. struct PremiumOption;
  23. struct TextStyle;
  24. struct PremiumBubble;
  25. } // namespace style
  26. namespace Ui {
  27. class GenericBox;
  28. class RadiobuttonGroup;
  29. class VerticalLayout;
  30. namespace Premium {
  31. inline constexpr auto kLimitRowRatio = 0.5;
  32. [[nodiscard]] QString Svg();
  33. [[nodiscard]] QByteArray ColorizedSvg(const QGradientStops &gradientStops);
  34. [[nodiscard]] QImage GenerateStarForLightTopBar(QRectF rect);
  35. void AddLimitRow(
  36. not_null<Ui::VerticalLayout*> parent,
  37. const style::PremiumLimits &st,
  38. QString max,
  39. QString min = {},
  40. float64 ratio = kLimitRowRatio);
  41. void AddLimitRow(
  42. not_null<Ui::VerticalLayout*> parent,
  43. const style::PremiumLimits &st,
  44. int max,
  45. std::optional<tr::phrase<lngtag_count>> phrase,
  46. int min = 0,
  47. float64 ratio = kLimitRowRatio);
  48. struct LimitRowLabels {
  49. rpl::producer<QString> leftLabel;
  50. rpl::producer<QString> leftCount;
  51. rpl::producer<QString> rightLabel;
  52. rpl::producer<QString> rightCount;
  53. };
  54. struct LimitRowState {
  55. float64 ratio = 0.;
  56. bool animateFromZero = false;
  57. bool dynamic = false;
  58. };
  59. void AddLimitRow(
  60. not_null<Ui::VerticalLayout*> parent,
  61. const style::PremiumLimits &st,
  62. LimitRowLabels labels,
  63. rpl::producer<LimitRowState> state,
  64. const style::margins &padding);
  65. struct AccountsRowArgs final {
  66. std::shared_ptr<Ui::RadiobuttonGroup> group;
  67. const style::RoundImageCheckbox &st;
  68. const style::TextStyle &stName;
  69. const style::color &stNameFg;
  70. struct Entry final {
  71. QString name;
  72. Ui::RoundImageCheckbox::PaintRoundImage paintRoundImage;
  73. };
  74. std::vector<Entry> entries;
  75. };
  76. void AddAccountsRow(
  77. not_null<Ui::VerticalLayout*> parent,
  78. AccountsRowArgs &&args);
  79. [[nodiscard]] QGradientStops LimitGradientStops();
  80. [[nodiscard]] QGradientStops ButtonGradientStops();
  81. [[nodiscard]] QGradientStops LockGradientStops();
  82. [[nodiscard]] QGradientStops FullHeightGradientStops();
  83. [[nodiscard]] QGradientStops GiftGradientStops();
  84. [[nodiscard]] QGradientStops CreditsIconGradientStops();
  85. [[nodiscard]] QLinearGradient ComputeGradient(
  86. not_null<QWidget*> content,
  87. int left,
  88. int width);
  89. struct ListEntry final {
  90. rpl::producer<QString> title;
  91. rpl::producer<TextWithEntities> about;
  92. int leftNumber = 0;
  93. int rightNumber = 0;
  94. std::optional<QString> customRightText;
  95. const style::icon *icon = nullptr;
  96. };
  97. void ShowListBox(
  98. not_null<Ui::GenericBox*> box,
  99. const style::PremiumLimits &st,
  100. std::vector<ListEntry> entries);
  101. void AddGiftOptions(
  102. not_null<Ui::VerticalLayout*> parent,
  103. std::shared_ptr<Ui::RadiobuttonGroup> group,
  104. std::vector<Data::PremiumSubscriptionOption> gifts,
  105. const style::PremiumOption &st,
  106. bool topBadges = false);
  107. } // namespace Premium
  108. } // namespace Ui