Commit Graph

5004 Commits

Author SHA1 Message Date
Emmanuele Bassi
fd5e422b9f actor: Paint the background color in the paint class handler
We need to paint the background color in the default class handler for
two reasons: it's logically appropriate, and we don't want actor
subclasses overriding the ::paint class handler to change behaviour only
because somebody decided to set the background color.
2012-01-16 23:37:12 +00:00
Emmanuele Bassi
e6082fe42f docs: Clean up ClutterContainer's description
The API to add/remove/iterate over children is in ClutterActor, now.
2012-01-16 23:37:12 +00:00
Emmanuele Bassi
7f092af15b container: Add diagnostic warnings for deprecated vfuncs
The old add(), remove(), and foreach() virtual functions are deprecated;
ClutterContainer should warn if the public API detects that the vfuncs
have been overridden.

Strictly speaking, it's still legal to override those vfuncs: you can
chain up to the default vtable, or you could just provide an equivalent
implementation. The goal is to avoid having to override the Container
interface, until we can safely deprecate it and remove it in Clutter
2.0.
2012-01-16 23:37:12 +00:00
Emmanuele Bassi
477c60c185 container: Provide default implementation of vfuncs
Instead of making ClutterActor implement the basic add/remove/foreach
virtual functions of ClutterContainer, we can simply do that from
within the ClutterContainer implementation.
2012-01-16 23:37:12 +00:00
Emmanuele Bassi
959f875cbc container: Deprecate more methods
The get_children(), foreach(), and foreach_with_internals() methods and
virtual functions are superceded by the Actor API, and should not be
used in newly written code.
2012-01-16 23:37:12 +00:00
Emmanuele Bassi
4eaa899871 group: Use Actor.remove_all_children()
To implement the remove_all() method.
2012-01-16 23:37:12 +00:00
Emmanuele Bassi
1979faee00 cally: Use Actor.get_children()
Instead of the Container method, given that the new get_children() gives
us more actors by default.
2012-01-16 23:37:12 +00:00
Emmanuele Bassi
425ead5bd7 actor: Add some debug spew 2012-01-16 23:37:12 +00:00
Emmanuele Bassi
86152f478d docs: Update the Actor API reference
Given the size and scope of the changes in ClutterActor, we ought to
rewrite the overall description of what an actor is, what it does, and
how are you supposed to use it and subclass it.
2012-01-16 23:37:11 +00:00
Emmanuele Bassi
5959099473 Deprecate Container add() and remove() methods
This will make things interesting.

We have better replacements in ClutterActor, that do The Right Thing™
instead of deferring control and requiring reimplementation in every
single container actor.
2012-01-16 23:37:11 +00:00
Emmanuele Bassi
f61916fc5e actor: Add remove_all_children()
A simple method for removing all children of an actor in one fell swoop.
2012-01-16 23:37:11 +00:00
Emmanuele Bassi
673961f40c docs: Clarify the Actor's iterator API behaviour
It should be noted in the documentation that it is not safe to operate
on the list of children of an Actor while iterating over it.
2012-01-16 23:37:11 +00:00
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
3ad77b417c stage: Use the Actor iteration API 2012-01-16 23:37:11 +00:00
Emmanuele Bassi
aa9e2a382c Remove usage of Actor/Container.get_children()
ClutterBox and ClutterGroup are still using the get_children() method
instead of the child iteration API.
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
ab429f4f45 Drop some more ClutterContainer.get_children() uses 2012-01-16 23:37:10 +00:00
Emmanuele Bassi
ec6873958b fixed-layout: Use the Actor iteration API
Forgot to migrate the FixedLayout layout manager like we did for the
other layout managers provided by Clutter.
2012-01-16 23:37:10 +00:00
Emmanuele Bassi
4d75e7a0f4 cally: Use the Actor API instead of ClutterContainer
Cally is doing a bunch of list traversals through the list returned by
ClutterContainer.get_children(); this means a traversal already, plus
a bunch of allocations. We can do better than that, now that we have
a proper graph iteration API inside ClutterActor.
2012-01-16 23:37:10 +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
7e377b5aee Port remaining layout managers to the new child iteration API
TableLayout and FlowLayout now use the ClutterActor API for iterating
over the children of an actor.
2012-01-16 23:37:09 +00:00
Emmanuele Bassi
9c9ab42060 Begin porting layout managers to the new child iteration API
Instead of getting the list of children to iterate over it, let's use
the newly added child iteration API; this should save us a bunch of
allocations, as well as indirections.

Ported: ClutterBinLayout and ClutterBoxLayout.
2012-01-16 23:37:09 +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
6d268fe5ca Deprecate ClutterRectangle
A ClutterActor with a background color set covers 99% of the use cases
for a Rectangle.
2012-01-16 23:35:17 +00:00
Emmanuele Bassi
6237eb7892 Deprecate ClutterGroup
The Group functionality is now provided by ClutterActor.

Sadly, we need to keep the ClutterGroup structure definition in the
non-deprecated header because ClutterStage inherits from Group - an API
wart that was never fixed during the 0.x cycles, and that we'll have to
keep around until we can break API.
2012-01-16 23:35:16 +00:00
Emmanuele Bassi
b4d269705e Deprecate ClutterBox
ClutterBox functionality has been implemented by ClutterActor, and
proxied by the Box subclass; with the removal of the abstract bit on
ClutterActor, we can safely deprecated ClutterBox.
2012-01-16 23:35:16 +00:00
Emmanuele Bassi
a6df0b6a53 cally: Do not use Group API
Avoids a deprecation warning.
2012-01-16 23:35:16 +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
8caee3e97e group: Proxy last few methods to Actor
At this point, ClutterGroup is basically just a shim layer on top of
ClutterActor.
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
b86cf3e2f3 group: Use the default get_paint_volume()
ClutterActor does everything we did, and more.
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
7195d0fccf flow-layout: Fix minimum size request
The minimum preferred size of a Flow layout manager is the size of a
column or a row, as the whole point of the layout policy enforced by
the Flow layout manager is to reflow when needed.
2012-01-16 23:35:16 +00:00
Emmanuele Bassi
ba093ed5e7 box: Proxy the Actor's background color properties
ClutterBox's color and color-set properties can be implemented as
proxies for the ClutterActor's newly added background-color and
background-color-set properties, respectively.

This also allows us to get rid of the paint() implementation inside
ClutterBox altogether.
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
3f877a3d71 group: Use the default paint() implementation
ClutterActor's paint implementation is perfectly fine for ClutterGroup:
it paints the actor's children, which is exactly what ClutteGroup does.
2012-01-16 23:35:15 +00:00
Emmanuele Bassi
798a2e5297 actor: Minor cosmetic fixes to the header 2012-01-16 23:35:15 +00:00
Emmanuele Bassi
b869019eb2 group: Do not override Container
Let ClutterActor do all the work.
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
038aadfa72 box: Drop Container interface overrides
And defer as much as possible to ClutterActor's default implementation
for basically everything.
2012-01-16 23:35:15 +00:00