mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
clutter/actor: Add get_transformed_extents
The clutter_actor_get_transformed_position returns the position of the top left point of the actor, with the actor transformations. That means that if the actor is rotated 180º it'll return the "screen" position top right. Using this to calculate if the actor is in the screen is causing problems when it's transformted. This patch adds a new function clutter_actor_get_transformed_extents, that will return the transformed actor bounding rect. This new function is used on the update_stage_views so the actor will get updated. this way rotated actors will be updated if they are on the screen. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1386
This commit is contained in:
parent
2c08eb6d16
commit
109fbdbac9
@ -10295,6 +10295,38 @@ clutter_actor_get_fixed_position (ClutterActor *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_get_transformed_extents:
|
||||
* @self: A #ClutterActor
|
||||
* @rect: (out): return location for the transformed bounding rect
|
||||
*
|
||||
* Gets the transformed bounding rect of an actor, in pixels relative to the stage.
|
||||
*/
|
||||
void
|
||||
clutter_actor_get_transformed_extents (ClutterActor *self,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
graphene_quad_t quad;
|
||||
graphene_point3d_t v[4];
|
||||
ClutterActorBox box;
|
||||
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = clutter_actor_box_get_width (&self->priv->allocation);
|
||||
box.y2 = clutter_actor_box_get_height (&self->priv->allocation);
|
||||
if (_clutter_actor_transform_and_project_box (self, &box, v))
|
||||
{
|
||||
graphene_quad_init (&quad,
|
||||
(graphene_point_t *) &v[0],
|
||||
(graphene_point_t *) &v[1],
|
||||
(graphene_point_t *) &v[2],
|
||||
(graphene_point_t *) &v[3]);
|
||||
|
||||
if (rect)
|
||||
graphene_quad_bounds (&quad, rect);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_get_transformed_position:
|
||||
* @self: A #ClutterActor
|
||||
@ -16183,12 +16215,7 @@ update_stage_views (ClutterActor *self)
|
||||
stage = CLUTTER_STAGE (_clutter_actor_get_stage_internal (self));
|
||||
g_return_if_fail (stage);
|
||||
|
||||
clutter_actor_get_transformed_position (self,
|
||||
&bounding_rect.origin.x,
|
||||
&bounding_rect.origin.y);
|
||||
clutter_actor_get_transformed_size (self,
|
||||
&bounding_rect.size.width,
|
||||
&bounding_rect.size.height);
|
||||
clutter_actor_get_transformed_extents (self, &bounding_rect);
|
||||
|
||||
if (bounding_rect.size.width == 0.0 ||
|
||||
bounding_rect.size.height == 0.0)
|
||||
|
@ -813,6 +813,11 @@ void clutter_actor_set_child_transform
|
||||
CLUTTER_EXPORT
|
||||
void clutter_actor_get_child_transform (ClutterActor *self,
|
||||
ClutterMatrix *transform);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
void clutter_actor_get_transformed_extents (ClutterActor *self,
|
||||
graphene_rect_t *rect);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
void clutter_actor_get_transformed_position (ClutterActor *self,
|
||||
gfloat *x,
|
||||
|
Loading…
Reference in New Issue
Block a user