]> git.0d.be Git - empathy.git/commitdiff
Don't clip overflowing border when drawing rounded rectangles
authorEmanuele Aina <em@nerd.ocracy.org>
Thu, 8 Mar 2012 13:40:54 +0000 (14:40 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 9 Mar 2012 08:14:25 +0000 (09:14 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=671644

src/empathy-call-window.c
src/empathy-rounded-rectangle.c

index ff810b2a0f7e31d468e84aac753bdd5295e19ed8..8eaf2cc33e529002953c9ea53eb4199643034523 100644 (file)
@@ -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);
 }
index 4cce28b06981cf7306e5fdb27010456fc42ff629..8e6dab3da36ec03170b26c842f406606a76c985c 100644 (file)
@@ -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);
 }