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
This commit is contained in:
parent
a9f728d2a7
commit
64b2c5d1b4
@ -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)
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -20,28 +20,6 @@ G_DEFINE_TYPE (ShellStack,
|
||||
shell_stack,
|
||||
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,
|
||||
@ -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;
|
||||
|
@ -104,32 +104,6 @@ clutter_container_iface_init (ClutterContainerIface *iface)
|
||||
iface->foreach = st_bin_foreach;
|
||||
}
|
||||
|
||||
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,
|
||||
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -512,41 +512,6 @@ clutter_text_password_char_cb (GObject *object,
|
||||
remove_capslock_feedback (entry);
|
||||
}
|
||||
|
||||
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,
|
||||
@ -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;
|
||||
|
@ -52,28 +52,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,
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -177,33 +177,6 @@ st_scroll_bar_dispose (GObject *gobject)
|
||||
G_OBJECT_CLASS (st_scroll_bar_parent_class)->dispose (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)
|
||||
{
|
||||
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -915,40 +915,6 @@ st_table_get_preferred_height (ClutterActor *self,
|
||||
st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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;
|
||||
|
@ -341,28 +341,44 @@ 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
|
||||
st_theme_node_paint (theme_node, &allocation, opacity);
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user