mirror of
https://github.com/brl/mutter.git
synced 2025-02-18 14:14:10 +00:00
use clutter_actor_project_point/vertices in clutter_actor_get_abs_position/size
This commit is contained in:
parent
61e3252ff1
commit
1391ee7306
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2007-06-14 Tomas Frydrych <tf@openedhand.com>
|
||||||
|
|
||||||
|
* clutter/clutter-actor.c:
|
||||||
|
(clutter_actor_get_abs_position):
|
||||||
|
(clutter_actor_get_abs_size):
|
||||||
|
Reimplement using clutter_actor_project_point() and
|
||||||
|
clutter_actor_project_vertices().
|
||||||
|
|
||||||
|
* tests/test-project.c:
|
||||||
|
Rename clutter_actor_allocate_coords -> clutter_actor_query_coords
|
||||||
|
|
||||||
2007-06-14 Matthew Allum <mallum@openedhand.com>
|
2007-06-14 Matthew Allum <mallum@openedhand.com>
|
||||||
|
|
||||||
* clutter/clutter-actor.c:
|
* clutter/clutter-actor.c:
|
||||||
|
@ -1553,41 +1553,10 @@ clutter_actor_get_abs_position_units (ClutterActor *self,
|
|||||||
gint32 *x,
|
gint32 *x,
|
||||||
gint32 *y)
|
gint32 *y)
|
||||||
{
|
{
|
||||||
ClutterActorBox box;
|
ClutterUnit zu = 0;
|
||||||
ClutterActor *parent;
|
|
||||||
gint32 px = 0, py = 0;
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
*x = *y = 0;
|
||||||
|
clutter_actor_project_point (self, x, y, &zu);
|
||||||
clutter_actor_query_coords (self, &box);
|
|
||||||
|
|
||||||
parent = self->priv->parent_actor;
|
|
||||||
|
|
||||||
/* FIXME: must be nicer way to get 0,0 for stage ? */
|
|
||||||
if (parent)
|
|
||||||
{
|
|
||||||
ClutterFixed parent_scale_x, parent_scale_y;
|
|
||||||
|
|
||||||
clutter_actor_get_scalex (parent,
|
|
||||||
&parent_scale_x,
|
|
||||||
&parent_scale_y);
|
|
||||||
|
|
||||||
if (parent_scale_x != CFX_ONE ||
|
|
||||||
parent_scale_y != CFX_ONE)
|
|
||||||
{
|
|
||||||
box.x1 = CFX_MUL (box.x1, parent_scale_x);
|
|
||||||
box.y1 = CFX_MUL (box.y1, parent_scale_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CLUTTER_IS_STAGE (parent))
|
|
||||||
clutter_actor_get_abs_position_units (parent, &px, &py);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x)
|
|
||||||
*x = px + box.x1;
|
|
||||||
|
|
||||||
if (y)
|
|
||||||
*y = py + box.y1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1620,6 +1589,16 @@ clutter_actor_get_abs_position (ClutterActor *self,
|
|||||||
* Gets the absolute size of an actor in clutter units taking into account
|
* Gets the absolute size of an actor in clutter units taking into account
|
||||||
* an scaling factors.
|
* an scaling factors.
|
||||||
*
|
*
|
||||||
|
* Note: When the actor (or one of its ancestors) is rotated around the x or y
|
||||||
|
* axis, it no longer appears as on the stage as a rectangle, but as a generic
|
||||||
|
* quadrangle; in that case this function returns the size of the smallest
|
||||||
|
* rectangle that encapsulates the entire quad. Please note that in this case
|
||||||
|
* no assumptions can be made about the relative position of this envelope to
|
||||||
|
* the absolute position of the actor, as returned by
|
||||||
|
* clutter_actor_get_abs_position() - if you need this information, you need
|
||||||
|
* to use clutter_actor_project_vertices() to get the coords of the actual
|
||||||
|
* quadrangle.
|
||||||
|
*
|
||||||
* Since: 0.4
|
* Since: 0.4
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
@ -1627,42 +1606,32 @@ clutter_actor_get_abs_size_units (ClutterActor *self,
|
|||||||
gint32 *width,
|
gint32 *width,
|
||||||
gint32 *height)
|
gint32 *height)
|
||||||
{
|
{
|
||||||
ClutterActorBox box;
|
ClutterVertex v[4];
|
||||||
ClutterActor *parent;
|
ClutterFixed x_min, x_max, y_min, y_max;
|
||||||
|
gint i;
|
||||||
|
|
||||||
clutter_actor_query_coords (self, &box);
|
clutter_actor_project_vertices (self, v);
|
||||||
|
|
||||||
if (width)
|
x_min = x_max = v[0].x;
|
||||||
*width = box.x2 - box.x1;
|
y_min = y_max = v[0].y;
|
||||||
|
|
||||||
if (height)
|
for (i = 1; i < sizeof(v)/sizeof(v[0]); ++i)
|
||||||
*height = box.y2 - box.y1;
|
|
||||||
|
|
||||||
parent = self;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if (parent->priv->scale_x != CFX_ONE ||
|
if (v[i].x < x_min)
|
||||||
parent->priv->scale_y != CFX_ONE)
|
x_min = v[i].x;
|
||||||
{
|
|
||||||
ClutterFixed fx, fy;
|
|
||||||
|
|
||||||
if (width)
|
if (v[i].x > x_max)
|
||||||
{
|
x_max = v[i].x;
|
||||||
fx = CLUTTER_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (*width),
|
|
||||||
parent->priv->scale_x);
|
if (v[i].y < y_min)
|
||||||
*width = CLUTTER_UNITS_FROM_FIXED (fx);
|
y_min = v[i].y;
|
||||||
|
|
||||||
|
if (v[i].y > y_max)
|
||||||
|
y_max = v[i].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height)
|
*width = x_max - x_min;
|
||||||
{
|
*height = y_max - y_min;
|
||||||
fy = CLUTTER_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (*height),
|
|
||||||
parent->priv->scale_x);
|
|
||||||
*height = CLUTTER_UNITS_FROM_FIXED (fy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ((parent = clutter_actor_get_parent (parent)) != NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,12 +116,7 @@ on_event (ClutterStage *stage,
|
|||||||
|
|
||||||
if (actor != CLUTTER_ACTOR (stage))
|
if (actor != CLUTTER_ACTOR (stage))
|
||||||
{
|
{
|
||||||
ClutterVertex v[4];
|
guint32 x, y;
|
||||||
ClutterActorBox b;
|
|
||||||
ClutterFixed vec[4];
|
|
||||||
ClutterFixed m[16];
|
|
||||||
ClutterFixed xp, yp, zp;
|
|
||||||
ClutterFixed xu, yu, zu;
|
|
||||||
|
|
||||||
if (actor != rect)
|
if (actor != rect)
|
||||||
dragging = actor;
|
dragging = actor;
|
||||||
@ -145,8 +140,8 @@ on_event (ClutterStage *stage,
|
|||||||
|
|
||||||
clutter_event_get_coords (event, &x, &y);
|
clutter_event_get_coords (event, &x, &y);
|
||||||
|
|
||||||
clutter_actor_allocate_coords (dragging, &box1);
|
clutter_actor_query_coords (dragging, &box1);
|
||||||
clutter_actor_allocate_coords (rect, &box2);
|
clutter_actor_query_coords (rect, &box2);
|
||||||
|
|
||||||
xp = CLUTTER_INT_TO_FIXED (x-3) - box1.x1;
|
xp = CLUTTER_INT_TO_FIXED (x-3) - box1.x1;
|
||||||
yp = CLUTTER_INT_TO_FIXED (y-3) - box1.y1;
|
yp = CLUTTER_INT_TO_FIXED (y-3) - box1.y1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user