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;
|
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) {
|
QImage prepareBlur(QImage img) {
|
||||||
if (img.isNull()) {
|
if (img.isNull()) {
|
||||||
return img;
|
return img;
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,18 @@ namespace Images {
|
||||||
|
|
||||||
[[nodiscard]] QPixmap PixmapFast(QImage &&image);
|
[[nodiscard]] QPixmap PixmapFast(QImage &&image);
|
||||||
[[nodiscard]] QImage BlurLargeImage(QImage image, int radius);
|
[[nodiscard]] QImage BlurLargeImage(QImage image, int radius);
|
||||||
|
|
||||||
[[nodiscard]] const std::array<QImage, 4> &CornersMask(
|
[[nodiscard]] const std::array<QImage, 4> &CornersMask(
|
||||||
ImageRoundRadius radius);
|
ImageRoundRadius radius);
|
||||||
[[nodiscard]] std::array<QImage, 4> PrepareCorners(
|
[[nodiscard]] std::array<QImage, 4> PrepareCorners(
|
||||||
ImageRoundRadius radius,
|
ImageRoundRadius radius,
|
||||||
const style::color &color);
|
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);
|
QImage prepareBlur(QImage image);
|
||||||
void prepareRound(
|
void prepareRound(
|
||||||
QImage &image,
|
QImage &image,
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,17 @@ RoundRect::RoundRect(
|
||||||
}, _lifetime);
|
}, _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 {
|
const style::color &RoundRect::color() const {
|
||||||
return _color;
|
return _color;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ void DrawRoundedRect(
|
||||||
class RoundRect final {
|
class RoundRect final {
|
||||||
public:
|
public:
|
||||||
RoundRect(ImageRoundRadius radius, const style::color &color);
|
RoundRect(ImageRoundRadius radius, const style::color &color);
|
||||||
|
RoundRect(int radius, const style::color &color);
|
||||||
|
|
||||||
[[nodiscard]] const style::color &color() const;
|
[[nodiscard]] const style::color &color() const;
|
||||||
void paint(
|
void paint(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue