aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmanuele Aina <em@nerd.ocracy.org>2012-03-08 21:40:54 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-03-09 16:14:25 +0800
commit2ca7e0fd3e98e4813e2dba5090577759a66542fa (patch)
tree2754e499d6f94df4039b3307423115bd404e0b65
parent06206fe711b721c6f33af4d4914c76cac540eda6 (diff)
downloadgsoc2013-empathy-2ca7e0fd3e98e4813e2dba5090577759a66542fa.tar
gsoc2013-empathy-2ca7e0fd3e98e4813e2dba5090577759a66542fa.tar.gz
gsoc2013-empathy-2ca7e0fd3e98e4813e2dba5090577759a66542fa.tar.bz2
gsoc2013-empathy-2ca7e0fd3e98e4813e2dba5090577759a66542fa.tar.lz
gsoc2013-empathy-2ca7e0fd3e98e4813e2dba5090577759a66542fa.tar.xz
gsoc2013-empathy-2ca7e0fd3e98e4813e2dba5090577759a66542fa.tar.zst
gsoc2013-empathy-2ca7e0fd3e98e4813e2dba5090577759a66542fa.zip
Don't clip overflowing border when drawing rounded rectangles
https://bugzilla.gnome.org/show_bug.cgi?id=671644
-rw-r--r--src/empathy-call-window.c2
-rw-r--r--src/empathy-rounded-rectangle.c30
2 files changed, 23 insertions, 9 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index ff810b2a0..8eaf2cc33 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 4cce28b06..8e6dab3da 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);
}