<html> <head> <title>Edje: embryo_custom_state.edc</title> <meta http-equiv="content-type" content="text/html;charset=UTF-8"> <meta name="author" content="Andres Blanc" > <link rel="icon" href="img/favicon.png" type="image/x-icon"> <link rel="shortcut icon" href="img/favicon.png" type="image/x-icon"> <link rel="icon" href="img/favicon.png" type="image/ico"> <link rel="shortcut icon" href="img/favicon.png" type="image/ico"> <link rel="stylesheet" type="text/css" href="e.css"> <link rel="stylesheet" type="text/css" href="edoxy.css"> </head> <body> <div id="container"> <div id="header"> <div class="layout"> <h1><span>Enlightenment</span></h1> <h2><span>Beauty at your fingertips</span></h2> <table cellspacing="0" cellpadding="0" width="100%"><tr> <td id="header_logo"> <a href="http://www.enlightenment.org"></a> </td> <td id="header_menu"> <table cellspacing="0" cellpadding="0" align="right"><tr> <td class="nav_passive"><a class="nav_passive" href="http://www.enlightenment.org/p.php?p=home">Home</a></td> <td class="nav_passive"><a class="nav_passive" href="http://www.enlightenment.org/p.php?p=news">News</a></td> <td class="nav_passive"><a class="nav_passive" href="http://www.enlightenment.org/p.php?p=about">About</a></td> <td class="nav_passive"><a class="nav_passive" href="http://www.enlightenment.org/p.php?p=download">Download</a></td> <td class="nav_passive"><a class="nav_passive" href="http://www.enlightenment.org/p.php?p=support">Support</a></td> <td class="nav_passive"><a class="nav_passive" href="http://www.enlightenment.org/p.php?p=contribute">Contribute</a></td> <td class="nav_passive"><a class="nav_passive" href="http://www.enlightenment.org/p.php?p=contact">Contact</a></td> <td class="nav_passive"><a class="nav_passive" href="http://trac.enlightenment.org/e">Tracker</a></td> <td class="nav_passive"><a class="nav_passive" href="http://www.enlightenment.org/p.php?p=docs">Docs</a></td> </tr></table> </td> <td id="header_last"></td> </tr></table> <div class="doxytitle"> Edje Documentation <small>at Tue Feb 8 2011</small> </div> <div class="menu-container"> <div class="submenu"> <ul class="current"> <li><a href="files.html">Files</a></li> <li><a href="Edje__Edit_8h.html">Edje Edit API</a></li> <li><a href="examples.html">Examples</a></li> <li><a href="luaref.html">LUA scripting</a></li> <li><a href="Edje_8h.html">Edje API</a></li> <li><a href="edcref.html">EDC Reference</a></li> <li class="current"><a href="index.html">Main Page</a></li> </ul> </div> </div> <div class="clear"></div> </div> </div> <div id="content"> <div class="layout"> <!-- Generated by Doxygen 1.7.3 --> </div> <div class="header"> <div class="headertitle"> <h1>embryo_custom_state.edc</h1> </div> </div> <div class="contents"> <p>This example show how to create a custom state from embryo. Clicking on the 3 labels will rotate the object in the given direction.</p> <div class="fragment"><pre class="fragment">collections { group { <a name="a0"></a><a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">"main"</span>; script { <span class="comment">/* define 3 global vars to hold the rotation values */</span> <span class="keyword">public</span> rotx; <span class="keyword">public</span> roty; <span class="keyword">public</span> rotz; } parts { part { <a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">"bg"</span>; <a name="a1"></a><a class="code" href="edje__data_8c.html#a0dae2edc8bfd2bedabfa38415c35f3ec">type</a>: RECT; description { state: <span class="stringliteral">"default"</span> 0.0; color: 255 255 255 255; } } part { <a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">"title"</span>; <a class="code" href="edje__data_8c.html#a0dae2edc8bfd2bedabfa38415c35f3ec">type</a>: TEXT; description { state: <span class="stringliteral">"default"</span> 0.0; color: 0 0 0 255; text { text: <span class="stringliteral">"Click labels to rotate"</span>; font: <span class="stringliteral">"Sans"</span>; size: 12; align: 0.5 0.0; } } } part { <a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">"X"</span>; <a class="code" href="edje__data_8c.html#a0dae2edc8bfd2bedabfa38415c35f3ec">type</a>: TEXT; description { state: <span class="stringliteral">"default"</span> 0.0; color: 0 0 0 255; text { text: <span class="stringliteral">"Rot X (0)"</span>; font: <span class="stringliteral">"Sans"</span>; size: 12; align: 0.1 0.5; } } } part { <a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">"Y"</span>; <a class="code" href="edje__data_8c.html#a0dae2edc8bfd2bedabfa38415c35f3ec">type</a>: TEXT; description { state: <span class="stringliteral">"default"</span> 0.0; color: 0 0 0 255; text { text: <span class="stringliteral">"Rot Y (0)"</span>; font: <span class="stringliteral">"Sans"</span>; size: 12; align: 0.5 0.9; } } } part { <a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">"Z"</span>; <a class="code" href="edje__data_8c.html#a0dae2edc8bfd2bedabfa38415c35f3ec">type</a>: TEXT; description { state: <span class="stringliteral">"default"</span> 0.0; color: 0 0 0 255; text { text: <span class="stringliteral">"Rot Z (0)"</span>; font: <span class="stringliteral">"Sans"</span>; size: 12; align: 0.9 0.5; } } } part { <a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">"rect"</span>; <a class="code" href="edje__data_8c.html#a0dae2edc8bfd2bedabfa38415c35f3ec">type</a>: RECT; mouse_events: 0; description { state: <span class="stringliteral">"default"</span> 0.0; color: 255 0 0 150; max: 150 150; align: 0.5 0.5; map { on: 1; perspective_on: 1; smooth: 1; alpha: 1; } } } } programs { program { signal: <span class="stringliteral">"mouse,down,1"</span>; source: <span class="stringliteral">"X"</span>; script { <span class="comment">/* define local vars */</span> <span class="keyword">new</span> buf[32]; <span class="keyword">new</span> Float:x; <span class="comment">/* get global var (and increment) */</span> x = get_int(rotx) + 10; <span class="comment">/* set global var */</span> set_int(rotx, round(x)); <span class="comment">/* crete a new custom state (inherit from default 0.0) */</span> custom_state(PART:<span class="stringliteral">"rect"</span>, <span class="stringliteral">"default"</span>, 0.0); <span class="comment">/* change the rotation in the custom state */</span> set_state_val(PART:<span class="stringliteral">"rect"</span>, STATE_MAP_ROT_X, x); <span class="comment">/* apply the custom state */</span> set_state(PART:<span class="stringliteral">"rect"</span>, <span class="stringliteral">"custom"</span>, 0.0); <span class="comment">/* update the label to show the current value */</span> snprintf(buf, <span class="keyword">sizeof</span>(buf), <span class="stringliteral">"Rot X (%d)"</span>, round(x)); set_text(PART:<span class="stringliteral">"X"</span>, buf); } } program { signal: <span class="stringliteral">"mouse,down,1"</span>; source: <span class="stringliteral">"Y"</span>; script { <span class="keyword">new</span> buf[32]; <span class="keyword">new</span> Float:y = get_int(roty) + 10; set_int(roty, round(y)); custom_state(PART:<span class="stringliteral">"rect"</span>, <span class="stringliteral">"default"</span>, 0.0); set_state_val(PART:<span class="stringliteral">"rect"</span>, STATE_MAP_ROT_Y, y); set_state(PART:<span class="stringliteral">"rect"</span>, <span class="stringliteral">"custom"</span>, 0.0); snprintf(buf, <span class="keyword">sizeof</span>(buf), <span class="stringliteral">"Rot Y (%d)"</span>, round(y)); set_text(PART:<span class="stringliteral">"Y"</span>, buf); } } program { signal: <span class="stringliteral">"mouse,down,1"</span>; source: <span class="stringliteral">"Z"</span>; script { <span class="keyword">new</span> buf[32]; <span class="keyword">new</span> Float:z = get_int(rotz) + 10; set_int(rotz, round(z)); custom_state(PART:<span class="stringliteral">"rect"</span>, <span class="stringliteral">"default"</span>, 0.0); set_state_val(PART:<span class="stringliteral">"rect"</span>, STATE_MAP_ROT_Z, z); set_state(PART:<span class="stringliteral">"rect"</span>, <span class="stringliteral">"custom"</span>, 0.0); snprintf(buf, <span class="keyword">sizeof</span>(buf), <span class="stringliteral">"Rot Z (%d)"</span>, round(z)); set_text(PART:<span class="stringliteral">"Z"</span>, buf); } } } } } </pre></div> </div> </div> <div id="push"></div> </div> <!-- #content --> </div> <!-- .layout --> </div> <!-- #container --> <div id="footer"> <table><tr> <td class="copyright">Copyright ©2011 Enlightenment</td> <td class="generated">Docs generated Tue Feb 8 2011 17:28:42</td> </tr></table> </div> </body> </html>