Clutter (software)

Clutter
Original author(s) Emmanuele Bassi, OpenedHand Ltd
Developer(s) The GNOME Project
Initial release June 22, 2006 (2006-06-22)
Stable release
1.22.0 / March 23, 2015 (2015-03-23)[1]
Preview release
1.21.8 / March 15, 2015 (2015-03-15)[2]
Written in C
Operating system Linux, BSDs, OS X, Microsoft Windows
Type Graphics library
License GNU Lesser General Public License[3]
Website GNOME/Projects/clutter
Clutter tarballs
Clutter git

Clutter is a GObject-based graphics library for creating hardware-accelerated user interfaces. Clutter is an OpenGL-based 'interactive canvas' library and does not contain any graphical control elements. It relies upon OpenGL (1.4+) or OpenGL ES (1.1 or 2.0) for rendering,. It also supports media playback using GStreamer and 2D graphics rendering using Cairo.[4]

Clutter was authored by OpenedHand Ltd, now part of Intel. Clutter is free and open-source software, subject to the requirements of the GNU Lesser General Public License (LGPL), version 2.1.[3]

Adoption

Popular programs that adopt Clutter are GNOME Videos (a.k.a. Totem), GNOME Shell, Pitivi, Cinnamon Desktop and GNOME Ease.

Mx is a widget toolkit based on Clutter originally designed for the graphical shell of Moblin/MeeGo netbook, but evolved into an independent project.

The widget toolkits Netbook Toolkit (nbtk) and Mx are based on Clutter.[5] Often Clutter is seen analogous to GTK+ but this is inaccurate. Only Clutter together with Mx or Nbtk can match the extent of the GTK+. This is also the reason why Clutter is used together with GTK+.

Clutter supports multi-touch gestures.

Software architecture

GDK contains back-ends to X11, Wayland, Broadway (HTTP), Quartz and GDI and relies on Cairo for the rendering. Its new SceneGraph is work-in-progress, Clutter's SceneGraph can be used.
Example of Clutter usage in Linux-based systems

Clutter is a scene graph-based canvas working in retained mode. Every object on the scene is usually a 2D surface inside a 3D space.

Clutter abstracts the native windowing environment behind a backend, which is also responsible for creating the main container for the scene graph; this top level container is called the stage. Items on the stage are called actors.

Instead of operating on matrices, as does OpenGL, the Clutter developer changes properties of each actor. Clutter will then notice the changes, and render the scene accordingly.

Clutter is currently being developed by OpenedHand to provide visually rich graphical user interfaces on desktop and embedded hardware. The main target are media center-like applications, small devices UIs and base drawing API for GL- and GL/ES-based UI toolkits. Clutter uses Pango for text rendering (with a special GL/GLES renderer) and GdkPixbuf for loading images into GL textures. Interaction with other GNOME platform libraries is done through multiple integration libraries, e.g.: clutter-gst (GStreamer), clutter-gtk (for embedding the stage into a GTK+ application), clutter-cairo (for using cairo to draw into a texture). It's API and ABI are kept stable within micro releases, but can break API during minor releases—until it reaches 1.0, then it will be API and ABI stable until the following major release.

ClutterActor

ClutterActor is the basic element of Clutter's scene graph, it encapsulates the position, size, and transformations of a node in the graph.[7]

Supported platforms

Clutter is developed for the X Window System using GLX as well as Wayland[8][9][10] using EGL. Clutter can also use the framebuffer. As of release 0.6, native support for Mac OS X has been added.[11] A native Microsoft Windows backend is supported since the 0.8 release[12] and Windows pre-compiled DLLs are available,[13][14][15] however, it is possible to build the latest DLL for Windows with MinGW and Bash shell for Windows.

Since version 1.19.4 from June 2014, Clutter's evdev input backend depends on libinput 0.4.0.[16]

Programming language bindings

Clutter is implemented using the C programming language with a design based on the GObject object system. Bindings are available for these languages:

Integration libraries

Clutter can be integrated with other libraries and toolkits, for instance:

Example

This example will add a label on the stage (written in C).

// Retrieve the default stage, which will contain all the actors on the scene.
ClutterActor *stage = clutter_stage_get_default ();

// Create a new label, using the Sans font 32 pixels high, and with the "Hello, world" text,
// and will place it into the stage.
ClutterActor *label = clutter_text_new_with_text ("Sans 32px", "Hello, world");
clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);

// Position the label at the center of the stage, taking into account the stage and the label size.
float x = (clutter_actor_get_width (stage) - clutter_actor_get_width (label)) / 2;
float y = (clutter_actor_get_height (stage) - clutter_actor_get_height (label)) / 2;
clutter_actor_set_position (label, x, y);

// Show the stage. All actors in Clutter are visible unless explicitly hidden, except for the stage;
// thus showing the stage will
// automatically display all of its visible children.
clutter_actor_show (stage);

Interface builder

Clutter can build user interfaces using a specialized JSON dialect.[18] The entire scene graph is defined using JSON types and built at run time through the ClutterScript class.

Example

This definition will create the main window and place a label with the text Hello, world! inside it.

{
    "id": "main-stage",
    "type": "ClutterStage",
    "color": "white",
    "width": 800,
    "height": 600,
    "title": "Script demo",
    "children": [{
        "id": "hello-label",
        "type": "ClutterText",
        "x": 400,
        "y": 300,
        "text": "Hello, world!",
        "color": "black",
        "font-name": "Sans 48px"
    }],
    "signals": [{
        "name": "destroy",
        "handler": "clutter_main_quit"
    }]
}

The definition can be saved into a file or as a string, and loaded using:

ClutterScript *script = clutter_script_new ();
GError *error = NULL;
clutter_script_load_from_data (script, description, -1, &error);
if (error)
{
    g_warning ("Unable to load UI description: %s", error->message);
    g_error_free (error);
}
else
{
    GObject *stage;

    clutter_script_connect_signals (script, NULL); /* connect the signal handlers */
    stage = clutter_script_get_object (script, "main-stage"); /* get the "main-stage" object */
    clutter_actor_show (CLUTTER_ACTOR (stage));
}

Animation

Clutter allows implicit animations of every item on the canvas using special objects called behaviours: each behaviour can be applied to multiple actors, and multiple behaviours can be composed on the same actor. Behaviours handle animations implicitly: the developer specifies the initial and final states, the time (or number of frames) needed to complete the animation, the function of time to be used (linear, sine wave, exponential, etc.), and the behaviour will take care of the tweening. Clutter provides a generic base class for developers to implement custom behaviours, and various simple classes handling simple properties, like opacity, position on the Z axis (depth), position along a path, rotation, etc.

Since Clutter 1.0, it is also possible to create simple, one-off animations using the ClutterAnimation class and the clutter_actor_animate() convenience function. The clutter_actor_animate() function animates an actor properties between their current state and the specified final state.

Example

This example will scale the label from its size to a factor of 2 in 2 seconds, using a linear function of time and behaviours:

ClutterTimeline *timeline = clutter_timeline_new (2000);
ClutterAlpha *alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
ClutterBehaviour *behaviour = clutter_behaviour_scale_new (alpha,
                                                           1.0, 1.0, /* initial scaling factors */
                                                           2.0, 2.0  /* final scaling factors */ );
clutter_behaviour_apply (behaviour, label);
These statements will create a timeline with a duration of 2 seconds; an alpha, binding the timeline to a linear easing mode; a behaviour, which will scale any actor to which it is applied between factor 1.0 and factor 2.0 (both horizontally and vertically). Finally, it applies the behaviour to an actor.

The equivalent code using the implicit animations API is:

clutter_actor_animate (label,          /* the actor to animate */
                       CLUTTER_LINEAR, /* the easing mode */
                       2000,           /* the duration of the animation */
                       "scale-x", 2.0, /* final horizontal scaling factor */
                       "scale-y", 2.0, /* final vertical scaling factor */
                       NULL);
This statement will create an implicit ClutterAnimation[19] object, which will animate the provided GObject properties between their current value and the specified final value.

COGL

Cogl is a small open source software library for using 3D graphics hardware to draw pretty pictures.[20] The API departs from the flat state machine style of OpenGL and is designed to make it easy to write orthogonal components that can render without stepping on each other's toes. Cogl currently supports OpenGL ES 1.1/2.0 and OpenGL > 1.3 (or 1.2 if you have the GL_ARB_multitexture extension), and having Gallium3D or D3D back-ends are options for the future.

libchamplain

libchamplain is a C library providing a ClutterActor to display maps. It also provides a Gtk+ widget to display maps in Gtk+ applications. libchamplain is named after Samuel de Champlain, a French navigator, explorer and cartographer.

History

Release history

Version Release date Significant changes
1.0 2010-Jan-11
1.1 2010-Feb-16
1.2 2010-Sep-24
1.3 2010-Sep-15
1.4 2010-Sep-24
1.5 2011-Jan-24
1.6 2011-Sep-15
1.7 2011-Sep-12
1.8 2012-Jan-30
1.9 2012-Mar-19
1.10 2012-Jun-19
1.11 2012-Sep-17
1.12 2012-Oct-17
1.13 2013-Mar-19
1.14 2013-Nov-21
1.15 2013-Sep-20
1.16 2014-Jan-24
1.17 2014-Mar-04
1.18 2014-Aug-13
1.19 2014-Sep-17
1.20 2015-Apr-23
1.21 2015-Mar-15
1.22 2015-Jun-30
1.23 2015-Aug-21
1.24 2015-Oct-12
1.25 2016-Feb-18
1.26 2016-Mar-21

See also

References

  1. "ANNOUNCE: Clutter 1.22.0 (stable)". 2015-03-23. Retrieved 2015-03-31.
  2. "ANNOUNCE: Clutter 1.21.8 (snapshot)". 2015-03-15.
  3. 1 2 "Clutter license".
  4. http://developer.gnome.org/clutter/stable/ClutterCairoTexture.html Clutter API Reference: ClutterCairoTexture
  5. https://wiki.gnome.org/Projects/Vala/MxSample
  6. https://github.com/clutter-project/clayland
  7. "GNOME developer documentation".
  8. Bassi, Emmanuele (31 January 2011). "ANNOUNCE: Clutter 1.6.0 (stable)". Retrieved 9 March 2016.
  9. Bradford, Rob (16 December 2011). "Clutter & Cogl Wayland update". Retrieved 9 March 2016.
  10. Bassi, Emmanuele (24 September 2013). "ANNOUNCE: Clutter 1.16.0 (stable)".
  11. http://blogs.gnome.org/tko/2008/05/26/three-steps-forward-one-giant-step-back/ Life with Clutter on OSX
  12. http://www.clutter-project.org/docs/clutter/stable/clutter-Win32-Specific-Support.html
  13. "vala-win32 Vala binaries for Windows". Retrieved 27 January 2013.
  14. "Val(a)IDE in Launchpad". Retrieved 27 January 2013.
  15. "x6-development-share". Retrieved 27 January 2013.
  16. "[ANNOUNCE] libinput 0.4.0". freedesktop.org. 2014-06-24.
  17. http://mail.gnome.org/archives/gnome-announce-list/2009-September/msg00099.html GNOME Mailing Lists: GTK+ 2.18.0 released
  18. http://www.clutter-project.org/docs/clutter/stable/ClutterScript.html#ClutterScript.description Clutter API Reference: ClutterScript
  19. http://www.clutter-project.org/docs/clutter/stable/clutter-Implicit-Animations.html
  20. "cogl 1.18.2". 2014-07-04.
This article is issued from Wikipedia - version of the 12/4/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.