cached_round_corners.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/rect_part.h"
  9. enum class ImageRoundRadius;
  10. namespace Ui {
  11. struct CornersPixmaps {
  12. QPixmap p[4];
  13. };
  14. enum CachedRoundCorners : int {
  15. BoxCorners,
  16. MenuCorners,
  17. DateCorners,
  18. OverviewVideoCorners,
  19. OverviewVideoSelectedCorners,
  20. ForwardCorners,
  21. MediaviewSaveCorners,
  22. StickerHoverCorners,
  23. BotKeyboardCorners,
  24. Doc1Corners,
  25. Doc2Corners,
  26. Doc3Corners,
  27. Doc4Corners,
  28. RoundCornersCount
  29. };
  30. void FillRoundRect(QPainter &p, int x, int y, int w, int h, style::color bg, CachedRoundCorners index);
  31. inline void FillRoundRect(QPainter &p, const QRect &rect, style::color bg, CachedRoundCorners index) {
  32. FillRoundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, index);
  33. }
  34. [[nodiscard]] const CornersPixmaps &CachedCornerPixmaps(CachedRoundCorners index);
  35. [[nodiscard]] CornersPixmaps PrepareCornerPixmaps(
  36. int radius,
  37. style::color bg,
  38. const style::color *sh = nullptr);
  39. [[nodiscard]] CornersPixmaps PrepareCornerPixmaps(
  40. ImageRoundRadius radius,
  41. style::color bg,
  42. const style::color *sh = nullptr);
  43. [[nodiscard]] CornersPixmaps PrepareInvertedCornerPixmaps(
  44. int radius,
  45. style::color bg);
  46. void FillRoundRect(QPainter &p, int x, int y, int w, int h, style::color bg, const CornersPixmaps &corners);
  47. inline void FillRoundRect(QPainter &p, const QRect &rect, style::color bg, const CornersPixmaps &corners) {
  48. return FillRoundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, corners);
  49. }
  50. void FillRoundShadow(QPainter &p, int x, int y, int w, int h, style::color shadow, const CornersPixmaps &corners);
  51. inline void FillRoundShadow(QPainter &p, const QRect &rect, style::color shadow, const CornersPixmaps &corners) {
  52. FillRoundShadow(p, rect.x(), rect.y(), rect.width(), rect.height(), shadow, corners);
  53. }
  54. enum class CachedCornerRadius {
  55. Small,
  56. ThumbSmall,
  57. ThumbLarge,
  58. BubbleSmall,
  59. BubbleLarge,
  60. kCount,
  61. };
  62. [[nodiscard]] int CachedCornerRadiusValue(CachedCornerRadius tag);
  63. [[nodiscard]] const std::array<QImage, 4> &CachedCornersMasks(
  64. CachedCornerRadius radius);
  65. void StartCachedCorners();
  66. void FinishCachedCorners();
  67. } // namespace Ui