2020-10-13 15:11:53 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/rect_part.h"
|
|
|
|
|
|
|
|
enum class ImageRoundRadius;
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
2021-08-27 20:44:47 +00:00
|
|
|
struct CornersPixmaps {
|
|
|
|
QPixmap p[4];
|
|
|
|
};
|
2020-10-13 15:11:53 +00:00
|
|
|
|
2021-08-27 20:44:47 +00:00
|
|
|
enum CachedRoundCorners : int {
|
2020-10-13 15:11:53 +00:00
|
|
|
BoxCorners,
|
|
|
|
MenuCorners,
|
|
|
|
DateCorners,
|
|
|
|
OverviewVideoCorners,
|
|
|
|
OverviewVideoSelectedCorners,
|
|
|
|
ForwardCorners,
|
|
|
|
MediaviewSaveCorners,
|
|
|
|
StickerHoverCorners,
|
|
|
|
BotKeyboardCorners,
|
|
|
|
|
|
|
|
Doc1Corners,
|
|
|
|
Doc2Corners,
|
|
|
|
Doc3Corners,
|
|
|
|
Doc4Corners,
|
|
|
|
|
|
|
|
RoundCornersCount
|
|
|
|
};
|
|
|
|
|
2022-11-13 19:38:18 +00:00
|
|
|
void FillRoundRect(QPainter &p, int x, int y, int w, int h, style::color bg, CachedRoundCorners index);
|
2022-10-03 11:11:05 +00:00
|
|
|
inline void FillRoundRect(QPainter &p, const QRect &rect, style::color bg, CachedRoundCorners index) {
|
|
|
|
FillRoundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, index);
|
2020-10-13 15:11:53 +00:00
|
|
|
}
|
|
|
|
|
2022-10-03 11:11:05 +00:00
|
|
|
[[nodiscard]] const CornersPixmaps &CachedCornerPixmaps(CachedRoundCorners index);
|
2021-08-27 20:44:47 +00:00
|
|
|
[[nodiscard]] CornersPixmaps PrepareCornerPixmaps(
|
2022-11-13 19:38:18 +00:00
|
|
|
int radius,
|
2021-08-27 20:44:47 +00:00
|
|
|
style::color bg,
|
2022-10-03 11:11:05 +00:00
|
|
|
const style::color *sh = nullptr);
|
2021-08-27 20:44:47 +00:00
|
|
|
[[nodiscard]] CornersPixmaps PrepareCornerPixmaps(
|
|
|
|
ImageRoundRadius radius,
|
|
|
|
style::color bg,
|
2022-10-03 11:11:05 +00:00
|
|
|
const style::color *sh = nullptr);
|
2022-11-13 19:38:18 +00:00
|
|
|
[[nodiscard]] CornersPixmaps PrepareInvertedCornerPixmaps(
|
|
|
|
int radius,
|
|
|
|
style::color bg);
|
|
|
|
void FillRoundRect(QPainter &p, int x, int y, int w, int h, style::color bg, const CornersPixmaps &corners);
|
2022-10-03 11:11:05 +00:00
|
|
|
inline void FillRoundRect(QPainter &p, const QRect &rect, style::color bg, const CornersPixmaps &corners) {
|
|
|
|
return FillRoundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, corners);
|
2021-09-02 22:08:57 +00:00
|
|
|
}
|
2022-11-13 19:38:18 +00:00
|
|
|
void FillRoundShadow(QPainter &p, int x, int y, int w, int h, style::color shadow, const CornersPixmaps &corners);
|
2022-09-30 19:03:44 +00:00
|
|
|
inline void FillRoundShadow(QPainter &p, const QRect &rect, style::color shadow, const CornersPixmaps &corners) {
|
|
|
|
FillRoundShadow(p, rect.x(), rect.y(), rect.width(), rect.height(), shadow, corners);
|
2021-09-03 13:09:43 +00:00
|
|
|
}
|
2021-08-27 20:44:47 +00:00
|
|
|
|
2022-09-30 14:49:48 +00:00
|
|
|
enum class CachedCornerRadius {
|
|
|
|
Small,
|
|
|
|
ThumbSmall,
|
|
|
|
ThumbLarge,
|
|
|
|
BubbleSmall,
|
|
|
|
BubbleLarge,
|
|
|
|
|
|
|
|
kCount,
|
|
|
|
};
|
2022-09-30 19:03:44 +00:00
|
|
|
[[nodiscard]] int CachedCornerRadiusValue(CachedCornerRadius tag);
|
2022-09-30 14:49:48 +00:00
|
|
|
|
|
|
|
[[nodiscard]] const std::array<QImage, 4> &CachedCornersMasks(
|
|
|
|
CachedCornerRadius radius);
|
|
|
|
|
2020-10-13 15:11:53 +00:00
|
|
|
void StartCachedCorners();
|
|
|
|
void FinishCachedCorners();
|
|
|
|
|
|
|
|
} // namespace Ui
|