

This example will show a flip with two rectangles on it(one blue, one green). Our example will allow the user to choose the animation the flip uses and to interact with it. To allow the user to choose the interaction mode we use radio buttons, we will however not explain them, if you would like to know more about radio buttons see Radio.

We start our example with the usual setup and then create the 2 rectangles we will use in our flip\+: 
\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -o flip\_example\_01 flip\_example\_01.c -g `pkg-config --cflags --libs elementary`}

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

\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_change\_interaction(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info);

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *rect, *rect2, *flip, *radio, *radio2, *radio3;

   elm_policy_set(ELM\_POLICY\_QUIT, ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"flip"}, \textcolor{stringliteral}{"Flip"});
   elm_win_autodel_set(win, EINA\_TRUE);

   rect = evas\_object\_rectangle\_add(evas\_object\_evas\_get(win));
   evas\_object\_resize(rect, 150, 150);
   evas\_object\_color\_set(rect, 0, 0, 255, 255);
   evas\_object\_show(rect);

   rect2 = evas\_object\_rectangle\_add(evas\_object\_evas\_get(win));
   evas\_object\_color\_set(rect2, 0, 255, 0, 255);
   evas\_object\_show(rect2);

\end{DoxyCodeInclude}


The next thing to do is to create our flip and set it\textquotesingle{}s front and back content\+: 
\begin{DoxyCodeInclude}

   flip = elm_flip_add(win);
   elm_object_part_content_set(flip, \textcolor{stringliteral}{"front"}, rect);
   elm_object_part_content_set(flip, \textcolor{stringliteral}{"back"}, rect2);
   evas\_object\_resize(flip, 150, 150);
   evas\_object\_move(flip, 10, 10);
   evas\_object\_show(flip);

\end{DoxyCodeInclude}


The next thing we do is set the interaction mode(which the user can later change) to the page animation\+: 
\begin{DoxyCodeInclude}

   elm_flip_interaction_set(flip, ELM\_FLIP\_INTERACTION\_PAGE);

\end{DoxyCodeInclude}


Setting a interaction mode however is not sufficient, we also need to choose which directions we allow interaction from, for this example we will use all of them\+: 
\begin{DoxyCodeInclude}
   elm_flip_interaction_direction_enabled_set(flip, ELM\_FLIP\_DIRECTION\_UP, EINA\_TRUE);
   elm_flip_interaction_direction_enabled_set(flip, ELM\_FLIP\_DIRECTION\_DOWN, EINA\_TRUE);
   elm_flip_interaction_direction_enabled_set(flip, ELM\_FLIP\_DIRECTION\_LEFT, EINA\_TRUE);
   elm_flip_interaction_direction_enabled_set(flip, ELM\_FLIP\_DIRECTION\_RIGHT, EINA\_TRUE);

\end{DoxyCodeInclude}


We are also going to set the hintsize to the entire flip(in all directions) to make our flip very easy to interact with\+: 
\begin{DoxyCodeInclude}
   elm_flip_interaction_direction_hitsize_set(flip, ELM\_FLIP\_DIRECTION\_UP, 1);
   elm_flip_interaction_direction_hitsize_set(flip, ELM\_FLIP\_DIRECTION\_DOWN, 1);
   elm_flip_interaction_direction_hitsize_set(flip, ELM\_FLIP\_DIRECTION\_LEFT, 1);
   elm_flip_interaction_direction_hitsize_set(flip, ELM\_FLIP\_DIRECTION\_RIGHT, 1);

\end{DoxyCodeInclude}


After that we create our radio buttons and start the main loop\+: 
\begin{DoxyCodeInclude}

   radio = elm_radio_add(win);
   elm\_object\_text\_set(radio, \textcolor{stringliteral}{"page"});
   elm_radio_value_set(radio, ELM\_FLIP\_INTERACTION\_PAGE);
   elm_radio_state_value_set(radio, ELM\_FLIP\_INTERACTION\_PAGE);
   evas\_object\_resize(radio, 55, 30);
   evas\_object\_move(radio, 10, 160);
   evas\_object\_show(radio);
   evas\_object\_smart\_callback\_add(radio, \textcolor{stringliteral}{"changed"}, \_change\_interaction, flip);

   radio2 = elm_radio_add(win);
   elm\_object\_text\_set(radio2, \textcolor{stringliteral}{"cube"});
   elm_radio_state_value_set(radio2, ELM\_FLIP\_INTERACTION\_CUBE);
   elm_radio_group_add(radio2, radio);
   evas\_object\_resize(radio2, 55, 30);
   evas\_object\_move(radio2, 75, 160);
   evas\_object\_show(radio2);
   evas\_object\_smart\_callback\_add(radio2, \textcolor{stringliteral}{"changed"}, \_change\_interaction, flip);

   radio3 = elm_radio_add(win);
   elm\_object\_text\_set(radio3, \textcolor{stringliteral}{"rotate"});
   elm_radio_state_value_set(radio3, ELM\_FLIP\_INTERACTION\_ROTATE);
   elm_radio_group_add(radio3, radio);
   evas\_object\_resize(radio3, 55, 30);
   evas\_object\_move(radio3, 140, 160);
   evas\_object\_show(radio3);
   evas\_object\_smart\_callback\_add(radio3, \textcolor{stringliteral}{"changed"}, \_change\_interaction, flip);

   evas\_object\_resize(win, 200, 200);
   evas\_object\_show(win);

   elm_run();

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

\end{DoxyCodeInclude}


When the user clicks a radio button a function that changes the interaction mode and animates the flip is called\+: 
\begin{DoxyCodeInclude}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_change\_interaction(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_flip_interaction_set(data, elm_radio_state_value_get(obj));
   elm_flip_go(data, ELM\_FLIP\_ROTATE\_XZ\_CENTER\_AXIS);
\}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
The \hyperlink{group__Elm__Flip_ga24518d66196b5b634a207fd02e09250e}{elm\+\_\+flip\+\_\+go()} call here serves no purpose other than to illustrate that it\textquotesingle{}s possible to animate the flip programmatically.
\end{DoxyNote}
Our example will look like this\+:

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{screenshots/flip_example_01}}
\end{DoxyImageNoCaption}


\begin{DoxyNote}{Note}
Since this is an animated example the screenshot doesn\textquotesingle{}t do it justice, it is a good idea to compile it and see the animations. 
\end{DoxyNote}
