Commit Graph

613 Commits

Author SHA1 Message Date
Emmanuele Bassi
4f470b9231 actor: Provide a proper implementation of replace_child()
The correct sequence of actions should be remove(old) → insert(new), not
insert(new) → remove(old). We can implement a simple delegate insertion
functions to insert the new child between the previous and next siblings
of the old child.

While we're at it, let's also add a unit test for replace_child().
2012-01-16 23:37:11 +00:00
Emmanuele Bassi
5cba801207 actor: Fix get_paint_volume() default implementation
Providing a default get_paint_volume() that takes into account the
children of an actor was a goal of the whole First Apocalypse; if we
make all the containers rely on it, and yet we return a FALSE value
(meaning: we don't have a valid paint volume) even when we do have it,
then we are going to break the whole machinery, though.
2012-01-16 23:37:11 +00:00
Emmanuele Bassi
62535bdc73 actor: Simplify first/last child updates 2012-01-16 23:37:11 +00:00
Emmanuele Bassi
bd58694678 actor: Add replace_child() method
A simple method that atomically replaces a child actor with another one.
2012-01-16 23:37:10 +00:00
Emmanuele Bassi
238a6eb03d actor: Deprecate the old parent modifiers
The old API should not be used in newly written code; we have better
methods for setting up and modifying the scene graph, now.
2012-01-16 23:37:10 +00:00
Emmanuele Bassi
813eef4325 actor: Fix child insertion issues
The insert_child_at_index, insert_below and insert_above messed up the
first and last child pointers in various cases. This commit fixes all
the instances of first and last child pointers being stale or set to
NULL.
2012-01-16 23:37:10 +00:00
Emmanuele Bassi
8b430507b5 actor: Add children iteration methods
Instead of requiring every consumer of the ClutterActor API that wishes
to iterate over the children of an actor to use the get_children()
method, we should provide an iteration API directly inside ClutterActor
itself.
2012-01-16 23:37:09 +00:00
Emmanuele Bassi
22259e0965 actor: Define the scene structure inside Actor
Instead of storing the list of children, let's turn Actor inside a
proper node of a tree.

This change adds the following members to the Actor private data
structure:

  first_child
  last_child
  prev_sibling
  next_sibling

and removes the "children" GList from it; iteration is performed through
the direct pointers to the siblings and children.

This change makes removal, insertion before a sibling, and insertion
after a sibling constant time operations, but it still retains the
feature of ClutterActor.add_child() to build the list of children while
taking into account the depth set on the newly added child, to allow the
default painter's algorithm we employ inside the paint() implementation
to at least try and cope with the :depth property (albeit in a fairly
naïve way). Changes in the :depth property will not change the paint
sequence any more: this functionality will be restored later.
2012-01-16 23:37:09 +00:00
Emmanuele Bassi
71545ae56f actor: Use a cairo_rectangle_t instead of a ridiculous array
Make the code maintainable and readable.
2012-01-16 23:35:17 +00:00
Emmanuele Bassi
ea7111333b actor: Document fields of ClutterActorPrivate
The private data structure members could do with more comments
documenting what they do.
2012-01-16 23:35:17 +00:00
Emmanuele Bassi
9eed2f58a6 actor: Add TransformInfo
ClutterTransformInfo is a (private) ancillary data structure that
contains all the decomposed transformation data, i.e. rotation angles
and centers, scale factors and centers, and anchor point. This data
structure is stored in the GData of the actor instance instead of the
actor's private data. This change gives us:

  • a smaller, cleaner private data structure;
  • no size penalty for untransformed actors;
  • static constant storage for the defaults, shared across all
    instances;
  • cache locality for all the decomposed transformation data,
    given that the structure size is smaller.

At the end of the day, the only authoritative piece of information for
actor transformation is the CoglMatrix that we initialize in
apply_transform() from all the decomposed parameters, and that can stay
inside the private data structure of ClutterActor.
2012-01-16 23:35:17 +00:00
Emmanuele Bassi
376bf4a990 actor: Tweak the underallocation warning
There are only two kinds of actors that allow underallocations,
according to the API contract:

  • ClutterStage, as it is a viewport and it doesn't have an implicit
    minimum size;

  • Actors using the CLUTTER_ACTOR_NO_LAYOUT escape hatch, which allows
    them to bail out from our layout management policies.

The warning about underallocations should take these two exceptions
under consideration.
2012-01-16 23:35:17 +00:00
Emmanuele Bassi
7fd35edd3f actor: Make Actor instantiatable
ClutterActor now has all the API and capabilities for being a concrete
class:

  - layout management, through delegation
  - container implementation and API
  - background color

This means that a simple scene can be built straight out of actors
without using subclasses except for the Stage.

This is the first step towards the deprecation of most of the Actor
subclasses provided by Clutter.
2012-01-16 23:35:16 +00:00
Emmanuele Bassi
4acf8de8b4 actor: Provide more children methods
Add a getter for the number of children, as well as a method to retrieve
the child at a given index.
2012-01-16 23:35:16 +00:00
Emmanuele Bassi
e62536fad6 actor: Provide a better get_paint_volume() implementation
ClutterActor can do better by default than just giving up immediately.

An actor can check for the clip region, and for its children's paint
volume, for instance.

Just these two should give us a better default implementation for newly
written code.
2012-01-16 23:35:16 +00:00
Emmanuele Bassi
98a8feae64 actor: Background color
Each actor should have a background color property, disabled by default.

This property allows us to cover 99% of the use cases for
ClutterRectangle, and brings us one step closer to being able to
instantiate ClutterActor directly.
2012-01-16 23:35:15 +00:00
Emmanuele Bassi
7d88a70b78 actor: Cosmetic fixes to internal add/remove child
Avoid code duplication all over the place.
2012-01-16 23:35:15 +00:00
Emmanuele Bassi
ef3dc2d1ba actor: Make Actor.add_child and Container.add_actor idempotent
And make sure that overriding Container and calling
clutter_actor_add_child() will result in the same sequence of operations
as the current set_parent()+queue_relayout()+signal_emit pattern.

Existing containers can continue using:

        clutter_actor_set_parent (child, CLUTTER_ACTOR (container));
        clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
        g_signal_emit_by_name (container, "actor-added", child);

and newly written containers overriding Container.add() can simply call:

        clutter_actor_add_child (CLUTTER_ACTOR (container), child);

instead.
2012-01-16 23:35:15 +00:00
Emmanuele Bassi
2894587b22 actor: Do not leak the layout manager 2012-01-16 23:35:15 +00:00
Emmanuele Bassi
b773785533 actor: Implement Container::sort_depth_order
There's no reason this vfunc should be left out.
2012-01-16 23:35:15 +00:00
Emmanuele Bassi
86ec629776 actor: Add child insertion methods
We should allow inserting children at given indices, and at given
stacking positions (relative or not to other children).
2012-01-16 23:35:14 +00:00
Emmanuele Bassi
37d46649ce actor: Adjust the preferred size too
Don't adjust just the allocation: we need to adjust the preferred size
of the actor to account for the margin.
2012-01-16 23:35:14 +00:00
Emmanuele Bassi
bf27575187 actor: Maintain invariants in add_child/remove_child
We need to queue a relayout when removing a visible child from a visible
parent.

We also need to insert the child at the right position (depending on the
depth) so that newly added actors will be painted on top.
2012-01-16 23:35:14 +00:00
Emmanuele Bassi
9d9e98968f actor: More cleanups to the Private data structure
Try to document it properly. We can also remove some things that are
properly encapsulated through functions, like the redraw clip volume.
2012-01-16 23:35:14 +00:00
Emmanuele Bassi
9132769767 actor: Store the fixed sizes into LayoutInfo
Remove four more floats from ClutterActorPrivate.

The fixed minimum and natural sizes should be stored inside the
ClutterLayoutInfo structure, along with the fixed position.
2012-01-16 23:35:14 +00:00
Emmanuele Bassi
b4d3b52b62 actor: Update the underallocations check
Add a failsafe against a NULL parent, to avoid a segfault when calling
clutter_actor_allocate() on the Stage.

We also need to deal with floating point values: straight comparison is
not going to cut it.
2012-01-16 23:35:14 +00:00
Emmanuele Bassi
409c3ed8ff actor: Adjust the allocation prior to call allocate()
ClutterActor has various properties controlling the allocation:

  - x-align, y-align
  - margin-top, margin-bottom, margin-left, margin-right

These properties should adjust the ClutterActorBox passed from the
parent actor to its children when calling clutter_actor_allocate(),
so that the child can just allocate its children at the right origin
with the right available size.
2012-01-16 23:35:14 +00:00
Emmanuele Bassi
a85c53ea0b actor: Clean up property installation 2012-01-16 23:35:14 +00:00
Emmanuele Bassi
a2a38ee797 actor: Add margin properties
The actor class should be able to hold the margin offsets like it does
for expand and alignment flags.

Instead of filling the private data structure with data, we should be
able to use an ancillary data structure, given that all this data is
optional and might never be set in the first place.
2012-01-16 23:35:13 +00:00
Emmanuele Bassi
c8659b6ca5 actor: Add [xy]-align
Allow an actor to define how it should occupy the extra space given to
by its parent during the allocation.
2012-01-16 23:35:13 +00:00
Emmanuele Bassi
4453ee7266 actor: Provide Container::raise/lower implementations 2012-01-16 23:35:13 +00:00
Emmanuele Bassi
752151bc97 actor: Remove is-a(Container) checks
All actors are now Container implementations, so there's no need to add
a type check.
2012-01-16 23:35:13 +00:00
Emmanuele Bassi
f2609dcca4 actor: Add [xy]-expand properties 2012-01-16 23:35:13 +00:00
Emmanuele Bassi
1c40151d0e actor: Default to a fixed layout manager
In case no layout manager was set during construction, we fall back to a
FixedLayout. The FixedLayout has the property of making the fixed
positioning and sizing API, as well as the various Constraints, work
out of the box.
2012-01-16 23:35:13 +00:00
Emmanuele Bassi
11e876c86b actor: Add :layout-manager
Now that ClutterActor implements the Container contract we can actually
defer the size negotiation to a ClutterLayoutManager directly from the
default implementation of the Actor's virtual functions.
2012-01-16 23:35:13 +00:00
Emmanuele Bassi
b45d78e6a1 actor: Provide a default Container implementation
We can provide most of the ClutterContainer implementation directly
within ClutterActor — basically removing the need of having the
Container interface in the first place. For backward compatibility
reasons we can keep the interface, but let Actor implement it directly.
2012-01-16 23:35:13 +00:00
Emmanuele Bassi
8462b5ba45 Do not use set_parent()/unparent() internally
Use add_child()/remove_child() instead.
2012-01-16 23:35:13 +00:00
Emmanuele Bassi
53aa64aeb9 actor: Provide add/remove child and get children methods
Let's try and move away from the reverse implicit scene graph build API,
which we mutuated from GTK+, towards a more traditional node/child API.

The set_parent()/unparent() API is confusing, unless you know the
history; having a add_child()/remove_child() methods pair makes it more
explicit.

We can easily implement the old set_parent()/unparent() pair in terms of
the newly add_child()/remove_child() one.
2012-01-16 23:35:13 +00:00
Emmanuele Bassi
7c14ba7d37 actor: Clean up the debug node for out-of-band transforms
Enclose the check inside a #ifdef CLUTTER_ENABLE_DEBUG ... #endif, so
that we can compile it out; also, use g_string_append() instead of the
g_string_append_printf() function, given that we're just concatenating
strings.
2012-01-16 11:04:44 +00:00
Emmanuele Bassi
95d3e0f962 actor: Change the point of emission of ::destroy
Currently, we're emitting the ClutterActor::destroy at the end of the
dispose implementation - right before we chain up to the parent
implementation.

The point of emission makes the ::destroy signal handlers able to just
use the actor pointer - as the actor state will have been mostly cleared
by the time application can run. This (undocumented) behaviour severely
limits the amount of things you can do inside a ::destroy signal
handler, thus making the ::destroy signal just a weird weak reference,
instead of a proper way to break application reference cycles.

Given that this change relaxes some of the conditions, this change
should be safe - obviously, if anything happens, we'll back it out; the
conformance and interactive tests confirm that, for common patterns of
usage, this change does not break existing code.
2012-01-06 14:09:11 +00:00
Emmanuele Bassi
fa39f67eab actor: Use g_clear_object()
GLib has a nice, atomic object clearing function that allows us to drop
code looking like:

  if (priv->object != NULL)
    {
      g_object_unref (priv->object);
      priv->object = NULL;
    }

from the ::dispose implementation.
2012-01-06 14:02:54 +00:00
Emmanuele Bassi
f0a246cdc6 actor: Add queue_redraw_with_clip()
Add a public version of the clipped queue redraw, using a 2D clip. This
allows implementing actors with trackable 2D clipped regions, like the
ClutterX11TexturePixmap, outside of Clutter itself.

https://bugzilla.gnome.org/show_bug.cgi?id=660997
2011-12-12 17:29:58 +00:00
Emmanuele Bassi
26aa4b5290 docs: Remove clutter_stage_get_default()
A lot of the example code in the cookbook and the API reference still
uses the default stage — sometimes as if it were a non-default one,
which once again demonstrates how the default stage was a flawed concept
that just confused people.
2011-11-10 15:37:51 +00:00
Emmanuele Bassi
ba8d682c09 actor: Deprecate [sg]et_geometry()
These methods are short-hands for accessing the position and size,
which are already shorthands for accessing the various dimensional
and positional attributes. Plus, they use ClutterGeometry, which is a
fairly bad data type for a rectangle.
2011-11-08 14:46:55 +00:00
Emmanuele Bassi
81a82867e1 docs: Clarify CLUTTER_ACTOR_IS_MAPPED
There are a couple of gotchas in the 'mapped' flag that are not properly
documented, or are documented only in the actor_invariants.txt file; we
should have a proper description in the API reference as well, to avoid
confusion.
2011-10-25 11:35:04 +01:00
Emmanuele Bassi
be4007ef53 Remove mentions of clutter_redraw() 2011-10-17 10:25:07 +01:00
Emmanuele Bassi
7f3363e1db Tag all deprecated symbols using CLUTTER_DEPRECATED
This requires some minor surgery in the build to disable the deprecation
warnings in the deprecated classes.
2011-10-14 11:34:38 +01:00
Emmanuele Bassi
e0283993f4 Avoid using deprecated API internally
Use the proper API to implement deprecated functions.
2011-10-12 16:44:55 +01:00
Adel Gadllah
e8ec7ebed0 ClutterActor: Add clutter_actor_has_actions
Adds an efficent way to query whether an actor has any
applied actions.

https://bugzilla.gnome.org/show_bug.cgi?id=660471
2011-09-29 19:34:32 +02:00
Adel Gadllah
e81800607c ClutterActor: Add clutter_actor_has_contraints
Adds an efficent way to query whether an actor has any
applied constraints.

https://bugzilla.gnome.org/show_bug.cgi?id=660471
2011-09-29 19:34:31 +02:00