Commit Graph

45 Commits

Author SHA1 Message Date
Neil Roberts
8d51617979 Conditionally use g_object_notify_by_pspec
This adds a wrapper macro to clutter-private that will use
g_object_notify_by_pspec if it's compiled against a version of GLib
that is sufficiently new. Otherwise it will notify by the property
name as before by extracting the name from the pspec. The objects can
then store a static array of GParamSpecs and notify using those as
suggested in the documentation for g_object_notify_by_pspec.

Note that the name of the variable used for storing the array of
GParamSpecs is obj_props instead of properties as used in the
documentation because some places in Clutter uses 'properties' as the
name of a local variable.

Mose of the classes in Clutter have been converted using the script in
the bug report. Some classes have not been modified even though the
script picked them up as described here:

json-generator:

 We probably don't want to modify the internal copy of JSON

behaviour-depth:
rectangle:
score:
stage-manager:

 These aren't using the separate GParamSpec* variable style.

blur-effect:
win32/device-manager:

 Don't actually define any properties even though it has the enum.

box-layout:
flow-layout:

  Have some per-child properties that don't work automatically with
  the script.

clutter-model:

  The script gets confused with ClutterModelIter

stage:

  Script gets confused because PROP_USER_RESIZE doesn't match
  "user-resizable"

test-layout:

  Don't really want to modify the tests

http://bugzilla.clutter-project.org/show_bug.cgi?id=2150
2010-08-10 17:12:06 +01:00
Emmanuele Bassi
fd27ca7398 Mark property strings for translation
Both the nick and the blurb fields should be translatable, for UI
builders and other introspection-based tools.
2010-07-15 14:07:07 +01:00
Emmanuele Bassi
a2f444ccbe box: Fix allow-none annotation
The syntax for allowing NULL is "allow-none", not "allow none".
2010-03-03 10:47:42 +00:00
Emmanuele Bassi
74a27bbb1c docs: Documentation fixes
Let's see if we can get a 100% coverage for Clutter too.
2010-03-02 11:12:32 +00:00
Emmanuele Bassi
4bc4c604e9 box: Let pack_at() create the ChildMeta, if any
A sub-class of ClutterBox might add ChildMeta support, and since
pack_at() does not go through clutter_container_add_actor(), we
need to manually call the create_child_meta() ourselves.
2010-02-25 12:55:12 +00:00
Emmanuele Bassi
26e22b2ede Conditionally use G_VALUE_COLLECT_INIT() macro
GLib 2.24 (but starting from the 2.23.2 unstable release) added a new
macro for collecting GValues from a va_list.

The newly added G_VALUE_COLLECT_INIT() macro should be used in place
of initializing the GValue and calling G_VALUE_COLLECT(), and improves
the collection performances by avoiding multiple checks, free and
initialization calls.
2010-02-25 10:22:36 +00:00
Emmanuele Bassi
aa8c812705 box: Do not short-circuit size negotiation for empty Boxes
The LayoutManager used might decide to have a default allocation or a
default preferred size when empty.
2010-02-24 12:10:23 +00:00
Neil Roberts
eb35c446b1 clutter-box: Layer new actors on top of all others at the same depth
g_list_insert_sorted inserts the new actor before all others that
compare equal so for the normal case when all actors have depth==0
this has the surprising behaviour of layering the actors in reverse
order. To fix this it now manually inserts the actor in the right
place by searching until it finds an actor at a higher depth and
inserting before that.

http://bugzilla.openedhand.com/show_bug.cgi?id=1988
2010-02-24 10:03:43 +00:00
Neil Roberts
da0315e4d6 box: Revert "Tweak the depth sorting function"
This reverts commit 939e56e2b1.

Changing the depth sort function to have inconsistent behaviour for
nodes that compare equal breaks the stability of g_list_sort. It ends
up so that every time clutter_container_sort_depth_order is called the
order of all actors with the same depth is reversed.

http://bugzilla.openedhand.com/show_bug.cgi?id=1988
2010-02-24 10:03:41 +00:00
Emmanuele Bassi
939e56e2b1 box: Tweak the depth sorting function
By changing the depth sorting function we can achieve the same effect as
ClutterGroup but without the costly append+sort.

http://bugzilla.openedhand.com/show_bug.cgi?id=1988
2010-02-23 17:59:09 +00:00
Robert Bragg
bfb271b403 box: port a ClutterGroup::foreach fix to ClutterBox
ClutterGroup::foreach was recently changed (ref: ce030a3fce) to use
g_list_foreach() to iterate the children instead of manually iterating
the list so it would safely handle calls like:

  clutter_container_foreach (container, clutter_actor_destroy);

  (In this example clutter_actor_destroy will result in the current
   list item being iterated being freed.)
2010-02-12 12:31:24 +00:00
Robert Bragg
60a4664d6e box: Adds missing copyright header
Adds a Copyright (C) 2009,2010  Intel Corporation header
2010-02-12 12:31:24 +00:00
Robert Bragg
4355621aeb group: make it comparable to ClutterBox
There is a lot of duplication between ClutterGroup and ClutterBox so
this makes the two files diff-able so that new fixes can easily be
ported to both and bug fixes missing in one or the other can be spotted
more easily. This doesn't change the behaviour of either actor; it's
really just a shuffle around of code and normalizes the coding style to
make the files comparable.

This has already uncovered one bug in ClutterBox, and also highlights
a bug in ClutterGroup + many other actors:

1) ClutterGroup::real_foreach was recently changed to use
   g_list_foreach instead of manually iterating the child list so it can
   safely handle calls like:
     clutter_container_foreach (container, clutter_actor_destroy);
   ClutterBox is still manually iterating the list.

2) In ClutterGroup we guard _queue_redraw() calls like this:
    if (CLUTTER_ACTOR_IS_VISIBLE (container))
	clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
   In ClutterBox we don't:
     I think ClutterBox is correct here because
     clutter_actor_queue_redraw already optimizes the case where the
     actor's not visible, but it also considers that the actor may be
     cloned and so the guard in ClutterGroup could break clones. This
     actually highlights a wider clutter bug since the same kinds of
     guards can be found in all other clutter actors.
2010-02-12 12:31:24 +00:00
Emmanuele Bassi
9ccdf2eb02 box: Add relative packing methods
ClutterBox should provide some convenience functions to pack a new child
at a given position, either an absolute index or relative to a sibling.
2009-12-04 16:54:22 +00:00
Emmanuele Bassi
15a04a1dd3 layout-manager: Create LayoutMeta on demand
The ClutterLayoutMeta instances should be created on demand, whenever
the layout manager needs them - if the layout manager supports layout
properties.

This removes the requirement to call add_child_meta() and
remove_child_meta() on add and remove respectively; it also simplifies
the implementation of LayoutManager sub-classes since we can add
fallback code in the base abstract class.

Eventually, this will also lead to an easier to implement ClutterScript
parser for layout properties.

With the new scheme, the ClutterLayoutMeta instance is created whenever
the layout manager tries to access it; if there isn't an instance
already attached to the container's child, one is created -- assuming
that the LayoutManager sub-class has overridden the
get_child_meta_type() virtual function and it's returning a valid GType.

We can also provide a default implementation for create_child_meta(),
by getting the GType and instantiating a ClutterLayoutMeta with all the
fields already set. If the layout manager requires more work then it can
obviously override the default implementation (and even chain up to it).

The ClutterBox actor has been updated, as well as the ClutterBoxLayout
layout manager, to take advantage of the changes of LayoutManager.
2009-11-30 19:11:00 +00:00
Emmanuele Bassi
a5a0171cb0 box: Depth level changes should queue a relayout
ClutterBox is not ClutterGroup: a change in the level of an actor
through raise, lower or depth sorting must trigger a relayout.
2009-10-26 15:09:07 +00:00
Emmanuele Bassi
2cad7e24f0 box: Check before using the LayoutManager instance
A ClutterBox might not have a ClutterLayoutManager instance
associated -- for instance, during destruction. We should check
for one before calling methods on it.
2009-10-26 15:08:03 +00:00
Emmanuele Bassi
4d153e4507 layout, box: Clean up
* Use g_list_foreach() instead of iterating over the list inside
  the destruction sequence, since we are causing the widgets to be
  implicitly removed from the list via the destroy() call.

* Use g_signal_connect_swapped() and spare us from a callback.
2009-10-15 12:15:49 +01:00
Emmanuele Bassi
adca939101 layout, box: Write long description for Box
Also have an example of how to create a Box with a layout manager
and how to use the pack() method.
2009-10-15 12:04:50 +01:00
Emmanuele Bassi
4663552a00 [layout] Typo and whitespace fixes 2009-10-14 11:31:30 +01:00
Emmanuele Bassi
c98388bb01 [layout, box] Add Box:color
Allow setting the background color of a ClutterBox
2009-10-14 11:31:29 +01:00
Emmanuele Bassi
755896664f [layout] Set a back pointer to Box inside the layout
Use the LayoutManager API to set a back pointer to the Box actor
inside the LayoutManager used by the box.

This also allows us to replace the LayoutManager on a Box, since
the LayoutManager will be able to replace all the metadata if
needed.
2009-10-14 11:31:29 +01:00
Emmanuele Bassi
f58bdbad15 [layout] Rename Box::add to Box::pack
Since ClutterBox is a ClutterContainer we should avoid naming
collisions between methods.
2009-10-14 11:31:29 +01:00
Emmanuele Bassi
aaae60e178 [layout] Implement ClutterBox::add
The ClutterBox::add method is a simple wrapper around the Container
add_actor() method and the LayoutManager layout properties API. It
allows adding an actor to a Box and setting the layout properties in
one call.

If the LayoutManager used by the Box does not support layout properties
then the add() method short-circuits out.

Along with the varargs version of the method there's also a vector-based
variant, for language bindings to use.
2009-10-14 11:31:29 +01:00
Emmanuele Bassi
98474076a1 [layout] Bind the layout ChildMeta inside Box
The ClutterBox container actor should add and remove ChildMeta to
each actor that has been added and removed to the list of children,
respectively.
2009-10-14 11:27:29 +01:00
Emmanuele Bassi
4e8d8bbc15 [layout] Update Box
* Use ::layout-changed to queue a relayout when the layout changes

* Destroy the Box children when destroying the Box

* Allow getting the layout manager from the Box
2009-10-14 11:27:29 +01:00
Emmanuele Bassi
141a155690 [layout] Make LayoutManager a floating object
A layout manager instance makes only sense if it's owned by a
container. For this reason, it should have a floating reference
instead of a full reference on construction; this allows constructing
Boxes like:

  box = clutter_box_new (clutter_fixed_layout_new ());

without leaking the layout manager instance.
2009-10-14 11:27:18 +01:00
Emmanuele Bassi
0340f65634 [box] Add ClutterBox
ClutterBox is an actor with no layout management. It relies on
a ClutterLayoutManager to perform size requisition and allocation
of its children.
2009-10-14 11:27:18 +01:00
Emmanuele Bassi
4976be12ca 2007-11-28 Emmanuele Bassi <ebassi@openedhand.com>
Remove the layout containers: they will be moved to a
	high-level library.

	* clutter/clutter.h:
	* clutter/Makefile.am: Remove layout and boxes from the
	build.

	* clutter/clutter-layout.[ch]: Remove the ClutterLayout
	interface.
	
	* clutter/clutter-box.[ch]:
	* clutter/clutter-hbox.[ch]:
	* clutter/clutter-vbox.[ch]: Remove ClutterBox and its
	subclasses.
	
	* clutter/clutter-label.c: Remove ClutterLayout implementation

	* clutter/clutter-script-private.h:
	* clutter/clutter-script-parser.c:
	* clutter/clutter-script.c:
	(clutter_script_parse_node): Remove special parsing for
	ClutterMargin and ClutterPadding.

	* clutter/clutter-types.h: Remove ClutterPadding and ClutterMargin.

	* tests/Makefile.am:
	* tests/test-boxes.c: Remove the boxes test case.
2007-11-28 13:50:24 +00:00
Emmanuele Bassi
7ee405a8b0 2007-11-06 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-box.c (clutter_box_dispose): Call unparent()
	on the children, instead of destroy(), to avoid a double free
	and a crash when destroying a ClutterBox.
2007-11-06 14:36:28 +00:00
Øyvind Kolås
9047f9d2bc * clutter/clutter-container.[ch]: removed find_child_by_id method
from interface (and all implementations of it) since this
functionality is now implemented using a global hash.
* clutter/clutter-box.c: 
* clutter/clutter-group.c:
2007-11-05 17:12:11 +00:00
Tomas Frydrych
abd6832dd9 2007-10-12 Tomas Frydrych <tf@o-hand.com>
* clutter/clutter-actor.c:
        * clutter/clutter-backend.c:
        * clutter/clutter-behaviour-depth.c:
        * clutter/clutter-box.c:
        * clutter/clutter-clone-texture.c:
        * clutter/clutter-container.c:
        * clutter/clutter-entry.c:
        * clutter/clutter-feature.c:
        * clutter/clutter-fixed.c:
        * clutter/clutter-group.c:
        * clutter/clutter-hbox.c:
        * clutter/clutter-label.c:
        * clutter/clutter-layout.c:
        * clutter/clutter-media.c:
        * clutter/clutter-rectangle.c:
        * clutter/clutter-score.c:
        * clutter/clutter-script.c:
        * clutter/clutter-stage.c:
        * clutter/clutter-texture.c:
        * clutter/clutter-timeline.c:
        * clutter/clutter-timeout-pool.c:
        * clutter/clutter-vbox.c:
        * clutter/cogl/gl/cogl.c:
        * clutter/cogl/gles/cogl.c:
        * clutter/eglnative/clutter-backend-egl.c:
        * clutter/eglnative/clutter-event-egl.c:
        * clutter/eglnative/clutter-stage-egl.c:
        * clutter/eglx/clutter-backend-egl.c:
        * clutter/eglx/clutter-event-egl.c:
        * clutter/eglx/clutter-stage-egl.c:
        * clutter/glx/clutter-event-glx.c:
        * clutter/json/json-array.c:
        * clutter/json/json-generator.c:
        * clutter/json/json-node.c:
        * clutter/json/json-object.c:
        * clutter/json/json-parser.c:
        * clutter/sdl/clutter-backend-sdl.c:
        * clutter/sdl/clutter-event-sdl.c:
        * clutter/sdl/clutter-stage-sdl.c:

	Fixedup config.h inclusion (must always be bracketed with #ifdef
	HAVE_CONFIG_H).
2007-10-12 08:17:00 +00:00
Emmanuele Bassi
143005bd79 Implement ::raise(), ::lower() and ::sort_depth_order() in ClutterBox
Provide the implementations of the newly added ClutterContainer virtual
functions inside ClutterBox.
2007-08-13 17:01:30 +00:00
Emmanuele Bassi
57c0be73cd Implement ClutterContainer::find_child_by_id() in ClutterBox
Iterate (recursively) on the children of a box to find the one with the
given unique id.
2007-08-13 17:00:47 +00:00
Emmanuele Bassi
ffbf7b64ab 2007-08-09 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-box.c: Rename a variable to fix a compiler
	warning.
2007-08-09 13:24:42 +00:00
Emmanuele Bassi
e548b53936 Add descriptions to ClutterBox and subclasses
Final touches to the ClutterBox implementation.
2007-08-06 19:37:55 +00:00
Emmanuele Bassi
cc80f3bb68 Add NULL-check on the padding in clutter_box_pack() 2007-08-06 19:37:26 +00:00
Emmanuele Bassi
5c8d18e619 Add default padding to ClutterBox
To avoid using a ClutterPadding each time you add an actor to a ClutterBox
when you want the same padding around each child, you can now set the
default padding. The API is pixel-based, since it's a commodity function,
and will affect only clutter_box_pack_defaults().
2007-08-06 19:37:15 +00:00
Emmanuele Bassi
a55cea7b2b Initialise the box allocation
We need the allocation to be < 0 for the subclasses to compute it
correctly the first time.
2007-08-06 19:36:39 +00:00
Emmanuele Bassi
54b77d12cd Update the ClutterBox API and structure
ClutterBox is meant to work like the HTML boxing model: it has a margin and
a backgrdound color, and every child actor is added with a pack type and a
padding. The ClutterBoxChild structure holds the child actor, the padding,
the packing type and the allocated coordinates for the actor.
2007-08-06 19:36:27 +00:00
Emmanuele Bassi
454e493197 Fix various compiler warnings
Most of these fixes are simple symbol shadowing issues, like index and the
braindead y0 and y1 extern symbols exported by math.h on GNU libc systems.

There is a masking issue in ClutterTexture which should be checked; I ran
the tests and everything looked fine.

The rest are just unused variables.
2007-07-26 11:04:04 +00:00
Matthew Allum
7ea9e2bcbb 2007-07-06 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-box.c: (clutter_box_pick):
        Call clutter_box_paint rather than actor paint method avoiding
        infinte loop (Fixes test-boxes crasher).

        * clutter/glx/clutter-stage-glx.c: (clutter_stage_glx_unrealize):
        Trap the X calls to avoid potential X errors.
2007-07-06 09:22:43 +00:00
Emmanuele Bassi
d7caae7f6a 2007-07-04 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/*: Loads of fixes for the API reference.
2007-07-04 14:00:41 +00:00
Emmanuele Bassi
450ac94e49 Override ClutterActor::pick
Override the default ClutterActor::pick method, by calling a full paint of the box actor
like ClutterGroup does.
2007-06-14 19:57:29 +00:00
Emmanuele Bassi
4a926f4155 Don't forget to add the boxes 2007-06-14 15:30:27 +00:00