Commit Graph

139 Commits

Author SHA1 Message Date
Elliot Smith
5bca30300e cookbook: Example of simple movement animation
Added example showing how to move an actor in one of the
three axes (x,y,z) in response to a button event on the
actor.
2010-09-23 16:24:21 +01:00
Emmanuele Bassi
4037f76a3e build: Update the remote publish path for the cookbook 2010-09-21 12:02:41 +01:00
Elliot Smith
e92b186719 cookbook: Add recipe about sync'ing actor sizes
The recipe covers how to use ClutterBindConstraint
to bind actor sizes together.

It gives some examples of where this approach is appropriate,
as well as explaining an alternative using allocation-changed
or notify::* signals.

Three examples are given:

1. Resizing a texture to the stage.
2. Resizing a rectangle to act as a transparent overlay on
top of a texture (using constraints).
3. Resizing a rectangle to act as a transparent overlay on
top of a texture, but with a size proportional to the texture
(using a handler connected to allocation-changed signals
emitted by the texture).
2010-09-17 15:58:48 +01:00
Elliot Smith
c3cbf1533f cookbook: Example using allocation-changed to sync actor size
An alternative method (not using constraints) to bind
one actor's size and position to another. Used as
an example in the recipe about resizing one actor in
sync with a source actor.
2010-09-17 15:58:48 +01:00
Elliot Smith
8a149521ce cookbook: Simple example to demonstrate bind constraint
A simple example showing how to scale an actor to the stage.

Demonstrates ClutterBindConstraint and ClutterAlignConstraint
in a fashion suitable for a short recipe.
2010-09-17 15:58:48 +01:00
Elliot Smith
a0f63a3153 cookbook: Example of using a bind constraint for an overlay
Example code which loads an image into a texture, and resizes
the image in response to +/- key presses. The overlay is
a transparent rectangle which is bound to the height and
width of the texture; on clicking the texture, the overlay
is made visible by increasing its opacity.

This demonstrates how to use constraints to simplify code
for resizing an actor which is "dependent" on another actor.
2010-09-17 15:58:48 +01:00
Elliot Smith
e8e360eaa7 cookbook: Added a recipe for reusing a complex animation
This recipe explains how to "reuse" the same animation
definition for different actors, by creating a new
instance of a "rig" (empty container) and animation
for the rig each time the animation is required.

An actor is then re-parented to the rig and animated
using it, rather than being animated directly.

JSON is used to define the rig + animator, to make
creating new instances of them simpler. The recipe
also discusses various caveats around using this
approach, rather than directly animating an actor.
2010-09-13 14:31:17 +01:00
Elliot Smith
6548bee56c cookbook: Added id for section in "rotating an actor" recipe
Added an id to a section in the "rotating an actor" recipe,
so that it can be referred to from the "reusing an animation"
recipe.
2010-09-13 12:25:47 +01:00
Elliot Smith
82ab00930b cookbook: Simplified and clarified example code
Modified the "animation reuse" sample code to provide
a simpler example to explain in the recipe.

Also modified variable names to mirror the names used
for the previous "complex animation" example and added
some more comments, to further simplify and support the
recipe.
2010-09-13 12:25:47 +01:00
Elliot Smith
d7a3e35f46 cookbook: Cleaned up the "animations reuse" example
With some help from pippin, moved variable declarations
into more sensible positions within their functions,
changed a function name, and found a better way
to unref a script once its associated actor has
been destroyed.
2010-09-13 12:25:47 +01:00
Elliot Smith
d4190cbf8c cookbook: Refactored reusable animation example
Extracted the animation into its own JSON definition,
then create a new script and get the animation each
time a rectangle is clicked.

Removes the need to reparent onto the background and
copy property values to the rectangle after the animation,
and generally much cleaner.
2010-09-13 12:25:47 +01:00
Elliot Smith
acc28cf60c cookbook: Added example for animation reuse recipe
Added an example showing how to reuse a ClutterAnimator
instance to animate multiple actors at different times
using an animatable rig, combined with reparenting.
2010-09-13 12:25:47 +01:00
Emmanuele Bassi
732eecf5c6 cookbook: Use the new CLUTTER_KEY_* symbol constants
Instead of the deprecated CLUTTER_* ones.
2010-09-10 18:21:45 +01:00
Emmanuele Bassi
f2669df6b5 build: Disable deprecated API when building the cookbook examples
Make sure we always use the latest API.
2010-09-10 18:21:19 +01:00
Emmanuele Bassi
abef73bb58 Replace cogl_color_set_from_* with cogl_color_init_from_*
The former is not yet "officially" deprecated by the latter, but it's
confusing to have them both in the code base.
2010-09-03 16:58:47 +01:00
Emmanuele Bassi
7fee8cf26a cookbook: Add a short introduction for the Text chapter 2010-09-03 15:44:03 +01:00
Elliot Smith
655c60aaa9 cookbook: Added recipe for complex animation
Uses ClutterAnimator to implement a reasonably complex
animation of a single actor (movement along a path with
simultaneous scaling).

Provides a metaphor for thinking about ClutterAnimator
animations (stage directions) and explains keys and key
frames in some depth. Also compares ClutterAnimator
with other possible approaches to this type of animation
(implicit animations, ClutterState).
2010-09-03 14:31:57 +01:00
Elliot Smith
60ff660d42 cookbook: Added a second example to show "overlapping" transitions
Added another JSON example to show how transitions can
be easily overlapped when using ClutterAnimator (two
sequences of 5 transitions, simultaneous with two
sequences of 1 transition).

Modified the C JSON loader program so it can be used with
this example as well.
2010-09-03 14:19:51 +01:00
Elliot Smith
c0aa72a042 cookbook: Added complex animations example
To support recipe about using ClutterAnimator to create
complex animations.
2010-09-03 14:19:51 +01:00
Elliot Smith
6c40b10083 cookbook: Added recipe for signal handling in ClutterScript
Added a recipe explaining how to connect signals to handlers
in the JSON definition used by ClutterScript; also shows
how to connect the signals in code once the JSON has been
loaded.

Includes guidelines on writing handlers (i.e. need to use
-export-dynamic and non-static functions) and example
which connects a handler for motion events on a rectangle.
2010-08-31 14:39:47 +01:00
Elliot Smith
a67111a17c cookbook: Added example of connecting signals in ClutterScript
To support recipe about connecting signals in script.
2010-08-31 10:06:08 +01:00
Elliot Smith
79a4dbb329 cookbook: Use nicknames for enumeration values
GEnum nicknames can be used to set properties in JSON
definitions, so added a callout to the JSON example explaining
this, and showing how to derive the nickname for an enumeration
value.

Modified the example code to use nicknames as well.
2010-08-27 15:29:15 +01:00
Elliot Smith
2c3ca20cdc cookbook: Don't use the default stage
It's not necessary to use the default stage, so
don't encourage this in the JSON example.
2010-08-27 15:13:28 +01:00
Elliot Smith
6db795baf6 cookbook: Mention nick names as possible values for enums
As JSON can make use of nicknames for GEnum properties,
mentioned this in the table mapping C property values
to their JSON equivalents (as the nick name is a much
shorter and cleaner way of setting a property in JSON).
2010-08-27 15:10:17 +01:00
Elliot Smith
b532f95917 cookbook: Added introduction to and recipe on ClutterScript
Wrote an introduction to using ClutterScript with JSON. Focus
is on explaining why you might want to use it, basic principles
of operation (with annotated JSON sample), and how to map
data types from C to JSON.

Written simultaneously with a short recipe (uses the same sample
code) showing how to load a JSON file and retrieve objects
from it in code.
2010-08-27 11:25:40 +01:00
Elliot Smith
7900ac4dc7 cookbook: Added comments to script example
Commented the ClutterScript example so it can be used
inline as part of the recipe, rather than as an
example in the appendix (it's too simple to warrant
a separate appendix).
2010-08-27 11:21:30 +01:00
Elliot Smith
0fc1c8503b cookbook: Added first draft of script introduction
New script chapter needs an introduction.

While writing the introduction, also slightly changed the
emphasis of the recipe (towards refactoring an existing
application to use ClutterScript) and incorporated example
code into documentation.
2010-08-27 11:21:30 +01:00
Elliot Smith
ce3a3d4404 cookbook: Use text for callouts in documentation
Set a parameter on the XSLT transform so that callout elements
are rendered as text rather than graphics (removes the need
to add callout graphics to the build).
2010-08-27 11:21:30 +01:00
Elliot Smith
fef53e1b28 cookbook: Added skeleton for script chapter of cookbook 2010-08-27 11:21:30 +01:00
Elliot Smith
27d9825abe cookbook: Simplified ClutterScript example
There was too much in the example code to cover in a single
recipe, so I trimmed it down to demonstrate simple
UI building (no constraints, effects, animations, or signals).
2010-08-27 11:21:30 +01:00
Elliot Smith
4cba0cf3e8 cookbook: Added ClutterScript example
Added a simple script and program to load it, to support
recipe on ClutterScript for UI definitions.

Also amended the Makefile (following the pattern of
the tests/interactive Makefile) to enable signal
connection from ClutterScript by passing -export-dynamic
to linker.
2010-08-27 11:21:30 +01:00
Emmanuele Bassi
5f15a620a1 Merge remote branch 'elliot/cookbook-textures-crossfade'
* elliot/cookbook-textures-crossfade:
  cookbook: Use GdkPixbuf instead of getting data from a texture
  cookbook: Added a recipe for cross-fading between two images
  cookbook: Modified COGL example for consistency
  cookbook: Added video of two texture cross-fade
  cookbook: Removed unused constant
  cookbook: Renamed front/back to top/bottom in cross-fade example
  cookbook: Don't need to set keep-aspect-ratio for simple example
  cookbook: Modified ordering of statements in cross-fade example
  cookbook: Added a longer slideshow example
  cookbook: Made code examples more consistent
  cookbook: Added example code for texture cross-fading
  Post-release version bump to 1.3.13
  Release Clutter 1.3.12 (developers snapshot)

Conflicts:
	doc/cookbook/examples/Makefile.am
2010-08-20 15:24:42 +01:00
Elliot Smith
81481cd803 cookbook: Added recipe for handling pointer events on an actor
Added a recipe about handling enter, leave, and motion events
on an actor.

Gives some pointers to data available from motion events,
explains a bit about stage-relative and actor-relative coords,
and covers how overlapping actors and reactivity of actors
can affect events occurring.

Examples include a simple scribble app showing how to integrate
pointer events into a more useful context.
2010-08-20 13:56:17 +01:00
Elliot Smith
c480e5ec00 cookbook: Added example to show how stacking affects pointer events
Added another example (used for a screenshot) to demonstrate
how pointer events pass through non-reactive actors and how
depth ordering affects whether an actor will emit a pointer
motion signal.
2010-08-20 12:54:19 +01:00
Elliot Smith
526b438b3a cookbook: Use get_coords rather than struct members
Use clutter_event_get_coords() to get x and y position,
rather than casting to the right event type then directly
accessing members of the event struct.
2010-08-20 12:54:19 +01:00
Elliot Smith
a4db7746f2 cookbook: Made callback names more consistent
Changed callback function names so they are more consistent
within this recipe and with other callback names used
in other recipes.
2010-08-20 12:54:19 +01:00
Elliot Smith
c1e2658104 cookbook: Added simple pointer motion example
Added a simple pointer motion example which just reports on
the stage and actor-relative coordinates of the pointer
as it moves.
2010-08-20 12:54:19 +01:00
Elliot Smith
7c196d31b4 cookbook: Added scribble example for pointer motion recipe
Simple scribbler application which demonstrates tracking
mouse enter and motion events on a texture, drawing with
COGL and ClutterPath as they occur.
2010-08-20 12:39:48 +01:00
Elliot Smith
b648bff10c cookbook: Renamed example for pointer crossing
Decided might be better to cover crossing and motion under
a broader "pointer motion" recipe, so renamed the example
(which only shows pointer crossing event handling).
2010-08-20 12:39:48 +01:00
Elliot Smith
72ddd471f0 cookbook: Added example for pointer cross recipe
Code example demonstrates detecting pointers entering/leaving
an actor by implementing a (very) simple button with hover
effect.
2010-08-20 12:39:48 +01:00
Elliot Smith
444d315078 cookbook: Use GdkPixbuf instead of getting data from a texture
Rewrote example for single texture + COGL to use
a GdkPixbuf to load images, rather than reading data
out of another CoglTexture.

The data is then loaded from the pixbuf to a region of
the CoglTexture (as before).
2010-08-18 16:02:51 +01:00
Elliot Smith
c207820bef cookbook: Added a recipe for cross-fading between two images
The recipe covers a two texture approach (using the Clutter API)
and a single texture approach (using COGL).

It also discusses issues with cross-fading between images of
different sizes with the COGL API, and gives a longer
example of cycling through multiple images in a slideshow
application.
2010-08-18 11:42:00 +01:00
Elliot Smith
c492faecb2 cookbook: Modified COGL example for consistency
Changed the stage size so the COGL API example for cross-fade
has a stage the same size as the two texture example.
2010-08-18 11:41:32 +01:00
Elliot Smith
e54d3e716b cookbook: Added video of two texture cross-fade
Added a video showing the two texture cross-fade.

Modified the example code to animate on key press, so
this video could be captured.

Also altered the stage size to minimise the video size.
2010-08-18 11:41:32 +01:00
Elliot Smith
0486c56a41 cookbook: Removed unused constant 2010-08-18 11:41:32 +01:00
Elliot Smith
8c0c2924ae cookbook: Renamed front/back to top/bottom in cross-fade example
Front/back seems like the wrong terminology when discussing
actors arranged in layers. Top/bottom fits better with Clutter
API function names and other recipes, so renamed variables.
2010-08-18 11:41:32 +01:00
Elliot Smith
1e4578d1dd cookbook: Don't need to set keep-aspect-ratio for simple example 2010-08-18 11:41:32 +01:00
Elliot Smith
1b2606a850 cookbook: Modified ordering of statements in cross-fade example
Changed the order of statements in the sample code to match
the order they will be explained in the walk-through in the recipe.
2010-08-18 11:41:32 +01:00
Elliot Smith
e332236b87 cookbook: Added a longer slideshow example
Cross-fading between two images is straightforward,
but cycling between more than two is more efficient
if done by copying COGL textures between the
two textures, rather than trying to reposition the
textures.

The example demonstrates how to reuse a pair of
textures to cycle through multiple images.
2010-08-18 11:41:32 +01:00
Elliot Smith
c230fd8dfd cookbook: Made code examples more consistent
Modified the code example for the Clutter API version
of the cross-fade to use the same command line
as the COGL version.

This also simplifies the explanation in the recipe.

Also made the COGL code sample more consistent with
the Clutter API code sample.
2010-08-18 11:41:32 +01:00