1 /* 2 This file is part of Telegram Desktop, 3 the official desktop application for the Telegram messaging service. 4 5 For license and copyright information please follow this link: 6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 7 */ 8 #pragma once 9 10 #include "ui/rect_part.h" 11 12 class Painter; 13 14 enum class ImageRoundRadius; 15 16 namespace Ui { 17 18 struct CornersPixmaps { 19 QPixmap p[4]; 20 }; 21 22 enum CachedRoundCorners : int { 23 BoxCorners, 24 MenuCorners, 25 DateCorners, 26 OverviewVideoCorners, 27 OverviewVideoSelectedCorners, 28 ForwardCorners, 29 MediaviewSaveCorners, 30 EmojiHoverCorners, 31 StickerHoverCorners, 32 BotKeyboardCorners, 33 34 Doc1Corners, 35 Doc2Corners, 36 Doc3Corners, 37 Doc4Corners, 38 39 RoundCornersCount 40 }; 41 42 void FillRoundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color bg, CachedRoundCorners index, const style::color *shadow = nullptr, RectParts parts = RectPart::Full); 43 inline void FillRoundRect(Painter &p, const QRect &rect, style::color bg, CachedRoundCorners index, const style::color *shadow = nullptr, RectParts parts = RectPart::Full) { 44 FillRoundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, index, shadow, parts); 45 } 46 void FillRoundShadow(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color shadow, CachedRoundCorners index, RectParts parts = RectPart::Full); 47 inline void FillRoundShadow(Painter &p, const QRect &rect, style::color shadow, CachedRoundCorners index, RectParts parts = RectPart::Full) { 48 FillRoundShadow(p, rect.x(), rect.y(), rect.width(), rect.height(), shadow, index, parts); 49 } 50 void FillRoundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color bg, ImageRoundRadius radius, RectParts parts = RectPart::Full); 51 inline void FillRoundRect(Painter &p, const QRect &rect, style::color bg, ImageRoundRadius radius, RectParts parts = RectPart::Full) { 52 FillRoundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, radius, parts); 53 } 54 55 [[nodiscard]] CornersPixmaps PrepareCornerPixmaps( 56 int32 radius, 57 style::color bg, 58 const style::color *sh); 59 [[nodiscard]] CornersPixmaps PrepareCornerPixmaps( 60 ImageRoundRadius radius, 61 style::color bg, 62 const style::color *sh); 63 void FillRoundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color bg, const CornersPixmaps &corner, const style::color *shadow = nullptr, RectParts parts = RectPart::Full); 64 inline void FillRoundRect(Painter &p, const QRect &rect, style::color bg, const CornersPixmaps &corner, const style::color *shadow = nullptr, RectParts parts = RectPart::Full) { 65 return FillRoundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, corner, shadow, parts); 66 } 67 void FillRoundShadow(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color shadow, const CornersPixmaps &corner, RectParts parts = RectPart::Full); 68 inline void FillRoundShadow(Painter &p, const QRect &rect, style::color shadow, const CornersPixmaps &corner, RectParts parts = RectPart::Full) { 69 FillRoundShadow(p, rect.x(), rect.y(), rect.width(), rect.height(), shadow, corner, parts); 70 } 71 72 void StartCachedCorners(); 73 void FinishCachedCorners(); 74 75 } // namespace Ui 76