summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext/utils.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/gtkmm2ext/utils.cc')
-rw-r--r--libs/gtkmm2ext/utils.cc86
1 files changed, 32 insertions, 54 deletions
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc
index c0c7a88362..61f93234ff 100644
--- a/libs/gtkmm2ext/utils.cc
+++ b/libs/gtkmm2ext/utils.cc
@@ -417,76 +417,54 @@ Gtkmm2ext::rounded_bottom_half_rectangle (Cairo::RefPtr<Cairo::Context> context,
void
Gtkmm2ext::rounded_rectangle (cairo_t* cr, double x, double y, double w, double h, double r)
{
-/* A****BQ
- H C
- * *
- G D
- F****E
-*/
- cairo_move_to (cr, x+r,y); // Move to A
- cairo_line_to (cr, x+w-r,y); // Straight line to B
- cairo_curve_to (cr, x+w,y,x+w,y,x+w,y+r); // Curve to C, Control points are both at Q
- cairo_line_to (cr, x+w,y+h-r); // Move to D
- cairo_curve_to (cr, x+w,y+h,x+w,y+h,x+w-r,y+h); // Curve to E
- cairo_line_to (cr, x+r,y+h); // Line to F
- cairo_curve_to (cr, x,y+h,x,y+h,x,y+h-r); // Curve to G
- cairo_line_to (cr, x,y+r); // Line to H
- cairo_curve_to (cr, x,y,x,y,x+r,y); // Curve to A
+ double degrees = M_PI / 180.0;
+
+ cairo_new_sub_path (cr);
+ cairo_arc (cr, x + w - r, y + r, r, -90 * degrees, 0 * degrees); //tr
+ cairo_arc (cr, x + w - r, y + h - r, r, 0 * degrees, 90 * degrees); //br
+ cairo_arc (cr, x + r, y + h - r, r, 90 * degrees, 180 * degrees); //bl
+ cairo_arc (cr, x + r, y + r, r, 180 * degrees, 270 * degrees); //tl
+ cairo_close_path (cr);
}
void
Gtkmm2ext::rounded_top_half_rectangle (cairo_t* cr, double x, double y, double w, double h, double r)
{
-/* A****BQ
- H C
- * *
- G D
- F****E
-*/
- cairo_move_to (cr, x+r,y); // Move to A
- cairo_line_to (cr, x+w-r,y); // Straight line to B
- cairo_curve_to (cr, x+w,y,x+w,y,x+w,y+r); // Curve to C, Control points are both at Q
- cairo_line_to (cr, x+w,y+h); // Move to E
- cairo_line_to (cr, x,y+h); // Line to F
- cairo_line_to (cr, x,y+r); // Line to H
- cairo_curve_to (cr, x,y,x,y,x+r,y); // Curve to A
+ double degrees = M_PI / 180.0;
+
+ cairo_new_sub_path (cr);
+ cairo_move_to (cr, x+w, y+h);
+ cairo_line_to (cr, x, y+h);
+ cairo_arc (cr, x + r, y + r, r, 180 * degrees, 270 * degrees); //tl
+ cairo_arc (cr, x + w - r, y + r, r, -90 * degrees, 0 * degrees); //tr
+ cairo_close_path (cr);
}
void
Gtkmm2ext::rounded_bottom_half_rectangle (cairo_t* cr, double x, double y, double w, double h, double r)
{
-/* A****BQ
- H C
- * *
- G D
- F****E
-*/
- cairo_move_to (cr, x,y); // Move to A
- cairo_line_to (cr, x+w,y); // Straight line to B
- cairo_line_to (cr, x+w,y+h-r); // Move to D
- cairo_curve_to (cr, x+w,y+h,x+w,y+h,x+w-r,y+h); // Curve to E
- cairo_line_to (cr, x+r,y+h); // Line to F
- cairo_curve_to (cr, x,y+h,x,y+h,x,y+h-r); // Curve to G
- cairo_line_to (cr, x,y); // Line to A
+ double degrees = M_PI / 180.0;
+
+ cairo_new_sub_path (cr);
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x+w, y);
+ cairo_arc (cr, x + w - r, y + h - r, r, 0 * degrees, 90 * degrees); //br
+ cairo_arc (cr, x + r, y + h - r, r, 90 * degrees, 180 * degrees); //bl
+ cairo_close_path (cr);
}
void
Gtkmm2ext::rounded_top_rectangle (cairo_t* cr, double x, double y, double w, double h, double r)
{
-/* A****BQ
- H C
- * *
- * *
- F****E
-*/
- cairo_move_to (cr, x+r,y); // Move to A
- cairo_line_to (cr, x+w-r,y); // Straight line to B
- cairo_curve_to (cr, x+w,y,x+w,y,x+w,y+r); // Curve to C, Control points are both at Q
- cairo_line_to (cr, x+w,y+h); // Move to E
- cairo_line_to (cr, x,y+h); // Line to F
- cairo_line_to (cr, x,y+r); // Line to H
- cairo_curve_to (cr, x,y,x,y,x+r,y); // Curve to A
+ double degrees = M_PI / 180.0;
+
+ cairo_new_sub_path (cr);
+ cairo_move_to (cr, x+w, y+h);
+ cairo_line_to (cr, x, y+h);
+ cairo_arc (cr, x + r, y + r, r, 180 * degrees, 270 * degrees); //tl
+ cairo_arc (cr, x + w - r, y + r, r, -90 * degrees, 0 * degrees); //tr
+ cairo_close_path (cr);
}
void