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.
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.
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.
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.
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.
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.
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.
* 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
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.
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
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.
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.
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.
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.
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>
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.
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>
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>
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.
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.
gdk is an optional clutter dependency, so the pick buffer debugging option
needs some guards so we don't break, for example, the OSX builds. This also
adds a comment for the bit fiddling done on the pick colors used to ensure
the pick colors are more distinguished while debugging. (we swap the
nibbles of each color component so that pick buffers don't just look black.)
ClutterGroup previously calculated the size as the distance from the
left edge of the leftmost child to the right edge of the rightmost
child except if there were any chidren left of the origin then the
left edge would be zero.
However the group is always allocated its size relative to its
origin so if all of the children are to the right of the origin then
the preferred size would not be large enough to reach the rightmost
child.
origin
┼──────────┐
│Group │
│ ┌────────┼─┐
│ │Child │ │
│ │ │ │
└─┼────────┘ │
│ │
└──────────┘
group size
╟──────────╢
This patch makes it so the size is always just the rightmost edge.
origin
┼────────────┐
│Group │
│ ┌──────────┤
│ │Child │
│ │ │
│ │ │
│ │ │
└─┴──────────┘
group size
╟────────────╢
Fixes bug:
http://bugzilla.openedhand.com/show_bug.cgi?id=1825
Since the Great Rework of ClutterUnits, functions have been using
'units' not 'unit' in their name. clutter_value_get_unit() is a left
over from a dark age, its declaration and documentation have been
updated but not the symbol itself.