Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 0e77bba279395d1c9e1f98c452d3b010 > files > 178

edje-devel-1.0.0-2.fc15.i686.rpm

<html>
<head>
    <title>Edje: Edje Library Documentation</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>Edje Library Documentation </h1>  </div>
</div>
<div class="contents">
<div class="textblock"><div align="center">
<img src="e.png" alt="e.png"/>
</div>
 <dl class="version"><dt><b>Version:</b></dt><dd>1.0.0 </dd></dl>
<dl class="author"><dt><b>Author:</b></dt><dd>Carsten Haitzler &lt;raster@rasterman.com&gt; </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>2003-2010</dd></dl>
<h2><a class="anchor" id="intro"></a>
Introduction</h2>
<p>Edje is a complex graphical design &amp; layout library.</p>
<p>It doesn't pretend to do containing and regular layout like a widget set, but it is the base for such components. Based on the requirements of Enlightenment 0.17, Edje should serve all the purposes of creating visual elements (borders of windows, buttons, scrollbars, etc.) and allow the designer the ability to animate, layout and control the look and feel of any program using Edje as its basic GUI constructor. This library allows for multiple collections of Layouts in one file, sharing the same image and font database and thus allowing a whole theme to be conveniently packaged into 1 file and shipped around.</p>
<p>Edje separates the layout and behavior logic. Edje files ship with an image and font database, used by all the parts in all the collections to source graphical data. It has a directory of logical part names pointing to the part collection entry ID in the file (thus allowing for multiple logical names to point to the same part collection, allowing for the sharing of data between display elements). Each part collection consists of a list of visual parts, as well as a list of programs. A program is a conditionally run program that if a particular event occurs (a button is pressed, a mouse enters or leaves a part) will trigger an action that may affect other parts. In this way a part collection can be "programmed" via its file as to hilight buttons when the mouse passes over them or show hidden parts when a button is clicked somewhere etc. The actions performed in changing from one state to another are also allowed to transition over a period of time, allowing animation. Programs and animations can be run in "parallel".</p>
<p>This separation and simplistic event driven style of programming can produce almost any look and feel one could want for basic visual elements. Anything more complex is likely the domain of an application or widget set that may use Edje as a convenient way of being able to configure parts of the display.</p>
<p>For details of Edje's history, see the <a class="el" href="index.html#history">Edje History</a> section.</p>
<h2><a class="anchor" id="requirements"></a>
What does Edje require?</h2>
<p>Edje requires fairly little on your system. to use the Edje runtime library you need:</p>
<ul>
<li>Evas (library)</li>
<li>Ecore (library)</li>
<li>Eet (library)</li>
<li>Embryo (library)</li>
<li>Eina (library)</li>
</ul>
<p>Evas needs to be build with the JPEG, PNG and EET image loaders enabled at a minimum. Edje uses X for the test program, so you will need the SOFTWARE_X11 engine built into Evas as well. A suggested configure list is below in the "cheat sheet" for Evas.</p>
<p>Ecore needs the ECORE, ECORE_EVAS and ECORE_X modules built at a minimum. It's suggested to build all the Ecore modules, but the ECORE_FB modules is definitely optional.</p>
<p>Eina, Eet and Embryo have no interesting options so just build and install them.</p>
<p>It is suggested right now that you get the latest SVN versions of the required libraries. You also need to build them in the right order and make sure the right options are enabled in the required libraries. Here is a quick "cheat sheet" on how to get started.</p>
<div class="fragment"><pre class="fragment">
1. You need Eina from the trunk svn branch.

  svn co http://svn.enlightenment.org/svn/e/trunk/eina/
  cd eina
  ./autogen.sh
  ./configure
  make
  sudo make install
  cd

2. You need Eet from the trunk svn branch.

  svn co http://svn.enlightenment.org/svn/e/trunk/eet/
  cd eet
  ./autogen.sh
  ./configure
  make
  sudo make install
  cd

3. You need Evas from the trunk svn branch built with eet, png and jpeg loader support.

  svn co http://svn.enlightenment.org/svn/e/trunk/evas/
  cd evas
  ./autogen.sh
  ./configure --enable-image-loader-eet --enable-font-loader-eet --enable-image-loader-jpeg --enable-image-loader-png --enable-buffer
  make
  sudo make install
  cd

4. You need Ecore from the trunk svn branch built with ecore-x and ecore-evas.

  svn co http://svn.enlightenment.org/svn/e/trunk/ecore/
  cd ecore
  ./autogen.sh
  ./configure --enable-ecore-x --enable-ecore-evas --enable-ecore-evas-software-buffer --enable-ecore-evas-software-x11 --enable-ecore-evas-software-buffer
  make
  sudo make install
  cd

5. You need embryo from the trunk svn branch

  svn co http://svn.enlightenment.org/svn/e/trunk/embryo/
  cd embryo
  ./autogen.sh
  ./configure
  make
  sudo make install
  cd

</pre></div><h2><a class="anchor" id="compiling"></a>
How to compile and test Edje</h2>
<p>Now you need to compile and install Edje.</p>
<div class="fragment"><pre class="fragment">
  ./configure
  make
  sudo make install
</pre></div><p>You now have it installed and ready to go, but you need input data. There are lots of examples in SVN, the best one is Enlightenment's own theme file.</p>
<p>You may use different tools to edit and view the generated ".edj" files, for instance:</p>
<ul>
<li>editje (<a href="http://trac.enlightenment.org/e/wiki/Editje">http://trac.enlightenment.org/e/wiki/Editje</a>)</li>
<li>edje_viewer (<a href="http://trac.enlightenment.org/e/wiki/Edje_Viewer">http://trac.enlightenment.org/e/wiki/Edje_Viewer</a>)</li>
</ul>
<h2><a class="anchor" id="details"></a>
So how does this all work?</h2>
<p>Edje internally holds a geometry state machine and state graph of what is visible, not, where, at what size, with what colors etc. This is described to Edje from an Edje .edj file containing this information. These files can be produced by using edje_cc to take a text file (a .edc file) and "compile" an output .edj file that contains this information, images and any other data needed.</p>
<p>The application using Edje will then create an object in its Evas canvas and set the bundle file to use, specifying the <b>group</b> name to use. Edje will load such information and create all the required children objects with the specified properties as defined in each <b>part</b> of the given group. See the following annotated example:</p>
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
<span class="comment"> edje_example.c:</span>
<span class="comment"></span>
<span class="comment">    Creates a window using Ecore_Evas and inside it an object with</span>
<span class="comment">    the edje group &quot;my_group&quot; from file &quot;edje_example.edj&quot;.</span>
<span class="comment"></span>
<span class="comment">     Requires edje_example.edj in the current folder.</span>
<span class="comment"></span>
<span class="comment"> Compile:</span>
<span class="comment">    gcc -o edje_example edje_example.c `pkg-config --cflags --libs eina evas ecore ecore-evas edje`</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &lt;Eina.h&gt;</span>
<span class="preprocessor">#include &lt;Evas.h&gt;</span>
<span class="preprocessor">#include &lt;Ecore.h&gt;</span>
<span class="preprocessor">#include &lt;Ecore_Evas.h&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="Edje_8h.html" title="Edje Graphical Design Library.">Edje.h</a>&gt;</span>

<span class="preprocessor">#define WIDTH 320</span>
<span class="preprocessor"></span><span class="preprocessor">#define HEIGHT 240</span>
<span class="preprocessor"></span>
<span class="keyword">static</span> Evas_Object *create_my_group(Evas *canvas, <span class="keyword">const</span> <span class="keywordtype">char</span> *text)
{
   Evas_Object *edje;

   <span class="comment">/* create the edje object where we&#39;ll load our file */</span>
   edje = <a class="code" href="Edje_8h.html#a8cb00e5256fd50487f0669bc3bf9b8e0" title="Constructs the Edje object.">edje_object_add</a>(canvas);
   <span class="keywordflow">if</span> (!edje)
     {
    EINA_LOG_CRIT(<span class="stringliteral">&quot;could not create edje object!&quot;</span>);
    <span class="keywordflow">return</span> NULL;
     }

   <span class="comment">/* load our desired file */</span>
   <span class="keywordflow">if</span> (!<a class="code" href="Edje_8h.html#ab375d28c2726ccc32165b66b64abfc0a" title="Sets the EET file and group to load obj from.">edje_object_file_set</a>(edje, <span class="stringliteral">&quot;edje_example.edj&quot;</span>, <span class="stringliteral">&quot;my_group&quot;</span>))
     {
    <span class="keywordtype">int</span> err = <a class="code" href="Edje_8h.html#a86bc9e6064d1dc7fcc0bef84a3b588b0" title="Gets the Edje load error.">edje_object_load_error_get</a>(edje);
    <span class="keyword">const</span> <span class="keywordtype">char</span> *errmsg = <a class="code" href="Edje_8h.html#ad2412132974a92f3827e03c692184a95">edje_load_error_str</a>(err);
    EINA_LOG_ERR(<span class="stringliteral">&quot;could not load &#39;my_group&#39; from edje_example.edj: %s&quot;</span>,
             errmsg);

    evas_object_del(edje);
    <span class="keywordflow">return</span> NULL;
     }

   <span class="keywordflow">if</span> (text)
     {
    <span class="comment">/* this is will replace the string used by &quot;text&quot; part in &quot;my_group&quot; */</span>
    <span class="keywordflow">if</span> (!<a class="code" href="Edje_8h.html#a9c06f3ce99e722e1cec2e9dc1bdb869e" title="Sets the text for an object part.">edje_object_part_text_set</a>(edje, <span class="stringliteral">&quot;text&quot;</span>, text))
      {
         EINA_LOG_WARN(<span class="stringliteral">&quot;could not set the text. &quot;</span>
               <span class="stringliteral">&quot;Maybe part &#39;text&#39; does not exist?&quot;</span>);
      }
     }

   <span class="comment">/* operate on edje as any other object */</span>
   evas_object_move(edje, 0, 0);
   evas_object_resize(edje, WIDTH, HEIGHT);
   evas_object_show(edje);
   <span class="keywordflow">return</span> edje;
}

<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
{
   Ecore_Evas *window;
   Evas *canvas;
   Evas_Object *edje;
   <span class="keyword">const</span> <span class="keywordtype">char</span> *text;

   eina_init();
   evas_init();
   ecore_init();
   ecore_evas_init();
   <a class="code" href="group__Edje__main__Group.html#ga18ea124be2b5f786aff0f2c3ba87883e" title="Initialize the edje library.">edje_init</a>();

   window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
   <span class="keywordflow">if</span> (!window)
     {
    EINA_LOG_CRIT(<span class="stringliteral">&quot;could not create window.&quot;</span>);
    <span class="keywordflow">return</span> -1;
     }
   canvas = ecore_evas_get(window);

   text = (argc &gt; 1) ? argv[1] : NULL;

   edje = create_my_group(canvas, text);
   <span class="keywordflow">if</span> (!edje)
     <span class="keywordflow">return</span> -2;

   ecore_evas_show(window);
   ecore_main_loop_begin();

   evas_object_del(edje);
   ecore_evas_free(window);

   <span class="keywordflow">return</span> 0;
}
</pre></div><p>It requires the following source Edje <a href="file:">file:</a> </p>
<div class="fragment"><pre class="fragment"><span class="comment">// compile: edje_cc edje_example.edc</span>
collections {
   group {
      <a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">&quot;my_group&quot;</span>; <span class="comment">// must be the same as in edje_example.c</span>

      parts {
         part {
            <a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">&quot;background&quot;</span>;
            <a class="code" href="edje__data_8c.html#a0dae2edc8bfd2bedabfa38415c35f3ec">type</a>: RECT; <span class="comment">// plain boring rectangle</span>
            mouse_events: 0; <span class="comment">// we don&#39;t need any mouse event on the background</span>

            <span class="comment">// just one state &quot;default&quot;</span>
            description {
               state: <span class="stringliteral">&quot;default&quot;</span> 0.0; <span class="comment">// must always exist</span>
               color: 255 255 255 255; <span class="comment">// white</span>

               <span class="comment">// define part coordinates:</span>

               rel1 { <span class="comment">// top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0]</span>
                  relative: 0.0 0.0;
                  offset: 0 0;
               }
               rel2 { <span class="comment">// bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1)</span>
                  relative: 1.0 1.0;
                  offset: -1 -1;
               }
            }
         }

         part {
            <a class="code" href="edje__data_8c.html#a8f8f80d37794cde9472343e4487ba3eb">name</a>: <span class="stringliteral">&quot;text&quot;</span>;
            <a class="code" href="edje__data_8c.html#a0dae2edc8bfd2bedabfa38415c35f3ec">type</a>: TEXT;
            mouse_events: 1; <span class="comment">// we want to change the color on mouse-over</span>

            <span class="comment">// 2 states, one &quot;default&quot; and another &quot;over&quot; to be used</span>
            <span class="comment">// on mouse over effect</span>

            description {
               state: <span class="stringliteral">&quot;default&quot;</span> 0.0;
               color: 255 0 0 255; <span class="comment">// red</span>

               <span class="comment">// define part coordinates:</span>

               rel1 { <span class="comment">// top-left at (WIDTH * 0.1 + 5, HEIGHT * 0.2 + 10)</span>
                  relative: 0.1 0.2;
                  offset: 5 10;
               }
               rel2 { <span class="comment">// bottom-right at (WIDTH * 0.9 - 6, HEIGHT * 0.8 - 11)</span>
                  relative: 0.9 0.8;
                  offset: -6 -11;
               }

               <span class="comment">// define text specific state details</span>
               text {
                  font: <span class="stringliteral">&quot;Sans&quot;</span>; <span class="comment">/* using fontconfig name! */</span>
                  size: 10;
                  text: <span class="stringliteral">&quot;hello world&quot;</span>;
               }
            }

            description {
               state: <span class="stringliteral">&quot;over&quot;</span> 0.0;
               inherit: <span class="stringliteral">&quot;default&quot;</span> 0.0; <span class="comment">// copy everything from &quot;default&quot; at this point</span>

               color: 0 255 0 255; <span class="comment">// override color, now it is green</span>
            }
         }

         <span class="comment">// do programs to change color on text mouse in/out (over)</span>
         programs {
            program {
               <span class="comment">// what triggers this program:</span>
               signal: <span class="stringliteral">&quot;mouse,in&quot;</span>;
               source: <span class="stringliteral">&quot;text&quot;</span>;

               <span class="comment">// what this program does:</span>
               action: STATE_SET <span class="stringliteral">&quot;over&quot;</span> 0.0;
               target: <span class="stringliteral">&quot;text&quot;</span>;

               <span class="comment">// do the state-set in a nice interpolation animation</span>
               <span class="comment">// using linear time in 0.1 second</span>
               transition: LINEAR 0.1;
            }

            program {
               <span class="comment">// what triggers this program:</span>
               signal: <span class="stringliteral">&quot;mouse,out&quot;</span>;
               source: <span class="stringliteral">&quot;text&quot;</span>;

               <span class="comment">// what this program does:</span>
               action: STATE_SET <span class="stringliteral">&quot;default&quot;</span> 0.0;
               target: <span class="stringliteral">&quot;text&quot;</span>;

               <span class="comment">// do the state-set in a nice interpolation animation</span>
               <span class="comment">// using linear time in 0.1 second</span>
               transition: LINEAR 0.1;
            }
         }
      }
   }
}
</pre></div><p>One should save these files as edje_example.c and edje_example.edc then: </p>
<div class="fragment"><pre class="fragment">
gcc -o edje_example edje_example.c `pkg-config --cflags --libs eina evas ecore ecore-evas edje`
edje_cc edje_example.edc

./edje_example "some text"
</pre></div><p>Although simple, this example illustrates that animations and state changes can be done from the Edje file itself without any requirement in the C application.</p>
<p>Before digging into changing or creating your own Edje source (edc) files, read the <a class="el" href="edcref.html">Edje Data Collection reference</a>.</p>
<h2><a class="anchor" id="history"></a>
Edje History</h2>
<p>It's a sequel to "Ebits" which has serviced the needs of Enlightenment development for early version 0.17. The original design parameters under which Ebits came about were a lot more restricted than the resulting use of them, thus Edje was born.</p>
<p>Edje is a more complex layout engine compared to Ebits. It doesn't pretend to do containing and regular layout like a widget set. It still inherits the more simplistic layout ideas behind Ebits, but it now does them a lot more cleanly, allowing for easy expansion, and the ability to cover much more ground than Ebits ever could. For the purposes of Enlightenment 0.17, Edje was conceived to serve all the purposes of creating visual elements (borders of windows, buttons, scrollbars, etc.) and allow the designer the ability to animate, layout and control the look and feel of any program using Edje as its basic GUI constructor.</p>
<p>Unlike Ebits, Edje separates the layout and behavior logic.</p>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd><p class="startdd">Complete documentation of API </p>
<p class="enddd">Bytecode language for extending programs... but what/how?</p>
</dd></dl>
</div></div>
 
 <div id="push"></div>
 </div> <!-- #content -->
  </div> <!-- .layout -->
 
 </div> <!-- #container -->
 
 
  <div id="footer">
    <table><tr>
      <td class="copyright">Copyright &copy;2011 Enlightenment</td>
      <td class="generated">Docs generated Tue Feb 8 2011 17:28:42</td>
    </tr></table>
  </div>


</body>
</html>