summaryrefslogtreecommitdiff
path: root/src/contacts-utils.vala
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2011-08-23 10:43:12 +0200
committerAlexander Larsson <alexl@redhat.com>2011-08-23 10:43:12 +0200
commit58c02ed901f380f25a32f1a937e35d778f979548 (patch)
treebd06791c07bc9e8b09d24afabc042369de6fcdb7 /src/contacts-utils.vala
parent3d69f965fe9fc22a3c26b80047ec1c5e50756014 (diff)
downloadgnome-contacts-58c02ed901f380f25a32f1a937e35d778f979548.tar.gz
Move round rect helpers to Utils
Diffstat (limited to 'src/contacts-utils.vala')
-rw-r--r--src/contacts-utils.vala48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala
index faacbc1..e266042 100644
--- a/src/contacts-utils.vala
+++ b/src/contacts-utils.vala
@@ -76,4 +76,52 @@ public class Contacts.Utils : Object {
}
}
}
+
+ public static void cairo_ellipsis (Cairo.Context cr,
+ double xc, double yc,
+ double xradius, double yradius,
+ double angle1 ,double angle2) {
+ if (xradius <= 0.0 || yradius <= 0.0) {
+ cr.line_to (xc, yc);
+ return;
+ }
+
+ cr.save ();
+ cr.translate (xc, yc);
+ cr.scale (xradius, yradius);
+ cr.arc (0, 0, 1.0, angle1, angle2);
+ cr.restore ();
+ }
+
+ public static void cairo_rounded_box (Cairo.Context cr,
+ int x, int y,
+ int width, int height,
+ int radius) {
+ cr.new_sub_path ();
+
+ cairo_ellipsis (cr,
+ x + radius,
+ y + radius,
+ radius,
+ radius,
+ Math.PI, 3 * Math.PI / 2);
+ cairo_ellipsis (cr,
+ x + width - radius,
+ y + radius,
+ radius,
+ radius,
+ - Math.PI / 2, 0);
+ cairo_ellipsis (cr,
+ x + width - radius,
+ y + height - radius,
+ radius,
+ radius,
+ 0, Math.PI / 2);
+ cairo_ellipsis (cr,
+ x + radius,
+ y + height - radius,
+ radius,
+ radius,
+ Math.PI / 2, Math.PI);
+ }
}