Commit Graph

38 Commits

Author SHA1 Message Date
Emmanuele Bassi
0b76ba332d Fixes for the API reference
Typos, missing symbols, and missing documentation.
2012-04-27 12:30:48 +01:00
Emmanuele Bassi
2b81d90dd7 Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.

We always used it to conform to the platform, at least for public-facing
API.

At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.

Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:

  https://bugzilla.gnome.org/show_bug.cgi?id=644611

Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 16:06:24 +01:00
Emmanuele Bassi
ab0eb0a12b docs: Documentation fixes 2010-12-09 13:59:08 +00:00
Emmanuele Bassi
63cef64d17 docs: Fix some wrong function/signal/property names 2010-11-18 15:21:16 +00:00
Emmanuele Bassi
46c597a1f6 Clean up clutter-private.h/6
Move all Actor private API to a separate file.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
43edfc9400 Clean up clutter-private.h/4
Move the private Backend API to a separate header.

This also allows us to finally move the class vtable and instance
structure to a separate file and plug the visibility hole that left
the Backend class bare for everyone to poke into.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
7dd09e2186 Use G_DEFINE_BOXED_TYPE for all boxed types
We actually need a couple more macros for registering GValue
transformation functions. Those should be added to upstream
GLib.
2010-10-18 11:26:45 +01:00
Emmanuele Bassi
ca8db4c2ee Add caller-allocates annotations
For ClutterColor, ClutterUnits, ClutterInterval and the Perspective
accessor in ClutterStage.
2010-09-08 17:04:21 +01:00
Emmanuele Bassi
7ca340fade docs: Avoid warnings from the g-ir-scanner
The scanner has some issues when parsing valid gtk-doc annotations; we
should make its (and, in return, ours) life easier.

We still get warnings for code declared in <programlisting> sections,
unfortunately.
2010-06-30 15:51:12 +01:00
Emmanuele Bassi
79acb088e7 Remove mentions of the FSF address
Since using addresses that might change is something that finally
the FSF acknowledge as a plausible scenario (after changing address
twice), the license blurb in the source files should use the URI
for getting the license in case the library did not come with it.

Not that URIs cannot possibly change, but at least it's easier to
set up a redirection at the same place.

As a side note: this commit closes the oldes bug in Clutter's bug
report tool.

http://bugzilla.openedhand.com/show_bug.cgi?id=521
2010-03-01 12:56:10 +00:00
Emmanuele Bassi
a9d2c0f690 Merge branch 'bug-1846'
* bug-1846:
  Fix warning message in the ParamSpec validation
2009-10-16 15:55:05 +01:00
Damien Lespiau
70c8128457 Fix warning message in the ParamSpec validation
When validating a new GValue against the ClutterParamSpecUnits, we issue
a warning when the units do not match with both the new value and the
unit we expect to have. Unfortunately we were printing the unit of the
new value twice and not the unit of the ParamSpec.

http://bugzilla.openedhand.com/show_bug.cgi?id=1846
2009-10-16 15:54:24 +01:00
Damien Lespiau
ee9f8c3bdf Add ClutterInterval integration
To be able to animate CLUTTER_TYPE_UNITS properties we need to register
the GType and its progress function against the ClutterInterval code.

The two ClutterUnits defining the interval can use different units, the
resulting unit will always be in pixels, so calculating a progress
between 10px and 4cm is valid.

http://bugzilla.openedhand.com/show_bug.cgi?id=1844
2009-10-16 15:52:40 +01:00
Emmanuele Bassi
83b4ec7a12 units: Cache the pixels value inside Units
When computing the pixels value of a ClutterUnits value we should
be caching the value to avoid recomputing for every call of
clutter_units_to_pixels(). We already have a flag telling us to
return the cached value, but we miss the mechanism to evict the
cache whenever the Backend settings affecting the conversion, that
is default font and resolution, change.

In order to implement the eviction we can use a "serial"; the
Backend will have an internal serial field which we retrieve and
put inside the ClutterUnits structure (we split one of the two
64 bit padding fields into two 32 bit fields to maintain ABI); every
time we call clutter_units_to_pixels() we compare the units serial
with that of the Backend; if they match and pixels_set is set to
TRUE then we just return the stored pixels value. If the serials
do not match then we unset the pixels_set flag and recompute the
pixels value.

We can verify this by adding a simple test unit checking that
by changing the resolution of ClutterBackend we get different
pixel values for 1 em.

http://bugzilla.openedhand.com/show_bug.cgi?id=1843
2009-10-16 15:25:37 +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
Damien Lespiau
a799f6ccec Fix string parsing when no unit is given
The check should really be on the character pointed by str. Added the
corresponding test case.
2009-10-05 13:08:16 +01:00
Damien Lespiau
4d7b8c9d42 clutter_value_get_unit() has not be renamed
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.
2009-10-05 13:08:13 +01:00
Emmanuele Bassi
90d8f31831 [units] Do not be locale-dependant on string conversion
When dumping a ClutterUnits structure to a string we are using a bare
g_strdup_printf(), which unfortunately is locale dependant. So, for
instance, a type of CLUTTER_UNIT_EM and a value of 42 are stringified
as:

        C:      42.00 em
        en_GB   42.00 em
        it_IT   42,00 em
        fr_FR   42,00 em

This would not be a problem -- clutter_units_from_string() allows both
'.' and ',' as fractionary part delimiters. The test suite, on the
other hand, does not know that, and it checks for exact matches with
the C locale.

Calling setlocale(LC_ALL,"C") at the beginning of the conformance test
suite is not a good idea, because it would prevent external testing; and
it's a lame cop out from doing exactly what we have to do -- pick a format
and stick with it.

Like other platforms, languages and frameworks before us, we opt to
be less liberal in what we create; so, we choose to always stringify
ClutterUnits with fractionary parts using '.' as the delimiter.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1763
2009-08-14 16:05:33 +01:00
Emmanuele Bassi
a5d6b23308 [units] Add binding-friendly initializers
We should follow the convention for boxed types initializers of:

  <type_name>_from_<another_type> (boxed, value)

For ClutterUnits as well; so:

  clutter_units_pixels -> clutter_units_from_pixels
  clutter_units_em     -> clutter_units_from_em
  ...

We should still keep the short-hand version as a macro, though.
2009-07-28 13:46:11 +01:00
Emmanuele Bassi
eff857bc7f [docs] Improve the Units to and from string conversion
Make sure to document the conversion to and from strings for ClutterUnits,
with negative examples and with the behaviour for fractionary bits.
2009-07-20 20:59:18 +01:00
Emmanuele Bassi
19c2e66398 [docs] Various gtk-docs fixes 2009-06-09 14:47:36 +01:00
Emmanuele Bassi
ea9bd6761a [units] Always recompute pixels
When asking for the pixels value we should always recompute it.

The "pixel_set" guard can be left in place for future use.
2009-06-06 15:59:45 +01:00
Emmanuele Bassi
c3dc03997c Fixes for some compiler warnings 2009-06-06 14:37:41 +01:00
Emmanuele Bassi
876dc22633 [units] Validate units against the ParamSpec
When declaring a property using ClutterParamSpecUnits we pass a
default type to limit the type of units we accept as valid values
for the property.

This means that we need to add the unit type check as part of the
validation process.
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
f2c25fd4f7 Allow specifying the font for the em conversion
Currently, the conversion from em to units is done by using the
default font name inside the backend. For actors using their own
font/text layout we need a way to specify the font name along
with the quantity we wish to transform.
2009-05-07 19:25:18 +01: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
Emmanuele Bassi
d1f3190f5b [units] Add more conversion functions
A GValue containing a ClutterUnit should be transformable into a
GValue holding an integer, a floating point value or a fixed point
value.

This means adding more transformation functions when registering
the ClutterUnit GType.
2009-03-10 12:38:04 +00:00
Emmanuele Bassi
6ca40faaec [units] Fix Units in GValue and ClutterParamSpecUnit
The GValue and GParamSpec integration of ClutterUnit was still
using the old, fixed-point based logic.

Storing ClutterUnits in a GValue should use floating point values,
and ClutterParamSpecUnit should follow suit.
2009-01-22 12:11:25 +00:00
Emmanuele Bassi
355555c1bf Store the units-per-em inside the Backend
Instead of recomputing the number of units needed to fit in
an em each time clutter_units_em() is called, we can store this
value into the default Backend along with the resolution and
font name. The value should also be updated each time the
resolution and font are changed, to keep it up to date.
2009-01-22 11:42:11 +00:00
Emmanuele Bassi
ee883f30d4 Add units-from-em conversion
An em is a unit of measurement in typography, equal to the point
size of the current font.

It should be possible to convert a value expressed in em to
ClutterUnits by using the current font and the current DPI as
stored by the default backend.
2009-01-21 17:35:47 +00:00
Emmanuele Bassi
93a0454c09 Remove the single-stage units converters
The stage-with/height-percentage converters had been broken by
the multiple-stages support of Clutter 0.8. They are also made
useless by the fact that Units are now floating point values.

The millimeters and typographic points converters also depended
on the default stage, but they can be reworked to use the default
DPI coming from the default Backend instead.
2009-01-21 17:10:36 +00:00
Emmanuele Bassi
1abccbad21 2008-05-09 Emmanuele Bassi <ebassi@openedhand.com>
Bug #902 - Support transform from G_TYPE_INT to ClutterUnit

	* clutter/clutter-units.c:
	(clutter_value_transform_int_unit),
	(clutter_unit_get_type): Add GValue transformation function from
	integer values to ClutterUnit. (#902)

	(param_unit_validate): Fix validation for ClutterParamSpecUnit;
	this allows writable ClutterUnit properties.

	* clutter/clutter-fixed.c:
	(clutter_value_transform_int_fixed),
	(clutter_value_transform_double_fixed),
	(clutter_value_transform_float_fixed): Add GValue transformation
	functions from native types (int, double, float) to ClutterFixed.

	(clutter_fixed_get_type): Register the new transformation functions.

	(param_fixed_validate): Fix validation for ClutterParamSpecUnit;
	this allows writable ClutterFixed properties.
2008-05-09 10:58:26 +00:00
Emmanuele Bassi
a7f4767ecb 2008-04-28 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-units.c (param_unit_init): Use the right
	macros to set the default minimum and maximum values.

	* clutter/clutter-fixed.c (param_fixed_init): Ditto as above.
2008-04-28 13:37:28 +00:00
Emmanuele Bassi
fd70c7df49 2008-04-17 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-fixed.c:
	(clutter_value_transform_fixed_int),
	(clutter_value_transform_fixed_double),
	(clutter_value_transform_fixed_float),
	(clutter_fixed_get_type): Add GValue transformation functions
	for ClutterFixed; copying a CLUTTER_TYPE_FIXED GValue into
	a G_TYPE_FLOAT/G_TYPE_DOUBLE one will automatically transform
	the fixed point representation into a floating point one. Also
	add the G_TYPE_INT transformation function to do a plain
	fixed->int copy.

	* clutter/clutter-units.c:
	(clutter_value_transform_unit_int),
	(clutter_unit_get_type): Add a unit->int transformation function.
2008-04-17 14:08:26 +00:00
Emmanuele Bassi
3d30622d96 2008-04-17 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-units.c (clutter_value_get_unit): Fix typo
	in the function name.
2008-04-17 11:40:46 +00:00
Emmanuele Bassi
d1ba07d0e7 2008-04-17 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/Makefile.am: Add clutter-units.c

	* clutter/clutter-units.[ch]: Add a ClutterUnit fundamental
	type, and wrappers for storing it into GValues; also add a
	GParamSpec subclass for defining parameters holding ClutterUnit
	values. This allows creating GObject properties using units.

	* doc/reference/clutter-sections.txt: Document the newly
	added API.
2008-04-17 09:13:12 +00:00