mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
clutter/actor: Add position argument to allocate_preferred_size()
Make clutter_actor_allocate_preferred_size() convenient to use from layout managers by not "automatically" honouring the fixed position of the actor, but instead allowing to pass a position to allocate the actor at. This way we can move the handling of fixed positions to ClutterFixedLayout, the layout manager which is responsible for allocating actors using fixed positions. This also makes clutter_actor_allocate_preferred_size() more similar to clutter_actor_allocate_available_size(). https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1310
This commit is contained in:
parent
dfa235aa5d
commit
03d177cf64
@ -14034,6 +14034,8 @@ clutter_actor_allocate_available_size (ClutterActor *self,
|
|||||||
/**
|
/**
|
||||||
* clutter_actor_allocate_preferred_size:
|
* clutter_actor_allocate_preferred_size:
|
||||||
* @self: a #ClutterActor
|
* @self: a #ClutterActor
|
||||||
|
* @x: the actor's X coordinate
|
||||||
|
* @y: the actor's Y coordinate
|
||||||
*
|
*
|
||||||
* Allocates the natural size of @self.
|
* Allocates the natural size of @self.
|
||||||
*
|
*
|
||||||
@ -14051,37 +14053,22 @@ clutter_actor_allocate_available_size (ClutterActor *self,
|
|||||||
* Since: 0.8
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
clutter_actor_allocate_preferred_size (ClutterActor *self)
|
clutter_actor_allocate_preferred_size (ClutterActor *self,
|
||||||
|
float x,
|
||||||
|
float y)
|
||||||
{
|
{
|
||||||
gfloat actor_x, actor_y;
|
|
||||||
gfloat natural_width, natural_height;
|
gfloat natural_width, natural_height;
|
||||||
ClutterActorBox actor_box;
|
ClutterActorBox actor_box;
|
||||||
ClutterActorPrivate *priv;
|
|
||||||
const ClutterLayoutInfo *info;
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
priv = self->priv;
|
|
||||||
|
|
||||||
if (priv->position_set)
|
|
||||||
{
|
|
||||||
info = _clutter_actor_get_layout_info_or_defaults (self);
|
|
||||||
actor_x = info->fixed_pos.x;
|
|
||||||
actor_y = info->fixed_pos.y;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
actor_x = 0;
|
|
||||||
actor_y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
clutter_actor_get_preferred_size (self,
|
clutter_actor_get_preferred_size (self,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
&natural_width,
|
&natural_width,
|
||||||
&natural_height);
|
&natural_height);
|
||||||
|
|
||||||
actor_box.x1 = actor_x;
|
actor_box.x1 = x;
|
||||||
actor_box.y1 = actor_y;
|
actor_box.y1 = y;
|
||||||
actor_box.x2 = actor_box.x1 + natural_width;
|
actor_box.x2 = actor_box.x1 + natural_width;
|
||||||
actor_box.y2 = actor_box.y1 + natural_height;
|
actor_box.y2 = actor_box.y1 + natural_height;
|
||||||
|
|
||||||
|
@ -419,7 +419,9 @@ CLUTTER_EXPORT
|
|||||||
void clutter_actor_allocate (ClutterActor *self,
|
void clutter_actor_allocate (ClutterActor *self,
|
||||||
const ClutterActorBox *box);
|
const ClutterActorBox *box);
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
void clutter_actor_allocate_preferred_size (ClutterActor *self);
|
void clutter_actor_allocate_preferred_size (ClutterActor *self,
|
||||||
|
float x,
|
||||||
|
float y);
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
void clutter_actor_allocate_available_size (ClutterActor *self,
|
void clutter_actor_allocate_available_size (ClutterActor *self,
|
||||||
gfloat x,
|
gfloat x,
|
||||||
|
@ -245,7 +245,13 @@ clutter_clone_allocate (ClutterActor *self,
|
|||||||
*/
|
*/
|
||||||
if (clutter_actor_get_parent (priv->clone_source) != NULL &&
|
if (clutter_actor_get_parent (priv->clone_source) != NULL &&
|
||||||
!clutter_actor_has_allocation (priv->clone_source))
|
!clutter_actor_has_allocation (priv->clone_source))
|
||||||
clutter_actor_allocate_preferred_size (priv->clone_source);
|
{
|
||||||
|
float x = 0.f;
|
||||||
|
float y = 0.f;
|
||||||
|
|
||||||
|
clutter_actor_get_fixed_position (priv->clone_source, &x, &y);
|
||||||
|
clutter_actor_allocate_preferred_size (priv->clone_source, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
clutter_actor_get_allocation_box (priv->clone_source, &source_box);
|
clutter_actor_get_allocation_box (priv->clone_source, &source_box);
|
||||||
|
|
||||||
|
@ -139,7 +139,11 @@ clutter_fixed_layout_allocate (ClutterLayoutManager *manager,
|
|||||||
child != NULL;
|
child != NULL;
|
||||||
child = clutter_actor_get_next_sibling (child))
|
child = clutter_actor_get_next_sibling (child))
|
||||||
{
|
{
|
||||||
clutter_actor_allocate_preferred_size (child);
|
float x = 0.f;
|
||||||
|
float y = 0.f;
|
||||||
|
|
||||||
|
clutter_actor_get_fixed_position (child, &x, &y);
|
||||||
|
clutter_actor_allocate_preferred_size (child, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1245,6 +1245,8 @@ clutter_stage_maybe_relayout (ClutterActor *actor)
|
|||||||
for (l = stolen_list; l; l = l->next)
|
for (l = stolen_list; l; l = l->next)
|
||||||
{
|
{
|
||||||
g_autoptr (ClutterActor) queued_actor = l->data;
|
g_autoptr (ClutterActor) queued_actor = l->data;
|
||||||
|
float x = 0.f;
|
||||||
|
float y = 0.f;
|
||||||
|
|
||||||
if (CLUTTER_ACTOR_IN_RELAYOUT (queued_actor)) /* avoid reentrancy */
|
if (CLUTTER_ACTOR_IN_RELAYOUT (queued_actor)) /* avoid reentrancy */
|
||||||
continue;
|
continue;
|
||||||
@ -1258,7 +1260,8 @@ clutter_stage_maybe_relayout (ClutterActor *actor)
|
|||||||
|
|
||||||
CLUTTER_SET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT);
|
CLUTTER_SET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT);
|
||||||
|
|
||||||
clutter_actor_allocate_preferred_size (queued_actor);
|
clutter_actor_get_fixed_position (queued_actor, &x, &y);
|
||||||
|
clutter_actor_allocate_preferred_size (queued_actor, x, y);
|
||||||
|
|
||||||
CLUTTER_UNSET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT);
|
CLUTTER_UNSET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user