Commit Graph

5038 Commits

Author SHA1 Message Date
Emmanuele Bassi
8ebf46d74c actor: Remove default layout-manager
It's creating more issues than what it's trying to solve. At least for
the time being, let's not set one.
2012-01-20 14:55:13 +00:00
Emmanuele Bassi
bd348625c7 group: Gut the implementation
A Group is a just a ClutterActor with the layout-manager property set at
instance initialization time. It doesn't need anything else from
ClutterActor's vtable, except the slightly custom show_all/hide_all
implementation, and a simplified get_paint_volume.
2012-01-20 14:53:41 +00:00
Emmanuele Bassi
1afd3827c7 actor: Move underallocation warning to diagnostic mode
This should keep down the warning messages — at least for the time
being.
2012-01-20 12:04:48 +00:00
Emmanuele Bassi
c760657903 actor: Use internal add/remove child in reparent()
Do not use the public API; reparent() used to use unparent() and
set_parent(), so we need to maintain the old behaviour.
2012-01-20 12:02:49 +00:00
Emmanuele Bassi
480514b721 stage: Use clutter_actor_set_allocation()
Instead of chaining up, given that we want to bypass chaining up and
just set the allocation. This also allows us to bail out of the
overridden allocate vfunc check, given that we want the default Actor
behaviour to apply - including eventual layout manager delegates.
2012-01-19 13:44:38 +00:00
Emmanuele Bassi
f7bae2a064 actor: Fix the has_overridden_allocate check 2012-01-19 13:39:14 +00:00
Emmanuele Bassi
b206a3d025 symbols: Add clutter_actor_set_allocation() 2012-01-19 13:14:33 +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
70679dc68c actor: Be more conservative with the default paint volume
Check the allocation, when one is being used to initialize the paint
volume.
2012-01-18 16:05:12 +00:00
Emmanuele Bassi
f7d9eab36d actor: Add :first-child and :last-child properties
Toolkits tracking first and last children of a ClutterActor can use
these properties to get notification of hierarchy changes.
2012-01-17 18:46:41 +00:00
Emmanuele Bassi
bb8abe832e actor: Do not use ::constructed
If we want to set a default layout manager, we need to do so inside
init(), as it's not guaranteed that people subclassing Actor and
overriding ::constructed will actually chain up as they should.
2012-01-17 18:13:42 +00:00
Emmanuele Bassi
629ded568e actor: Provide a better default pick() behaviour
The default pick() behaviour does not take into consideration the
children of a ClutterActor because the existing containter actors
usually override pick(), chain up, and then paint their children.

With ClutterActor now a concrete class, though, we need a way to pick
its children without requiring a sub-class; we could simply iterate over
the children inside the default pick() implementation, but this would
lead to double painting, which is not acceptable.

A moderately gross hack is to check if the Actor instance did override
the pick() implementation, and if it is not the case, paint the children
in pick mode.
2012-01-17 16:21:54 +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
696f9e84c9 text: Fix the buffer length check on paint 2012-01-17 14:29:45 +00:00
Emmanuele Bassi
9f0ba2da0f script: Fix a segfault
Accessing a variable before it is being set is not a great plan.
2012-01-17 14:29:45 +00:00
Emmanuele Bassi
37d94c6b87 text-buffer: Fix the Since annotations 2012-01-17 14:29:45 +00:00
Emmanuele Bassi
5085c11bde Add ClutterTextBuffer to the API reference 2012-01-17 14:29:45 +00:00
Emmanuele Bassi
57f5813058 Update clutter.symbols for TextBuffer 2012-01-17 14:29:45 +00:00
Stef Walter
c073764369 text: Implement ClutterTextBuffer
* Abstracts the buffer for text in ClutterText
 * Allows implementation of undo/redo.
 * Allows use of non-pageable memory for text
   in the case of sensitive passwords.
 * Implement a test with two ClutterText using the same
   buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=652653
2012-01-17 14:29:44 +00:00
Emmanuele Bassi
6b5b291029 Update clutter.symbols 2012-01-17 11:49:05 +00:00
Emmanuele Bassi
1dfc503df1 Fix compiler warnings
When dereferencing GArray.data to a C structure you need a double cast
from guint8* to void*, and then from void* to the actual type. This
avoids compiler warnings, especially when using clang on OSX.
2012-01-16 23:49:49 +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
ad2cfc0150 docs: Fixes for the API reference 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
25ca2f135c build: Add inclusion guards and license notices 2012-01-16 23:37:14 +00:00
Emmanuele Bassi
6f4578838c actor: Use proper internal API
Inside the set_child_[above|below]_sibling() and set_child_at_index() we
should be using the internal API for mutating the children list, instead
of the delegate functions. This ensures that we go through a single,
well-defined code path for all operations on the list of children of
an actor.
2012-01-16 23:37:13 +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
fa1792c394 actor: Use flags to control add/remove child
The internal versions of add_child() and remove_child() currently use
boolean arguments to control things like the ChildMeta instances and
the emissions of signals; using more than one boolean argument is an
indication that you need flags to avoid readability issues, as well as
providing a way to add new behaviours without a combinatorial explosion
of arguments, later on.
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
72b523c9e9 table-layout: Override compute_expand()
The TableLayout has two expansion flags that need to be taken into
consideration when computing the Actor expansion flags.
2012-01-16 23:37:13 +00:00
Emmanuele Bassi
5f79f6ee37 box-layout: Override compute_expand()
ClutterBoxLayout has an expansion flag, and we need to take that into
consideration when computing the Actor expansion flags.
2012-01-16 23:37:13 +00:00
Emmanuele Bassi
508f09f0a0 actor: Ask the LayoutManager to compute the expansion flags
If an actor has a layout manager, we want to involve the delegate object
into the lazy computation of the expansion flags state.
2012-01-16 23:37:13 +00:00
Emmanuele Bassi
2956116561 layout-manager: Add compute_expand() vfunc
This virtual function will let layout managers with legacy expansion
flags be able to influence the lazy computation of the expansion flags
on ClutterActor.
2012-01-16 23:37:13 +00:00
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