1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>ClutterBindConstraint</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="Clutter Reference Manual">
8 <link rel="up" href="ch05.html" title="Constraints">
9 <link rel="prev" href="ClutterAlignConstraint.html" title="ClutterAlignConstraint">
10 <link rel="next" href="ClutterPathConstraint.html" title="ClutterPathConstraint">
11 <meta name="generator" content="GTK-Doc V1.18.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
17 <td><a accesskey="p" href="ClutterAlignConstraint.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="ch05.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">Clutter Reference Manual</th>
21 <td><a accesskey="n" href="ClutterPathConstraint.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#ClutterBindConstraint.synopsis" class="shortcut">Top</a>
26 <a href="#ClutterBindConstraint.description" class="shortcut">Description</a>
28 <a href="#ClutterBindConstraint.object-hierarchy" class="shortcut">Object Hierarchy</a>
30 <a href="#ClutterBindConstraint.properties" class="shortcut">Properties</a>
33 <div class="refentry">
34 <a name="ClutterBindConstraint"></a><div class="titlepage"></div>
35 <div class="refnamediv"><table width="100%"><tr>
37 <h2><span class="refentrytitle"><a name="ClutterBindConstraint.top_of_page"></a>ClutterBindConstraint</span></h2>
38 <p>ClutterBindConstraint — A constraint binding the position or size of an actor</p>
40 <td valign="top" align="right"></td>
42 <div class="refsynopsisdiv">
43 <a name="ClutterBindConstraint.synopsis"></a><h2>Synopsis</h2>
44 <pre class="synopsis"> <a class="link" href="ClutterBindConstraint.html#ClutterBindConstraint-struct" title="ClutterBindConstraint">ClutterBindConstraint</a>;
45 enum <a class="link" href="ClutterBindConstraint.html#ClutterBindCoordinate" title="enum ClutterBindCoordinate">ClutterBindCoordinate</a>;
46 <a class="link" href="ClutterConstraint.html" title="ClutterConstraint"><span class="returnvalue">ClutterConstraint</span></a> * <a class="link" href="ClutterBindConstraint.html#clutter-bind-constraint-new" title="clutter_bind_constraint_new ()">clutter_bind_constraint_new</a> (<em class="parameter"><code><a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> *source</code></em>,
47 <em class="parameter"><code><a class="link" href="ClutterBindConstraint.html#ClutterBindCoordinate" title="enum ClutterBindCoordinate"><span class="type">ClutterBindCoordinate</span></a> coordinate</code></em>,
48 <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gfloat"><span class="type">gfloat</span></a> offset</code></em>);
49 <span class="returnvalue">void</span> <a class="link" href="ClutterBindConstraint.html#clutter-bind-constraint-set-source" title="clutter_bind_constraint_set_source ()">clutter_bind_constraint_set_source</a> (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>,
50 <em class="parameter"><code><a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> *source</code></em>);
51 <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="returnvalue">ClutterActor</span></a> * <a class="link" href="ClutterBindConstraint.html#clutter-bind-constraint-get-source" title="clutter_bind_constraint_get_source ()">clutter_bind_constraint_get_source</a> (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>);
52 <span class="returnvalue">void</span> <a class="link" href="ClutterBindConstraint.html#clutter-bind-constraint-set-coordinate" title="clutter_bind_constraint_set_coordinate ()">clutter_bind_constraint_set_coordinate</a>
53 (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>,
54 <em class="parameter"><code><a class="link" href="ClutterBindConstraint.html#ClutterBindCoordinate" title="enum ClutterBindCoordinate"><span class="type">ClutterBindCoordinate</span></a> coordinate</code></em>);
55 <a class="link" href="ClutterBindConstraint.html#ClutterBindCoordinate" title="enum ClutterBindCoordinate"><span class="returnvalue">ClutterBindCoordinate</span></a> <a class="link" href="ClutterBindConstraint.html#clutter-bind-constraint-get-coordinate" title="clutter_bind_constraint_get_coordinate ()">clutter_bind_constraint_get_coordinate</a>
56 (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>);
57 <span class="returnvalue">void</span> <a class="link" href="ClutterBindConstraint.html#clutter-bind-constraint-set-offset" title="clutter_bind_constraint_set_offset ()">clutter_bind_constraint_set_offset</a> (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>,
58 <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gfloat"><span class="type">gfloat</span></a> offset</code></em>);
59 <a href="../glib/glib-Basic-Types.html#gfloat"><span class="returnvalue">gfloat</span></a> <a class="link" href="ClutterBindConstraint.html#clutter-bind-constraint-get-offset" title="clutter_bind_constraint_get_offset ()">clutter_bind_constraint_get_offset</a> (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>);
62 <div class="refsect1">
63 <a name="ClutterBindConstraint.object-hierarchy"></a><h2>Object Hierarchy</h2>
64 <pre class="synopsis">
65 <a href="../gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a>
66 +----<a href="../gobject/gobject-The-Base-Object-Type.html#GInitiallyUnowned">GInitiallyUnowned</a>
67 +----<a class="link" href="ClutterActorMeta.html" title="ClutterActorMeta">ClutterActorMeta</a>
68 +----<a class="link" href="ClutterConstraint.html" title="ClutterConstraint">ClutterConstraint</a>
69 +----ClutterBindConstraint
72 <div class="refsect1">
73 <a name="ClutterBindConstraint.properties"></a><h2>Properties</h2>
74 <pre class="synopsis">
75 "<a class="link" href="ClutterBindConstraint.html#ClutterBindConstraint--coordinate" title='The "coordinate" property'>coordinate</a>" <a class="link" href="ClutterBindConstraint.html#ClutterBindCoordinate" title="enum ClutterBindCoordinate"><span class="type">ClutterBindCoordinate</span></a> : Read / Write / Construct
76 "<a class="link" href="ClutterBindConstraint.html#ClutterBindConstraint--offset" title='The "offset" property'>offset</a>" <a href="../glib/glib-Basic-Types.html#gfloat"><span class="type">gfloat</span></a> : Read / Write / Construct
77 "<a class="link" href="ClutterBindConstraint.html#ClutterBindConstraint--source" title='The "source" property'>source</a>" <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a>* : Read / Write / Construct
80 <div class="refsect1">
81 <a name="ClutterBindConstraint.description"></a><h2>Description</h2>
83 <a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> is a <a class="link" href="ClutterConstraint.html" title="ClutterConstraint"><span class="type">ClutterConstraint</span></a> that binds the
84 position or the size of the <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> to which it is applied
85 to the the position or the size of another <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a>, or
89 An offset can be applied to the constraint, to avoid overlapping. The offset
90 can also be animated. For instance, the following code will set up three
91 actors to be bound to the same origin:
95 <div class="informalexample">
96 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
99 <td class="listing_lines" align="right"><pre>1
123 <td class="listing_code"><pre class="programlisting"><span class="comment">/* source */</span>
124 <span class="normal">rect</span><span class="symbol">[</span><span class="number">0</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterRectangle.html#clutter-rectangle-new-with-color">clutter_rectangle_new_with_color</a></span><span class="normal"> </span><span class="symbol">(&</span><span class="normal">red_color</span><span class="symbol">);</span>
125 <span class="function"><a href="ClutterActor.html#clutter-actor-set-position">clutter_actor_set_position</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">0</span><span class="symbol">],</span><span class="normal"> x_pos</span><span class="symbol">,</span><span class="normal"> y_pos</span><span class="symbol">);</span>
126 <span class="function"><a href="ClutterActor.html#clutter-actor-set-size">clutter_actor_set_size</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">0</span><span class="symbol">],</span><span class="normal"> </span><span class="number">100</span><span class="symbol">,</span><span class="normal"> </span><span class="number">100</span><span class="symbol">);</span>
128 <span class="comment">/* second rectangle */</span>
129 <span class="normal">rect</span><span class="symbol">[</span><span class="number">1</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterRectangle.html#clutter-rectangle-new-with-color">clutter_rectangle_new_with_color</a></span><span class="normal"> </span><span class="symbol">(&</span><span class="normal">green_color</span><span class="symbol">);</span>
130 <span class="function"><a href="ClutterActor.html#clutter-actor-set-size">clutter_actor_set_size</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">1</span><span class="symbol">],</span><span class="normal"> </span><span class="number">100</span><span class="symbol">,</span><span class="normal"> </span><span class="number">100</span><span class="symbol">);</span>
131 <span class="function"><a href="ClutterActor.html#clutter-actor-set-opacity">clutter_actor_set_opacity</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">1</span><span class="symbol">],</span><span class="normal"> </span><span class="number">0</span><span class="symbol">);</span>
133 <span class="normal">constraint </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterBindConstraint.html#clutter-bind-constraint-new">clutter_bind_constraint_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">0</span><span class="symbol">],</span><span class="normal"> <a href="ClutterBindConstraint.html#CLUTTER-BIND-X:CAPS">CLUTTER_BIND_X</a></span><span class="symbol">,</span><span class="normal"> </span><span class="number">0.0</span><span class="symbol">);</span>
134 <span class="function"><a href="ClutterActor.html#clutter-actor-add-constraint-with-name">clutter_actor_add_constraint_with_name</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">1</span><span class="symbol">],</span><span class="normal"> </span><span class="string">"green-x"</span><span class="symbol">,</span><span class="normal"> constraint</span><span class="symbol">);</span>
135 <span class="normal">constraint </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterBindConstraint.html#clutter-bind-constraint-new">clutter_bind_constraint_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">0</span><span class="symbol">],</span><span class="normal"> <a href="ClutterBindConstraint.html#CLUTTER-BIND-Y:CAPS">CLUTTER_BIND_Y</a></span><span class="symbol">,</span><span class="normal"> </span><span class="number">0.0</span><span class="symbol">);</span>
136 <span class="function"><a href="ClutterActor.html#clutter-actor-add-constraint-with-name">clutter_actor_add_constraint_with_name</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">1</span><span class="symbol">],</span><span class="normal"> </span><span class="string">"green-y"</span><span class="symbol">,</span><span class="normal"> constraint</span><span class="symbol">);</span>
138 <span class="comment">/* third rectangle */</span>
139 <span class="normal">rect</span><span class="symbol">[</span><span class="number">2</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterRectangle.html#clutter-rectangle-new-with-color">clutter_rectangle_new_with_color</a></span><span class="normal"> </span><span class="symbol">(&</span><span class="normal">blue_color</span><span class="symbol">);</span>
140 <span class="function"><a href="ClutterActor.html#clutter-actor-set-size">clutter_actor_set_size</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">2</span><span class="symbol">],</span><span class="normal"> </span><span class="number">100</span><span class="symbol">,</span><span class="normal"> </span><span class="number">100</span><span class="symbol">);</span>
141 <span class="function"><a href="ClutterActor.html#clutter-actor-set-opacity">clutter_actor_set_opacity</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">2</span><span class="symbol">],</span><span class="normal"> </span><span class="number">0</span><span class="symbol">);</span>
143 <span class="normal">constraint </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterBindConstraint.html#clutter-bind-constraint-new">clutter_bind_constraint_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">0</span><span class="symbol">],</span><span class="normal"> <a href="ClutterBindConstraint.html#CLUTTER-BIND-X:CAPS">CLUTTER_BIND_X</a></span><span class="symbol">,</span><span class="normal"> </span><span class="number">0.0</span><span class="symbol">);</span>
144 <span class="function"><a href="ClutterActor.html#clutter-actor-add-constraint-with-name">clutter_actor_add_constraint_with_name</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">2</span><span class="symbol">],</span><span class="normal"> </span><span class="string">"blue-x"</span><span class="symbol">,</span><span class="normal"> constraint</span><span class="symbol">);</span>
145 <span class="normal">constraint </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterBindConstraint.html#clutter-bind-constraint-new">clutter_bind_constraint_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">0</span><span class="symbol">],</span><span class="normal"> <a href="ClutterBindConstraint.html#CLUTTER-BIND-Y:CAPS">CLUTTER_BIND_Y</a></span><span class="symbol">,</span><span class="normal"> </span><span class="number">0.0</span><span class="symbol">);</span>
146 <span class="function"><a href="ClutterActor.html#clutter-actor-add-constraint-with-name">clutter_actor_add_constraint_with_name</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">2</span><span class="symbol">],</span><span class="normal"> </span><span class="string">"blue-y"</span><span class="symbol">,</span><span class="normal"> constraint</span><span class="symbol">);</span></pre></td>
155 The following code animates the second and third rectangles to "expand"
156 them horizontally from underneath the first rectangle:
160 <div class="informalexample">
161 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
164 <td class="listing_lines" align="right"><pre>1
172 <td class="listing_code"><pre class="programlisting"><span class="function"><a href="clutter-Implicit-Animations.html#clutter-actor-animate">clutter_actor_animate</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">1</span><span class="symbol">],</span><span class="normal"> <a href="clutter-Implicit-Animations.html#CLUTTER-EASE-OUT-CUBIC:CAPS">CLUTTER_EASE_OUT_CUBIC</a></span><span class="symbol">,</span><span class="normal"> </span><span class="number">250</span><span class="symbol">,</span>
173 <span class="normal"> </span><span class="string">"@constraints.green-x.offset"</span><span class="symbol">,</span><span class="normal"> </span><span class="number">100.0</span><span class="symbol">,</span>
174 <span class="normal"> </span><span class="string">"opacity"</span><span class="symbol">,</span><span class="normal"> </span><span class="number">255</span><span class="symbol">,</span>
175 <span class="normal"> <a href="/home/ebassi/gnome3/install/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span>
176 <span class="function"><a href="clutter-Implicit-Animations.html#clutter-actor-animate">clutter_actor_animate</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">rect</span><span class="symbol">[</span><span class="number">2</span><span class="symbol">],</span><span class="normal"> <a href="clutter-Implicit-Animations.html#CLUTTER-EASE-OUT-CUBIC:CAPS">CLUTTER_EASE_OUT_CUBIC</a></span><span class="symbol">,</span><span class="normal"> </span><span class="number">250</span><span class="symbol">,</span>
177 <span class="normal"> </span><span class="string">"@constraints.blue-x.offset"</span><span class="symbol">,</span><span class="normal"> </span><span class="number">200.0</span><span class="symbol">,</span>
178 <span class="normal"> </span><span class="string">"opacity"</span><span class="symbol">,</span><span class="normal"> </span><span class="number">255</span><span class="symbol">,</span>
179 <span class="normal"> <a href="/home/ebassi/gnome3/install/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span></pre></td>
189 <div class="example">
190 <a name="bind-constraint-example"></a><p class="title"><b>Example 8. Animating the offset property of ClutterBindConstraint</b></p>
191 <div class="example-contents">
192 <pre class="programlisting">
193 #include <stdlib.h>
194 #include <gmodule.h>
195 #include <clutter/clutter.h>
197 #define RECT_SIZE 128
204 NorthWest, North, NorthEast,
206 SouthWest, South, SouthEast,
211 static ClutterActor *rects[N_RECTS] = { NULL, };
212 static const gchar *colors[N_RECTS] = {
213 "#8ae234", "#73d216", "#4e9a06",
214 "#729fcf", "#3465a4", "#204a87",
215 "#ef2929", "#cc0000", "#a40000"
217 static const gchar *names[N_RECTS] = {
218 "North West", "North", "North East",
219 "West", "Center", "East",
220 "South West", "South", "South East"
223 static const gchar *desaturare_glsl_shader =
224 "uniform sampler2D tex;\n"
225 "uniform float factor;\n"
227 "vec3 desaturate (const vec3 color, const float desaturation)\n"
229 " const vec3 gray_conv = vec3 (0.299, 0.587, 0.114);\n"
230 " vec3 gray = vec3 (dot (gray_conv, color));\n"
231 " return vec3 (mix (color.rgb, gray, desaturation));\n"
236 " vec4 color = cogl_color_in * texture2D (tex, vec2 (cogl_tex_coord_in[0].xy));\n"
237 " color.rgb = desaturate (color.rgb, factor);\n"
238 " cogl_color_out = color;\n"
241 static gboolean is_expanded = FALSE;
244 on_button_release (ClutterActor *actor,
246 gpointer data G_GNUC_UNUSED)
250 gfloat north_offset, south_offset;
251 gfloat west_offset, east_offset;
253 /* expand the 8 rectangles by animating the offset of the
257 north_offset = (clutter_actor_get_height (rects[Center]) + V_PADDING)
259 south_offset = (clutter_actor_get_height (rects[Center]) + V_PADDING);
261 west_offset = (clutter_actor_get_width (rects[Center]) + H_PADDING)
263 east_offset = (clutter_actor_get_width (rects[Center]) + H_PADDING);
265 clutter_actor_animate (rects[NorthWest], CLUTTER_EASE_OUT_EXPO, 500,
267 "@constraints.x-bind.offset", west_offset,
268 "@constraints.y-bind.offset", north_offset,
271 clutter_actor_animate (rects[North], CLUTTER_EASE_OUT_EXPO, 500,
273 "@constraints.y-bind.offset", north_offset,
276 clutter_actor_animate (rects[NorthEast], CLUTTER_EASE_OUT_EXPO, 500,
278 "@constraints.x-bind.offset", east_offset,
279 "@constraints.y-bind.offset", north_offset,
283 clutter_actor_animate (rects[West], CLUTTER_EASE_OUT_EXPO, 500,
285 "@constraints.x-bind.offset", west_offset,
288 /* turn on the desaturation effect and set the center
289 * rectangle not reactive
291 clutter_actor_animate (rects[Center], CLUTTER_LINEAR, 500,
292 "@effects.desaturate.enabled", TRUE,
295 clutter_actor_animate (rects[East], CLUTTER_EASE_OUT_EXPO, 500,
297 "@constraints.x-bind.offset", east_offset,
301 clutter_actor_animate (rects[SouthWest], CLUTTER_EASE_OUT_EXPO, 500,
303 "@constraints.x-bind.offset", west_offset,
304 "@constraints.y-bind.offset", south_offset,
307 clutter_actor_animate (rects[South], CLUTTER_EASE_OUT_EXPO, 500,
309 "@constraints.y-bind.offset", south_offset,
312 clutter_actor_animate (rects[SouthEast], CLUTTER_EASE_OUT_EXPO, 500,
314 "@constraints.x-bind.offset", east_offset,
315 "@constraints.y-bind.offset", south_offset,
323 clutter_actor_animate (rects[Center], CLUTTER_LINEAR, 500,
324 "@effects.desaturate.enabled", FALSE,
328 for (i = NorthWest; i < N_RECTS; i++)
333 /* put the 8 rectangles back into their initial state */
334 clutter_actor_animate (rects[i], CLUTTER_EASE_OUT_EXPO, 500,
336 "@constraints.x-bind.offset", 0.0f,
337 "@constraints.y-bind.offset", 0.0f,
343 is_expanded = !is_expanded;
345 g_print ("Selected: [%s]\n", clutter_actor_get_name (actor));
351 test_constraints_main (int argc, char *argv[])
353 ClutterActor *stage, *rect;
354 ClutterConstraint *constraint;
355 ClutterEffect *effect;
356 ClutterColor rect_color;
359 if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
362 stage = clutter_stage_new ();
363 g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
364 clutter_stage_set_title (CLUTTER_STAGE (stage), "Constraints");
365 clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
366 clutter_actor_set_size (stage, 800, 600);
369 clutter_color_from_string (&rect_color, "#3465a4");
370 rect = clutter_actor_new ();
371 g_signal_connect (rect, "button-release-event",
372 G_CALLBACK (on_button_release),
374 clutter_actor_set_background_color (rect, &rect_color);
375 clutter_actor_set_size (rect, RECT_SIZE, RECT_SIZE);
376 clutter_actor_set_reactive (rect, TRUE);
377 clutter_actor_set_name (rect, names[Center]);
378 clutter_actor_add_child (stage, rect);
380 /* align the center rectangle to the center of the stage */
381 constraint = clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5);
382 clutter_actor_add_constraint_with_name (rect, "align", constraint);
384 /* this is the equivalent of the DesaturateEffect; we cannot animate
385 * the factor because the animation API only understands GObject
386 * properties; so we use the ActorMeta:enabled property to toggle
389 effect = clutter_shader_effect_new (CLUTTER_FRAGMENT_SHADER);
390 clutter_shader_effect_set_shader_source (CLUTTER_SHADER_EFFECT (effect),
391 desaturare_glsl_shader);
392 clutter_shader_effect_set_uniform (CLUTTER_SHADER_EFFECT (effect),
393 "tex", G_TYPE_INT, 1, 0);
394 clutter_shader_effect_set_uniform (CLUTTER_SHADER_EFFECT (effect),
395 "factor", G_TYPE_FLOAT, 1, 0.66);
396 clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE);
397 clutter_actor_add_effect_with_name (rect, "desaturate", effect);
399 rects[Center] = rect;
401 /* build the other rectangles, and bind their position and size
402 * to the center rectangle. we are going to animate the offset
403 * of the BindConstraints
405 for (i = 0; i < N_RECTS; i++)
410 clutter_color_from_string (&rect_color, colors[i]);
412 rect = clutter_actor_new ();
413 clutter_actor_set_background_color (rect, &rect_color);
414 clutter_actor_set_opacity (rect, 0);
415 clutter_actor_set_name (rect, names[i]);
416 clutter_actor_add_child (stage, rect);
418 constraint = clutter_bind_constraint_new (rects[Center], CLUTTER_BIND_X, 0.0);
419 clutter_actor_add_constraint_with_name (rect, "x-bind", constraint);
421 constraint = clutter_bind_constraint_new (rects[Center], CLUTTER_BIND_Y, 0.0);
422 clutter_actor_add_constraint_with_name (rect, "y-bind", constraint);
424 constraint = clutter_bind_constraint_new (rects[Center], CLUTTER_BIND_SIZE, 0.0);
425 clutter_actor_add_constraint_with_name (rect, "size-bind", constraint);
427 g_signal_connect (rect, "button-release-event",
428 G_CALLBACK (on_button_release),
434 clutter_actor_show (stage);
441 G_MODULE_EXPORT const char *
442 test_constraints_describe (void)
444 return "Visualize usage of Bind and Align constraints";
448 <p>The example above creates eight rectangles and binds them to a
449 rectangle positioned in the center of the stage; when the user presses
450 the center rectangle, the <a class="link" href="ClutterBindConstraint.html#ClutterBindConstraint--offset" title='The "offset" property'><span class="type">"offset"</span></a> property is
451 animated through the <a class="link" href="clutter-Implicit-Animations.html#clutter-actor-animate" title="clutter_actor_animate ()"><code class="function">clutter_actor_animate()</code></a> function to lay out the
452 eight rectangles around the center one. Pressing one of the outer
453 rectangles will animate the offset back to 0.</p>
456 <p><br class="example-break">
459 <a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> is available since Clutter 1.4
462 <div class="refsect1">
463 <a name="ClutterBindConstraint.details"></a><h2>Details</h2>
464 <div class="refsect2">
465 <a name="ClutterBindConstraint-struct"></a><h3>ClutterBindConstraint</h3>
466 <pre class="programlisting">typedef struct _ClutterBindConstraint ClutterBindConstraint;</pre>
468 <span class="structname">ClutterBindConstraint</span> is an opaque structure
469 whose members cannot be directly accessed
471 <p class="since">Since 1.4</p>
474 <div class="refsect2">
475 <a name="ClutterBindCoordinate"></a><h3>enum ClutterBindCoordinate</h3>
476 <pre class="programlisting">typedef enum {
477 /*< prefix=CLUTTER_BIND >*/
482 CLUTTER_BIND_POSITION,
485 } ClutterBindCoordinate;
488 Specifies which property should be used in a binding
490 <div class="variablelist"><table border="0">
491 <col align="left" valign="top">
494 <td><p><a name="CLUTTER-BIND-X:CAPS"></a><span class="term"><code class="literal">CLUTTER_BIND_X</code></span></p></td>
495 <td>Bind the X coordinate
499 <td><p><a name="CLUTTER-BIND-Y:CAPS"></a><span class="term"><code class="literal">CLUTTER_BIND_Y</code></span></p></td>
500 <td>Bind the Y coordinate
504 <td><p><a name="CLUTTER-BIND-WIDTH:CAPS"></a><span class="term"><code class="literal">CLUTTER_BIND_WIDTH</code></span></p></td>
509 <td><p><a name="CLUTTER-BIND-HEIGHT:CAPS"></a><span class="term"><code class="literal">CLUTTER_BIND_HEIGHT</code></span></p></td>
514 <td><p><a name="CLUTTER-BIND-POSITION:CAPS"></a><span class="term"><code class="literal">CLUTTER_BIND_POSITION</code></span></p></td>
515 <td>Equivalent to to <a class="link" href="ClutterBindConstraint.html#CLUTTER-BIND-X:CAPS"><code class="literal">CLUTTER_BIND_X</code></a> and
516 <a class="link" href="ClutterBindConstraint.html#CLUTTER-BIND-Y:CAPS"><code class="literal">CLUTTER_BIND_Y</code></a> (added in Clutter 1.6)
520 <td><p><a name="CLUTTER-BIND-SIZE:CAPS"></a><span class="term"><code class="literal">CLUTTER_BIND_SIZE</code></span></p></td>
521 <td>Equivalent to <a class="link" href="ClutterBindConstraint.html#CLUTTER-BIND-WIDTH:CAPS"><code class="literal">CLUTTER_BIND_WIDTH</code></a> and
522 <a class="link" href="ClutterBindConstraint.html#CLUTTER-BIND-HEIGHT:CAPS"><code class="literal">CLUTTER_BIND_HEIGHT</code></a> (added in Clutter 1.6)
526 <td><p><a name="CLUTTER-BIND-ALL:CAPS"></a><span class="term"><code class="literal">CLUTTER_BIND_ALL</code></span></p></td>
527 <td>Equivalent to <a class="link" href="ClutterBindConstraint.html#CLUTTER-BIND-POSITION:CAPS"><code class="literal">CLUTTER_BIND_POSITION</code></a> and
528 <a class="link" href="ClutterBindConstraint.html#CLUTTER-BIND-SIZE:CAPS"><code class="literal">CLUTTER_BIND_SIZE</code></a> (added in Clutter 1.10)
533 <p class="since">Since 1.4</p>
536 <div class="refsect2">
537 <a name="clutter-bind-constraint-new"></a><h3>clutter_bind_constraint_new ()</h3>
538 <pre class="programlisting"><a class="link" href="ClutterConstraint.html" title="ClutterConstraint"><span class="returnvalue">ClutterConstraint</span></a> * clutter_bind_constraint_new (<em class="parameter"><code><a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> *source</code></em>,
539 <em class="parameter"><code><a class="link" href="ClutterBindConstraint.html#ClutterBindCoordinate" title="enum ClutterBindCoordinate"><span class="type">ClutterBindCoordinate</span></a> coordinate</code></em>,
540 <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gfloat"><span class="type">gfloat</span></a> offset</code></em>);</pre>
542 Creates a new constraint, binding a <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a>'s position to
543 the given <em class="parameter"><code>coordinate</code></em> of the position of <em class="parameter"><code>source</code></em>
545 <div class="variablelist"><table border="0">
546 <col align="left" valign="top">
549 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
550 <td>the <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> to use as the source of
551 the binding, or <a href="/home/ebassi/gnome3/install/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
555 <td><p><span class="term"><em class="parameter"><code>coordinate</code></em> :</span></p></td>
556 <td>the coordinate to bind</td>
559 <td><p><span class="term"><em class="parameter"><code>offset</code></em> :</span></p></td>
560 <td>the offset to apply to the binding, in pixels</td>
563 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
564 <td>the newly created <a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a>
569 <p class="since">Since 1.4</p>
572 <div class="refsect2">
573 <a name="clutter-bind-constraint-set-source"></a><h3>clutter_bind_constraint_set_source ()</h3>
574 <pre class="programlisting"><span class="returnvalue">void</span> clutter_bind_constraint_set_source (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>,
575 <em class="parameter"><code><a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> *source</code></em>);</pre>
577 Sets the source <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> for the constraint
579 <div class="variablelist"><table border="0">
580 <col align="left" valign="top">
583 <td><p><span class="term"><em class="parameter"><code>constraint</code></em> :</span></p></td>
584 <td>a <a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a>
588 <td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
589 <td>a <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a>, or <a href="/home/ebassi/gnome3/install/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to unset the source. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
594 <p class="since">Since 1.4</p>
597 <div class="refsect2">
598 <a name="clutter-bind-constraint-get-source"></a><h3>clutter_bind_constraint_get_source ()</h3>
599 <pre class="programlisting"><a class="link" href="ClutterActor.html" title="ClutterActor"><span class="returnvalue">ClutterActor</span></a> * clutter_bind_constraint_get_source (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>);</pre>
601 Retrieves the <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> set using <a class="link" href="ClutterBindConstraint.html#clutter-bind-constraint-set-source" title="clutter_bind_constraint_set_source ()"><code class="function">clutter_bind_constraint_set_source()</code></a>
603 <div class="variablelist"><table border="0">
604 <col align="left" valign="top">
607 <td><p><span class="term"><em class="parameter"><code>constraint</code></em> :</span></p></td>
608 <td>a <a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a>
612 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
613 <td>a pointer to the source actor. <span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span>
618 <p class="since">Since 1.4</p>
621 <div class="refsect2">
622 <a name="clutter-bind-constraint-set-coordinate"></a><h3>clutter_bind_constraint_set_coordinate ()</h3>
623 <pre class="programlisting"><span class="returnvalue">void</span> clutter_bind_constraint_set_coordinate
624 (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>,
625 <em class="parameter"><code><a class="link" href="ClutterBindConstraint.html#ClutterBindCoordinate" title="enum ClutterBindCoordinate"><span class="type">ClutterBindCoordinate</span></a> coordinate</code></em>);</pre>
627 Sets the coordinate to bind in the constraint
629 <div class="variablelist"><table border="0">
630 <col align="left" valign="top">
633 <td><p><span class="term"><em class="parameter"><code>constraint</code></em> :</span></p></td>
634 <td>a <a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a>
638 <td><p><span class="term"><em class="parameter"><code>coordinate</code></em> :</span></p></td>
639 <td>the coordinate to bind</td>
643 <p class="since">Since 1.4</p>
646 <div class="refsect2">
647 <a name="clutter-bind-constraint-get-coordinate"></a><h3>clutter_bind_constraint_get_coordinate ()</h3>
648 <pre class="programlisting"><a class="link" href="ClutterBindConstraint.html#ClutterBindCoordinate" title="enum ClutterBindCoordinate"><span class="returnvalue">ClutterBindCoordinate</span></a> clutter_bind_constraint_get_coordinate
649 (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>);</pre>
651 Retrieves the bound coordinate of the constraint
653 <div class="variablelist"><table border="0">
654 <col align="left" valign="top">
657 <td><p><span class="term"><em class="parameter"><code>constraint</code></em> :</span></p></td>
658 <td>a <a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a>
662 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
663 <td>the bound coordinate</td>
667 <p class="since">Since 1.4</p>
670 <div class="refsect2">
671 <a name="clutter-bind-constraint-set-offset"></a><h3>clutter_bind_constraint_set_offset ()</h3>
672 <pre class="programlisting"><span class="returnvalue">void</span> clutter_bind_constraint_set_offset (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>,
673 <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gfloat"><span class="type">gfloat</span></a> offset</code></em>);</pre>
675 Sets the offset to be applied to the constraint
677 <div class="variablelist"><table border="0">
678 <col align="left" valign="top">
681 <td><p><span class="term"><em class="parameter"><code>constraint</code></em> :</span></p></td>
682 <td>a <a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a>
686 <td><p><span class="term"><em class="parameter"><code>offset</code></em> :</span></p></td>
687 <td>the offset to apply, in pixels</td>
691 <p class="since">Since 1.4</p>
694 <div class="refsect2">
695 <a name="clutter-bind-constraint-get-offset"></a><h3>clutter_bind_constraint_get_offset ()</h3>
696 <pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gfloat"><span class="returnvalue">gfloat</span></a> clutter_bind_constraint_get_offset (<em class="parameter"><code><a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a> *constraint</code></em>);</pre>
698 Retrieves the offset set using <a class="link" href="ClutterBindConstraint.html#clutter-bind-constraint-set-offset" title="clutter_bind_constraint_set_offset ()"><code class="function">clutter_bind_constraint_set_offset()</code></a>
700 <div class="variablelist"><table border="0">
701 <col align="left" valign="top">
704 <td><p><span class="term"><em class="parameter"><code>constraint</code></em> :</span></p></td>
705 <td>a <a class="link" href="ClutterBindConstraint.html" title="ClutterBindConstraint"><span class="type">ClutterBindConstraint</span></a>
709 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
710 <td>the offset, in pixels</td>
714 <p class="since">Since 1.4</p>
717 <div class="refsect1">
718 <a name="ClutterBindConstraint.property-details"></a><h2>Property Details</h2>
719 <div class="refsect2">
720 <a name="ClutterBindConstraint--coordinate"></a><h3>The <code class="literal">"coordinate"</code> property</h3>
721 <pre class="programlisting"> "coordinate" <a class="link" href="ClutterBindConstraint.html#ClutterBindCoordinate" title="enum ClutterBindCoordinate"><span class="type">ClutterBindCoordinate</span></a> : Read / Write / Construct</pre>
723 The coordinate to be bound
725 <p>Default value: CLUTTER_BIND_X</p>
726 <p class="since">Since 1.4</p>
729 <div class="refsect2">
730 <a name="ClutterBindConstraint--offset"></a><h3>The <code class="literal">"offset"</code> property</h3>
731 <pre class="programlisting"> "offset" <a href="../glib/glib-Basic-Types.html#gfloat"><span class="type">gfloat</span></a> : Read / Write / Construct</pre>
733 The offset, in pixels, to be applied to the binding
735 <p>Default value: 0</p>
736 <p class="since">Since 1.4</p>
739 <div class="refsect2">
740 <a name="ClutterBindConstraint--source"></a><h3>The <code class="literal">"source"</code> property</h3>
741 <pre class="programlisting"> "source" <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a>* : Read / Write / Construct</pre>
743 The <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> used as the source for the binding.
746 The <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> must not be contained inside the actor associated
749 <p class="since">Since 1.4</p>
755 Generated by GTK-Doc V1.18.1</div>