[clutter/clutter-1.20] rectangle: Do not draw the border if bigger than the allocation
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/clutter-1.20] rectangle: Do not draw the border if bigger than the allocation
- Date: Thu, 23 Apr 2015 20:59:43 +0000 (UTC)
commit 48661d6593cb6d27391c97990567f5914282ea48
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sat Mar 14 23:15:01 2015 +0000
rectangle: Do not draw the border if bigger than the allocation
If the rectangle is allocate a size smaller than the border, drawing the
border will end up with negative coordinates, and will mess up the whole
thing. Since rectangles don't have a minimum preferred size, we cannot
rely on the allocation being big enough to contain the border and the
background color.
If the rectangle is smaller than the border width value, we just paint
the border color as well.
(cherry picked from commit 6de341392126e83e098a360b2d77f6259ee09a23)
Signed-off-by: Emmanuele Bassi <ebassi gnome org>
clutter/deprecated/clutter-rectangle.c | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/clutter/deprecated/clutter-rectangle.c b/clutter/deprecated/clutter-rectangle.c
index 0565658..d170e8c 100644
--- a/clutter/deprecated/clutter-rectangle.c
+++ b/clutter/deprecated/clutter-rectangle.c
@@ -88,10 +88,10 @@ clutter_rectangle_paint (ClutterActor *self)
: "unknown");
clutter_actor_get_allocation_geometry (self, &geom);
- /* parent paint call will have translated us into position so
- * paint from 0, 0
- */
- if (priv->has_border)
+ /* 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)
{
/* compute the composited opacity of the actor taking into
* account the opacity of the color set by the user
@@ -147,10 +147,24 @@ clutter_rectangle_paint (ClutterActor *self)
* priv->color.alpha
/ 255;
- cogl_set_source_color4ub (priv->color.red,
- priv->color.green,
- priv->color.blue,
- tmp_alpha);
+ if (priv->border_width < geom.width &&
+ priv->border_width < geom.height)
+ {
+ cogl_set_source_color4ub (priv->color.red,
+ priv->color.green,
+ priv->color.blue,
+ tmp_alpha);
+ }
+ else
+ {
+ /* If the rectangle is as big as the border, we
+ * use the border color to draw
+ */
+ 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]