[empathy] Don't clip overflowing border when drawing rounded rectangles



commit 2ca7e0fd3e98e4813e2dba5090577759a66542fa
Author: Emanuele Aina <em nerd ocracy org>
Date:   Thu Mar 8 14:40:54 2012 +0100

    Don't clip overflowing border when drawing rounded rectangles
    
    https://bugzilla.gnome.org/show_bug.cgi?id=671644

 src/empathy-call-window.c       |    2 +-
 src/empathy-rounded-rectangle.c |   30 ++++++++++++++++++++++--------
 2 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index ff810b2..8eaf2cc 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -876,7 +876,7 @@ empathy_call_window_highlight_preview_rectangle (EmpathyCallWindow *self,
   rectangle = empathy_call_window_get_preview_rectangle (self, pos);
 
   empathy_rounded_rectangle_set_border_width (
-      EMPATHY_ROUNDED_RECTANGLE (rectangle), 5);
+      EMPATHY_ROUNDED_RECTANGLE (rectangle), 3);
   empathy_rounded_rectangle_set_border_color (
       EMPATHY_ROUNDED_RECTANGLE (rectangle), CLUTTER_COLOR_Red);
 }
diff --git a/src/empathy-rounded-rectangle.c b/src/empathy-rounded-rectangle.c
index 4cce28b..8e6dab3 100644
--- a/src/empathy-rounded-rectangle.c
+++ b/src/empathy-rounded-rectangle.c
@@ -32,6 +32,7 @@ G_DEFINE_TYPE (EmpathyRoundedRectangle,
 
 struct _EmpathyRoundedRectanglePriv
 {
+  guint width, height;
   ClutterColor border_color;
   guint border_width;
 };
@@ -45,8 +46,8 @@ empathy_rounded_rectangle_paint (EmpathyRoundedRectangle *self)
 
 #define RADIUS (height / 8.)
 
-  clutter_cairo_texture_get_surface_size (CLUTTER_CAIRO_TEXTURE (self),
-      &width, &height);
+  width = self->priv->width;
+  height = self->priv->height;
 
   /* compute the composited opacity of the actor taking into
    * account the opacity of the color set by the user */
@@ -68,6 +69,9 @@ empathy_rounded_rectangle_paint (EmpathyRoundedRectangle *self)
   cairo_paint (cr);
   cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 
+  /* make room for the portion of the border drawn on the outside */
+  cairo_translate (cr, self->priv->border_width/2.0, self->priv->border_width/2.0);
+
   cairo_new_sub_path (cr);
   cairo_arc (cr, width - RADIUS, RADIUS, RADIUS,
       -M_PI/2.0, 0);
@@ -100,20 +104,29 @@ empathy_rounded_rectangle_class_init (EmpathyRoundedRectangleClass *klass)
   g_type_class_add_private (klass, sizeof (EmpathyRoundedRectanglePriv));
 }
 
+static void
+empathy_rounded_rectangle_update_surface_size (EmpathyRoundedRectangle *self)
+{
+  clutter_cairo_texture_set_surface_size (CLUTTER_CAIRO_TEXTURE (self),
+      self->priv->width + self->priv->border_width,
+      self->priv->height + self->priv->border_width);
+}
+
 ClutterActor *
 empathy_rounded_rectangle_new (guint width,
     guint height)
 {
-  ClutterActor *self;
+  EmpathyRoundedRectangle *self;
 
-  self = CLUTTER_ACTOR (g_object_new (EMPATHY_TYPE_ROUNDED_RECTANGLE, NULL));
+  self = EMPATHY_ROUNDED_RECTANGLE (g_object_new (EMPATHY_TYPE_ROUNDED_RECTANGLE, NULL));
 
-  clutter_cairo_texture_set_surface_size (CLUTTER_CAIRO_TEXTURE (self),
-      width, height);
+  self->priv->width = width;
+  self->priv->height = height;
 
-  empathy_rounded_rectangle_paint (EMPATHY_ROUNDED_RECTANGLE (self));
+  empathy_rounded_rectangle_update_surface_size (self);
+  empathy_rounded_rectangle_paint (self);
 
-  return self;
+  return CLUTTER_ACTOR (self);
 }
 
 void
@@ -122,6 +135,7 @@ empathy_rounded_rectangle_set_border_width (EmpathyRoundedRectangle *self,
 {
   self->priv->border_width = border_width;
 
+  empathy_rounded_rectangle_update_surface_size (self);
   empathy_rounded_rectangle_paint (self);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]