Allow RoundRect to have arbitrary radius.
This commit is contained in:
parent
8a70d4b6c5
commit
d2ae2cf8f6
4 changed files with 32 additions and 0 deletions
|
|
@ -97,6 +97,20 @@ std::array<QImage, 4> PrepareCorners(
|
|||
return result;
|
||||
}
|
||||
|
||||
std::array<QImage, 4> CornersMask(int radius) {
|
||||
return PrepareCornersMask(radius);
|
||||
}
|
||||
|
||||
std::array<QImage, 4> PrepareCorners(
|
||||
int radius,
|
||||
const style::color &color) {
|
||||
auto result = CornersMask(radius);
|
||||
for (auto &image : result) {
|
||||
style::colorizeImage(image, color->c, &image);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QImage prepareBlur(QImage img) {
|
||||
if (img.isNull()) {
|
||||
return img;
|
||||
|
|
|
|||
|
|
@ -27,12 +27,18 @@ namespace Images {
|
|||
|
||||
[[nodiscard]] QPixmap PixmapFast(QImage &&image);
|
||||
[[nodiscard]] QImage BlurLargeImage(QImage image, int radius);
|
||||
|
||||
[[nodiscard]] const std::array<QImage, 4> &CornersMask(
|
||||
ImageRoundRadius radius);
|
||||
[[nodiscard]] std::array<QImage, 4> PrepareCorners(
|
||||
ImageRoundRadius radius,
|
||||
const style::color &color);
|
||||
|
||||
[[nodiscard]] std::array<QImage, 4> CornersMask(int radius);
|
||||
[[nodiscard]] std::array<QImage, 4> PrepareCorners(
|
||||
int radius,
|
||||
const style::color &color);
|
||||
|
||||
QImage prepareBlur(QImage image);
|
||||
void prepareRound(
|
||||
QImage &image,
|
||||
|
|
|
|||
|
|
@ -74,6 +74,17 @@ RoundRect::RoundRect(
|
|||
}, _lifetime);
|
||||
}
|
||||
|
||||
RoundRect::RoundRect(
|
||||
int radius,
|
||||
const style::color &color)
|
||||
: _color(color)
|
||||
, _corners(Images::PrepareCorners(radius, color)) {
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
_corners = Images::PrepareCorners(radius, _color);
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
const style::color &RoundRect::color() const {
|
||||
return _color;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ void DrawRoundedRect(
|
|||
class RoundRect final {
|
||||
public:
|
||||
RoundRect(ImageRoundRadius radius, const style::color &color);
|
||||
RoundRect(int radius, const style::color &color);
|
||||
|
||||
[[nodiscard]] const style::color &color() const;
|
||||
void paint(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue