The Clutter Cookbook

Emmanuele Bassi

Elliot Smith

for Clutter 1.0

Permission is granted to copy, distribute and/or modify this document under the terms of the Creative Commons Attribution-Non-Commercial-Share Alike 2.0 UK: England & Wales as published by Creative Commons.

Table of Contents

1. Preface
1. About Clutter
2. About this document
3. Acknowledgments
4. Where to get Clutter
2. Actors
1. Introduction
2. Implementing a simple custom actor
3. Knowing when an actor's position or size changes
4. Overriding the paint sequence
5. Making an actor transparent by changing its opacity
6. Creating an actor with a non-rectangular shape
3. Events
1. Introduction
2. Handling key events
3. Detecting mouse scrolling on an actor
4. Detecting pointer movements on an actor
5. Making an actor respond to button events
4. Textures
1. Introduction
2. Drawing 2D graphics onto a texture
3. Maintaining the aspect ratio when loading an image into a texture
4. Loading image data into a texture
5. Creating sub-textures from an existing texture
6. Creating a reflection of a texture
7. Cross-fading between two images
5. Animations
1. Introduction
2. Inverting Animations
3. Fading an actor out of or into view
4. Rotating an actor
5. Creating complex animations with ClutterAnimator
6. Reusing a complex animation on different actors
7. Moving actors
8. Looping an animation
9. Animated scaling
10. Animating an actor along a curved path
6. Text
1. Introduction
2. Drawing a shadow under the text
7. Layout management
1. Introduction
2. Stacking actors on top of each other
3. Binding the size of one actor to the size of another
4. Arranging actors in a single row or column
8. Script
1. Introduction
2. Defining a user interface with JSON
3. Connecting to signals in ClutterScript
4. Connecting ClutterState states in ClutterScript
9. Effects
1. Introduction
2. Changing an actor's paint sequence using ClutterEffect
3. Creating and animating a custom ClutterDeformEffect
1. Contributing to this document

List of Examples

2.1. cb-button.h: header file
2.2. cb-button.c: ClutterActor and GObject implementation
2.3. actors-composite-main.c: trivial application demonstrating usage of CbButton
3.1. Mouse scrolling over a ClutterActor
3.2. Simple button with a hover animation (change in opacity as the pointer enters and leaves it)
3.3. Detecting pointer motion on a ClutterRectangle
3.4. How actors influence pointer events on each other
3.5. Scribbling on a ClutterTexture in response to pointer events
3.6. Examining properties of a ClutterButtonEvent
3.7. Using ClutterClickAction to capture button events on an actor
3.8. Using button and pointer events for drawing
4.1. Creating a sub-texture from an existing texture
4.2. Creating a sub-texture from an existing texture
4.3. Creating a glassy reflection of a texture
4.4. Cross-fading between two images using two ClutterTextures
4.5. Cross-fading between two images using one ClutterTexture and the COGL API
4.6. A simple slideshow application using two ClutterTextures
5.1. Rotating an actor around x, y, and z axes using ClutterState
5.2. JSON definition of a complex animation using ClutterAnimator
5.3. Simple program for loading a JSON script; any key press starts the animation
5.4. Running multiple transition sequences with different key frames in parallel using ClutterAnimator
5.5. ClutterScript JSON defining several rectangles with signal handlers
5.6. ClutterScript JSON describing a "rig" and a ClutterAnimator animation
5.7. Loading ClutterScript from JSON files in response to events in a user interface
5.8. Simple movement using implicit animations
5.9. Using ClutterState to repeatedly move (and scale) two actors
5.10. Using ClutterAnimator to randomly move three actors along the x axis
5.11. Looping an implicit animation
5.12. Looping with ClutterAnimator
5.13. Looping with ClutterState
5.14. Animated scaling of an actor using each of the scale gravities. Press any key to start the animation.
5.15. Animated scaling (up and down) of a texture in response to button presses. Call with the path to an image as the first argument.
5.16. Using a ClutterPathConstraint with implicit animations to move an actor along a curved path
5.17. Using a ClutterPathConstraint with ClutterAnimator to animate an actor on a simulated circular path
5.18. Animating actors on curved paths using easing modes
6.1. Creating a shadow of a text
7.1. ClutterBinLayout, with actors in 9 combinations of start, center and end alignment combinations
7.2. Layering multiple textures on top of each other inside a ClutterBinLayout
7.3. Constraining the size of a texture to the size of the stage using ClutterBindConstraint
7.4. Creating an automatically-resizing overlay for a texture using ClutterBindConstraint
7.5. Using the allocation-changed signal of one actor to trigger proportional size changes in another
7.6. Different approaches to setting child layout properties in a ClutterBoxLayout
7.7. A simple ClutterBoxLayout menu
7.8. A demonstrator for "toggling and tweaking" a ClutterBoxLayout's properties
8.1. Example UI definition in JSON for use with ClutterScript
8.2. Loading JSON from a file and retrieving objects defined by it
8.3. ClutterScript JSON with signal handler definitions
8.4. Loading a JSON file into a ClutterScript and connecting signal handlers
8.5. ClutterScript JSON with state definitions
8.6. Loading a JSON file into a ClutterScript and connecting states
9.1. Applying a ClutterColorizeEffect to a texture loaded with an image
9.2. cb-background-effect.h (header file)
9.3. cb-background-effect.c (code file)
9.4. cb-border-effect.h (header file)
9.5. cb-border-effect.c (code file)
9.6. Application which applies CbBorderEffect and CbBackgroundEffect to a group of ClutterTextures.
9.7. cb-page-fold-effect.h (header file)
9.8. cb-page-fold-effect.c (code file)
9.9. Application which uses CbPageFoldEffect to do animated folding of a ClutterTexture