summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-10-26 20:56:57 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-10-26 20:56:57 +0000
commitae3eb6e3f4f270a03ff297d1bbe7cd3f3a2159a9 (patch)
tree5764dee73dc1cc56f021bc696e3a5ab75f5098fc
parent56d397495a0f3ec4e8cfba23c6a7d98a849f3844 (diff)
provide C API for rounded rectangle cairo utility
git-svn-id: svn://localhost/ardour2/branches/3.0@10310 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/utils.h1
-rw-r--r--libs/gtkmm2ext/utils.cc32
2 files changed, 24 insertions, 9 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h
index 370dd02b76..82eeaf71ea 100644
--- a/libs/gtkmm2ext/gtkmm2ext/utils.h
+++ b/libs/gtkmm2ext/gtkmm2ext/utils.h
@@ -98,6 +98,7 @@ namespace Gtkmm2ext {
void container_clear (Gtk::Container&);
void rounded_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r=10);
+ void rounded_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
};
#endif /* __gtkmm2ext_utils_h__ */
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc
index 19b6f2c46b..58adb74f6f 100644
--- a/libs/gtkmm2ext/utils.cc
+++ b/libs/gtkmm2ext/utils.cc
@@ -399,15 +399,29 @@ Gtkmm2ext::rounded_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, d
G D
F****E
*/
- context->move_to(x+r,y); // Move to A
- context->line_to(x+w-r,y); // Straight line to B
- context->curve_to(x+w,y,x+w,y,x+w,y+r); // Curve to C, Control points are both at Q
- context->line_to(x+w,y+h-r); // Move to D
- context->curve_to(x+w,y+h,x+w,y+h,x+w-r,y+h); // Curve to E
- context->line_to(x+r,y+h); // Line to F
- context->curve_to(x,y+h,x,y+h,x,y+h-r); // Curve to G
- context->line_to(x,y+r); // Line to H
- context->curve_to(x,y,x,y,x+r,y); // Curve to A
+ rounded_rectangle (context->cobj(), x, y, w, h, r);
+}
+
+void
+Gtkmm2ext::rounded_rectangle (cairo_t* cr, double x, double y, double w, double h, double r)
+{
+ /* renders small shapes better than most others */
+
+/* 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
}
#else