<p>The <span style="font-family: Courier New,Courier,monospace;">create_base_gui()</span> function draws 2 different rectangles and calls the <span style="font-family: Courier New,Courier,monospace;">ecore_animator_frametime_set()</span>, <span style="font-family: Courier New,Courier,monospace;">ecore_animator_timeline_add()</span>, <span style="font-family: Courier New,Courier,monospace;">ecore_animator_add()</span>, and <span style="font-family: Courier New,Courier,monospace;">ecore_timer_add()</span> functions to give animation effects.</p>
<pre class="prettyprint">
-#include "animator.h"
-#include "dbg.h"
typedef struct appdata
{
Evas_Object *win;
- Evas_Object *label;
+ Evas_Object *layout;
} appdata_s;
static void create_base_gui(appdata_s *ad)
{
- // Window
- ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
- elm_win_autodel_set(ad->win, EINA_TRUE);
-
- evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
- eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
- // Main part of the animator function
- Evas_Object *rect, *bg, *rect2;
- Ecore_Evas *ee;
Evas *evas;
- Ecore_Animator *anim;
- ee = ecore_evas_new(NULL, 0, 0, 300, 400, NULL);
- ecore_evas_show(ee);
- evas = ecore_evas_get(ee);
- bg = evas_object_rectangle_add(evas);
- evas_object_resize(bg, 300, 400);
- evas_object_show(bg);
- rect = evas_object_rectangle_add(evas);
- evas_object_color_set(rect, 0, 0, 255, 255);
- evas_object_resize(rect, 50, 50);
- evas_object_show(rect);
+ /* Window */
+ ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
+ elm_win_autodel_set(ad->win, EINA_TRUE);
+ if (elm_win_wm_rotation_supported_get(ad->win)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
+ }
+ evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
+ eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
+ /* Base layout */
+ ad->layout = elm_layout_add(ad->win);
+ elm_layout_theme_set(ad->layout, "layout", "application", "default");
+ evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(ad->layout);
+ /* Animator */
+ evas = evas_object_evas_get(ad->layout);
+ rect1 = evas_object_rectangle_add(evas);
+ evas_object_color_set(rect1, 0, 0, 255, 255);
+ evas_object_resize(rect1, 50, 50);
+ evas_object_show(rect1);
rect2 = evas_object_rectangle_add(evas);
evas_object_color_set(rect2, 0, 55, 0, 255);
evas_object_resize(rect2, 50, 50);
evas_object_show(rect2);
ecore_animator_frametime_set(1. / 50);
- ecore_animator_timeline_add(5, _advance_frame, rect);
- anim = ecore_animator_add(_advance_frame3, rect2);
- ecore_timer_add(10, _start_second_anim, rect);
- ecore_timer_add(5, _freeze_third_anim, anim);
- ecore_timer_add(10, _thaw_third_anim, anim);
- ecore_main_loop_begin();
- evas_object_del(rect);
- ecore_evas_free(ee);
- ecore_animator_del(anim);
- // Show the window after the base GUI is set up
- evas_object_show(ad->win);
+ anim1 = ecore_animator_timeline_add(5, _advance_frame1, rect1);
+ anim2 = ecore_animator_add(_advance_frame3, rect2);
+ timer1 = ecore_timer_add(10, _start_second_anim, rect1);
+ timer2 = ecore_timer_add(5, _freeze_third_anim, anim2);
+ timer3 = ecore_timer_add(10, _thaw_third_anim, anim2);
+ /* Show window after base gui is set up */
+ evas_object_show(ad->win);
}
</pre>
<p>The <span style="font-family: Courier New,Courier,monospace;">_advance_frame()</span>, <span style="font-family: Courier New,Courier,monospace;">_advance_frame2()</span>, and <span style="font-family: Courier New,Courier,monospace;">_advance_frame3()</span> functions are callbacks that give animation effects by resizing the rectangle for a different time frame, moving the rectangle location and changing the color.</p>
<pre class="prettyprint">
-static Eina_Bool _advance_frame(void *data, double pos)
+static Eina_Bool _advance_frame1(void *data, double pos)
{
double frame = pos;
frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_SPRING, 1.2, 15);
evas_object_move(data, 100 * frame, 100 * frame);
evas_object_color_set(data, 255 * frame, 0, 255 * (1 - frame), 255);
- return EINA_TRUE;
+ return ECORE_CALLBACK_RENEW;
}
static Eina_Bool _advance_frame2(void *data, double pos)
evas_object_move(data, 100 * (1 - frame), 100 * (1 - frame));
evas_object_color_set(data, 255 * (1 - frame), 0, 255 * frame, 255);
- return EINA_TRUE;
+ return ECORE_CALLBACK_RENEW;
}
static Eina_Bool _advance_frame3(void *data)
x = 0;
evas_object_move(data, ++x, 350);
- return EINA_TRUE;
+ return ECORE_CALLBACK_RENEW;
}
</pre>
ecore_animator_frametime_set(1. / 10);
ecore_animator_timeline_add(20, _advance_frame2, data);
- return EINA_FALSE;
+ return ECORE_CALLBACK_CANCEL;
}
static Eina_Bool _freeze_third_anim(void *data)
{
ecore_animator_freeze(data);
- return EINA_FALSE;
+ return ECORE_CALLBACK_CANCEL;
}
static Eina_Bool _thaw_third_anim(void *data)
{
ecore_animator_thaw(data);
- return EINA_FALSE;
+ return ECORE_CALLBACK_CANCEL;
}
</pre>
</script>
</body>
-</html>
\ No newline at end of file
+</html>