provide C API for rounded rectangle cairo utility
git-svn-id: svn://localhost/ardour2/branches/3.0@10310 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
56d397495a
commit
ae3eb6e3f4
@ -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__ */
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user