diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2015-03-15 15:10:31 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2015-04-23 20:27:10 +0100 |
commit | 26d4d8452d18d7fde3e2b92b1c2da3eaad8ac95c (patch) | |
tree | db3932ca4dd5dfd84aa180f110f1be1bcc295039 | |
parent | 48661d6593cb6d27391c97990567f5914282ea48 (diff) | |
download | clutter-26d4d8452d18d7fde3e2b92b1c2da3eaad8ac95c.tar.gz |
rectangle: Fix the border drawing conditions
And reorganize the code a bit while we're at it.
(cherry picked from commit ce2d86515a58042011b41066492833d189f3fd1a)
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
-rw-r--r-- | clutter/deprecated/clutter-rectangle.c | 117 |
1 files changed, 62 insertions, 55 deletions
diff --git a/clutter/deprecated/clutter-rectangle.c b/clutter/deprecated/clutter-rectangle.c index d170e8c70..f1e95317f 100644 --- a/clutter/deprecated/clutter-rectangle.c +++ b/clutter/deprecated/clutter-rectangle.c @@ -88,83 +88,90 @@ clutter_rectangle_paint (ClutterActor *self) : "unknown"); clutter_actor_get_allocation_geometry (self, &geom); - /* We paint the border if the rectangle is big enough to show it */ - if (priv->has_border && - priv->border_width < geom.width && - priv->border_width < geom.height) + if (priv->has_border) { - /* compute the composited opacity of the actor taking into - * account the opacity of the color set by the user + /* We paint the border and the content only if the rectangle + * is big enough to show them */ - tmp_alpha = clutter_actor_get_paint_opacity (self) - * priv->border_color.alpha - / 255; - - /* paint the border */ - cogl_set_source_color4ub (priv->border_color.red, - priv->border_color.green, - priv->border_color.blue, - tmp_alpha); + if ((priv->border_width * 2) < geom.width && + (priv->border_width * 2) < geom.height) + { + /* compute the composited opacity of the actor taking into + * account the opacity of the color set by the user + */ + tmp_alpha = clutter_actor_get_paint_opacity (self) + * priv->border_color.alpha + / 255; - /* this sucks, but it's the only way to make a border */ - cogl_rectangle (priv->border_width, 0, - geom.width, - priv->border_width); + /* paint the border */ + cogl_set_source_color4ub (priv->border_color.red, + priv->border_color.green, + priv->border_color.blue, + tmp_alpha); - cogl_rectangle (geom.width - priv->border_width, - priv->border_width, - geom.width, - geom.height); + /* this sucks, but it's the only way to make a border */ + cogl_rectangle (priv->border_width, 0, + geom.width, + priv->border_width); - cogl_rectangle (0, geom.height - priv->border_width, - geom.width - priv->border_width, - geom.height); + cogl_rectangle (geom.width - priv->border_width, + priv->border_width, + geom.width, + geom.height); - cogl_rectangle (0, 0, - priv->border_width, - geom.height - priv->border_width); + cogl_rectangle (0, geom.height - priv->border_width, + geom.width - priv->border_width, + geom.height); - tmp_alpha = clutter_actor_get_paint_opacity (self) - * priv->color.alpha - / 255; + cogl_rectangle (0, 0, + priv->border_width, + geom.height - priv->border_width); - /* now paint the rectangle */ - cogl_set_source_color4ub (priv->color.red, - priv->color.green, - priv->color.blue, - tmp_alpha); + tmp_alpha = clutter_actor_get_paint_opacity (self) + * priv->color.alpha + / 255; - cogl_rectangle (priv->border_width, priv->border_width, - geom.width - priv->border_width, - geom.height - priv->border_width); - } - else - { - /* compute the composited opacity of the actor taking into - * account the opacity of the color set by the user - */ - tmp_alpha = clutter_actor_get_paint_opacity (self) - * priv->color.alpha - / 255; - - if (priv->border_width < geom.width && - priv->border_width < geom.height) - { + /* now paint the rectangle */ cogl_set_source_color4ub (priv->color.red, priv->color.green, priv->color.blue, tmp_alpha); + + cogl_rectangle (priv->border_width, priv->border_width, + geom.width - priv->border_width, + geom.height - priv->border_width); } else { - /* If the rectangle is as big as the border, we - * use the border color to draw + /* Otherwise, we draw a rectangle with the same color + * as the border, since we can only fit that into the + * allocation. */ + tmp_alpha = clutter_actor_get_paint_opacity (self) + * priv->border_color.alpha + / 255; + cogl_set_source_color4ub (priv->border_color.red, priv->border_color.green, priv->border_color.blue, tmp_alpha); + + cogl_rectangle (0, 0, geom.width, geom.height); } + } + else + { + /* compute the composited opacity of the actor taking into + * account the opacity of the color set by the user + */ + tmp_alpha = clutter_actor_get_paint_opacity (self) + * priv->color.alpha + / 255; + + cogl_set_source_color4ub (priv->color.red, + priv->color.green, + priv->color.blue, + tmp_alpha); cogl_rectangle (0, 0, geom.width, geom.height); } |