Commit Graph

825 Commits

Author SHA1 Message Date
Emmanuele Bassi
9424e995fa actor: Improve conditions for skipping implicit transitions
The "should this implicit transition be skipped" check should live into
its own function, where we can actually explain what it does and which
conditions should be respected.

Instead of just blindly skipping actors that are unmapped, or haven't
been painted yet, we should add a couple of escape hatches.

First of all, we don't want :allocation to be implicitly animated until
we have been painted (thus allocated) once; this avoids actors "flying
in" into their allocation.

We also want to allow implicit transitions on the opacity even if we
haven't been painted yet; the internal optimization that we employ in
clutter_actor_paint() and skips painting fully transparent actors is
exactly that: an internal optimization. Caller code should not be aware
of this change, and it should not influence code outside of ClutterActor
itself.

The rest of the conditions are the same: if the easing state's duration
is zero, or if the actor is both unmapped and not in a cloned branch of
the scene graph, then implicit transitions are pointless, as they won't
be painted.

https://bugzilla.gnome.org/show_bug.cgi?id=698766
2013-05-06 10:04:22 -07:00
Lionel Landwerlin
b914ae70b1 actor: fix translation-z setting
https://bugzilla.gnome.org/show_bug.cgi?id=695982
2013-03-18 10:39:08 +00:00
Emmanuele Bassi
8f032d5952 actor: Skip transitions on invisible actors
If an actor has not been painted yet, or it's not going to be painted,
we can ignore transitions queued on it.

By ignoring transitions on actors that have not been painted yet, we can
avoid doing work during the set up phase of the scene graph, as well as
avoiding actors "flying in" from nowhere.

Obviously, we have to take into account potential clones, so we need to
check that the actor is not part of a cloned branch of the scene graph,
as well as checking if the actor has mapped clones.
2013-03-13 15:05:28 -03:00
Emmanuele Bassi
20c0985869 actor: Propagate the cloned state to the children
If we clone a container, we still want redraws queued on the children to
be propagated.
2013-03-13 15:05:28 -03:00
Emmanuele Bassi
0e0db890e1 actor: Ignore redraws queued on unmapped actors
If an actor is unmapped then it won't be painted, so we can safely
short-circuit out of _clutter_actor_queue_redraw_full() if the mapped
flag is not set.

We need, on the other hand, make an exception for Clones, otherwise
they won't receive notification that the source actor has changed
and they won't be painted.

This allows us to ignore redraws queued on children of invisible
parents, and avoid traversing the scene graph.
2013-03-13 15:05:28 -03:00
Emmanuele Bassi
028baa99a0 actor: Keep track of clones
Instead of using signal notifications, we should be able to keep track
of the clones of an actor from within ClutterActor itself, using private
API. There's no point in pretending that people can actually create a
Clone class out of tree, given the amount of invariants we have to punch
through in order to implement a proper replicator node of the scene
graph, so we can just skip the signal emissions and just do the right
thing at the right time.
2013-03-13 15:05:28 -03:00
Emmanuele Bassi
c32973158d actor: Clean up internal add/remove functions
More comments are warranted: these functions are pretty much full of
potential side effects, and I'd really like to avoid keeping everything
in my head forever.

Along with the comments and the type casting reduction, I sneaked in a
one line change that is clearly correct after reading the flow of the
whole thing: we queue only a relayout after three potential redraws have
been queued. If we manage to miss a redraw and yet still get a relayout
then it means that most of our assumptions are fundamentally wrong, and
that we ought to dump this whole business of computer programming, and
just go back to being a hunter-gatherer species.
2013-03-13 15:05:28 -03:00
Emmanuele Bassi
900015a4eb actor: Clean up ::show and ::hide class handlers
The main body of the function should not live inside an 'if' block.
2013-03-13 15:05:27 -03:00
Emmanuele Bassi
a622d34444 actor: Revert the Transition/Actor leak fix
The original code inside ClutterActor that dealt with Transitions
stopping was written for the ::completed signal, thus the code was
correctly handling the lifetime of the instances; when we moved to the
::stopped signal, we assumed that it worked in the same way - with less
conditions to be checked, obviously, but fundamentally similar to the
::completed signal. Sadly, I screwed up the signal definition, and the
signal ended up calling our handlers, but not the default one that did
the cleanup and released references on the Animatable instance.

After fixing the Timeline::stopped signal, we can go back to the
previous code.

Thanks to Craig Hughes for the help in tracking down this mess.

https://bugzilla.gnome.org/show_bug.cgi?id=695158
2013-03-05 00:48:11 +00:00
Emmanuele Bassi
f3659d35a0 actor: Release a reference on the implicit Transitions
When stopping the transition we need to release the reference we
maintain while removing the Transition from the hash table inside an
actor. If we fail to do so, the Transition is never released, which
means we leak the Animatable instance we tied to it.

https://bugzilla.gnome.org/show_bug.cgi?id=695158
2013-03-04 23:06:27 +00:00
Emmanuele Bassi
1f3e56b3be docs: Clean up the documentation for the allocate() methods
The wording could be better, especially on the side effects and the
honoured state.
2013-03-04 12:24:24 +00:00
Emmanuele Bassi
67f10bcc6f docs: Clean up the wording of a couple of comments 2013-03-04 12:24:24 +00:00
Emmanuele Bassi
e317ca11fc Fix compiler warnings by initializing variables 2013-02-21 00:39:15 +00:00
Jasper St. Pierre
50f6b2ac2c actor: Fix clutter_actor_allocate_align_fill for partially-filled actors
If we pass TRUE for x_align and FALSE for y_align, the full available
width should be passed to clutter_get_preferred_height, and the same
should be true in the other dimension.

https://bugzilla.gnome.org/show_bug.cgi?id=694237
2013-02-21 00:13:11 +00:00
Josselin Mouette
e4598a9e52 actor: Use the correct return value
The get_z_rotation_gravity() method returns an enumeration value, not a
floating point value.

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=694187
2013-02-20 23:06:28 +00:00
Jasper St. Pierre
578e81dc2e actor: Correct documentation formatting for clutter_actor_event()
TRUE and FALSE need to be symbolified here.
2013-01-14 13:00:28 -05:00
Jasper St. Pierre
0caba876e6 actor: Fix documentation reference for pivot-point 2013-01-14 13:00:28 -05:00
Tomeu Vizoso
060b05cc29 actor: Remove transition when stopping it
This covers more cases when the transition completes but was still
being tracked by its actor.

https://bugzilla.gnome.org/show_bug.cgi?id=685982
2012-12-18 01:27:32 +00:00
Emmanuele Bassi
84b4f2f0a3 actor: Clean up the code in ::apply-transform
Instead of placing the whole body of the function inside an if block,
let's make it clear what each part of the function does. Also, add more
comments.
2012-12-18 00:05:42 +00:00
Emanuele Aina
219d0efcc6 actor: rollback pivot translation even on explicit transforms
When setting an explicit transform with clutter_actor_set_transform()
and a non (0,0) pivot-point, clutter_actor_apply_transform() will fail
to roll back the pivot-point translation done before multiplying the
transformation matrix due to the "out:" label being slightly misplaced
in clutter_actor_real_apply_transform().

This works properly:
  clutter_actor_set_pivot_point (actor, 0.5, 0.5);
  clutter_actor_set_rotation_angle (actor, CLUTTER_Z_AXIS, 30);

This results in the actor being moved to the pivot-point position:
  clutter_actor_set_pivot_point (actor, 0.5, 0.5);
  clutter_matrix_init_identity(&matrix);
  cogl_matrix_rotate (&matrix, 30, 0, 0, 1.0);
  clutter_actor_set_transform (actor, &matrix);

This also add a conformance test checking that even when using a
pivot-point, no matter how a rotation is set the resulting
transformation matrix will be the same.

https://bugzilla.gnome.org/show_bug.cgi?id=690214
2012-12-14 19:15:48 +01:00
Jasper St. Pierre
15b811840c actor: Use fixed positioning for allocate_preferred_size
clutter_actor_allocate_preferred_size is supposed to use the fixed
position of an actor. Unfortunately, recent refactorings made it so
that it accidentally used the current allocation. As the current
allocation may be adjusted by the actor, or have been previously
allocated in a strange spot, it may have unintended side effects. Use
the fixed positioning of the actor instead.

This fixes weird issues with margins colliding with
ClutterFixedLayout, causing strange offsets on relayout.

https://bugzilla.gnome.org/show_bug.cgi?id=689316
2012-11-30 18:13:53 -05:00
Lionel Landwerlin
da498fdb9a actor: fix allocate_align_fill() to maintain the child preferred size
When trying to clamp to pixel a box that is exactly in between 2
pixels, the clutter_actor_box_clamp_to_pixel() function changes the
size of the box.

Here is an example :

ClutterActorBox box = { 10.5, 10, 20.5, 20};

g_message ("%fx%f -> %fx%f", box.x1, box.y1, box.x2, box.y2);
clutter_actor_box_clamp_to_pixel (&box);
g_message ("%fx%f -> %fx%f", box.x1, box.y1, box.x2, box.y2);

Here is what you get :

** Message: 10.500000x10.000000 -> 20.500000x20.000000
** Message: 10.000000x10.000000 -> 21.000000x20.000000

That is because of the properties of the ceilf and floorf function
used to do the clamping.

For example, ceil(0.5) is 1.0, and ceil(-0.5) is 0.0.
And, floor(0.5) is 0.0, and floor(-0.5) is -1.0.

To work around that problem this patch retains the distance between x
and y coordinates and apply that difference before calling ceilf() on
x2 and y2.

https://bugzilla.gnome.org/show_bug.cgi?id=689073
2012-11-26 11:22:24 +00:00
Guillaume Desmottes
2be88b34b2 Don't annotate with (transfer full) constructors of GInitiallyUnowned subclasses
https://bugzilla.gnome.org/show_bug.cgi?id=686776
2012-10-24 13:17:57 +02:00
Tomeu Vizoso
36c2343001 actor: Place coordinate of the pivot point in the right pointer 2012-10-08 11:08:20 +02:00
Emmanuele Bassi
696f1afc04 actor: Fix transform-set condition
The :transform-set property is set if the matrix in :transform is not
the identity matrix.
2012-09-25 09:12:54 +01:00
Debarshi Ray
c3e574a389 actor: Fix the content box for CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT
The code for calculating the content box when the aspect ratio is
greater than 1 was broken. The same code that did the calculation for
aspect ratio less than 1 should be used in all cases.

Fixes: https://bugzilla.gnome.org/682161
2012-09-07 21:23:24 +01:00
Emmanuele Bassi
48a2846ab9 actor: Make :transform and :child-transform animatable
Now that we can interpolate between two matrices, we can mark the
matrix-based property as animatable.
2012-09-03 21:00:40 +01:00
Emmanuele Bassi
03f4f1c69e actor: Remove existing implicit transition if duration is 0
When changing an implicit transition mid flight we may end up with an
easing state with a duration of zero milliseconds; this leads to the
implicit transition machinery setting the final state directly onto the
actor. If there is a running transition, though, we need to remove it
from the transitions table, otherwise it will keep running.

This regression happened when the update_transition() internal function
was merged into the create_transition() one.

Tested-by: Lionel Landwerlin <llandwerlin@gmail.com>
2012-09-03 13:03:16 +01:00
Lionel Landwerlin
fe92acd649 actor-iter: fix prev()/next() annotations
https://bugzilla.gnome.org/show_bug.cgi?id=682795
2012-08-27 13:47:29 +01:00
Emmanuele Bassi
3937a7c74c actor: Setting the child-transform invalidates the children's modelview
We need to ensure that the children's cached modelview matrix gets
invalidated when setting the :child-transform property on their parent.
2012-08-27 12:24:20 +01:00
Emmanuele Bassi
1b155504c5 actor: Call queue_redraw() when setting child-transform 2012-08-27 10:48:28 +01:00
Emmanuele Bassi
6bf0b983af actor: Deprecate the pick signal
Just like we did for the paint signal; a warning will be emitted if the
diagnostic mode of GLib is enabled through the G_ENABLE_DIAGNOSTIC env
var.
2012-08-27 10:48:27 +01:00
Emmanuele Bassi
ffe32426b8 actor: Add the :child-transform property
An additional transformation that is applied to the children of an actor
before their own transformations, but not to the actor itself.
2012-08-19 17:23:26 +01:00
Emmanuele Bassi
93a43f879d Deprecate ClutterActor::paint
Only the signal connection. When using G_ENABLE_DIAGNOSTIC there will be
a warning for every signal connection.

We should try and discourage people from ever using the paint signal
ever again, until we can safely remove it in Clutter 2.0.
2012-08-11 11:43:28 +01:00
Emmanuele Bassi
5b7c61a026 actor: Deprecate Geometry-related API
We cannot fully deprecate Geometry, because ClutterActor and ClutterText
are actually using the type in signals and properties; but we can
deprecate the API that uses this type, so that 2.0 will be able to avoid
it entirely.
2012-08-10 15:05:43 +01:00
Emmanuele Bassi
7a59b69f96 actor: Deprecate :clip and introduce :clip-rect instead
The :clip property still uses ClutterGeometry, which is a very bad
rectangle type. Since we cannot change the type of the property
compatibly, we should introduce a new property using ClutterRect
instead. This also matches the ClutterActor.set_clip() API, which uses a
decomposed rectangle with floating point values, like we do with
set_position() and set_size().
2012-08-10 15:05:33 +01:00
Emmanuele Bassi
9515cc5b94 docs: Fix the link to set_content_gravity() 2012-08-10 15:05:28 +01:00
Emmanuele Bassi
a4d1e6f6f1 actor: Ensure the invariants of transition-stopped
We need to make sure that ClutterActor::transition-stopped is emitted
after the transition was removed from the actor's list of transitions.

We cannot just remove the TransitionClosure from the hash table that
holds the transitions associated to an actor, and let the
TransitionClosure free function stop the timeline, thus emitting the
::transition-stopped signal - otherwise, stopping the timeline will end
up trying to remove the transition from the hash table, and we'll get
either a warning or a segfault.

Since we know we're removing the timeline anyway, we can emit the signal
ourselves in case the timeline is playing, in both the implicit and
explicit cases.
2012-07-26 14:01:01 +01:00
Emmanuele Bassi
17860b128e Annotate things to be removed/changed for 2.0
Lest we forget, like we did during the 0.9 → 1.0 cycle.
2012-07-26 14:01:01 +01:00
Emmanuele Bassi
178e6b2294 Add ClutterActor.transform
The :transform property controls the modelview matrix of an actor; it
can be used to set a custom modelview matrix on the actor, as opposed
to the decomposed transformations (rotation, scaling, translation)
provided by the ClutterActor class.
2012-07-26 14:01:00 +01:00
Emmanuele Bassi
3f732cdc2b actor: Ensure that we remove only implicit transitions
The transitions we create implicitly should be removed from the set of
transitions associated to an actor; the transitions explicitly
associated to an actor, though, have to survive the emission of their
'stopped' signal.
2012-07-26 14:01:00 +01:00
Emmanuele Bassi
ee00e37bc4 actor: Simplify the implicit transition handling
We can remove the update_transition() private method, and move its
functionality inside the create_transition() private method, thereby
removing lots of duplicated code, as well as redundant checks on the
existence of a transition. This will allow handling transition updates
atomically in the future.
2012-07-26 14:01:00 +01:00
Emmanuele Bassi
28c2eeef95 actor: Add ::transition-stopped
The ::transition-stopped signal can be used to get notification of the
end of a transition.
2012-07-26 14:01:00 +01:00
Emmanuele Bassi
b10e7057ad actor: Consolidate rotation angle internal setter
Use the GParamSpec, instead of the rotation axis enumeration, to
simplify the caller code, similarly to how we handle scaling and
translation factors.
2012-07-19 13:58:50 -04:00
Emmanuele Bassi
2bec43c3c2 actor: Round the adjusted allocation origin correctly
We use floorf() for the allocation origin, and ceilf() for the
allocation size. Swapping the two introduces rounding errors if
the original allocation is not clamped to the nearest pixel.
2012-07-12 22:32:02 +01:00
Emmanuele Bassi
42ca7bf1f4 Use Vertex zero init macro 2012-07-11 13:22:21 +01:00
Emmanuele Bassi
9b52f9b3f5 actor: Add scaling factor in the Z axis
Having a scaling factor on the Z axis helps with projects that use fully
3D elements, like Mash.

https://bugzilla.gnome.org/show_bug.cgi?id=677853
2012-07-11 13:22:20 +01:00
Emmanuele Bassi
6feee080b3 actor: Clean up the order of transformations
https://bugzilla.gnome.org/show_bug.cgi?id=677853
2012-07-11 13:22:20 +01:00
Emmanuele Bassi
1796b37948 actor: Deprecate anchor-point
The pivot point and the translation transformation replace it
completely.

https://bugzilla.gnome.org/show_bug.cgi?id=677853
2012-07-11 13:22:20 +01:00
Emmanuele Bassi
8cea162d3c actor: Add translation transformation
We need an alternative to the translation performed by the anchor point,
one that possibly applies to all three axes and is relative to the
pivot-point.

https://bugzilla.gnome.org/show_bug.cgi?id=677853
2012-07-11 13:22:20 +01:00