[gnome-shell/wip/clutter-deprecation-fixes: 10/22] st-widget: Add a proper paint, add st_widget_paint_background
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/clutter-deprecation-fixes: 10/22] st-widget: Add a proper paint, add st_widget_paint_background
- Date: Wed, 15 Feb 2012 12:28:43 +0000 (UTC)
commit fbb49ceeee1ae8f62d3752a89397b2e48f5ef929
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.
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/st/st-box-layout.c | 2 +-
src/st/st-icon.c | 3 +--
src/st/st-label.c | 4 +---
src/st/st-scroll-view.c | 9 +++++----
src/st/st-widget.c | 32 ++++++++++++++++++++++++--------
src/st/st-widget.h | 1 +
8 files changed, 35 insertions(+), 21 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/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-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-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-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]