forked from enlightenment/efl
Efl.Ui.Image.Zoomable: implement efl.play.get/set
ref T5352
This commit is contained in:
parent
835262f592
commit
66a79ece6b
|
@ -181,6 +181,7 @@ void test_index_horizontal(void *data, Evas_Object *obj, void *event_info);
|
|||
void test_photocam(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_photocam_remote(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_photocam_icon(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_photocam_animated(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_photo(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_prefs(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_thumb(void *data, Evas_Object *obj, void *event_info);
|
||||
|
@ -679,6 +680,7 @@ add_tests:
|
|||
ADD_TEST(NULL, "Images", "Photocam", test_photocam);
|
||||
ADD_TEST(NULL, "Images", "Photocam Remote", test_photocam_remote);
|
||||
ADD_TEST(NULL, "Images", "Photocam Icon", test_photocam_icon);
|
||||
ADD_TEST(NULL, "Images", "Image Zoomable animation", test_photocam_animated);
|
||||
ADD_TEST(NULL, "Images", "Photo", test_photo);
|
||||
ADD_TEST(NULL, "Images", "Thumb", test_thumb);
|
||||
ADD_TEST(NULL, "Images", "Image", test_image);
|
||||
|
|
|
@ -731,3 +731,58 @@ test_photocam_icon(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
|
|||
evas_object_resize(win, 150, 150);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
||||
static void
|
||||
_btn_clicked_cb(void *data , Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *zoomable = data;
|
||||
Eina_Bool play = EINA_FALSE;
|
||||
|
||||
play = !efl_player_play_get(zoomable);
|
||||
printf("image clicked! play = %d\n", play);
|
||||
efl_player_play_set(zoomable, play);
|
||||
}
|
||||
|
||||
void
|
||||
test_photocam_animated(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *bx, *lbl, *zoomable, *btn;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||
|
||||
win = elm_win_util_standard_add("ImageZoomable", "Image Zoomable animation");
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
|
||||
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_show(bx);
|
||||
|
||||
lbl = elm_label_add(bx);
|
||||
elm_object_text_set(lbl, "Clicking the button will play/pause animation.");
|
||||
elm_box_pack_end(bx, lbl);
|
||||
evas_object_show(lbl);
|
||||
|
||||
zoomable = efl_add(EFL_UI_IMAGE_ZOOMABLE_CLASS, win);
|
||||
snprintf(buf, sizeof(buf), "%s/images/animated_logo.gif", elm_app_data_dir_get());
|
||||
efl_file_set(zoomable, buf, NULL);
|
||||
if (efl_player_playable_get(zoomable))
|
||||
{
|
||||
printf("animation is available for this image.\n");
|
||||
efl_player_play_set(zoomable, EINA_TRUE);
|
||||
}
|
||||
evas_object_size_hint_weight_set(zoomable, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_fill_set(zoomable, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx, zoomable);
|
||||
evas_object_show(zoomable);
|
||||
|
||||
btn = efl_add(EFL_UI_BUTTON_CLASS, bx);
|
||||
efl_text_set(btn, "start/stop");
|
||||
evas_object_smart_callback_add(btn, "clicked", _btn_clicked_cb, zoomable);
|
||||
elm_box_pack_end(bx, btn);
|
||||
evas_object_show(btn);
|
||||
|
||||
evas_object_resize(win, 320, 320);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
|
|
@ -699,7 +699,6 @@ _main_img_preloaded_cb(void *data,
|
|||
|
||||
ELM_PHOTOCAM_DATA_GET(data, sd);
|
||||
ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
|
||||
|
||||
evas_object_show(sd->img);
|
||||
sd->main_load_pending = 0;
|
||||
g = _grid_create(obj);
|
||||
|
@ -1496,6 +1495,7 @@ _efl_ui_image_zoomable_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Image_Zoomable
|
|||
{
|
||||
Efl_Ui_Image_Zoomable_Grid *g;
|
||||
|
||||
ecore_timer_del(sd->anim_timer);
|
||||
ELM_SAFE_FREE(sd->icon_edje, evas_object_del);
|
||||
|
||||
EINA_LIST_FREE(sd->grids, g)
|
||||
|
@ -2624,6 +2624,115 @@ _efl_ui_image_zoomable_efl_player_playable_get(Eo *obj EINA_UNUSED, Efl_Ui_Image
|
|||
return evas_object_image_animated_get(sd->img);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_ui_image_zoomable_animated_get_internal(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
|
||||
{
|
||||
if (sd->icon_edje)
|
||||
return edje_object_animation_get(sd->icon_edje);
|
||||
return sd->anim;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_ui_image_zoomable_animated_set_internal(Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool anim)
|
||||
{
|
||||
anim = !!anim;
|
||||
if (sd->anim == anim) return;
|
||||
|
||||
sd->anim = anim;
|
||||
|
||||
if (sd->icon_edje)
|
||||
{
|
||||
edje_object_animation_set(sd->icon_edje, anim);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!evas_object_image_animated_get(sd->img)) return;
|
||||
|
||||
if (anim)
|
||||
{
|
||||
sd->frame_count = evas_object_image_animated_frame_count_get(sd->img);
|
||||
sd->cur_frame = 1;
|
||||
sd->frame_duration =
|
||||
evas_object_image_animated_frame_duration_get
|
||||
(sd->img, sd->cur_frame, 0);
|
||||
evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
sd->frame_count = -1;
|
||||
sd->cur_frame = -1;
|
||||
sd->frame_duration = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_ui_image_zoomable_animate_cb(void *data)
|
||||
{
|
||||
ELM_PHOTOCAM_DATA_GET(data, sd);
|
||||
_grid_clear_all(data);
|
||||
|
||||
if (!sd->anim) return ECORE_CALLBACK_CANCEL;
|
||||
|
||||
sd->cur_frame++;
|
||||
if ((sd->frame_count > 0) && (sd->cur_frame > sd->frame_count))
|
||||
sd->cur_frame = sd->cur_frame % sd->frame_count;
|
||||
|
||||
evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
|
||||
sd->frame_duration = evas_object_image_animated_frame_duration_get
|
||||
(sd->img, sd->cur_frame, 0);
|
||||
|
||||
if (sd->frame_duration > 0)
|
||||
ecore_timer_interval_set(sd->anim_timer, sd->frame_duration);
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_ui_image_zoomable_animated_play_set_internal(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool play)
|
||||
{
|
||||
if (!sd->anim) return;
|
||||
if (sd->play == play) return;
|
||||
sd->play = play;
|
||||
if (sd->icon_edje)
|
||||
{
|
||||
edje_object_play_set(sd->icon_edje, play);
|
||||
return;
|
||||
}
|
||||
if (play)
|
||||
{
|
||||
sd->anim_timer = ecore_timer_add
|
||||
(sd->frame_duration, _efl_ui_image_zoomable_animate_cb, obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
|
||||
}
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_image_zoomable_efl_player_play_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool play)
|
||||
{
|
||||
evas_object_image_preload(sd->img, EINA_FALSE);
|
||||
if (play && !_efl_ui_image_zoomable_animated_get_internal(obj, sd))
|
||||
_efl_ui_image_zoomable_animated_set_internal(obj, sd, play);
|
||||
|
||||
_efl_ui_image_zoomable_animated_play_set_internal(obj, sd, play);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_ui_image_zoomable_animated_play_get_internal(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
|
||||
{
|
||||
if (sd->icon_edje)
|
||||
return edje_object_play_get(sd->icon_edje);
|
||||
return sd->play;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_ui_image_zoomable_efl_player_play_get(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd)
|
||||
{
|
||||
return _efl_ui_image_zoomable_animated_play_get_internal(obj, sd);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_image_zoomable_class_constructor(Efl_Class *klass)
|
||||
{
|
||||
|
|
|
@ -53,6 +53,7 @@ class Efl.Ui.Image.Zoomable (Efl.Ui.Image, Efl.Ui.Zoom,
|
|||
Efl.Image.image_size { get; }
|
||||
Efl.Ui.Image.icon { set; get; }
|
||||
Efl.Player.playable { get; }
|
||||
Efl.Player.play { get; set; }
|
||||
Efl.Ui.Zoom.zoom_animation { set; get; }
|
||||
Efl.Ui.Zoom.zoom { set; get; }
|
||||
Efl.Ui.Zoom.zoom_mode { set; get; }
|
||||
|
|
|
@ -127,6 +127,11 @@ struct _Efl_Ui_Image_Zoomable_Data
|
|||
Eina_Bool use : 1;
|
||||
} freedesktop;
|
||||
|
||||
Ecore_Timer *anim_timer;
|
||||
double frame_duration;
|
||||
int cur_frame;
|
||||
int frame_count;
|
||||
|
||||
Eina_List *grids;
|
||||
Efl_Orient orient;
|
||||
Efl_Flip flip;
|
||||
|
@ -140,6 +145,8 @@ struct _Efl_Ui_Image_Zoomable_Data
|
|||
Eina_Bool on_hold : 1;
|
||||
Eina_Bool paused : 1;
|
||||
Eina_Bool orientation_changed : 1;
|
||||
Eina_Bool play : 1;
|
||||
Eina_Bool anim : 1;
|
||||
};
|
||||
|
||||
struct _Efl_Ui_Image_Zoomable_Pan_Data
|
||||
|
|
Loading…
Reference in New Issue