Days of Elaine

September 29, 2011

oh man, it’s getting harder to find blog post titles…

clutter 1.8 — last Friday I rolled the first release of the new stable 1.8 cycle, and Rob rolled the first stable release of the now standalone Cogl. it’s been six months of intense development, with lots of contributions, and I’d like to thank everyone who submitted patches, opened bugs, added a translation, or even dropped by in the #clutter IRC channel to tell us that they were using Clutter for their awesome project.

clutter 1.9 — instead of resting after pushing 1.8 out of the door, we’re already hard at work on what will become 1.10 in six months. while Cogl is getting more and more refactoring to make the code base more understandable and reliable, as well as preparing the way for new features, Clutter is also getting some refactoring. today, for instance, I worked on building Clutter with multiple backends in the same shared object. one of my first major contributions to Clutter, back in the OpenedHand days, was to provide the ability to have multiple backends — and it worked pretty well: after the GLX backend we got a Windows backend, then a framebuffer backend, then an OS X backend. during the years, the implementation was amended here and there to avoid leaking the backend implementation all over the place, and we always resisted the temptation (and the outside pressure) to provide a full abstraction library for the windowing system akin to GDK. this allowed us to maintain the backend code lean and lightweight, to the point that it took me literally an hour this morning to go from the current HEAD of master to a test running with either GDK or GLX (depending on an environment variable) — and most of my changes were in the build system, not in the code.

as an example, this is a simple test program that checks the backend support at both compile and run time; using Clutter from the multi-backend branch, compiled with --enable-x11 and --enable-gdk, you can run the example on X11 using:

$ CLUTTER_BACKEND=x11 ./test-backend &
$ CLUTTER_BACKEND=gdk ./test-backend &

multiple backends, same great taste

and have two instances, one using the native X11 backend and the other using the GDK backend.

there’s still some work to do, namely fixing Clutter-GTK to work with a multi-backend Clutter, and making it use the GDK backend by default, if found. there’s also the issue of being able to use the GLX_EXT_texture_from_pixmap extension under the GDK backend on X11, if available, so that we can efficiently embed GTK widgets rendered off-screen like we can already do when using the Clutter X11 backend.

all in all, this work will help towards the goal of using Clutter and GTK together in a more organic fashion, and with fewer blocks and hacks in the middle.

Constraints

May 19, 2010

last time, I described the Effects in Clutter as anything that should affect the way an actor paints itself without sub-classing.

this kind of modification of the behaviour of an Actor can also be applied to other areas, and leads to defining three different kinds of modifiers:

  • Effects, which modify the way an actor paints itself
  • Actions, which modify the way an actor responds to user events
  • Constraints, which modify the way an actor is positioned or sized

being capable of being dragged using the pointer can be defined as an action: it changes the way an Actor responds to user events (button press, motion, button release). in the same way, update the X position using the X position of another actor is a constraint placed on an Actor.

Clutter already has signals, properties and virtual functions for dealing with these modifiers, and they can be seen as the building blocks. What’s missing is a set of classes that wrap those building blocks into something that leads to run-time composition of effects, actions and constraints on top of an existing Actor class.

last week I started working on the implementation of these modifiers, and now I’m pretty close to a finalized API for Clutter 1.4. the usage of an action is pretty simple:

  ClutterAction *action = clutter_drag_action_new ();
  g_signal_connect (action, "drag-motion",
                    G_CALLBACK (on_drag_motion),
                    NULL);

  clutter_actor_add_action (some_actor, action)
  clutter_actor_set_reactive (actor, TRUE);

the simplest implementation of a ClutterDragAction::drag-motion signal handler is:

  static void
  on_drag_motion (ClutterDragAction *action,
                  ClutterActor      *actor,
                  float              delta_x,
                  float              delta_y)
  {
    clutter_actor_move_by (actor, delta_x, delta_y);
  }

there’s no fundamental difference for the constraints API; for instance, this positions an actor in the middle of another:

  ClutterConstraint *constraint;

  constraint = clutter_align_constraint_new (parent, CLUTTER_ALIGN_X_AXIS, 0.5);
  clutter_actor_add_constraint (some_actor, constraint);

  constraint = clutter_align_constraint_new (parent, CLUTTER_ALIGN_Y_AXIS, 0.5);
  clutter_actor_add_constraint (some_actor, constraint);

it’s important to note that parent in this case can be any actor, and not necessarily the scene graph parent of some_actor.

this example binds the X coordinate of an actor to the X coordinate of another one, while keeping it Y aligned at the center of its parent:

  ClutterConstraint *constraint;

  constraint = clutter_bind_constraint_new (source, CLUTTER_BIND_X, 0.0);
  clutter_actor_add_constraint_with_name (some_actor, "x-bind", source);

  constraint = clutter_align_constraint_new (parent, CLUTTER_ALIGN_Y_AXIS, 0.5);
  clutter_actor_add_constraint_with_name (some_actor, "y-bind", constraint);

Update: I’ve updated the example to use the newly added add_constraint_with_name() instead of set_name()+add_constraint(); I also changed the constraint names.

now, I’ve added a call to clutter_actor_meta_set_name() in the mix because I might decide to animate the offset property of the ClutterBindConstraint using a specific syntax for ClutterAnimation ((the change is contained in ClutterActor so I’m not over-complicating the parsing code in the animation class itself; which also means that ClutterAnimator and the upcoming ClutterState classes will be able to use the same syntax to address action, effect and constraint properties)):

  float new_offset = clutter_actor_get_width (source) + h_padding;
  clutter_actor_animate (some_actor, CLUTTER_EASE_OUT_CUBIC, 500,
                         "@constraints.x-bind.offset", new_offset,
                         "opacity", 128,
                         NULL);

the new syntax is still type checked, so you’ll get warnings if you’re using the wrong type or the wrong interval ((I’m still considering using a dotted notation; I might switch to a colon notation, or a slash notation. and yes: I know that it looks like the syntax for key access in CoreAnimation; it turns out that there aren’t many new ways to access an item in a path)).

caveat: obviously, a constraint only applies to an actor that is in a fixed positioning layout manager.

the new classes and API are available in the wip/actor-actions branch here and wip/constraints branch here; there are also a couple of interactive tests that show you how actions and constraints can be used with existing actors. if all goes according to plan, I’ll merge them by the end of the week — following Frederic’s blog post, I want to make a 1.3 snapshot release in time for GNOME 2.31.2.

Clutter Q&A

July 8, 2009

since there are free slots here at GCDS I was wondering if somebody wanted to have a sit down and ask questions about Clutter; bugs and feature requests for 1.2 are also welcomed. just send me an email at: ebassi at gnome dot org.

A Year of Clutter

July 6, 2009

so, GUADEC/GCDS is now halfway through, and it’s been a pretty cool conference so far. obviously, lots of talks and loads of people to meet and to talk to.

Rob did a roundup of the talks that the Intel/Moblin contingent has done and will do here.

yesterday, like Josh and Rob ((also known as “the yummy Rob Bradford”)), I had my talk on a technology used by Moblin and that can be (or are already) shared with the GNOME Mobile and Desktop platforms.

I talked about Clutter and the 1.0 release; what does it mean, what will be the future direction and some of the highlights of the Clutter library in its current state. instead of using my 30 minutes to do a big talk, I decided to split them into four, five minutes lightning talks, plus an introduction and a conclusion (still five minutes each). I think it worked out pretty well, given the feedback, and I had much more fun while writing it and while delivering it. I’ll put it online on the moblin.org website as soon as the network connection I have access to gets more reliable.

other talks worth of mention: obviously, the gnome-shell and the zeitgest ones, and alexl’s client-side-windows talk. great work by everyone involved — you are all my heroes.

so, we’re finally free to show what we’ve been doing for the past six months:

it’s been a great ride — and it’s just getting started. we’ve been pushing Clutter forward and center of an entire platform user experience, and it was up to to the task to a degree that excited me, and made me incredibly proud.

the Moblin 2.0 UI is also one of the reasons we delayed the 1.0 release — the other being that we wanted to be confident in the API, since we’re going to be committing to it for the next two to three years. the wait is almost over: we’re planning a 1.0 release of Clutter by the end of May ((hopefully, it’ll all be fixed by that time :-) )). prepare yourself to have muchy more fun with Clutter!

Dream About Flying

February 20, 2009

as usual — long time, no blog.

my only excuse is that I was busy with other things: new job, new office, holidays… you know, whatever happens between coding. :-)

it’s that time of year again, and we’re nearing another Clutter release — this time it’s a special one, though, as it is 1.0.0. which also means that the API will be frozen for the entire duration of the 1.x branch: only additions and deprecations will be allowed ((no worries about stagnation, though — we are already planning for 2.0, even though it’ll take at least a couple of years to get there)).

since we’re in the process of finalizing the 1.0 API I thought about writing something about what changed, what was added and what has been removed for good.

let’s start with the Effects API. the Effects were meant to provide a high level API for simple, fire-and-forget animations ((even though people always tried to find new ways to abuse the term “fire-and-forget”)). they were sub-obtimal in the memory management — you had to keep around the EffectTemplate, the effects copied the timelines — and they weren’t extensible — writing your own effect would have been impossible without reimplementing the whole machinery. after the experiments done by Øyvind and myself, and after looking at what the high-level languages provided, I implemented a new implicit animation API — all based around a single object, with the most automagic memory management possible:

  /* resize the actor in 250 milliseconds using a cubic easing
   * and attach a callback at the end of the animation
   */
  ClutterAnimation *animation =
    clutter_actor_animate (actor, 250, CLUTTER_EASE_IN_CUBIC,
                           "width", 200,
                           "height", 200,
                           "color", &new_color,
                           NULL);
  g_signal_connect (animation, "completed",
                    G_CALLBACK (on_animation_complete),
                    NULL);

this should make a lot of people happy. the easing modes in particular are the same shared among various animation framworks, like tweener and jQuery.

what might make some people slightly less happy is the big API churn that removed both ClutterLabel and ClutterEntry and added ClutterText. the trade-off, though, is clearly in favour of ClutterText, as this is a base class for both editable and non-editable text displays; it supports pointer and keyboard selection, and multi-line as well as single-line editing.

another big changed happened on the low level COGL API, with the introduction of vertex buffers — which allow you to efficiently store arrays of vertex attributes; and, more importantly, with the introduction of the Materials which decouple the drawing operations with the fill operations. it also adds support for multi-texturing, colors and other GL features — on both GL and GLES.

Gradients with Clutter

after unifying Label and Entry, we also decided to unify BehaviourPath and BehaviourBspline; after that we added support for creating paths using SVG-like descriptions and for “replaying” a Path on a cairo_t. well, the Cairo integration is also another feature — clutter-cairo has been deprecated and its functionality moved inside ClutterCairoTexture.

one of the last minute additions has been ClutterClone, an efficient way to clone generic actors without using FBOs — which also supercedes the CloneTexture actor.

the Pango integration has been extended, and the internal Pango API exposed and officially supported — now you can display text using the Pango renderer and glyphs cache inside your own custom actors without using internal/unstable API.

thanks to Johan Dahlin and Owen Taylor, Clutter now generates GObject-Introspection data at compile time, so that runtime language bindings will be ready as soon as 1.0.0 hits the internets.

finally, there’s a ton of bug fixes in how we use GL, how we render text, how we relayout actors, etc.

hope you’ll have fun with Clutter!

the third and final installment of the ongoing saga

thanks to Damien, I finally found a way to shut up libtool and get a clean output for the build of a project: shave.

Clutter is the first project using it, and I already easily caught compiler warnings ((even without using the anal-retentive compiler flags and -Werror)) because my terminal is not full of crappy, four lines long incantations ((and even though I’m not an autotools ninja, at least I read the documentation and not just blindly copy stuff from various projects in the hope they work; so the autotools setup in Clutter is pretty much well tested so that I don’t need to worry that files get installed in a different location than expected)).

big kudos to Damien!