[Xfce4-commits] [apps/xfdashboard] 01/01: Allow overriding draw function of background borders and corner, e.g. interesting for popup-menus to draw an arrow on any side of background.

noreply at xfce.org noreply at xfce.org
Sun Aug 21 21:06:00 CEST 2016


This is an automated email from the git hooks/post-receive script.

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit 387eb45962eb05a18a50b2bd227dc300744922cd
Author: Stephan Haller <nomad at froevel.de>
Date:   Sun Aug 21 21:04:58 2016 +0200

    Allow overriding draw function of background borders and corner, e.g. interesting for popup-menus to draw an arrow on any side of background.
---
 libxfdashboard/background.c | 72 +++++++++++++++++++++++++++++----------------
 libxfdashboard/background.h |  1 +
 2 files changed, 47 insertions(+), 26 deletions(-)

diff --git a/libxfdashboard/background.c b/libxfdashboard/background.c
index 913f426..895f507 100644
--- a/libxfdashboard/background.c
+++ b/libxfdashboard/background.c
@@ -96,35 +96,22 @@ static GParamSpec* XfdashboardBackgroundProperties[PROP_LAST]={ 0, };
 
 /* IMPLEMENTATION: Private variables and methods */
 
-/* Rectangle canvas should be redrawn */
-static gboolean _xfdashboard_background_on_draw_fill_canvas(XfdashboardBackground *self,
-																cairo_t *inContext,
-																int inWidth,
-																int inHeight,
-																gpointer inUserData)
+/* Draw border and corners */
+static void _xfdashboard_background_draw(XfdashboardBackground *self,
+											cairo_t *inContext,
+											int inWidth,
+											int inHeight)
 {
 	XfdashboardBackgroundPrivate	*priv;
 
-	g_return_val_if_fail(XFDASHBOARD_IS_BACKGROUND(self), TRUE);
-	g_return_val_if_fail(CLUTTER_IS_CANVAS(inUserData), TRUE);
+	g_return_if_fail(XFDASHBOARD_IS_BACKGROUND(self));
 
 	priv=self->priv;
 
-	/* Clear current contents of the canvas */
-	cairo_save(inContext);
-	cairo_set_operator(inContext, CAIRO_OPERATOR_CLEAR);
-	cairo_paint(inContext);
-	cairo_restore(inContext);
-
-	cairo_set_operator(inContext, CAIRO_OPERATOR_OVER);
-
-	/* Do nothing if type does not include filling background */
-	if(!(priv->type & XFDASHBOARD_BACKGROUND_TYPE_FILL)) return(CLUTTER_EVENT_PROPAGATE);
-
-	/* Determine if we should draw rounded corners */
-
-	/* Draw rectangle with or without rounded corners */
-	if((priv->type & XFDASHBOARD_BACKGROUND_TYPE_ROUNDED_CORNERS) &&
+	/* Determine if we should draw rounded corners and call virtual function
+	 * to draw rectangle with or without rounded corners.
+	 */
+	if((priv->type & XFDASHBOARD_BACKGROUND_TYPE_ROUNDED_CORNERS) && 
 		(priv->fillCorners & XFDASHBOARD_CORNERS_ALL) &&
 		priv->fillCornersRadius>0.0f)
 	{
@@ -174,6 +161,37 @@ static gboolean _xfdashboard_background_on_draw_fill_canvas(XfdashboardBackgroun
 		{
 			cairo_rectangle(inContext, 0, 0, inWidth, inHeight);
 		}
+}
+
+/* Rectangle canvas should be redrawn */
+static gboolean _xfdashboard_background_on_draw_fill_canvas(XfdashboardBackground *self,
+															cairo_t *inContext,
+															int inWidth,
+															int inHeight,
+															gpointer inUserData)
+{
+	XfdashboardBackgroundPrivate	*priv;
+	XfdashboardBackgroundClass		*klass;
+
+	g_return_val_if_fail(XFDASHBOARD_IS_BACKGROUND(self), CLUTTER_EVENT_PROPAGATE);
+	g_return_val_if_fail(CLUTTER_IS_CANVAS(inUserData), CLUTTER_EVENT_PROPAGATE);
+
+	priv=self->priv;
+
+	/* Clear current contents of the canvas */
+	cairo_save(inContext);
+	cairo_set_operator(inContext, CAIRO_OPERATOR_CLEAR);
+	cairo_paint(inContext);
+	cairo_restore(inContext);
+
+	cairo_set_operator(inContext, CAIRO_OPERATOR_OVER);
+
+	/* Do nothing if type does not include filling background */
+	if(!(priv->type & XFDASHBOARD_BACKGROUND_TYPE_FILL)) return(CLUTTER_EVENT_PROPAGATE);
+
+	/* Call virtual function to draw rectangle with or without rounded corners */
+	klass=XFDASHBOARD_BACKGROUND_GET_CLASS(self);
+	if(klass->draw) klass->draw(self, inContext, inWidth, inHeight);
 
 	/* Set color for filling and fill canvas */
 	if(priv->fillColor) clutter_cairo_set_source_color(inContext, priv->fillColor);
@@ -406,13 +424,15 @@ static void xfdashboard_background_class_init(XfdashboardBackgroundClass *klass)
 	GObjectClass			*gobjectClass=G_OBJECT_CLASS(klass);
 
 	/* Override functions */
-	gobjectClass->dispose=_xfdashboard_background_dispose;
-	gobjectClass->set_property=_xfdashboard_background_set_property;
-	gobjectClass->get_property=_xfdashboard_background_get_property;
+	klass->draw=_xfdashboard_background_draw;
 
 	clutterActorClass->paint_node=_xfdashboard_background_paint_node;
 	clutterActorClass->allocate=_xfdashboard_background_allocate;
 
+	gobjectClass->dispose=_xfdashboard_background_dispose;
+	gobjectClass->set_property=_xfdashboard_background_set_property;
+	gobjectClass->get_property=_xfdashboard_background_get_property;
+
 	/* Set up private structure */
 	g_type_class_add_private(klass, sizeof(XfdashboardBackgroundPrivate));
 
diff --git a/libxfdashboard/background.h b/libxfdashboard/background.h
index 3d02f01..b7b8d78 100644
--- a/libxfdashboard/background.h
+++ b/libxfdashboard/background.h
@@ -86,6 +86,7 @@ struct _XfdashboardBackgroundClass
 
 	/*< public >*/
 	/* Virtual functions */
+	void (*draw)(XfdashboardBackground *self, cairo_t *inContext, gint inWidth, gint inHeight);
 };
 
 /* Public API */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list