aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/elementary/src/bin/test_transit.c
diff options
context:
space:
mode:
authorTiago Rezende Campos Falcao <developer@tiagofalcao.com>2010-11-10 18:06:20 +0000
committerTiago Rezende Campos Falcao <developer@tiagofalcao.com>2010-11-10 18:06:20 +0000
commit677b123e3251bd4dc2d29f6e8960fb3b486af7a3 (patch)
treeece807def4f5d810c19e50b7884d380a1fb6b66c /legacy/elementary/src/bin/test_transit.c
parentTransit Effect: Effect Translation whith variance (diff)
downloadefl-677b123e3251bd4dc2d29f6e8960fb3b486af7a3.tar.gz
test_transit.c - activate effects when click
Author: Helen Fornazier <helen.fornazier@profusion.mobi> SVN revision: 54429
Diffstat (limited to 'legacy/elementary/src/bin/test_transit.c')
-rw-r--r--legacy/elementary/src/bin/test_transit.c364
1 files changed, 213 insertions, 151 deletions
diff --git a/legacy/elementary/src/bin/test_transit.c b/legacy/elementary/src/bin/test_transit.c
index e3e2de58e1..7df4a55b1f 100644
--- a/legacy/elementary/src/bin/test_transit.c
+++ b/legacy/elementary/src/bin/test_transit.c
@@ -14,7 +14,8 @@ struct _Custom_Effect
} from, to;
};
-static void _custom_op(void *data, Elm_Transit *transit, double progress)
+static void
+_custom_op(void *data, Elm_Transit *transit, double progress)
{
if (!data) return;
Evas_Coord w, h;
@@ -26,15 +27,14 @@ static void _custom_op(void *data, Elm_Transit *transit, double progress)
if (progress < 0.5)
{
- h = custom_effect->from.h + \
- (Evas_Coord) ((float)custom_effect->to.h * (float)progress * 2);
+ h = custom_effect->from.h + (custom_effect->to.h * progress * 2);
w = custom_effect->from.w;
}
else
{
- h = custom_effect->from.h + (Evas_Coord) ((float)custom_effect->to.h);
- w = custom_effect->from.w + (Evas_Coord) ((float)custom_effect->to.w \
- * ((float)progress - 0.5) * 2);
+ h = custom_effect->from.h + custom_effect->to.h;
+ w = custom_effect->from.w + \
+ (custom_effect->to.w * (progress - 0.5) * 2);
}
EINA_LIST_FOREACH(objs, elist, obj)
@@ -42,7 +42,8 @@ static void _custom_op(void *data, Elm_Transit *transit, double progress)
}
-static void *_custom_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
+static void *
+_custom_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coord to_w, Evas_Coord to_h)
{
Custom_Effect *custom_effect;
@@ -57,48 +58,71 @@ static void *_custom_context_new(Evas_Coord from_w, Evas_Coord from_h, Evas_Coor
return custom_effect;
}
-static void _custom_context_free(void *data, Elm_Transit *transit __UNUSED__)
+static void
+_custom_context_free(void *data, Elm_Transit *transit __UNUSED__)
{
free(data);
}
-/* Translation, Rotation, Color, Wipe, ImagemAnimation Effect */
-void
-test_transit(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+static void
+_transit_rotation_translation_color(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
- Evas_Object *win, *bg, *bx, *bt, *ic;
Elm_Transit *trans;
void *effect_context;
- char buf[PATH_MAX];
- Eina_List *images = NULL;
- win = elm_win_add(NULL, "transit", ELM_WIN_BASIC);
- elm_win_title_set(win, "Transit");
- elm_win_autodel_set(win, EINA_TRUE);
+ trans = elm_transit_add(5.0);
+ elm_transit_object_add(trans, obj);
+ elm_transit_auto_reverse_set(trans, EINA_TRUE);
+ elm_transit_repeat_times_set(trans, 2);
- bg = elm_bg_add(win);
- elm_win_resize_object_add(win, bg);
- evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(bg);
+ /* Translation Effect */
+ effect_context = elm_transit_effect_translation_context_new(-70.0, -150.0,
+ 70.0, 150.0);
+ elm_transit_effect_add(trans,
+ elm_transit_effect_translation_op, effect_context,
+ elm_transit_effect_translation_context_free);
- bx = elm_box_add(win);
- evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, bx);
- evas_object_size_hint_min_set(bx, 318, 318);
- evas_object_show(bx);
+ /* Color Effect */
+ effect_context = elm_transit_effect_color_context_new(100, 255, 100,
+ 255, 200, 50, 200, 50);
+ elm_transit_effect_add(trans,
+ elm_transit_effect_color_op, effect_context,
+ elm_transit_effect_color_context_free);
+ /* Rotation Effect */
+ effect_context = elm_transit_effect_rotation_context_new(0.0,
+ 135.0, EINA_FALSE);
+ elm_transit_effect_add(trans,
+ elm_transit_effect_rotation_op, effect_context,
+ elm_transit_effect_rotation_context_free);
- ic = elm_icon_add(win);
- snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
- elm_icon_file_set(ic, buf, NULL);
- evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+}
- bt = elm_button_add(win);
- elm_button_label_set(bt, "ImageAnimation Effect");
- elm_button_icon_set(bt, ic);
- elm_box_pack_end(bx, bt);
- evas_object_show(bt);
- evas_object_show(ic);
+static void
+_transit_wipe(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+{
+ Elm_Transit *trans;
+ void *effect_context;
+
+ trans = elm_transit_add(5.0);
+ elm_transit_object_add(trans, obj);
+
+ effect_context = \
+ elm_transit_effect_wipe_context_new(ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE,
+ ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT);
+ elm_transit_effect_add(trans,
+ elm_transit_effect_wipe_op, effect_context,
+ elm_transit_effect_wipe_context_free);
+}
+
+static void
+_transit_image_animation(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Eina_List *images = NULL;
+ char buf[PATH_MAX];
+ Elm_Transit *trans;
+ Evas_Object *ic = data;
+ void *effect_context;
snprintf(buf, sizeof(buf), "%s/images/icon_19.png", PACKAGE_DATA_DIR);
images = eina_list_append(images, eina_stringshare_add(buf));
@@ -112,64 +136,160 @@ test_transit(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
images = eina_list_append(images, eina_stringshare_add(buf));
- /* Transit Creation */
trans = elm_transit_add(5.0);
elm_transit_object_add(trans, ic);
- /* ImagemAnimation */
effect_context = \
elm_transit_effect_image_animation_context_new(images);
elm_transit_effect_add(trans,
- elm_transit_effect_image_animation_op, effect_context,
- elm_transit_effect_image_animation_context_free);
+ elm_transit_effect_image_animation_op, effect_context,
+ elm_transit_effect_image_animation_context_free);
+}
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Color, Rotation and Translation");
- elm_box_pack_end(bx, bt);
- evas_object_show(bt);
+static void
+_transit_resizing(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+{
+ Elm_Transit *trans;
+ void *effect_context;
- /* Transit Creation */
trans = elm_transit_add(5.0);
- elm_transit_object_add(trans, bt);
- elm_transit_auto_reverse_set(trans, EINA_TRUE);
- elm_transit_repeat_times_set(trans, 2);
+ effect_context = elm_transit_effect_resizing_context_new(100, 50, 300, 150);
- /* Translation Effect */
- effect_context = elm_transit_effect_translation_context_new(0.0, 0.0,
- 280.0, 280.0);
+ elm_transit_object_add(trans, obj);
elm_transit_effect_add(trans,
- elm_transit_effect_translation_op, effect_context,
- elm_transit_effect_translation_context_free);
+ elm_transit_effect_resizing_op, effect_context,
+ elm_transit_effect_resizing_context_free);
+}
- /* Color Effect */
- effect_context = elm_transit_effect_color_context_new(100, 255, 100,
- 255, 200, 50, 200, 50);
+static void
+_transit_flip(void *data, Evas_Object *obj, void *event_info __UNUSED__)
+{
+ Elm_Transit *trans;
+ void *effect_context;
+ Evas_Object *obj2 = data;
+
+ trans = elm_transit_add(5.0);
+ elm_transit_object_add(trans, obj);
+ elm_transit_object_add(trans, obj2);
+ effect_context = elm_transit_effect_flip_context_new(
+ ELM_TRANSIT_EFFECT_FLIP_AXIS_X,
+ EINA_TRUE);
elm_transit_effect_add(trans,
- elm_transit_effect_color_op, effect_context,
- elm_transit_effect_color_context_free);
+ elm_transit_effect_flip_op, effect_context,
+ elm_transit_effect_flip_context_free);
+}
- /* Rotation Effect */
- effect_context = elm_transit_effect_rotation_context_new(0.0,
- 135.0, EINA_FALSE);
+static void
+_transit_zoom(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+{
+ Elm_Transit *trans;
+ void *effect_context;
+
+ trans = elm_transit_add(5.0);
+ elm_transit_object_add(trans, obj);
+ effect_context = elm_transit_effect_zoom_context_new(0.5, 5.0);
elm_transit_effect_add(trans,
- elm_transit_effect_rotation_op, effect_context,
- elm_transit_effect_rotation_context_free);
+ elm_transit_effect_zoom_op, effect_context,
+ elm_transit_effect_zoom_context_free);
+}
+
+static void
+_transit_blend(void *data, Evas_Object *obj, void *event_info __UNUSED__)
+{
+ Elm_Transit *trans;
+ void *effect_context;
+ Evas_Object *obj2 = data;
+
+ trans = elm_transit_add(5.0);
+ elm_transit_object_add(trans, obj);
+ elm_transit_object_add(trans, obj2);
+ effect_context = elm_transit_effect_blend_context_new();
+ elm_transit_effect_add(trans,
+ elm_transit_effect_blend_op, effect_context,
+ elm_transit_effect_blend_context_free);
+}
+
+static void
+_transit_fade(void *data, Evas_Object *obj, void *event_info __UNUSED__)
+{
+ Elm_Transit *trans;
+ void *effect_context;
+ Evas_Object *obj2 = data;
+
+ trans = elm_transit_add(5.0);
+ elm_transit_object_add(trans, obj);
+ elm_transit_object_add(trans, obj2);
+ effect_context = elm_transit_effect_fade_context_new();
+ elm_transit_effect_add(trans,
+ elm_transit_effect_fade_op, effect_context,
+ elm_transit_effect_fade_context_free);
+}
+
+static void
+_transit_resizable_flip(void *data, Evas_Object *obj, void *event_info __UNUSED__)
+{
+ Elm_Transit *trans;
+ void *effect_context;
+ Evas_Object *obj2 = data;
+
+ trans = elm_transit_add(5.0);
+ elm_transit_object_add(trans, obj);
+ elm_transit_object_add(trans, obj2);
+ effect_context = elm_transit_effect_resizable_flip_context_new(
+ ELM_TRANSIT_EFFECT_FLIP_AXIS_X,
+ EINA_TRUE);
+ elm_transit_effect_add(trans,
+ elm_transit_effect_resizable_flip_op, effect_context,
+ elm_transit_effect_resizable_flip_context_free);
+}
+
+/* Translation, Rotation, Color, Wipe, ImagemAnimation Effect */
+void
+test_transit(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Evas_Object *win, *bg, *bx, *bt, *ic;
+ char buf[PATH_MAX];
+
+ win = elm_win_add(NULL, "transit", ELM_WIN_BASIC);
+ elm_win_title_set(win, "Transit");
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ bg = elm_bg_add(win);
+ elm_win_resize_object_add(win, bg);
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(bg);
+
+ bx = elm_box_add(win);
+ evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bx);
+ evas_object_size_hint_min_set(bx, 318, 318);
+ evas_object_show(bx);
+
+ ic = elm_icon_add(win);
+ snprintf(buf, sizeof(buf), "%s/images/icon_11.png", PACKAGE_DATA_DIR);
+ elm_icon_file_set(ic, buf, NULL);
+ evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
- elm_button_label_set(bt, "Wipe Effect");
+ elm_button_label_set(bt, "ImageAnimation Effect");
+ elm_button_icon_set(bt, ic);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
+ evas_object_show(ic);
+ evas_object_smart_callback_add(bt, "clicked", _transit_image_animation, ic);
- /* Transit Creation */
- trans = elm_transit_add(5.0);
- elm_transit_object_add(trans, bt);
+ bt = elm_button_add(win);
+ elm_button_label_set(bt, "Color, Rotation and Translation");
+ elm_box_pack_end(bx, bt);
+ evas_object_show(bt);
+ evas_object_smart_callback_add(bt, "clicked",
+ _transit_rotation_translation_color, NULL);
- /* Wipe Effect */
- effect_context = elm_transit_effect_wipe_context_new(ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE,
- ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT);
- elm_transit_effect_add(trans,
- elm_transit_effect_wipe_op, effect_context,
- elm_transit_effect_wipe_context_free);
+ bt = elm_button_add(win);
+ elm_button_label_set(bt, "Wipe Effect");
+ elm_box_pack_end(bx, bt);
+ evas_object_show(bt);
+ evas_object_smart_callback_add(bt, "clicked", _transit_wipe, NULL);
evas_object_show(win);
}
@@ -179,8 +299,6 @@ void
test_transit2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *bt;
- Elm_Transit *trans;
- void *effect_context;
win = elm_win_add(NULL, "transit-2", ELM_WIN_BASIC);
elm_win_title_set(win, "Transit 2");
@@ -193,21 +311,13 @@ test_transit2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_show(bg);
bt = elm_button_add(win);
- elm_button_label_set(bt, "Button - Resizing Effect");
+ elm_button_label_set(bt, "Resizing Effect");
evas_object_show(bt);
evas_object_move(bt, 50, 100);
- evas_object_resize(bt, 250, 150);
+ evas_object_resize(bt, 100, 50);
+ evas_object_smart_callback_add(bt, "clicked", _transit_resizing, NULL);
evas_object_show(win);
-
- /* Adding Transit */
- trans = elm_transit_add(5.0);
- effect_context = elm_transit_effect_resizing_context_new(100, 100, 250, 250);
- elm_transit_object_add(trans, bt);
- elm_transit_effect_add(trans,
- elm_transit_effect_resizing_op, effect_context,
- elm_transit_effect_resizing_context_free);
-
}
/* Flip Effect */
@@ -215,8 +325,6 @@ void
test_transit3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *bt, *bt2;
- Elm_Transit *trans;
- void *effect_context;
win = elm_win_add(NULL, "transit-3", ELM_WIN_BASIC);
elm_win_title_set(win, "Transit 3");
@@ -242,15 +350,8 @@ test_transit3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_show(win);
- /* Adding Transit */
- trans = elm_transit_add(5.0);
- elm_transit_object_add(trans, bt);
- elm_transit_object_add(trans, bt2);
- effect_context = elm_transit_effect_flip_context_new(ELM_TRANSIT_EFFECT_FLIP_AXIS_X,
- EINA_TRUE);
- elm_transit_effect_add(trans,
- elm_transit_effect_flip_op, effect_context,
- elm_transit_effect_flip_context_free);
+ evas_object_smart_callback_add(bt, "clicked", _transit_flip, bt2);
+ evas_object_smart_callback_add(bt2, "clicked", _transit_flip, bt);
}
/* Zoom Effect */
@@ -258,8 +359,6 @@ void
test_transit4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *bx, *bt;
- Elm_Transit *trans;
- void *effect_context;
win = elm_win_add(NULL, "transit-4", ELM_WIN_BASIC);
elm_win_title_set(win, "Transit 4");
@@ -286,16 +385,9 @@ test_transit4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
elm_box_pack_end(bx, bt);
evas_object_show(bt);
- evas_object_show(win);
-
- /* Adding Transit */
- trans = elm_transit_add(5.0);
- elm_transit_object_add(trans, bt);
- effect_context = elm_transit_effect_zoom_context_new(0.5, 5.0);
- elm_transit_effect_add(trans,
- elm_transit_effect_zoom_op, effect_context,
- elm_transit_effect_zoom_context_free);
+ evas_object_smart_callback_add(bt, "clicked", _transit_zoom, NULL);
+ evas_object_show(win);
bt = elm_button_add(win);
elm_button_label_set(bt, "Button");
@@ -308,8 +400,6 @@ void
test_transit5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *bx, *bt, *bt2;
- Elm_Transit *trans;
- void *effect_context;
win = elm_win_add(NULL, "transit-5", ELM_WIN_BASIC);
elm_win_title_set(win, "Transit 5");
@@ -332,21 +422,13 @@ test_transit5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_show(bt);
bt2 = elm_button_add(win);
- elm_button_label_set(bt2, "After BUTTON - Blend Effect");
+ elm_button_label_set(bt2, "After Button - Blend Effect");
elm_box_pack_end(bx, bt2);
- evas_object_show(bt2);
evas_object_show(win);
- /* Adding Transit */
- trans = elm_transit_add(5.0);
- elm_transit_object_add(trans, bt);
- elm_transit_object_add(trans, bt2);
- effect_context = elm_transit_effect_blend_context_new();
- elm_transit_effect_add(trans,
- elm_transit_effect_blend_op, effect_context,
- elm_transit_effect_blend_context_free);
-
+ evas_object_smart_callback_add(bt, "clicked", _transit_blend, bt2);
+ evas_object_smart_callback_add(bt2, "clicked", _transit_blend, bt);
}
/* Fade Effect */
@@ -354,8 +436,6 @@ void
test_transit6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *bt, *bt2;
- Elm_Transit *trans;
- void *effect_context;
win = elm_win_add(NULL, "transit-6", ELM_WIN_BASIC);
elm_win_title_set(win, "Transit 6");
@@ -381,14 +461,8 @@ test_transit6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_show(win);
- /* Adding Transit */
- trans = elm_transit_add(5.0);
- elm_transit_object_add(trans, bt);
- elm_transit_object_add(trans, bt2);
- effect_context = elm_transit_effect_fade_context_new();
- elm_transit_effect_add(trans,
- elm_transit_effect_fade_op, effect_context,
- elm_transit_effect_fade_context_free);
+ evas_object_smart_callback_add(bt, "clicked", _transit_fade, bt2);
+ evas_object_smart_callback_add(bt2, "clicked", _transit_fade, bt);
}
/* Resizable Flip Effect */
@@ -396,11 +470,9 @@ void
test_transit7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *bt, *bt2;
- Elm_Transit *trans;
- void *effect_context;
- win = elm_win_add(NULL, "transit-10", ELM_WIN_BASIC);
- elm_win_title_set(win, "Transit 10");
+ win = elm_win_add(NULL, "transit-7", ELM_WIN_BASIC);
+ elm_win_title_set(win, "Transit 7");
elm_win_autodel_set(win, EINA_TRUE);
evas_object_resize(win, 400, 400);
@@ -410,30 +482,20 @@ test_transit7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_show(bg);
bt = elm_button_add(win);
- elm_button_label_set(bt, "Front Button");
- evas_object_show(bt);
+ elm_button_label_set(bt, "Front Button - Resizable Flip Effect");
evas_object_move(bt, 50, 100);
- evas_object_resize(bt, 250, 150);
+ evas_object_resize(bt, 350, 200);
bt2 = elm_button_add(win);
- elm_button_label_set(bt2, "Back Button");
+ elm_button_label_set(bt2, "Back Button - Resizable Flip Effect");
evas_object_show(bt2);
evas_object_move(bt2, 50, 100);
- evas_object_resize(bt2, 100, 30);
+ evas_object_resize(bt2, 200, 30);
evas_object_show(win);
- /* Adding Transit */
- effect_context = \
- elm_transit_effect_resizable_flip_context_new(ELM_TRANSIT_EFFECT_FLIP_AXIS_X,
- EINA_TRUE);
- trans = elm_transit_add(5.0);
- elm_transit_object_add(trans, bt2);
- elm_transit_object_add(trans, bt);
- elm_transit_effect_add(trans,
- elm_transit_effect_resizable_flip_op, effect_context,
- elm_transit_effect_resizable_flip_context_free);
-
+ evas_object_smart_callback_add(bt, "clicked", _transit_resizable_flip, bt2);
+ evas_object_smart_callback_add(bt2, "clicked", _transit_resizable_flip, bt);
}
/* Custom Effect */