Commit Graph

192 Commits

Author SHA1 Message Date
Emmanuele Bassi
e7aa21203c actor: Add content-repeat
ClutterContent implementations may allow repeating their contents when
painting; we should provide the repeat policy on the actor, like we do
for scaling filters and content gravity.
2012-06-08 14:33:00 +01:00
Emmanuele Bassi
0dd74ca3fb docs: Annotation fixes
The introspection scanner has become slightly more annoying, in the hope
that people start fixing their annotations. As it turns out, it was the
right move.
2012-04-30 17:17:41 +01:00
Emmanuele Bassi
78aae84d43 actor: Coalesce needs_[xy]_expand() into one method
Use the orientation enumeration instead of a per-axis method.
2012-04-27 12:30:49 +01:00
Emmanuele Bassi
90032e0019 actor: Add basic automatic expand flags
The :x-expand and :y-expand flags on ClutterActor are used to signal
that an actor should expand horizontally and/or vertically - i.e. that
its parent's layout management policy should try to assign extra space
to the actor when allocating it.

The expand flags are automatic: when set on a leaf node in the actor
tree, they will bubble up through the parent and grandparents up to the
top level actor; during allocation, the actors with children will lazily
compute whether their children needs to expand.
2012-04-27 12:30:48 +01:00
Emmanuele Bassi
b44290c436 docs: Add ClutterActorClass.paint_node() description 2012-03-16 12:33:40 +00:00
Emmanuele Bassi
77729c7362 actor: Add minification/magnification filters
These settings are informative, and will only be used by the eventual
content of an actor.
2012-03-16 12:33:38 +00:00
Emmanuele Bassi
be4746b15f Add ClutterContent
ClutterContent is an interface for creating delegate objects that handle
what an actor is going to paint.

Since they are a newly added type, they only hook into the new PaintNode
based API.

The position and size of the content is controlled in part by the
content's own preferred size, and by the ClutterContentGravity
enumeration.
2012-03-16 12:33:36 +00:00
Emmanuele Bassi
6f0782e0a4 actor: Add paint_node virtual function
The ::paint-node virtual inside ClutterActor is what we want people to
use when painting their actors.

Right now, it's a new code path, that gets called while painting; the
paint_node() implementation should only paint the actor itself, and not
its children — they will get their own paint_node() called when needed.

Internally, ClutterActor will automatically create a dummy PaintNode and
paint the background color; then control will be handed out to the
implementation on the class. This is required to maintain compatibility
with the old ::paint signal emission.

Once we are able to get rid of the paint (and pick) sequences, we'll
switch to a fully retained render tree.
2012-03-16 12:33:35 +00:00
Emmanuele Bassi
4bd3583dbf actor: Add generic transition support
ClutterActor should be able to hold all transitions, even the ones that
have been explicitly created.

This will allow to add new transitions types in the future, like the
keyframe-based one, or the transition group.
2012-03-15 17:01:14 +00:00
Emmanuele Bassi
1511e588df actor: Add delay to the easing state
It should be possible to set up the delay of a transition, but since
we start the Transition instance before returning control to the caller,
we cannot use clutter_actor_get_transition() to do it without something
extra-awkward, like:

  transition = clutter_actor_get_transition (actor, "width");
  clutter_timeline_stop (transition);
  clutter_timeline_set_delay (transition, 1000);
  clutter_timeline_start (transition);

for each property involved. It's much easier to add a delay to the
easing state of an actor.
2012-03-15 17:01:13 +00:00
Emmanuele Bassi
67113ed690 actor: Implement implicit animatable properties
Clutter is meant to be, and I quote from the README, a toolkit:

  for creating fast, compelling, portable, and dynamic graphical
  user interfaces

and yet the default mode of operation for setting an actor's state on
the scene graph (position, size, opacity, rotation, scaling, depth,
etc.) is *not* dynamic. We assume a static UI, and then animate it.

This is the wrong way to design an API for a toolkit meant to be used to
create animated user interfaces. The default mode of operation should be
to implicitly animate every state transition, and only allow skipping
the animation if the user consciously decides to do so — i.e. the design
tenet of the API should be to make The Right Thing™ by default, and make
it really hard (or even impossible) to do The Wrong Thing™.

So we should identify "animatable" properties, i.e. those properties
that should be implicitly animated by ClutterActor, and use the
animation framework we provide to tween the transitions between the
current state and the desired state; the implicit animation should
happen when setting these properties using the public accessors, and not
through some added functionality. For instance, the following:

  clutter_actor_set_position (actor, newX, newY);

should not make the actor jump to the (newX, newY) point; it should
tween the actor's position between the current point and the desired
point.

Since we have to maintain backward compatibility with existing
applications, we still need to mark the transitions explicitly, but we
can be smart about it, and treat transition states as a stack that can
be pushed and popped, e.g.:

  clutter_actor_save_easing_state (actor);

    clutter_actor_set_easing_duration (actor, 500);
    clutter_actor_set_position (actor, newX, newY);
    clutter_actor_set_opacity (actor, newOpacity);

  clutter_actor_restore_easing_state (actor);

And we can even start stacking animations, e.g.:

  clutter_actor_save_easing_state (actor);

    clutter_actor_set_easing_duration (actor, 500);
    clutter_actor_set_position (actor, newX, newY);

    clutter_actor_save_easing_state (actor);

      clutter_actor_set_easing_duration (actor, 500);
      clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR);
      clutter_actor_set_opacity (actor, newOpacity);
      clutter_actor_set_depth (actor, newDepth);

    clutter_actor_restore_easing_state (actor);

  clutter_actor_restore_easing_state (actor);

And so on, and so forth.

The implementation takes advantage of the newly added Transition API,
which uses only ClutterTimeline sub-classes and ClutterInterval, to cut
down the amount of signal emissions and memory management of object
instances; as well of using the ClutterAnimatable interface for custom
properties and interpolation of values.
2012-03-15 17:01:12 +00:00
Emmanuele Bassi
fb9df4bef2 Annotate all functions available since 1.10 2012-02-27 16:35:09 +00:00
Emmanuele Bassi
e4c948b150 actor: Add a method for computing the default paint volume
Now that ClutterActor has a default paint volume, subclasses may wish
to retrieve it without chaining up to the parent's implementation of
the get_paint_volume() function.

The get_default_paint_volume() returns a ClutterPaintVolume pointer
to the paint volume as computed by the default implementation of the
get_paint_volume() virtual function; it can only be used immediately,
as it's not guaranteed to survive across multiple frames.
2012-02-27 11:59:57 +00:00
Emmanuele Bassi
3996ae4348 actor: Add destroy_all_children()
There are times when we don't want to remove all children and count of
the reference count to drop to 0 to ensure destruction; there are cases,
such as managed environments, where it's preferable to ensure that the
children of an actor get actually destroyed.
2012-02-13 17:42:07 +00:00
Emmanuele Bassi
d0e945fb70 actor: Add ClutterActorIter.destroy()
Similar to the clutter_actor_iter_remove(), but it'll call destroy()
instead of remove_child().

We can also reimplement the ::destroy default handler using it, and make
it more compact.
2012-02-09 15:49:30 +00:00
Emmanuele Bassi
bfe7129375 Clean up clutter-actor.h
It's time, we delayed far too long.
2012-02-05 08:47:17 +00:00
Emmanuele Bassi
58ffcfb10e actor: Add ClutterActorIter
Iterating over children and ancestors of an actor is a relatively common
operation. Currently, you only have one option: start a for() loop, get
the first child of the actor, and advance to the next sibling for the
list of children; or start a for() loop and advance to the parent of the
actor.

These operations can be easily done through the ClutterActor API, but
they all require going through the public API, and performing multiple
type checks on the arguments.

Along with the DOM API, it would be nice to have an ancillary, utility
API that uses an iterator structure to hold the state, and can be
advanced in a loop.

https://bugzilla.gnome.org/show_bug.cgi?id=668669
2012-01-27 11:55:39 +00:00
Emmanuele Bassi
67eeea6b62 actor: Maintain behaviour of old allocate() implementations
The usual way to implement a container actor is to override the
allocate() virtual function, chain up, and then allocate the actor's
children.

Clutter now has the ability to delegate layout management to
ClutterLayoutManager directly; in the allocation, this is done by
checking whether the actor has children, and then call
clutter_layout_manager_allocate() from within the default implementation
of the ClutterActor::allocate() vfunc. The same vfunc that everyone, has
been chaining up to.

Whoopsie.

Well, we can check if there's a layout manager, and if it's NULL, we
bail out. Except that there's a default layout manager, and it's the
fixed layout manager, so that classes like Group and Stage work by
default.

Double whoopsie.

The fix for this scenario is a bit nasty; we have to check if the actor
class has overridden the allocate() vfunc or not, before actually
looking at the layout manager. This means that classes that override the
allocate() vfunc are expected to do everything that ClutterActor's
default implementation does - which I think it's a fair requirement to
have.

For newly written code, though, it would probably be best if we just
provided a function that does the right thing by default, and that
you're supposed to be calling from within the allocate() vfunc
implementation, if you ever chose to override it. This new function,
clutter_actor_set_allocation(), should come with a warning the size of
Texas, to avoid people thinking it's a way to override the whole "call
allocate() on each child" mechanism. Plus, it should check if we're
inside an allocation sequence, and bail out if not.
2012-01-19 12:40:32 +00:00
Emmanuele Bassi
0f39f20db6 actor: Deprecate show_all()/hide_all()
The hide_all() method is pretty much pointless, as hiding an actor will
automatically prevent its children from being painted. The show_all()
method would only be marginally useful, if actors weren't set to be
visible by default when added to another actor - which was the case when
we introduced show_all() and hide_all().
2012-01-17 16:21:54 +00:00
Emmanuele Bassi
f41061b8df actor: Deprecated push/pop internal methods
The concept of "internal child" only meant anything when we had a
separate API for containers and actors. Now that we plugged that
particular hole, we can drop all the hacks we used to have in place
to work around its design limitations.
2012-01-16 23:37:14 +00:00
Emmanuele Bassi
ea6ddd1534 actor: Add boxed margin accessors
It can be convenient to be able to set, or get, all the components of an
actor's margin at the same time; since we already have a boxed type for
storing a margin, an accessors pair based on it is not a complicated
addition to the API.
2012-01-16 23:37:14 +00:00
Emmanuele Bassi
b835e1f8c4 Deprecate the old raise/lower API
We have a replacement in ClutterActor, now.

The old ClutterContainer API needs to be deprecated, and the raise() and
lower() virtual functions need a default implementation, so we can check
for implementations overriding them, by using the diagnostic mode like
we do for add(), remove(), and foreach().

The sort_depth_order() virtual function just doesn't do anything, as it
should have been made ages ago.

The Actor wrappers for the Container methods also need to be deprecated.
2012-01-16 23:37:13 +00:00
Emmanuele Bassi
9a66392d49 actor: Add new methods for changing the paint sequence
ClutterActor provides four methods for changing the paint sequence order
of its children:

  raise_top()
  raise()
  lower()
  lower_bottom()

The first and last one being just wrappers around raise() and lower(),
respectively. These methods have various issues: they omit the parent,
preferring to retrieve it from the actor passed as the first argument;
this does not match the new style of API introduced to operate on the
list of children of an actor.

Additionally, the raise() and lower() methods of ClutterActor call into
the Container interface, and are not really aptly named (raise() in
particular collides with the completely unrelated 'raise' keyword in
Python, and usually needs to be wrapped in order to be used at all).

Furthermore, we need public methods that Container can call from its
default implementation, as well as methods to port current Container
implementations.

Finally, since we have insert_child_at_index(), we should also have an
equivalent set_child_at_index() as well.
2012-01-16 23:37:13 +00:00
Emmanuele Bassi
72fa75c034 actor: Remove automagic "expand" flag
I don't feel comfortable with this feature, and its implementation
still has too many rough edges. We can safely punt it for now, and
introduce it at a later point, as it doesn't block existing features
or API.
2012-01-16 23:37:13 +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
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
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
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
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
798a2e5297 actor: Minor cosmetic fixes to the header 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
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
f2609dcca4 actor: Add [xy]-expand properties 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
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
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
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
b19c919645 actor: Move deprecated symbols into separate headers
The clutter-actor.h header is already pretty big, so let's try to keep
the deprecated symbols out of it.
2011-11-02 13:00:46 +00:00
Emmanuele Bassi
af7afc29a7 Add a Clutter-specific deprecation macro for symbols
Just like GLIB_DEPRECATED and GLIB_DEPRECATED_FOR, Clutter should have
its own wrappers for G_DEPRECATED and G_DEPRECATED_FOR, to allow opting
out of deprecation warnings.

Deprecation warnings are enabled by default, now, even when building
Clutter.
2011-10-11 23:03:09 +01:00
Emmanuele Bassi
d28e04be72 Move all enumerations to a separate file
This should allow sharing types, and we can avoid glib-mkenums thrawling
the whole repository for enumerations.
2011-10-11 17:59:46 +01:00
Robert Bragg
0aacbd47b7 actor: make offscreen_redirect prop take flags + default off
Because we have had several reports about significant performance
regressions since we enabled offscreen redirection by default for
handling correct opacity we are now turning this feature off by default.

We feel that clutter should prioritize performance over correctness in
this case. Correct opacity is still possible if required but the
overhead of the numerous offscreen allocations as well as the cost of
many render target switches per-frame seems too high relative the
improvement in quality for many cases.

On reviewing the offscreen_redirect property so we have a way to
disable redirection by default we realized that it makes more sense for
it to take a set of flags instead of an enum so we can potentially
extend the number of things that might result in offscreen redirection.

We removed the ability to say REDIRECT_ALWAYS_FOR_OPACITY, since it
seems that implies you don't trust the implementation of an actor's
has_overlaps() vfunc which doesn't seem right.

The default value if actor::redirect_offscreen is now 0 which
effectively means don't ever redirect the actor offscreen.
2011-08-30 16:20:16 +01:00
Evan Nemerson
a6bd11ac62 introspection: add missing introspection data from Vala bindings
https://bugzilla.gnome.org/show_bug.cgi?id=655387
2011-07-29 13:06:51 +01:00
Emmanuele Bassi
9a3b97b55e Revert "build: Detect the appropriate default flavour"
Ouch, butterfingers and git commit -a.

This reverts commit 81e8c8dec9.
2011-07-13 14:26:05 +01:00
Emmanuele Bassi
81e8c8dec9 build: Detect the appropriate default flavour
If we're building on/for Windows, set 'win32' as the default flavour; if
we're building on OS X, set 'osx' as the default flavour. For everything
else, use 'glx'.
2011-07-13 14:20:47 +01:00
Emmanuele Bassi
2b81d90dd7 Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.

We always used it to conform to the platform, at least for public-facing
API.

At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.

Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:

  https://bugzilla.gnome.org/show_bug.cgi?id=644611

Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 16:06:24 +01:00