From d1070154f645de4ffe97b22a2dc5dfed1db07355 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Fri, 11 Apr 2025 09:05:50 +0200 Subject: [PATCH] Painter: Rectangle/RoundedRectangle/Ellipse/Circle convenience overloads --- uppsrc/Painter/Painter.cpp | 5 ----- uppsrc/Painter/Painter.h | 11 ++++++++++- uppsrc/Painter/src.tpp/Painter_en-us.tpp | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/uppsrc/Painter/Painter.cpp b/uppsrc/Painter/Painter.cpp index 90a151ae4..1855f1920 100644 --- a/uppsrc/Painter/Painter.cpp +++ b/uppsrc/Painter/Painter.cpp @@ -284,11 +284,6 @@ Painter& Painter::Rectangle(double x, double y, double cx, double cy) return Move(x, y).RelLine(cx, 0).RelLine(0, cy).RelLine(-cx, 0).Close(); } -Painter& Painter::RoundedRectangle(double x, double y, double cx, double cy, double r) -{ - return RoundedRectangle(x, y, cx, cy, r, r); -} - Painter& Painter::RoundedRectangle(double x, double y, double cx, double cy, double rx, double ry) { ASSERT(rx >= 0 && ry >= 0); diff --git a/uppsrc/Painter/Painter.h b/uppsrc/Painter/Painter.h index d8a327702..d978f1e82 100644 --- a/uppsrc/Painter/Painter.h +++ b/uppsrc/Painter/Painter.h @@ -335,10 +335,19 @@ public: void Paint(const Painting& p); Painter& Rectangle(double x, double y, double cx, double cy); - Painter& RoundedRectangle(double x, double y, double cx, double cy, double r); + Painter& Rectangle(const Rectf& r) { return Rectangle(r.left, r.top, r.Width(), r.Height()); } + Painter& Rectangle(Pointf p1, Pointf p2) { return Rectangle(Rectf(p1, p2)); } Painter& RoundedRectangle(double x, double y, double cx, double cy, double r1, double r2); + Painter& RoundedRectangle(const Rectf& r, double r1, double r2) { return RoundedRectangle(r.left, r.top, r.Width(), r.Height(), r1, r2); } + Painter& RoundedRectangle(Pointf p1, Pointf p2, double r1, double r2) { return RoundedRectangle(Rectf(p1, p2), r1, r2); } + Painter& RoundedRectangle(double x, double y, double cx, double cy, double r) { return RoundedRectangle(x, y, cx, cy, r, r); } + Painter& RoundedRectangle(const Rectf& rc, double r) { return RoundedRectangle(rc, r, r); } + Painter& RoundedRectangle(Pointf p1, Pointf p2, double r) { return RoundedRectangle(p1, p2, r, r); } Painter& Ellipse(double x, double y, double rx, double ry); + Painter& Ellipse(const Rectf& r) { return Ellipse(r.left, r.top, r.Width(), r.Height()); } + Painter& Ellipse(Pointf p1, Pointf p2) { return Ellipse(Rectf(p1, p2)); } Painter& Circle(double x, double y, double r); + Painter& Circle(Pointf p, double r) { return Circle(p.x, p.y, r); } Painter& RectPath(int x, int y, int cx, int cy); Painter& RectPath(const Rect& r); diff --git a/uppsrc/Painter/src.tpp/Painter_en-us.tpp b/uppsrc/Painter/src.tpp/Painter_en-us.tpp index 1674fa97b..1332d92d0 100644 --- a/uppsrc/Painter/src.tpp/Painter_en-us.tpp +++ b/uppsrc/Painter/src.tpp/Painter_en-us.tpp @@ -340,6 +340,10 @@ of them, advance between characters can be overriden with [%-*@3 dx].&] [s5;:Upp`:`:Painter`:`:Rectangle`(double`,double`,double`,double`): Painter[@(0.0.255) `& ] [* Rectangle]([@(0.0.255) double] [*@3 x], [@(0.0.255) double] [*@3 y], [@(0.0.255) double] [*@3 cx], [@(0.0.255) double] [*@3 cy])&] +[s5;:Upp`:`:Painter`:`:Rectangle`(const Rectf`&`): Painter[@(0.0.255) `&] +[* Rectangle]([@(0.0.255) const] Rectf[@(0.0.255) `&] [*@3 r])&] +[s5;:Upp`:`:Painter`:`:Rectangle`(Pointf`,Pointf`): Painter[@(0.0.255) `&] +[* Rectangle](Pointf [*@3 p1], Pointf [*@3 p2])&] [s2;%% Convenience method that adds a rectangle to the path.&] [s3; &] [s4; &] @@ -351,6 +355,18 @@ inter[@(0.0.255) `&] [* RoundedRectangle]([@(0.0.255) double] [*@3 x], ainter[@(0.0.255) `&] [* RoundedRectangle]([@(0.0.255) double] [*@3 x], [@(0.0.255) double] [*@3 y], [@(0.0.255) double] [*@3 cx], [@(0.0.255) double] [*@3 cy], [@(0.0.255) double] [*@3 rx], [@(0.0.255) double] [*@3 ry])&] +[s5;:Upp`:`:Painter`:`:RoundedRectangle`(const Rectf`&`,double`): Painter[@(0.0.255) `& +] [* RoundedRectangle]([@(0.0.255) const] Rectf[@(0.0.255) `&] [*@3 rc], +[@(0.0.255) double] [*@3 r])&] +[s5;:Upp`:`:Painter`:`:RoundedRectangle`(Pointf`,Pointf`,double`): Painter[@(0.0.255) `& +] [* RoundedRectangle](Pointf [*@3 p1], Pointf [*@3 p2], [@(0.0.255) double] +[*@3 r])&] +[s5;:Upp`:`:Painter`:`:RoundedRectangle`(const Rectf`&`,double`,double`): Painter[@(0.0.255) `& +] [* RoundedRectangle]([@(0.0.255) const] Rectf[@(0.0.255) `&] [*@3 r], +[@(0.0.255) double] [*@3 r1], [@(0.0.255) double] [*@3 r2])&] +[s5;:Upp`:`:Painter`:`:RoundedRectangle`(Pointf`,Pointf`,double`,double`): Painter[@(0.0.255) `& +] [* RoundedRectangle](Pointf [*@3 p1], Pointf [*@3 p2], [@(0.0.255) double] +[*@3 r1], [@(0.0.255) double] [*@3 r2])&] [s2;%% Convenience method that adds rounded rectangle to the path. [%-*@3 r] specifies the radius of circular corner, [%-*@3 rx] [%-*@3 ry] radii of elliptical corners.&] @@ -359,12 +375,18 @@ radii of elliptical corners.&] [s5;:Upp`:`:Painter`:`:Ellipse`(double`,double`,double`,double`): Painter[@(0.0.255) `& ] [* Ellipse]([@(0.0.255) double] [*@3 x], [@(0.0.255) double] [*@3 y], [@(0.0.255) double] [*@3 rx], [@(0.0.255) double] [*@3 ry])&] +[s5;:Upp`:`:Painter`:`:Ellipse`(const Rectf`&`): Painter[@(0.0.255) `&] +[* Ellipse]([@(0.0.255) const] Rectf[@(0.0.255) `&] [*@3 r])&] +[s5;:Upp`:`:Painter`:`:Ellipse`(Pointf`,Pointf`): Painter[@(0.0.255) `&] +[* Ellipse](Pointf [*@3 p1], Pointf [*@3 p2])&] [s2;%% Convenience method that adds ellipse to the path.&] [s3; &] [s4; &] [s5;:Upp`:`:Painter`:`:Circle`(double`,double`,double`): Painter[@(0.0.255) `&] [* Circle]([@(0.0.255) double] [*@3 x], [@(0.0.255) double] [*@3 y], [@(0.0.255) double] [*@3 r])&] +[s5;:Upp`:`:Painter`:`:Circle`(Pointf`,double`): Painter[@(0.0.255) `&] +[* Circle](Pointf [*@3 p], [@(0.0.255) double] [*@3 r])&] [s2;%% Convenience method that adds circle to the path.&] [s3; &] [s4; &]