[gnome-shell/wip/clutter-deprecation-fixes: 6/18] st-widget: Add a proper paint, add st_widget_paint_background



commit a21579595d8e777913997c5c2e1c0a7bc025de02
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Feb 13 16:41:29 2012 -0500

    st-widget: Add a proper paint, add st_widget_paint_background
    
    Since we want to paint children by default in StWidget, we need to
    provide a way for custom subclasses to paint their CSS backgrounds
    without painting children... introducing st_widget_paint_background.
    
    Additionally, remove any custom paint/pick handlers added by subclasses
    of StWidget that just painted their children. This will cause double
    painting if left alone.
    
    This also removes the hacky things that some subclasses of StBin did
    to prevent their one child to be painted by StBin.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=670034

 src/shell-generic-container.c |    2 +-
 src/shell-slicer.c            |    3 +--
 src/shell-stack.c             |   24 ------------------------
 src/st/st-bin.c               |   28 ----------------------------
 src/st/st-box-layout.c        |    2 +-
 src/st/st-entry.c             |   37 -------------------------------------
 src/st/st-group.c             |   24 ------------------------
 src/st/st-icon.c              |    3 +--
 src/st/st-label.c             |    4 +---
 src/st/st-scroll-bar.c        |   29 -----------------------------
 src/st/st-scroll-view.c       |    9 +++++----
 src/st/st-table.c             |   36 ------------------------------------
 src/st/st-widget.c            |   32 ++++++++++++++++++++++++--------
 src/st/st-widget.h            |    1 +
 14 files changed, 35 insertions(+), 199 deletions(-)
---
diff --git a/src/shell-generic-container.c b/src/shell-generic-container.c
index 382e79b..bed22b2 100644
--- a/src/shell-generic-container.c
+++ b/src/shell-generic-container.c
@@ -127,7 +127,7 @@ shell_generic_container_paint (ClutterActor  *actor)
   ShellGenericContainer *self = (ShellGenericContainer*) actor;
   GList *iter, *children;
 
-  CLUTTER_ACTOR_CLASS (shell_generic_container_parent_class)->paint (actor);
+  st_widget_paint_background (ST_WIDGET (actor));
 
   children = st_container_get_children_list (ST_CONTAINER (actor));
   for (iter = children; iter; iter = iter->next)
diff --git a/src/shell-slicer.c b/src/shell-slicer.c
index c6a9915..986214e 100644
--- a/src/shell-slicer.c
+++ b/src/shell-slicer.c
@@ -134,8 +134,7 @@ shell_slicer_paint_child (ShellSlicer *self)
 static void
 shell_slicer_paint (ClutterActor *self)
 {
-  /* StWidget paints CSS elements */
-  CLUTTER_ACTOR_CLASS (g_type_class_peek (st_widget_get_type ()))->paint (self);
+  st_widget_paint_background (ST_WIDGET (self));
 
   shell_slicer_paint_child (SHELL_SLICER (self));
 }
diff --git a/src/shell-stack.c b/src/shell-stack.c
index 4093f40..439aa83 100644
--- a/src/shell-stack.c
+++ b/src/shell-stack.c
@@ -21,28 +21,6 @@ G_DEFINE_TYPE (ShellStack,
                ST_TYPE_CONTAINER);
 
 static void
-shell_stack_paint (ClutterActor *actor)
-{
-  CLUTTER_ACTOR_CLASS (shell_stack_parent_class)->paint (actor);
-
-  clutter_container_foreach (CLUTTER_CONTAINER (actor),
-                             CLUTTER_CALLBACK (clutter_actor_paint),
-                             NULL);
-}
-
-static void
-shell_stack_pick (ClutterActor       *actor,
-                  const ClutterColor *pick)
-{
-  /* Chain up so we get a bounding box painted (if we are reactive) */
-  CLUTTER_ACTOR_CLASS (shell_stack_parent_class)->pick (actor, pick);
-
-  clutter_container_foreach (CLUTTER_CONTAINER (actor),
-                             CLUTTER_CALLBACK (clutter_actor_paint),
-                             NULL);
-}
-
-static void
 shell_stack_allocate (ClutterActor           *self,
                       const ClutterActorBox  *box,
                       ClutterAllocationFlags  flags)
@@ -206,8 +184,6 @@ shell_stack_class_init (ShellStackClass *klass)
   ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
   StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
 
-  actor_class->paint = shell_stack_paint;
-  actor_class->pick = shell_stack_pick;
   actor_class->get_preferred_width = shell_stack_get_preferred_width;
   actor_class->get_preferred_height = shell_stack_get_preferred_height;
   actor_class->allocate = shell_stack_allocate;
diff --git a/src/st/st-bin.c b/src/st/st-bin.c
index 4a8c332..0ca1a92 100644
--- a/src/st/st-bin.c
+++ b/src/st/st-bin.c
@@ -105,32 +105,6 @@ clutter_container_iface_init (ClutterContainerIface *iface)
 }
 
 static void
-st_bin_paint (ClutterActor *self)
-{
-  StBinPrivate *priv = ST_BIN (self)->priv;
-
-  /* allow StWidget to paint the background */
-  CLUTTER_ACTOR_CLASS (st_bin_parent_class)->paint (self);
-
-  /* the pain our child */
-  if (priv->child)
-    clutter_actor_paint (priv->child);
-}
-
-static void
-st_bin_pick (ClutterActor       *self,
-             const ClutterColor *pick_color)
-{
-  StBinPrivate *priv = ST_BIN (self)->priv;
-
-  /* get the default pick implementation */
-  CLUTTER_ACTOR_CLASS (st_bin_parent_class)->pick (self, pick_color);
-
-  if (priv->child)
-    clutter_actor_paint (priv->child);
-}
-
-static void
 st_bin_allocate (ClutterActor          *self,
                  const ClutterActorBox *box,
                  ClutterAllocationFlags flags)
@@ -340,8 +314,6 @@ st_bin_class_init (StBinClass *klass)
   actor_class->get_preferred_width = st_bin_get_preferred_width;
   actor_class->get_preferred_height = st_bin_get_preferred_height;
   actor_class->allocate = st_bin_allocate;
-  actor_class->paint = st_bin_paint;
-  actor_class->pick = st_bin_pick;
 
   widget_class->navigate_focus = st_bin_navigate_focus;
 
diff --git a/src/st/st-box-layout.c b/src/st/st-box-layout.c
index 453a3c2..c57b7e0 100644
--- a/src/st/st-box-layout.c
+++ b/src/st/st-box-layout.c
@@ -915,7 +915,7 @@ st_box_layout_paint (ClutterActor *actor)
       cogl_translate ((int)x, (int)y, 0);
     }
 
-  CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->paint (actor);
+  st_widget_paint_background (ST_WIDGET (actor));
 
   if (x != 0 || y != 0)
     {
diff --git a/src/st/st-entry.c b/src/st/st-entry.c
index 3856a46..a4e5dba 100644
--- a/src/st/st-entry.c
+++ b/src/st/st-entry.c
@@ -513,41 +513,6 @@ clutter_text_password_char_cb (GObject    *object,
 }
 
 static void
-st_entry_paint (ClutterActor *actor)
-{
-  StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
-  ClutterActorClass *parent_class;
-
-  parent_class = CLUTTER_ACTOR_CLASS (st_entry_parent_class);
-  parent_class->paint (actor);
-
-  clutter_actor_paint (priv->entry);
-
-  if (priv->primary_icon)
-    clutter_actor_paint (priv->primary_icon);
-
-  if (priv->secondary_icon)
-    clutter_actor_paint (priv->secondary_icon);
-}
-
-static void
-st_entry_pick (ClutterActor       *actor,
-               const ClutterColor *c)
-{
-  StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
-
-  CLUTTER_ACTOR_CLASS (st_entry_parent_class)->pick (actor, c);
-
-  clutter_actor_paint (priv->entry);
-
-  if (priv->primary_icon)
-    clutter_actor_paint (priv->primary_icon);
-
-  if (priv->secondary_icon)
-    clutter_actor_paint (priv->secondary_icon);
-}
-
-static void
 st_entry_clipboard_callback (StClipboard *clipboard,
                              const gchar *text,
                              gpointer     data)
@@ -660,8 +625,6 @@ st_entry_class_init (StEntryClass *klass)
   actor_class->get_preferred_width = st_entry_get_preferred_width;
   actor_class->get_preferred_height = st_entry_get_preferred_height;
   actor_class->allocate = st_entry_allocate;
-  actor_class->paint = st_entry_paint;
-  actor_class->pick = st_entry_pick;
 
   actor_class->key_press_event = st_entry_key_press_event;
   actor_class->key_focus_in = st_entry_key_focus_in;
diff --git a/src/st/st-group.c b/src/st/st-group.c
index fac0124..172726f 100644
--- a/src/st/st-group.c
+++ b/src/st/st-group.c
@@ -53,28 +53,6 @@
 G_DEFINE_TYPE (StGroup, st_group, ST_TYPE_CONTAINER);
 
 static void
-st_group_paint (ClutterActor *actor)
-{
-  CLUTTER_ACTOR_CLASS (st_group_parent_class)->paint (actor);
-
-  clutter_container_foreach (CLUTTER_CONTAINER (actor),
-                             CLUTTER_CALLBACK (clutter_actor_paint),
-                             NULL);
-}
-
-static void
-st_group_pick (ClutterActor       *actor,
-               const ClutterColor *pick)
-{
-  /* Chain up so we get a bounding box painted (if we are reactive) */
-  CLUTTER_ACTOR_CLASS (st_group_parent_class)->pick (actor, pick);
-
-  clutter_container_foreach (CLUTTER_CONTAINER (actor),
-                             CLUTTER_CALLBACK (clutter_actor_paint),
-                             NULL);
-}
-
-static void
 st_group_get_preferred_width (ClutterActor *actor,
                               gfloat        for_height,
                               gfloat       *min_width_p,
@@ -240,8 +218,6 @@ st_group_class_init (StGroupClass *klass)
   actor_class->get_preferred_width = st_group_get_preferred_width;
   actor_class->get_preferred_height = st_group_get_preferred_height;
   actor_class->allocate = st_group_allocate;
-  actor_class->paint = st_group_paint;
-  actor_class->pick = st_group_pick;
   actor_class->show_all = st_group_show_all;
   actor_class->hide_all = st_group_hide_all;
 }
diff --git a/src/st/st-icon.c b/src/st/st-icon.c
index c2c4205..45c2122 100644
--- a/src/st/st-icon.c
+++ b/src/st/st-icon.c
@@ -263,8 +263,7 @@ st_icon_paint (ClutterActor *actor)
 {
   StIconPrivate *priv = ST_ICON (actor)->priv;
 
-  /* Chain up to paint background */
-  CLUTTER_ACTOR_CLASS (st_icon_parent_class)->paint (actor);
+  st_widget_paint_background (ST_WIDGET (actor));
 
   if (priv->icon_texture)
     {
diff --git a/src/st/st-label.c b/src/st/st-label.c
index dfb1428..594b5d8 100644
--- a/src/st/st-label.c
+++ b/src/st/st-label.c
@@ -207,12 +207,10 @@ static void
 st_label_paint (ClutterActor *actor)
 {
   StLabelPrivate *priv = ST_LABEL (actor)->priv;
-  ClutterActorClass *parent_class;
   StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
   StShadow *shadow_spec = st_theme_node_get_text_shadow (theme_node);
 
-  parent_class = CLUTTER_ACTOR_CLASS (st_label_parent_class);
-  parent_class->paint (actor);
+  st_widget_paint_background (ST_WIDGET (actor));
 
   if (shadow_spec)
     {
diff --git a/src/st/st-scroll-bar.c b/src/st/st-scroll-bar.c
index 8069d93..fb6b171 100644
--- a/src/st/st-scroll-bar.c
+++ b/src/st/st-scroll-bar.c
@@ -178,33 +178,6 @@ st_scroll_bar_dispose (GObject *gobject)
 }
 
 static void
-st_scroll_bar_paint (ClutterActor *actor)
-{
-  StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
-
-  CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->paint (actor);
-
-  clutter_actor_paint (priv->trough);
-
-  if (priv->handle && CLUTTER_ACTOR_IS_VISIBLE (priv->handle))
-    clutter_actor_paint (priv->handle);
-}
-
-static void
-st_scroll_bar_pick (ClutterActor       *actor,
-                    const ClutterColor *pick_color)
-{
-  StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
-
-  CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->pick (actor, pick_color);
-
-  clutter_actor_paint (priv->trough);
-
-  if (priv->handle && priv->adjustment)
-    clutter_actor_paint (priv->handle);
-}
-
-static void
 st_scroll_bar_unmap (ClutterActor *actor)
 {
   CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->unmap (actor);
@@ -526,8 +499,6 @@ st_scroll_bar_class_init (StScrollBarClass *klass)
   actor_class->get_preferred_width  = st_scroll_bar_get_preferred_width;
   actor_class->get_preferred_height = st_scroll_bar_get_preferred_height;
   actor_class->allocate       = st_scroll_bar_allocate;
-  actor_class->paint          = st_scroll_bar_paint;
-  actor_class->pick           = st_scroll_bar_pick;
   actor_class->scroll_event   = st_scroll_bar_scroll_event;
   actor_class->unmap          = st_scroll_bar_unmap;
 
diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c
index c4a2796..3dd9327 100644
--- a/src/st/st-scroll-view.c
+++ b/src/st/st-scroll-view.c
@@ -266,10 +266,10 @@ st_scroll_view_paint (ClutterActor *actor)
 {
   StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
 
-  /* StBin will paint the child */
-  CLUTTER_ACTOR_CLASS (st_scroll_view_parent_class)->paint (actor);
+  st_widget_paint_background (ST_WIDGET (actor));
 
-  /* paint our custom children */
+  if (priv->child)
+    clutter_actor_paint (priv->child);
   if (priv->hscrollbar_visible)
     clutter_actor_paint (priv->hscroll);
   if (priv->vscrollbar_visible)
@@ -285,7 +285,8 @@ st_scroll_view_pick (ClutterActor       *actor,
   /* Chain up so we get a bounding box pained (if we are reactive) */
   CLUTTER_ACTOR_CLASS (st_scroll_view_parent_class)->pick (actor, color);
 
-  /* paint our custom children */
+  if (priv->child)
+    clutter_actor_paint (priv->child);
   if (priv->hscrollbar_visible)
     clutter_actor_paint (priv->hscroll);
   if (priv->vscrollbar_visible)
diff --git a/src/st/st-table.c b/src/st/st-table.c
index a44f21f..9b1db4d 100644
--- a/src/st/st-table.c
+++ b/src/st/st-table.c
@@ -916,40 +916,6 @@ st_table_get_preferred_height (ClutterActor *self,
 }
 
 static void
-st_table_paint (ClutterActor *self)
-{
-  GList *list, *children;
-
-  /* make sure the background gets painted first */
-  CLUTTER_ACTOR_CLASS (st_table_parent_class)->paint (self);
-
-  children = st_container_get_children_list (ST_CONTAINER (self));
-  for (list = children; list; list = list->next)
-    {
-      ClutterActor *child = CLUTTER_ACTOR (list->data);
-      if (CLUTTER_ACTOR_IS_VISIBLE (child))
-        clutter_actor_paint (child);
-    }
-}
-
-static void
-st_table_pick (ClutterActor       *self,
-               const ClutterColor *color)
-{
-  GList *list, *children;
-
-  /* Chain up so we get a bounding box painted (if we are reactive) */
-  CLUTTER_ACTOR_CLASS (st_table_parent_class)->pick (self, color);
-
-  children = st_container_get_children_list (ST_CONTAINER (self));
-  for (list = children; list; list = list->next)
-    {
-      if (CLUTTER_ACTOR_IS_VISIBLE (list->data))
-        clutter_actor_paint (CLUTTER_ACTOR (list->data));
-    }
-}
-
-static void
 st_table_show_all (ClutterActor *table)
 {
   GList *l, *children;
@@ -1009,8 +975,6 @@ st_table_class_init (StTableClass *klass)
   gobject_class->get_property = st_table_get_property;
   gobject_class->finalize = st_table_finalize;
 
-  actor_class->paint = st_table_paint;
-  actor_class->pick = st_table_pick;
   actor_class->allocate = st_table_allocate;
   actor_class->get_preferred_width = st_table_get_preferred_width;
   actor_class->get_preferred_height = st_table_get_preferred_height;
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index 5005af1..9cc8848 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -341,22 +341,29 @@ st_widget_get_preferred_height (ClutterActor *self,
   st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
 }
 
-static void
-st_widget_paint (ClutterActor *actor)
+/**
+ * st_widget_paint_background:
+ * @widget: The #StWidget
+ *
+ * Paint the background of the widget. This is meant to be called by
+ * subclasses of StWiget that need to paint the background without
+ * painting children.
+ */
+void
+st_widget_paint_background (StWidget *widget)
 {
-  StWidget *self = ST_WIDGET (actor);
   StThemeNode *theme_node;
   ClutterActorBox allocation;
   guint8 opacity;
 
-  theme_node = st_widget_get_theme_node (self);
+  theme_node = st_widget_get_theme_node (widget);
 
-  clutter_actor_get_allocation_box (actor, &allocation);
+  clutter_actor_get_allocation_box (CLUTTER_ACTOR (widget), &allocation);
 
-  opacity = clutter_actor_get_paint_opacity (actor);
+  opacity = clutter_actor_get_paint_opacity (CLUTTER_ACTOR (widget));
 
-  if (self->priv->transition_animation)
-    st_theme_node_transition_paint (self->priv->transition_animation,
+  if (widget->priv->transition_animation)
+    st_theme_node_transition_paint (widget->priv->transition_animation,
                                     &allocation,
                                     opacity);
   else
@@ -364,6 +371,15 @@ st_widget_paint (ClutterActor *actor)
 }
 
 static void
+st_widget_paint (ClutterActor *actor)
+{
+  st_widget_paint_background (ST_WIDGET (actor));
+
+  /* Chain up so we paint children. */
+  CLUTTER_ACTOR_CLASS (st_widget_parent_class)->paint (actor);
+}
+
+static void
 st_widget_parent_set (ClutterActor *widget,
                       ClutterActor *old_parent)
 {
diff --git a/src/st/st-widget.h b/src/st/st-widget.h
index 10becf8..ed1e508 100644
--- a/src/st/st-widget.h
+++ b/src/st/st-widget.h
@@ -154,6 +154,7 @@ StThemeNode *         st_widget_get_theme_node            (StWidget        *widg
 StThemeNode *         st_widget_peek_theme_node           (StWidget        *widget);
 
 GList *               st_widget_get_focus_chain           (StWidget        *widget);
+void                  st_widget_paint_background          (StWidget        *widget);
 
 
 /* debug methods */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]