st-widget: Implement a proper allocate
Since an StWidget now has children, it needs to allocate those children properly. Defer to the currently installed layout manager, like Clutter does. Now that we have something that allocates children in St, to prevent double allocations, we use clutter_actor_set_allocation rather than chaining up to StWidget::allocate. https://bugzilla.gnome.org/show_bug.cgi?id=670034
This commit is contained in:
parent
cc2f5d19c8
commit
ea19790828
@ -66,7 +66,7 @@ shell_generic_container_allocate (ClutterActor *self,
|
||||
StThemeNode *theme_node;
|
||||
ClutterActorBox content_box;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (shell_generic_container_parent_class)->allocate (self, box, flags);
|
||||
clutter_actor_set_allocation (self, box, flags);
|
||||
|
||||
theme_node = st_widget_get_theme_node (ST_WIDGET (self));
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
@ -81,9 +81,7 @@ shell_slicer_allocate (ClutterActor *self,
|
||||
{
|
||||
ClutterActor *child;
|
||||
|
||||
/* Chain up directly to ClutterActor to set actor->allocation. We explicitly skip our parent class
|
||||
* StBin here because we want to override the allocate function. */
|
||||
CLUTTER_ACTOR_CLASS (g_type_class_peek (clutter_actor_get_type ()))->allocate (self, box, flags);
|
||||
clutter_actor_set_allocation (self, box, flags);
|
||||
|
||||
child = st_bin_get_child (ST_BIN (self));
|
||||
if (child)
|
||||
|
@ -29,7 +29,7 @@ shell_stack_allocate (ClutterActor *self,
|
||||
ClutterActorBox content_box;
|
||||
GList *children, *iter;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (shell_stack_parent_class)->allocate (self, box, flags);
|
||||
clutter_actor_set_allocation (self, box, flags);
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
|
@ -111,8 +111,7 @@ st_bin_allocate (ClutterActor *self,
|
||||
{
|
||||
StBinPrivate *priv = ST_BIN (self)->priv;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_bin_parent_class)->allocate (self, box,
|
||||
flags);
|
||||
clutter_actor_set_allocation (self, box, flags);
|
||||
|
||||
if (priv->child)
|
||||
{
|
||||
|
@ -628,8 +628,7 @@ st_box_layout_allocate (ClutterActor *actor,
|
||||
gboolean flip = (st_widget_get_direction (ST_WIDGET (actor)) == ST_TEXT_DIRECTION_RTL)
|
||||
&& (!priv->is_vertical);
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->allocate (actor, box,
|
||||
flags);
|
||||
clutter_actor_set_allocation (actor, box, flags);
|
||||
|
||||
children = st_container_get_children_list (ST_CONTAINER (actor));
|
||||
if (children == NULL)
|
||||
|
@ -382,13 +382,11 @@ st_entry_allocate (ClutterActor *actor,
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
ClutterActorClass *parent_class;
|
||||
ClutterActorBox content_box, child_box, icon_box;
|
||||
gfloat icon_w, icon_h;
|
||||
gfloat entry_h, min_h, pref_h, avail_h;
|
||||
|
||||
parent_class = CLUTTER_ACTOR_CLASS (st_entry_parent_class);
|
||||
parent_class->allocate (actor, box, flags);
|
||||
clutter_actor_set_allocation (actor, box, flags);
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
|
@ -232,7 +232,7 @@ st_icon_allocate (ClutterActor *actor,
|
||||
StIconPrivate *priv = ST_ICON (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_icon_parent_class)->allocate (actor, box, flags);
|
||||
clutter_actor_set_allocation (actor, box, flags);
|
||||
|
||||
if (priv->icon_texture)
|
||||
{
|
||||
|
@ -172,13 +172,11 @@ st_label_allocate (ClutterActor *actor,
|
||||
{
|
||||
StLabelPrivate *priv = ST_LABEL (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
ClutterActorClass *parent_class;
|
||||
ClutterActorBox content_box;
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
clutter_actor_set_allocation (actor, box, flags);
|
||||
|
||||
parent_class = CLUTTER_ACTOR_CLASS (st_label_parent_class);
|
||||
parent_class->allocate (actor, box, flags);
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
clutter_actor_allocate (priv->label, &content_box, flags);
|
||||
}
|
||||
|
@ -368,8 +368,7 @@ st_scroll_bar_allocate (ClutterActor *actor,
|
||||
{
|
||||
StScrollBar *bar = ST_SCROLL_BAR (actor);
|
||||
|
||||
/* Chain up */
|
||||
CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->allocate (actor, box, flags);
|
||||
clutter_actor_set_allocation (actor, box, flags);
|
||||
|
||||
scroll_bar_allocate_children (bar, box, flags);
|
||||
}
|
||||
|
@ -492,24 +492,13 @@ st_scroll_view_allocate (ClutterActor *actor,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
ClutterActorBox content_box, child_box;
|
||||
ClutterActorClass *parent_parent_class;
|
||||
gfloat avail_width, avail_height, sb_width, sb_height;
|
||||
gboolean hscrollbar_visible, vscrollbar_visible;
|
||||
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
|
||||
/* Chain up to the parent's parent class
|
||||
*
|
||||
* We do this because we do not want StBin to allocate the child, as we
|
||||
* give it a different allocation later, depending on whether the scrollbars
|
||||
* are visible
|
||||
*/
|
||||
parent_parent_class
|
||||
= g_type_class_peek_parent (st_scroll_view_parent_class);
|
||||
|
||||
CLUTTER_ACTOR_CLASS (parent_parent_class)->
|
||||
allocate (actor, box, flags);
|
||||
clutter_actor_set_allocation (actor, box, flags);
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
|
@ -717,7 +717,7 @@ st_table_allocate (ClutterActor *self,
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
|
||||
ClutterActorBox content_box;
|
||||
|
||||
CLUTTER_ACTOR_CLASS (st_table_parent_class)->allocate (self, box, flags);
|
||||
clutter_actor_set_allocation (self, box, flags);
|
||||
|
||||
if (priv->n_cols < 1 || priv->n_rows < 1)
|
||||
return;
|
||||
|
@ -329,6 +329,32 @@ 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_allocate (ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
ClutterActorBox content_box;
|
||||
|
||||
/* Note that we can't just chain up to clutter_actor_real_allocate --
|
||||
* Clutter does some dirty tricks for backwards compatibility.
|
||||
* Clutter also passes the actor's allocation directly to the layout
|
||||
* manager, meaning that we can't modify it for children only.
|
||||
*/
|
||||
|
||||
clutter_actor_set_allocation (actor, box, flags);
|
||||
|
||||
st_theme_node_get_content_box (theme_node, box, &content_box);
|
||||
|
||||
/* If we've chained up to here, we want to allocate the children using the
|
||||
* currently installed layout manager */
|
||||
clutter_layout_manager_allocate (clutter_actor_get_layout_manager (actor),
|
||||
CLUTTER_CONTAINER (actor),
|
||||
&content_box,
|
||||
flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_widget_paint_background:
|
||||
* @widget: The #StWidget
|
||||
@ -713,6 +739,7 @@ st_widget_class_init (StWidgetClass *klass)
|
||||
|
||||
actor_class->get_preferred_width = st_widget_get_preferred_width;
|
||||
actor_class->get_preferred_height = st_widget_get_preferred_height;
|
||||
actor_class->allocate = st_widget_allocate;
|
||||
actor_class->paint = st_widget_paint;
|
||||
actor_class->get_paint_volume = st_widget_get_paint_volume;
|
||||
actor_class->parent_set = st_widget_parent_set;
|
||||
|
Loading…
Reference in New Issue
Block a user