Commit Graph

304 Commits

Author SHA1 Message Date
Emmanuele Bassi
5ebb59e6b0 [actor] Add the ::allocation-changed signal
Sometimes it is useful to be able to track changes in the allocation
flags, like the absolute origin, inside children of a container.

Using the notify::allocation signal is not enough, in these cases, so
we need a specific signal that gives us both the allocation box and the
allocation flags.
2009-06-04 16:30:31 +01:00
Emmanuele Bassi
0187bb3965 [actor] Use flags to control allocations
Instead of passing a boolean value, the ::allocate virtual function
should use a bitmask and flags. This gives us room for expansion
without breaking API/ABI, and allows to encode more information to
the allocation process instead of just changes of absolute origin.
2009-06-04 16:30:31 +01:00
Emmanuele Bassi
0d5e17ecd1 [units] Rework Units into logical distance value
Units as they have been implemented since Clutter 0.4 have always been
misdefined as "logical distance unit", while they were just pixels with
fractionary bits.

Units should be reworked to be opaque structures to hold a value and
its unit type, that can be then converted into pixels when Clutter needs
to paint or compute size requisitions and perform allocations.

The previous API should be completely removed to avoid collisions, and
a new type:

        ClutterUnits

should be added; the ability to install GObject properties using
ClutterUnits should be maintained.
2009-06-04 16:30:31 +01:00
Emmanuele Bassi
1580ffb884 Remove a stray g_value_get_int()
Now that all properties are float, using g_value_get_int() to
retrieve the value of the :anchor-x property is going to print
out a warning.
2009-06-04 16:30:30 +01:00
Emmanuele Bassi
6825b9db1c [actor] Unrealize on destroy
If the application code calls for destruction of an actor we need
to make sure that the actor is unrealized before running the dispose
sequence; otherwise, we might trigger an assertion failure on composite
actors.
2009-06-03 14:05:06 +01:00
Emmanuele Bassi
c759aeb6a7 Uniformly use floats in Actor properties
All the underlying implementation and the public entry points have
been switched to floats; the only missing bits are the Actor properties
that deal with positioning and sizing.

This usually means a major pain when dealing with GValues and varargs
functions. While GValue will warn you when dealing with the wrong
conversions, varags will simply die an horrible (and hard to debug)
death via segfault. Nothing much to do here, except warn people in the
release notes and hope for the best.
2009-06-01 14:57:18 +01:00
Emmanuele Bassi
4afe1e9a8b [actor] Add allocate_available_size()
The allocate_available_size() method is a convenience method in
the same spirit as allocate_preferred_size(). While the latter
will allocate the preferred size of an actor regardless of the
available size provided by the actor's parent -- and thus it's
suitable for simple fixed layout managers like ClutterGroup -- the
former will take into account the available size provided by the
parent and never allocate more than that; it is, thus, suitable
for simple fluid layout managers.
2009-05-29 17:53:19 +01:00
Emmanuele Bassi
9557328e4e Merge branch 'master' into 1.0-integration
* master:
  [test-text-perf] Use queue_redraw instead of painting the stage directly
  [actor] In paint when opacity == 0, clear the queued_redraw flag
2009-05-28 15:53:56 +01:00
Neil Roberts
654c26a130 [actor] In paint when opacity == 0, clear the queued_redraw flag
If we are short-circuiting the paint when the opacity is zero we still
need to clear the queued_redraw flag otherwise it won't be possible to
queue another redraw of the actor until something else has caused a
paint first.
2009-05-22 14:50:37 +01:00
Emmanuele Bassi
c262ab0b63 Merge branch 'master' into 1.0-integration
* master:
  [cogl-vertex-buffer] Ensure the clip state before rendering
  [test-text-perf] Small fix-ups
  Add a test for text performance
  [build] Ensure that cogl-debug is disabled by default
  [build] The cogl GE macro wasn't passing an int according to the format string
  Use the right internal format for GL_ARB_texture_rectangle
  [actor_paint] Ensure painting is a NOP for actors with opacity = 0
  Make backface culling work with vertex buffers
2009-05-22 12:00:33 +01:00
Robert Bragg
2c6719502a [actor_paint] Ensure painting is a NOP for actors with opacity = 0
Since it is convenient to use geometry with an opacity of 0 for input only
purposes it's a worthwhile optimization to avoid submitting anything
for such actors while painting.
2009-05-21 15:10:37 +01:00
Emmanuele Bassi
3428e4dd1d [actor] Do not try to dereference NULL data
If the shader_data bound to an Actor is NULL we should not try to access
its members.
2009-05-20 17:26:39 +01:00
Emmanuele Bassi
0b7e459d48 Add more debugging notes 2009-05-11 12:45:33 +01:00
Emmanuele Bassi
0acb98e987 [actor] Conditionally verify the map state
The verify_map_state() internal method is conditionally compiled
if we have CLUTTER_ENABLE_DEBUG set; for this reason, all calls to
that method should be made conditional.
2009-05-11 12:45:33 +01:00
Emmanuele Bassi
91126558d3 [actor] Relax some of the invariants checks
When destroying a top-level actor we can actually relax the verification
of the map state, since it might be fully asynchronous and we might not
re-enter inside the mainloop in time to receive the unmap notification.
2009-05-08 17:14:49 +01:00
Emmanuele Bassi
533c9c5365 [debug] Show the actor name/type on queue_redraw() 2009-05-07 19:25:24 +01:00
Emmanuele Bassi
33ef1675f5 [script] Allow parsing units in em
When creating an actor, using "em" as a unit should result
in an implicit conversion, like for "mm" and "pt".
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
515350a77f [actor] Rename focus-in and focus-out signals
For consistency, and since those signals are key-related, the
::focus-in signal is not ::key-focus-in and the ::focus-out
signal is now ::key-focus-out.
2009-05-06 17:56:40 +01:00
Emmanuele Bassi
d6d208da7d Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.

ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.

So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:

  - we have to maintain twice the amount of entry points in ClutterActor
  - we still do an integer-to-float implicit conversion
  - we introduce a weird impedance between pixels and "pixels with
    fractionary bits"
  - language bindings will have to choose what to bind, and resort
    to manually overriding the API
    + *except* for language bindings based on GObject-Introspection, as
      they cannot do manual overrides, thus will replicate the entire
      set of entry points

For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:

  void clutter_actor_set_x (ClutterActor *self,
                            gfloat        x);
  void clutter_actor_get_size (ClutterActor *self,
                               gfloat       *width,
                               gfloat       *height);
  gfloat clutter_actor_get_height (ClutterActor *self);

etc.

The issues I have identified are:

  - we'll have a two cases of compiler warnings:
    - printf() format of the return values from %d to %f
    - clutter_actor_get_size() taking floats instead of unsigned ints
  - we'll have a problem with varargs when passing an integer instead
    of a floating point value, except on 64bit platforms where the
    size of a float is the same as the size of an int

To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:

  - we remove ambiguity in the API with regard to pixels and units
  - we remove entry points we get to maintain for the whole 1.0
    version of the API
  - we make things simpler to bind for both manual language bindings
    and automatic (gobject-introspection based) ones
  - we have the simplest API possible while still exposing the
    capabilities of the underlying GL implementation
2009-05-06 16:44:47 +01:00
Emmanuele Bassi
72562cda58 [actor] Add ActorFlags accessor methods
The flags field of ClutterActor should have accessor methods for,
language bindings.

Also, the set_flags() and unset_flags() methods should actively
emit notifications for the changed properties.
2009-05-05 18:08:53 +01:00
Emmanuele Bassi
fc991e9b67 [actor] Add the :realized property
The :realized property is the only missing property for an actor flag.
2009-05-05 15:36:29 +01:00
Emmanuele Bassi
1a87e4e252 [clone] Allow painting hidden source actors
With the introduction of the map/unmap flags and the split of the
visible state from the mapped state we require that every part of
a scene graph branch is mapped in order to be painted. This breaks
the ability of a ClutterClone to paint an hidden source actor.

In order to fix this we need to introduce an override flag, similar
in spirit to the current modelview and paint opacity overrides that
Clone is already using.

The override flag, when set, will force a temporary map on a
Clone source (and its children).
2009-05-01 12:33:42 +01:00
Emmanuele Bassi
5d2d8297e2 [actor] Use foreach_with_internals()
ClutterContainer provides a foreach_with_internals() vfunc for
iterating over all of a container's children, be them added using
the Container API or be them internal to the container itself.

We should be using the foreach_with_internals() function instead
of the plain foreach().
2009-05-01 12:31:06 +01:00
Johan Bilien
51f4e9680b Relinquish the focus when unmapped while owning it
Bug 1547 - when an actor is unmapped while owning the focus, it should
           release it

When an actor is unmapped while owning the focus, the should release it.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:27:47 +01:00
Havoc Pennington
125bded814 Enforce invariants on mapped, realized, visibility states
Bug 1138 - No trackable "mapped" state

* Add a VISIBLE flag tracking application programmer's
  expected showing-state for the actor, allowing us to
  always ensure we keep what the app wants while tracking
  internal implementation state separately.

* Make MAPPED reflect whether the actor will be painted;
  add notification on a ClutterActor::mapped property.
  Keep MAPPED state updated as the actor is shown,
  ancestors are shown, actor is reparented, etc.

* Require a stage and realized parents to realize; this means
  at realization time the correct window system and GL resources
  are known. But unparented actors can no longer be realized.

* Allow children to be unrealized even if parent is realized.
  Otherwise in effect either all actors or no actors are realized,
  i.e. it becomes a stage-global flag.

* Allow clutter_actor_realize() to "fail" if not inside a toplevel

* Rework clutter_actor_unrealize() so internally we have
  a flavor that does not mess with visibility flag

* Add _clutter_actor_rerealize() to encapsulate a somewhat
  tricky operation we were doing in a couple of places

* Do not realize/unrealize children in ClutterGroup,
  ClutterActor already does it

* Do not realize impl by hand in clutter_stage_show(),
  since showing impl already does that

* Do not unrealize in various dispose() methods, since
  ClutterActor dispose implementation already does it
  and chaining up is mandatory

* ClutterTexture uses COGL while unrealizable (before it's
  added to a stage). Previously this breakage was affecting
  ClutterActor because we had to allow realize outside
  a stage. Move the breakage to ClutterTexture, by making
  ClutterTexture just use COGL while not realized.

* Unrealize before we set parent to NULL in clutter_actor_unparent().
  This means unrealize() implementations can get to the stage.
  Because actors need the stage in order to detach from stage.

* Update clutter-actor-invariants.txt to reflect latest changes

* Remove explicit hide/unrealize from ClutterActor::dispose since
  unparent already forces those
  Instead just assert that unparent() occurred and did the right thing.

* Check whether parent implements unrealize before chaining up
  Needed because ClutterGroup no longer has to implement unrealize.

* Perform unrealize in the default handler for the signal.
  This allows non-containers that have children to work properly,
  and allows containers to override how it's done.

* Add map/unmap virtual methods and set MAPPED flag on self and
  children in there. This allows subclasses to hook map/unmap.
  These are not signals, because notify::mapped is better for
  anything it's legitimate for a non-subclass to do.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:27:19 +01:00
Emmanuele Bassi
709bb69970 Add debug annotations for the layout process
If we need to check that the layout sequence is correct in
terms of order of execution and with respect to caching, then
having a CLUTTER_DEBUG_LAYOUT debug flag would make things
easier.
2009-04-15 17:25:50 +01:00
Emmanuele Bassi
d6937b797e [doc] Update the should_pick_paint() documentation
The should_pick_paint() method of ClutterActor is not clearly
documented.
2009-03-21 20:40:22 +00:00
Øyvind Kolås
e94e5ad65b [actor] use an epsilon whens sanity checking sizes
Clutter was complaining about netural width smaller than minimum widths
(differences around 0.0005) by using an epsilon value of 1e-4 for these
floating point comparisons, these warnings have now been silenced.
2009-03-19 14:46:23 +00:00
Emmanuele Bassi
ccca24ab76 Remove usage of the grave accent as quotation mark
See:

  http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

This should make Thomas happy.
2009-03-17 14:13:31 +00:00
Havoc Pennington
961aac3fb3 [actor] Add ::queue-redraw signal
Bug 1454 - move queue_redraw virtualization to ClutterActor

The ClutterActor::queue-redraw signal allows parent containers to
track whether their children need a redraw.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-16 12:13:55 +00:00
Havoc Pennington
5706105123 [actor] Add :clip-to-allocation property
A common use of setting clip is to keep an actor inside its allocation;
right now to do this you have to set up a callback on notify::allocation.

There's no overhead added by sticking another bit in ClutterActor
clip-to-allocation that will clip painting to the allocation if set.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
72f9646804 Do not cause more size requisitions than necessary
Bug 1499 - clutter_actor_notify_if_geometry_changed causes sync
           layout cycles

Whenever clutter_actor_set_{width,height,x,y,size...} is used, extra
synchronous size requests are triggered in
clutter_actor_notify_if_geometry_changed.

If the get_preferred_width() and get_preferred_height() implementations
are particularly costly (e.g. ClutterText) this will result in a performance
impact.

To avoid excessive allocation or requisition cycles we use the
cached values and flags. If we don't have an allocation, we assume
that we need to notify all the properties; if we don't have a size
requisition we notify only width and height; finally, if we do have
a valid allocation we notify only on the changed values.
2009-03-13 15:20:49 +00:00
Owen W. Taylor
02b2b664d8 Add (out) annotations for ClutterActor
Add missing (out) annotations to the doc comments for ClutterActor methods
with multiple return values.

Fix the definition of clutter_actor_get_allocation_vertices() to be
consistent with the declaration and have verts[4] rather than verts[].x

http://bugzilla.openedhand.com/show_bug.cgi?id=1481
2009-03-11 18:14:49 +00:00
Emmanuele Bassi
7a5cea44dd [docs] Calling g_object_ref() will not dispose an object
The right way to dispose a PangoContext is to call g_object_unref(),
not g_object_ref().
2009-03-11 13:58:31 +00:00
Emmanuele Bassi
a1f0b25d14 [actor] Remove usage of ClutterFixed
The ClutterFixed type and symbols are now equivalent to the native
float type. In order to remove ambiguity and clean up the code, any
usage of ClutterFixed and relative macros has been removed.
2009-02-23 13:00:52 +00:00
Robert Bragg
34e53736ed [Cogl] the cogl_get_*_matrix functions now work with CoglMatrix types
Since the CoglMatrix type was added for supporting texture matrices recently
it made sense to be consistent accross the Cogl API and use the Cogl type
over the GL style GLfloat m[16] arrays.
2009-02-23 10:49:35 +00:00
Owen W. Taylor
c5afd98416 Add gobject-introspection annotations
Add annotations such as (transfer-none) (out) (element-type ClutterActor),
and so forth to the doc comments as appropriate.

The annotations added here are a combination of the annotations previously
in gir-repository for Clutter and annotations found in a review of all
return values with that were being parsed with a transfer of "full".

http://bugzilla.openedhand.com/show_bug.cgi?id=1452

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-20 12:09:07 +00:00
Emmanuele Bassi
4aecece48d [docs] Add a missing "return" annotation
The documentation for the get_anchor_point_gravity() method is
missing the "Return value:" section.
2009-02-19 14:56:07 +00:00
Neil Roberts
deed85035f Allow rotation angle properties to be negative
Bug 1167 - clutter_effect_rotate improperly clamps negative angles

The rotation angle properties had a minimum value of 0.0 but the
rotation works fine with a negative value so the limitation is
unnecessary. This makes rotation using the ClutterAnimation API more
flexible because it was previously not possible to rotate
counter-clockwise from the 0.0 position.
2009-02-18 17:32:23 +00:00
Neil Roberts
99248fa90f Override the opacity when painting a clone instead of combining
When rendering a clone before this commit the clone's opacity was
combined with the opacity of the source but this is not usually the
desired effect. Instead the clone's opacity (combined with its
parents) should completely override the opacity of the source.
2009-02-18 17:01:12 +00:00
Robert Bragg
2b5a72dde5 [Cogl] cogl_clip_{set*,unset} renamed to cogl_clip_{push*,pop}
This is so they self document the stacking semantics of the cogl clip API
2009-02-18 16:00:51 +00:00
Emmanuele Bassi
8f59f25beb [actor] Revert part of commit 402e022c
An unintended chunk of commit 402e022c got committed before I looked
at the diff.
2009-02-14 13:11:13 +00:00
Emmanuele Bassi
402e022c36 [actor] Check out parameters before setting them
The clutter_actor_get_rotation() out parameters may be NULL, so
we need to check before dereferencing them.
2009-02-11 17:57:44 +00:00
Chris Lord
6bc7f4c723 [actor] Force a relayout on set_parent()
The current code that handles the invariant that the new parent
of an actor needing a layout should also be queued for relayout
is hitting the short-circuiting we do in the queue_relayout()
method.

In order to fix this we can forcibly set the actor to need a
width/height request and an allocation; then we queue a relayout
on the parent.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-05 19:54:48 +00:00
Emmanuele Bassi
801e535e94 Add Actor::create_pango_layout()
Final bit of integration between ClutterActor and Pango: a simple
method for creating a PangoLayout, pre-filled with text and ready
to be rendered using cogl_pango_render_layout().

This should make writing new Actors rendering custom text in their
paint() implementation easy and reliable.
2009-02-02 12:07:28 +00:00
Neil Roberts
3e68b23ea8 Merge branch 'scale-center'
Bug 1349 - Using the anchor point to set the scale center is messy

The branch adds an extra center point for scaling which can be used
for example to set a scale about the center without affecting the
position of the actor.

The scale center can be specified as a unit offset from the origin or
as a gravity. If specified as a gravity it will be stored as a
fraction of the actor's size so that the position will track when the
actor changes size.

The anchor point and rotation centers have been modified so they can
be set with a gravity in the same way. However, only the Z rotation
exposes a property to set using a gravity because the other two
require a Z coordinate which doesn't make sense to interpret as a
fraction of the actor's width or height.

Conflicts:

	clutter/clutter-actor.c
2009-01-28 15:39:51 +00:00
Neil Roberts
1cd313477b [clutter-actor] Use G_STMT_START/END instead of do { } while (0)
In the TRANSFORM_ABOUT_ANCHOR_COORD macro it now uses G_STMT_START and
G_STMT_END instead of directly using do/while because it's more
readable.
2009-01-28 15:33:34 +00:00
Emmanuele Bassi
3cfc7fb1ca Merge branch 'generic-actor-clone'
* generic-actor-clone:
  Remove CloneTexture from the API
  [tests] Clean up the Clone interactive test
  Rename ActorClone to Clone/2
  Rename ActorClone to Clone/1
  Improves the unit test to verify more awkward scaling and some corresponding fixes
  Implements a generic ClutterActorClone that doesn't need fbos.
2009-01-27 16:14:35 +00:00
Robert Bragg
70d7d16f13 Support scaling on the z axis with cogl_scale
This simply adds a z argument to cogl_scale and updates clutter-actor.c
to pass 1.0 for the z scale.
2009-01-27 15:20:13 +00:00
Havoc Pennington
9ccae46bc1 Bug 1415 - short-circuit setting same clip again
There is some GL work and a repaint anytime the clip is set
or unset, so avoid that if it isn't really changed.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-01-26 16:22:39 +00:00