mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 11:02:05 +00:00
clutter/actor: Add API to get fixed position
It's currently a bit hard to get the fixed position of an actor. It can be either done by using g_object_get() with the "fixed-x"/"fixed-y" properties or by calling clutter_actor_get_position(). Calling clutter_actor_get_position() can return the fixed position, but it might also return the allocated position if the allocation is valid. The latter is not the best behavior when querying the fixed position during an allocation, so introduce a new function clutter_actor_get_fixed_position() which always gets the fixed position and returns FALSE in case no fixed position is set. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1310
This commit is contained in:
parent
d722e59aac
commit
dfa235aa5d
@ -10258,6 +10258,43 @@ clutter_actor_get_position (ClutterActor *self,
|
||||
*y = clutter_actor_get_y (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_get_fixed_position:
|
||||
* @self: a #ClutterActor
|
||||
* @x: (out) (allow-none): return location for the X coordinate, or %NULL
|
||||
* @y: (out) (allow-none): return location for the Y coordinate, or %NULL
|
||||
*
|
||||
* This function gets the fixed position of the actor, if set. If there
|
||||
* is no fixed position set, this function returns %FALSE and doesn't set
|
||||
* the x and y coordinates.
|
||||
*
|
||||
* Returns: %TRUE if the fixed position is set, %FALSE if it isn't
|
||||
*/
|
||||
gboolean
|
||||
clutter_actor_get_fixed_position (ClutterActor *self,
|
||||
float *x,
|
||||
float *y)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
|
||||
|
||||
if (self->priv->position_set)
|
||||
{
|
||||
const ClutterLayoutInfo *info;
|
||||
|
||||
info = _clutter_actor_get_layout_info_or_defaults (self);
|
||||
|
||||
if (x)
|
||||
*x = info->fixed_pos.x;
|
||||
|
||||
if (y)
|
||||
*y = info->fixed_pos.y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_get_transformed_position:
|
||||
* @self: A #ClutterActor
|
||||
|
@ -454,6 +454,10 @@ void clutter_actor_set_position
|
||||
gfloat x,
|
||||
gfloat y);
|
||||
CLUTTER_EXPORT
|
||||
gboolean clutter_actor_get_fixed_position (ClutterActor *self,
|
||||
float *x,
|
||||
float *y);
|
||||
CLUTTER_EXPORT
|
||||
void clutter_actor_get_position (ClutterActor *self,
|
||||
gfloat *x,
|
||||
gfloat *y);
|
||||
|
Loading…
Reference in New Issue
Block a user