This example shows how to apply the following transition effects\+:

\begin{DoxyItemize}
\item translation \item color \item rotation \item wipe \item zoom \item resizing\end{DoxyItemize}
It allows you to apply more than one effect at once, and also allows to set properties like event\+\_\+enabled, auto\+\_\+reverse, repeat\+\_\+times and tween\+\_\+mode.


\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -o transit\_example\_03 transit\_example\_03.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{comment}{/* structure to hold context for many callbacks */}
\textcolor{keyword}{struct }Context
\{
   Eina\_Bool events\_enabled;
   Eina\_Bool auto\_reverse;
   Eina\_Bool final\_state\_keep;
   \textcolor{keywordtype}{int} repeat\_times;
   Elm_Transit_Tween_Mode tween\_mode;
   Evas\_Object *obj;
\};

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_translation(Elm_Transit *trans)
\{
   \textcolor{comment}{/* considering the original position (x0, y0), moves the object from}
\textcolor{comment}{    * (x0 - 20, y0 - 50) to (x0 + 70, y0 + 150) */}
   elm_transit_effect_translation_add(trans, -20, -50, 70, 150);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_color(Elm_Transit *trans)
\{
   \textcolor{comment}{/* changes the object color from 100, 255, 100, 255 to}
\textcolor{comment}{    * 40, 10, 40, 50 */}
   elm_transit_effect_color_add(trans, 100, 255, 100, 255, 40, 10, 40, 50);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_rotation(Elm_Transit *trans)
\{
   \textcolor{comment}{/* rotates the object from its original angle to 135 degrees to the right */}
   elm_transit_effect_rotation_add(trans, 0.0, 135.0);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_wipe(Elm_Transit *trans)
\{
   \textcolor{comment}{/* hide the object clipping it from the left to the right */}
   elm_transit_effect_wipe_add(trans,
                               ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE,
                               ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_zoom(Elm_Transit *trans)
\{
   \textcolor{comment}{/* zoom the object from its original size to 2x */}
   elm_transit_effect_zoom_add(trans, 1.0, 2.0);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transit\_resizing(Elm_Transit *trans)
\{
   \textcolor{comment}{/* resize the object from 250x100 to 400x160 */}
   elm_transit_effect_resizing_add(trans, 250, 100, 400, 160);
\}

\textcolor{comment}{/* helper structure that will hold the transit checkboxes string, callbacks}
\textcolor{comment}{ * and checked statuses */}
\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}{"Translation"}, \_transit\_translation, EINA\_FALSE \},
       \{ \textcolor{stringliteral}{"Color"}, \_transit\_color, EINA\_FALSE \},
       \{ \textcolor{stringliteral}{"Rotation"}, \_transit\_rotation, EINA\_FALSE \},
       \{ \textcolor{stringliteral}{"Wipe"}, \_transit\_wipe, EINA\_FALSE \},
       \{ \textcolor{stringliteral}{"Zoom"}, \_transit\_zoom, EINA\_FALSE \},
       \{ \textcolor{stringliteral}{"Resizing"}, \_transit\_resizing, EINA\_FALSE \},
       \{ NULL, NULL, EINA\_FALSE \}
\};

\textcolor{comment}{/* add a checkbox to the box with the given label, and uses the checked}
\textcolor{comment}{ * pointer as state\_pointer to this checkbox */}
\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(elm_object_parent_widget_get(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;
   \textcolor{keywordtype}{int} i;
   \textcolor{keyword}{struct }Context *ctxt = data;
   Evas\_Object *obj = ctxt->obj; \textcolor{comment}{// the object on which the transition will be}
                                 \textcolor{comment}{// applied}

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

   \textcolor{comment}{/* initialization: create the transition and add the object to it */}
   trans = elm_transit_add();
   elm_transit_object_add(trans, obj);

   \textcolor{comment}{/* from our helper structure and array, check if the specified transition is}
\textcolor{comment}{    * checked and use its callback to add this transition to trans */}
   \textcolor{keywordflow}{for} (i = 0; \_transitions[i].label; i++)
     \{
        \textcolor{keywordflow}{if} (\_transitions[i].checked)
          \_transitions[i].transition\_add\_cb(trans);
     \}

   \textcolor{comment}{/* get the various options for this transition from the context structure */}
   elm_transit_event_enabled_set(trans, ctxt->events\_enabled);
   elm_transit_auto_reverse_set(trans, ctxt->auto\_reverse);
   elm_transit_objects_final_state_keep_set(trans, ctxt->final\_state\_keep);
   elm_transit_tween_mode_set(trans, ctxt->tween\_mode);
   elm_transit_repeat_times_set(trans, ctxt->repeat\_times);

   \textcolor{comment}{/* set the transition time to 2 seconds and start it */}
   elm_transit_duration_set(trans, 2.0);
   elm_transit_go(trans);
\}

\textcolor{comment}{/* callback useful just to know whether we can receive events from the}
\textcolor{comment}{ * object or not */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_object\_clicked(\textcolor{keywordtype}{void} *data, Evas\_Object *o, \textcolor{keywordtype}{void} *event\_info)
\{
   printf(\textcolor{stringliteral}{"object clicked!\(\backslash\)n"});
\}

\textcolor{comment}{/* update our context with the given value for repeat count */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_cb\_repeat\_changed(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   \textcolor{keywordtype}{int} *repeat\_cnt = data;

   *repeat\_cnt = elm_spinner_value_get(obj);
\}

\textcolor{comment}{/* update our context with the given tween mode for the transition */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_cb\_tween\_changed(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Elm_Transit_Tween_Mode *mode = data;
   \textcolor{keywordtype}{double} val = 0.0;

   val = elm_spinner_value_get(obj);
   \textcolor{keywordflow}{if} (val == 1.0)
     *mode = ELM_TRANSIT_TWEEN_MODE_LINEAR;
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val == 2.0)
     *mode = ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL;
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val == 3.0)
     *mode = ELM_TRANSIT_TWEEN_MODE_DECELERATE;
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val == 4.0)
     *mode = ELM_TRANSIT_TWEEN_MODE_ACCELERATE;
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *obj, *icon, *box, *vbox, *vbox2, *hbox, *btn;
   Evas\_Object *cbox, *dummy, *spinner;
   \textcolor{keywordtype}{char} buf[PATH\_MAX];
   \textcolor{keywordtype}{int} i;
   \textcolor{keyword}{struct }Context context;

   \textcolor{comment}{/* initialize our context */}
   context.events\_enabled = EINA\_FALSE;
   context.auto\_reverse = EINA\_FALSE;
   context.final\_state\_keep = EINA\_FALSE;
   context.repeat\_times = 0;
   context.tween\_mode = ELM_TRANSIT_TWEEN_MODE_LINEAR;

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

   \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);

   \textcolor{comment}{/* add a vertical box that will hold everything */}
   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}{/* a dummy background to create some space for the animation */}
   dummy = elm_bg_add(win);
   evas\_object\_size\_hint\_weight\_set(dummy, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_box_pack_end(box, dummy);
   evas\_object\_show(dummy);

   \textcolor{comment}{/* add an object that we are going to play with */}
   \textcolor{comment}{/* this object isn't packed inside the box because we don't want it to have}
\textcolor{comment}{    * its size, position, aspect or anything else controled by the container */}
   obj = elm_button_add(win);
   elm\_object\_text\_set(obj, \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(obj, \textcolor{stringliteral}{"icon"}, icon);
   evas\_object\_move(obj, 160, 60);
   evas\_object\_resize(obj, 250, 100);
   evas\_object\_show(obj);
   context.obj = obj;

   \textcolor{comment}{/* a callback to know if clicks are being received */}
   evas\_object\_smart\_callback\_add(obj, \textcolor{stringliteral}{"clicked"}, \_object\_clicked, NULL);

   \textcolor{comment}{/* button to start our transition */}
   btn = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Transit!"});
   elm_box_pack_end(box, btn);
   evas\_object\_show(btn);
   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_transit\_start, &context);

   \textcolor{comment}{/* horizontal box to help visual organization */}
   hbox = elm_box_add(win);
   elm_box_horizontal_set(hbox, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(hbox, EVAS\_HINT\_EXPAND, EVAS\_HINT\_FILL);
   evas\_object\_size\_hint\_align\_set(hbox, EVAS\_HINT\_FILL, 0.0);
   elm_box_pack_end(box, hbox);
   evas\_object\_show(hbox);

   \textcolor{comment}{/* horizontal box that will hold the many transition checkboxes */}
   vbox = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(vbox, EVAS\_HINT\_EXPAND, EVAS\_HINT\_FILL);
   evas\_object\_size\_hint\_align\_set(vbox, EVAS\_HINT\_FILL, 0.0);

   \textcolor{comment}{/* create the respective checkboxes based on our helper structure and}
\textcolor{comment}{    * array */}
   \textcolor{keywordflow}{for} (i = 0; \_transitions[i].label; i++)
     \_checkbox\_transition\_add(vbox, \_transitions[i].label,
                              &\_transitions[i].checked);

   elm_box_pack_end(hbox, vbox);
   evas\_object\_show(vbox);

   \textcolor{comment}{/* vertical box that will hold the many transition option checkboxes */}
   vbox2 = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(vbox2, EVAS\_HINT\_EXPAND, EVAS\_HINT\_FILL);
   evas\_object\_size\_hint\_align\_set(vbox2, EVAS\_HINT\_FILL, 0.0);
   elm_box_pack_end(hbox, vbox2);
   evas\_object\_show(vbox2);

   \textcolor{comment}{/* the rest of this code adds widgets to control some of the behavior of}
\textcolor{comment}{    * the transitions */}
   cbox = elm_check_add(win);
   evas\_object\_size\_hint\_weight\_set(cbox, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(cbox, 0.0, 0.0);
   elm\_object\_text\_set(cbox, \textcolor{stringliteral}{"Events enabled"});
   elm_check_state_pointer_set(cbox, &context.events\_enabled);
   elm_box_pack_end(vbox2, cbox);
   evas\_object\_show(cbox);

   cbox = elm_check_add(win);
   evas\_object\_size\_hint\_weight\_set(cbox, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(cbox, 0.0, 0.0);
   elm\_object\_text\_set(cbox, \textcolor{stringliteral}{"Auto reverse"});
   elm_check_state_pointer_set(cbox, &context.auto\_reverse);
   elm_box_pack_end(vbox2, cbox);
   evas\_object\_show(cbox);

   cbox = elm_check_add(win);
   evas\_object\_size\_hint\_weight\_set(cbox, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(cbox, 0.0, 0.0);
   elm\_object\_text\_set(cbox, \textcolor{stringliteral}{"Keep final state"});
   elm_check_state_pointer_set(cbox, &context.final\_state\_keep);
   elm_box_pack_end(vbox2, cbox);
   evas\_object\_show(cbox);

   spinner = elm_spinner_add(win);
   elm_object_style_set(spinner, \textcolor{stringliteral}{"vertical"});
   elm_spinner_min_max_set(spinner, 0, 4);
   elm_spinner_label_format_set(spinner, \textcolor{stringliteral}{"%.0f"});
   elm_spinner_editable_set(spinner, EINA\_FALSE);
   evas\_object\_size\_hint\_weight\_set(spinner, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(spinner, 0.0, EVAS\_HINT\_FILL);
   evas\_object\_smart\_callback\_add(spinner, \textcolor{stringliteral}{"changed"}, \_cb\_repeat\_changed, &context.repeat\_times);
   elm_box_pack_end(vbox2, spinner);
   evas\_object\_show(spinner);

   spinner = elm_spinner_add(win);
   elm_object_style_set(spinner, \textcolor{stringliteral}{"vertical"});
   elm_spinner_min_max_set(spinner, 1, 4);
   elm_spinner_label_format_set(spinner, \textcolor{stringliteral}{"%.0f"});
   elm_spinner_editable_set(spinner, EINA\_FALSE);
   elm_spinner_special_value_add(spinner, 1, \textcolor{stringliteral}{"linear"});
   elm_spinner_special_value_add(spinner, 2, \textcolor{stringliteral}{"sinusoidal"});
   elm_spinner_special_value_add(spinner, 3, \textcolor{stringliteral}{"decelerate"});
   elm_spinner_special_value_add(spinner, 4, \textcolor{stringliteral}{"accelerate"});
   evas\_object\_size\_hint\_weight\_set(spinner, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(spinner, 0.0, EVAS\_HINT\_FILL);
   evas\_object\_smart\_callback\_add(spinner, \textcolor{stringliteral}{"changed"}, \_cb\_tween\_changed, &context.tween\_mode);
   elm_box_pack_end(vbox2, spinner);
   evas\_object\_show(spinner);

   evas\_object\_show(win);

   elm_run();

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