Commit Graph

3358 Commits

Author SHA1 Message Date
Emmanuele Bassi
5737cf869f [layout] Initial implementation of FlowLayout
FlowLayout is a layout manager that arranges its children in a
reflowing line; the orientation controls the major axis for the
layout: horizontal, for reflow on the Y axis, and vertical, for
reflow on the X axis.
2009-10-14 11:31:30 +01:00
Emmanuele Bassi
857b0239e9 [layout] Use FixedLayout inside Group
The Group actor should use the FixedLayout layout manager object
to avoid duplicating code.
2009-10-14 11:31:30 +01:00
Emmanuele Bassi
62db72cf41 [layout] Update FixedLayout
The behaviour of ClutterGroup has been fixed with regards to the
preferred size request; the fixed layout manager should use the
same behaviour.
2009-10-14 11:31:30 +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
df6ca3d171 [layout, docs] Clean up BinLayout documentation
Documentation and code style fixes for BinLayout.
2009-10-14 11:31:29 +01:00
Emmanuele Bassi
8b2088a917 [layout, tests] Use variants for child packing in Box
There are three potential variants to add a child inside a Box
with a BinLayout:

  - clutter_box_pack(), a variadic argument function which
    allows passing arbitrary LayoutMeta properties and values;

  - clutter_bin_layout_add(), which uses the backpointer to
    the container from the LayoutManager and sets the layout
    properties directly without GValue (de)marshalling

  - clutter_container_add_actor() and
    clutter_bin_layout_set_alignment(), similar to the
    clutter_bin_layout_add() function above, but split in two

The test-box interactive test should exercise all three variants.
2009-10-14 11:31:29 +01:00
Emmanuele Bassi
431a63d04a [layout] Store and use the container inside BinLayout
The BinLayout should store a pointer to the Container that it is
using it as the layout manager.

This allows us to fix the API and drop the additional Container
arguments from set_alignment() and get_alignment().

This also allows us to add a ClutterBinLayout::add() method which
adds an actor and sets the alignment policies without dealing with
variadic arguments functions and GValue (de)marshalling.
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
22bb243ec2 [layout] Replace stale LayoutMeta
If a LayoutMeta references a different container and/or layout manager
then we should simply replace it and discard the previous one.
2009-10-14 11:31:29 +01:00
Emmanuele Bassi
9117ee2056 [layout] Allow taking a back pointer to the Container
The LayoutManager implementation might opt to take a back pointer
to the Container that is using the layout instance; this allows
direct access to the container itself from within the implementation.
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
c6f67bf872 [layout, docs] Document FixedLayout 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
a2086f1178 [layout] Add LayoutMeta
Instead of overloading ClutterChildMeta with both container and layout
metadata and delegate to every LayoutManager implementation to keep a
backpointer to the layout manager instance, we can simply subclass
ChildMeta into LayoutMeta and presto! everything works out pretty well
for everyone.
2009-10-14 11:31:26 +01:00
Emmanuele Bassi
899db6f226 [layout, docs] Add layout managers sections
Add LayoutManager and its subclasses, and the Box actor to the
gtk-doc machinery needed to generate the API reference.
2009-10-14 11:30:43 +01:00
Emmanuele Bassi
9cccff504a [layout] Add layers to BinLayout
Each actor managed by a BinLayout policy should reside inside its
own "layer", with horizontal and vertical alignment. The :x-align
and :y-align properties of the BinLayout are the default alignment
policies, which are copied to each new "layer" when it is created.

The set_alignment() and get_alignment() methods of BinLayout can
be changed to operate on a specific "layer".

The whole machinery uses the new ChildMeta support inside the
LayoutManager base abstract class.
2009-10-14 11:27: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
7051fe275d [layout] Bind ChildMeta to LayoutManager
The ChildMeta object is a storage for child-container properties,
that is properties that exist only when an actor is inside a specific
container. The LayoutManager delegate class should also have
layout-specific properties -- so, for this job, we can "recycle"
ChildMeta as the storage.
2009-10-14 11:27:29 +01:00
Emmanuele Bassi
83a4e96267 [layout] Document BinLayout 2009-10-14 11:27:29 +01:00
Emmanuele Bassi
b06a3293fe [layout] Notify of alignment changes in BinLayout
Emit the ::layout-changed when the BinLayout alignment policies change.

This will result in a queue_relayout() on the containers using the
BinLayout layout manager.
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
d096a3c791 [layout] Add LayoutManager::layout-changed signal
If a sub-class of LayoutManager wishes to implement a parametrized
layout policy it also needs a way to notify the container using the
layout manager that the layout has changed. We cannot do it directly
and automatically from the LayoutManager because a) it has no back
link to the actor that it is using it and b) it can be attached to
multiple actors.

This is a job for <cue raising dramatic music> signals!

By adding ClutterLayoutManager::layout-changed (and its relative
emitted function) we can notify actors using the layout manager that
the layout parameters have been changed, and thus they should queue
a relayout.
2009-10-14 11:27:29 +01:00
Emmanuele Bassi
a1853892ba [tests] Add a Box interactive test 2009-10-14 11:27:19 +01:00
Emmanuele Bassi
1061ebeac9 [layout] Add BinLayout
A BinLayout is a simple layout manager that allocates a single cell,
providing alignment on both the horizontal and vertical axis.

If the container associated to the BinLayout has more than one child,
the preferred size returned by the layout manager will be as big as
the maximum of the children preferred sizes; the allocation will be
applied to all children - but it will still depend on each child
preferred size and the BinLayout horizontal and vertical alignment
properties.

The supported alignment properties are:

  * center: align the child by centering it
  * start: align the child at the top or left border of the layout
  * end: align the child at the bottom or right border of the layout
  * fill: expand the child to fill the size of the layout
  * fixed: let the child position itself
2009-10-14 11:27:19 +01:00
Emmanuele Bassi
6d4cc13f7c [layout] Add Fixed layout manager
The FixedLayout layout manager object implements the same layout
policy of ClutterGroup.
2009-10-14 11:27:18 +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
d6183e95e5 [layout] Add initial implementation of LayoutManager
The LayoutManager class is an abstract proxy for the size requesition
and size allocation process in ClutterActor.

A ClutterLayoutManager sub-class must implement get_preferred_width(),
get_preferred_height() and allocate(); a ClutterContainer using the
LayoutManager API will then proxy the corresponding Actor virtual
functions to the LayoutManager instance. This allows having a generic
"blank" ClutterActor sub-class, implementing the ClutterContainer
interface, which leaves only the layout management implementation to
the application developers.
2009-10-14 11:27:18 +01:00
Emmanuele Bassi
4f2bfc003a build: Clean up main Makefile.am 2009-10-14 09:07:11 +01:00
Emmanuele Bassi
46b736f42e build: Move marshallers and enum types rules out
The rules to create signal marshallers and enumeration GTypes are
usually copied and pasted all over different projects, though they
are pretty generic and, given a little bit of parametrization, can
be put in separate Makefile.am files and included whenever needed.
2009-10-14 09:07:11 +01:00
Emmanuele Bassi
0e33c10048 docs: Allow XInclude fallback for the annotation glossary 2009-10-14 09:07:11 +01:00
Emmanuele Bassi
a99f693c85 docs: Make StageManager a public class
The StageManager API is useful to track the stages of an application.
It will also be useful when we land the modules API.
2009-10-14 09:07:11 +01:00
Emmanuele Bassi
c3d056533c stage/manager: Set :default-stage as read-only
The StageManager:default-stage property should be read-only, since
the default stage is owned by Clutter itself.
2009-10-14 09:07:11 +01:00
Emmanuele Bassi
74eaa29413 stage/manager: Deprecate set_default_stage()
The set_default_stage() method of StageManager should not be used
by application code; technically, nothing in Clutter uses it, and
StageManager's API is not considered public anyway.
2009-10-14 09:07:11 +01:00
Damien Lespiau
a7ff5385a5 [actor] Unset the IN_DESTRUCTION flag when leaving ::destroy()
The IN_DESTRUCTION flag is set around the unrealization and disposal of
the actor in clutter_actor_destroy() but is never unset (it's set twice
instead).

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-10-12 17:40:46 +01:00
Emmanuele Bassi
3bbc96e17e text: Make the :text property not set the :use-markup one
Currently, setting the :text property has the side-effect of
setting the :use-markup property to FALSE. This prevents
constructing a Text actor, or setting its properties, like:

  g_object_set (text,
                "use-markup", TRUE,
                "text", some_string,
                NULL);

as the ordering becomes important. Unfortunately, the ordering
of the properties cannot be enforced with ClutterScript or
with language bindings.

The documentation of the clutter_text_set_text() method should
be expanded to properly specify that the set_text() method will
change the :use-markup property to FALSE as a side effect.
2009-10-07 21:55:54 +01:00
Emmanuele Bassi
1f207c00d9 docs: Add the "clipping" section to the COGL API reference
All the clip-related API in COGL is missing from the API reference
because the cogl-clipping section is not included inside the main
index file.
2009-10-07 17:41:54 +01:00
Damien Lespiau
80b3a8d328 [units] Ensure we don't have ponies
The documentation states we should not parse ponies. Even with those
with exclamation marks.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-10-07 17:10:51 +01:00
Damien Lespiau
19c6879960 [path] Add GValue transform functions from and to G_TYPE_STRING
Transform functions allow the use of g_value_transform() to cast
GValues. It's very handy to have casts to and from G_TYPE_STRING as it
allows generic serialization and parsing of GTypes.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-10-07 16:06:26 +01:00
Damien Lespiau
8605073edb [units] Add support for centimeters
The only tricky part of the patch is to remember that 1cm is 10mm.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-10-07 16:06:26 +01:00
Damien Lespiau
96859959bd [units] Be more strict in the grammar we are parsing
Current parsing of units has a number of shortcomings:
  * a number followed by trailing space (without any unit specified) was
    not recognized,
  * "5 emeralds" was parsed as 5em,
  * the way we parse the digits after the separator makes us lose
    precision for no good reason (5.0 is parsed as 5.00010014...f which
    makes g_assert_cmpfloat() fail)

Let's define a stricter grammar we can recognize and try to do so. The
description is in EBNF form, removing the optional <> which is a pain
when having to write DocBook, and using '' for the terminal symbols.

Last step, add more ClutterUnits unit test to get a better coverage of
the grammar we want to parse.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-10-07 16:06:26 +01:00
Emmanuele Bassi
4d481e03f3 color: Measure the string just once when parsing
Instead of measuring the color hexadecimal string for each case, just
measure it once and then use a switch() to go to the right case.
2009-10-07 13:00:57 +01:00
Thomas Wood
c7d50083ec [color] allow alpha to be omitted when converting to color from string
Parse #rgb and #rrggbb in addition to forms with the alpha channel
specified. This allows conversion of colour strings from documents such as
CSS where the alpha channel is not specified when using '#' notation.

This patch also adds the relevant conformance test.
2009-10-07 12:56:01 +01:00
Neil Roberts
13ac1fe75b [clutter-id-pool] Also warn if the ID refers to a deleted actor
We should also warn if the glReadPixels happens to generate an ID that
is within the range of the ID array but no longer points to an
existing actor.
2009-10-07 12:53:19 +01:00
Neil Roberts
a4ff4d37a4 [clutter-id-pool] Fix the check for out-of-range IDs
If id == the length of the array then it is also invalid and could
cause a crash.
2009-10-07 12:53:19 +01:00
Thomas Wood
142f886518 Revert "[color] allow alpha to omitted when converting from strings"
This reverts commit eb8daac4b0.

The original commit was incorrect and pushed accidentally.
2009-10-07 12:15:26 +01:00
Thomas Wood
bdf7499207 [color] add a note to the documentation to specify the values of the alpha
The alpha channel is fully opaque at 255 and fully transparent at 0.
2009-10-07 11:40:41 +01:00
Thomas Wood
eb8daac4b0 [color] allow alpha to omitted when converting from strings
Parse #rgb and #rrggbb in addition to forms with the alpha channel
specified. This allows conversion of colour strings from documents such as
CSS where the alpha channel is not specified when using '#' notation.
2009-10-07 11:38:08 +01:00
Damien Lespiau
9e03d92316 [path] MOVE_TO and LINE_TO only use a pair of coordinates
The documentation of ClutterPathNode had a small typo and stated that
they use 2 pairs of coordinates.
2009-10-06 10:43:41 +01:00