\section{transit\+\_\+example\+\_\+04.\+c}

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -o transit\_example\_04 transit\_example\_04.c `pkg-config --cflags --libs elementary`
       -DDATA\_DIR="\(\backslash\)"<directory>\(\backslash\)""}
\textcolor{comment}{//where directory is the a path where images/icon\_07.png can be found.}

\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_flip(Elm_Transit *trans)
\{
   elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_blend(Elm_Transit *trans)
\{
   elm_transit_effect_blend_add(trans);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_fade(Elm_Transit *trans)
\{
   elm_transit_effect_fade_add(trans);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_resizable\_flip(Elm_Transit *trans)
\{
   elm_transit_effect_resizable_flip_add(
      trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keyword}{struct }\{
     \textcolor{keyword}{const} \textcolor{keywordtype}{char} *label;
     void (*transition\_add\_cb)(Elm_Transit *);
     Eina\_Bool checked;
\} \_transitions[] = \{
       \{ \textcolor{stringliteral}{"Flip"}, \_transit\_flip, EINA\_FALSE \},
       \{ \textcolor{stringliteral}{"Blend"}, \_transit\_blend, EINA\_FALSE \},
       \{ \textcolor{stringliteral}{"Fade"}, \_transit\_fade, EINA\_FALSE \},
       \{ \textcolor{stringliteral}{"Resizable Flip"}, \_transit\_resizable\_flip, EINA\_FALSE \},
       \{ NULL, NULL, EINA\_FALSE \}
\};

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_checkbox\_transition\_add(Evas\_Object *box, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *label, Eina\_Bool *checked)
\{
   Evas\_Object *check = elm_check_add(box);
   evas\_object\_size\_hint\_weight\_set(check, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(check, 0.0, 0.0);
   elm\_object\_text\_set(check, label);
   elm_check_state_pointer_set(check, checked);
   elm_box_pack_end(box, check);
   evas\_object\_show(check);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_start(\textcolor{keywordtype}{void} *data, Evas\_Object *o, \textcolor{keywordtype}{void} *event\_info)
\{
   Elm_Transit *trans = NULL;
   Eina\_List *objs = data, *l;
   Evas\_Object *obj;
   \textcolor{keywordtype}{int} i;

   trans = elm_transit_add();
   EINA\_LIST\_FOREACH(objs, l, obj)
     elm_transit_object_add(trans, obj);

   \textcolor{comment}{// FIXME: Should check if there's another transit going before starting a new}
   \textcolor{comment}{// one}

   for (i = 0; \_transitions[i].label; i++)
     \{
        \textcolor{keywordflow}{if} (\_transitions[i].checked)
          \_transitions[i].transition\_add\_cb(trans);
     \}

   elm_transit_duration_set(trans, 2.0);
   elm_transit_go(trans);
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *icon, *box, *hbox, *btn, *rect;
   Eina\_List *objs = NULL;
   \textcolor{keywordtype}{char} buf[PATH\_MAX];
   \textcolor{keywordtype}{int} i;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
   elm_app_info_set(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"images/icon\_07.png"});

   \textcolor{comment}{/* add a window */}
   win = elm_win_util_standard_add(\textcolor{stringliteral}{"transit"}, \textcolor{stringliteral}{"Transit Example"});
   elm_win_autodel_set(win, EINA\_TRUE);

   box = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, box);
   evas\_object\_show(box);

   \textcolor{comment}{/* add an object that we are going to play with */}
   btn = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(btn, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(btn, EVAS\_HINT\_FILL, 0.0);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Transformed object!"});
   icon = elm_icon_add(win);
   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%s/images/icon\_07.png"}, elm_app_data_dir_get());
   elm_image_file_set(icon, buf, NULL);
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, icon);
   evas\_object\_move(btn, 50, 50);
   evas\_object\_resize(btn, 200, 50);
   evas\_object\_show(btn);

   objs = eina\_list\_append(objs, btn);

   \textcolor{comment}{/* add another object that we are going to play with */}
   btn = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(btn, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(btn, EVAS\_HINT\_FILL, 0.0);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Another object!"});
   icon = elm_icon_add(win);
   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%s/images/icon\_08.png"}, elm_app_data_dir_get());
   elm_image_file_set(icon, buf, NULL);
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, icon);
   evas\_object\_move(btn, 50, 50);
   evas\_object\_resize(btn, 200, 50);

   objs = eina\_list\_append(objs, btn);

   hbox = elm_box_add(win);
   elm_box_horizontal_set(hbox, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(hbox, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(hbox, EVAS\_HINT\_FILL, 0.0);
   elm_box_pack_end(box, hbox);
   evas\_object\_show(hbox);

   \textcolor{keywordflow}{for} (i = 0; \_transitions[i].label; i++)
     \_checkbox\_transition\_add(hbox, \_transitions[i].label, &\_transitions[i].checked);

   btn = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(btn, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Transit!"});
   elm_box_pack_end(hbox, btn);
   evas\_object\_show(btn);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_transit\_start, objs);

   rect = evas\_object\_rectangle\_add(evas\_object\_evas\_get(win));
   evas\_object\_color\_set(rect, 0, 0, 0, 0);
   evas\_object\_size\_hint\_weight\_set(rect, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(rect, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(box, rect);
   evas\_object\_show(rect);

   evas\_object\_resize(win, 300, 100);
   evas\_object\_show(win);

   elm_run();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 