[gnome-contacts] Move round rect helpers to Utils
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Move round rect helpers to Utils
- Date: Tue, 23 Aug 2011 12:55:39 +0000 (UTC)
commit 58c02ed901f380f25a32f1a937e35d778f979548
Author: Alexander Larsson <alexl redhat com>
Date: Tue Aug 23 10:43:12 2011 +0200
Move round rect helpers to Utils
src/contacts-contact.vala | 54 ++------------------------------------------
src/contacts-utils.vala | 48 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 51 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 199490c..21c3961 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -702,54 +702,6 @@ public class Contacts.Contact : GLib.Object {
return res;
}
- private 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 ();
- }
-
- private static void rounded_box_path (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);
- }
-
public static Gdk.Pixbuf frame_icon (Gdk.Pixbuf icon) {
int w = icon.get_width ();
int h = icon.get_height ();
@@ -761,9 +713,9 @@ public class Contacts.Contact : GLib.Object {
cr.fill ();
Gdk.cairo_set_source_pixbuf (cr, icon, 0, 0);
- rounded_box_path (cr,
- 0, 0,
- w, h, 4);
+ Utils.cairo_rounded_box (cr,
+ 0, 0,
+ w, h, 4);
cr.fill ();
return Gdk.pixbuf_get_from_surface (cst, 0, 0, w, h);
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);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]