mirror of
https://github.com/brl/mutter.git
synced 2025-03-03 19:58:10 +00:00
[actor] Add allocate_available_size()
The allocate_available_size() method is a convenience method in the same spirit as allocate_preferred_size(). While the latter will allocate the preferred size of an actor regardless of the available size provided by the actor's parent -- and thus it's suitable for simple fixed layout managers like ClutterGroup -- the former will take into account the available size provided by the parent and never allocate more than that; it is, thus, suitable for simple fluid layout managers.
This commit is contained in:
parent
293eeed507
commit
4afe1e9a8b
@ -8166,6 +8166,118 @@ clutter_actor_get_stage (ClutterActor *actor)
|
|||||||
return actor;
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clutter_actor_allocate_available_size:
|
||||||
|
* @self: a #ClutterActor
|
||||||
|
* @x: the actor's X coordinate
|
||||||
|
* @y: the actor's Y coordinate
|
||||||
|
* @available_width: the maximum available width, or -1 to use the
|
||||||
|
* actor's natural width
|
||||||
|
* @available_height: the maximum available height, or -1 to use the
|
||||||
|
* actor's natural height
|
||||||
|
* @absolute_origin_changed: whether the position of the parent has
|
||||||
|
* changed in stage coordinates
|
||||||
|
*
|
||||||
|
* Allocates @self taking into account the #ClutterActor<!-- -->'s
|
||||||
|
* preferred size, but limiting it to the maximum available width
|
||||||
|
* and height provided.
|
||||||
|
*
|
||||||
|
* This function will do the right thing when dealing with the
|
||||||
|
* actor's request mode.
|
||||||
|
*
|
||||||
|
* The implementation of this function is equivalent to:
|
||||||
|
*
|
||||||
|
* |[
|
||||||
|
* if (request_mode == CLUTTER_REQUEST_HEIGHT_FOR_WIDTH)
|
||||||
|
* {
|
||||||
|
* clutter_actor_get_preferred_width (self, available_height,
|
||||||
|
* &min_width,
|
||||||
|
* &natural_width);
|
||||||
|
* width = CLAMP (natural_width, min_width, available_width);
|
||||||
|
*
|
||||||
|
* clutter_actor_get_preferred_height (self, width,
|
||||||
|
* &min_height,
|
||||||
|
* &natural_height);
|
||||||
|
* height = CLAMP (natural_height, min_height, available_height);
|
||||||
|
* }
|
||||||
|
* else
|
||||||
|
* {
|
||||||
|
* clutter_actor_get_preferred_height (self, available_width,
|
||||||
|
* &min_height,
|
||||||
|
* &natural_height);
|
||||||
|
* height = CLAMP (natural_height, min_height, available_height);
|
||||||
|
*
|
||||||
|
* clutter_actor_get_preferred_width (self, height,
|
||||||
|
* &min_width,
|
||||||
|
* &natural_width);
|
||||||
|
* width = CLAMP (natural_width, min_width, available_width);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* box.x1 = x; box.y1 = y;
|
||||||
|
* box.x2 = box.x1 + available_width;
|
||||||
|
* box.y2 = box.y1 + available_height;
|
||||||
|
* clutter_actor_allocate (self, &box, absolute_origin_changed);
|
||||||
|
* ]|
|
||||||
|
*
|
||||||
|
* This function can be used by fluid layout managers to allocate
|
||||||
|
* an actor's preferred size without making it bigger than the area
|
||||||
|
* available for the container.
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
clutter_actor_allocate_available_size (ClutterActor *self,
|
||||||
|
gfloat x,
|
||||||
|
gfloat y,
|
||||||
|
gfloat available_width,
|
||||||
|
gfloat available_height,
|
||||||
|
gboolean absolute_origin_changed)
|
||||||
|
{
|
||||||
|
ClutterActorPrivate *priv;
|
||||||
|
gfloat width, height;
|
||||||
|
gfloat min_width, min_height;
|
||||||
|
gfloat natural_width, natural_height;
|
||||||
|
ClutterActorBox box;
|
||||||
|
|
||||||
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
|
priv = self->priv;
|
||||||
|
|
||||||
|
switch (priv->request_mode)
|
||||||
|
{
|
||||||
|
case CLUTTER_REQUEST_HEIGHT_FOR_WIDTH:
|
||||||
|
clutter_actor_get_preferred_width (self, available_height,
|
||||||
|
&min_width,
|
||||||
|
&natural_width);
|
||||||
|
width = CLAMP (natural_width, min_width, available_width);
|
||||||
|
|
||||||
|
clutter_actor_get_preferred_height (self, width,
|
||||||
|
&min_height,
|
||||||
|
&natural_height);
|
||||||
|
height = CLAMP (natural_height, min_height, available_height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CLUTTER_REQUEST_WIDTH_FOR_HEIGHT:
|
||||||
|
clutter_actor_get_preferred_height (self, available_width,
|
||||||
|
&min_height,
|
||||||
|
&natural_height);
|
||||||
|
height = CLAMP (natural_height, min_height, available_height);
|
||||||
|
|
||||||
|
clutter_actor_get_preferred_width (self, height,
|
||||||
|
&min_width,
|
||||||
|
&natural_width);
|
||||||
|
width = CLAMP (natural_width, min_width, available_width);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
box.x1 = x;
|
||||||
|
box.y1 = y;
|
||||||
|
box.x2 = box.x1 + width;
|
||||||
|
box.y2 = box.y1 + height;
|
||||||
|
clutter_actor_allocate (self, &box, absolute_origin_changed);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_actor_allocate_preferred_size:
|
* clutter_actor_allocate_preferred_size:
|
||||||
* @self: a #ClutterActor
|
* @self: a #ClutterActor
|
||||||
|
@ -323,6 +323,12 @@ void clutter_actor_allocate (ClutterActor
|
|||||||
gboolean absolute_origin_changed);
|
gboolean absolute_origin_changed);
|
||||||
void clutter_actor_allocate_preferred_size (ClutterActor *self,
|
void clutter_actor_allocate_preferred_size (ClutterActor *self,
|
||||||
gboolean absolute_origin_changed);
|
gboolean absolute_origin_changed);
|
||||||
|
void clutter_actor_allocate_available_size (ClutterActor *self,
|
||||||
|
gfloat x,
|
||||||
|
gfloat y,
|
||||||
|
gfloat available_width,
|
||||||
|
gfloat available_height,
|
||||||
|
gboolean absolute_origin_changed);
|
||||||
void clutter_actor_get_allocation_coords (ClutterActor *self,
|
void clutter_actor_get_allocation_coords (ClutterActor *self,
|
||||||
gint *x_1,
|
gint *x_1,
|
||||||
gint *y_1,
|
gint *y_1,
|
||||||
|
@ -301,6 +301,7 @@ clutter_actor_unmap
|
|||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
clutter_actor_allocate
|
clutter_actor_allocate
|
||||||
clutter_actor_allocate_preferred_size
|
clutter_actor_allocate_preferred_size
|
||||||
|
clutter_actor_allocate_available_size
|
||||||
clutter_actor_get_allocation_coords
|
clutter_actor_get_allocation_coords
|
||||||
clutter_actor_get_allocation_box
|
clutter_actor_get_allocation_box
|
||||||
clutter_actor_get_allocation_geometry
|
clutter_actor_get_allocation_geometry
|
||||||
|
Loading…
x
Reference in New Issue
Block a user