(image), not just icon.
SVN revision: 71467
int in_eval;
- /* for animation feature */
- Ecore_Timer *timer;
- int frame_count;
- int cur_frame;
- double duration;
-
- Eina_Bool anim : 1;
- Eina_Bool play : 1;
Eina_Bool is_video : 1;
};
}
static Eina_Bool
-_elm_icon_animate_cb(void *data)
-{
- Elm_Icon_Smart_Data *sd = data;
- Evas_Object *img_obj;
-
- if (!sd->anim) return ECORE_CALLBACK_CANCEL;
-
- img_obj = elm_image_object_get(ELM_WIDGET_DATA(sd)->obj);
-
- sd->cur_frame++;
- if (sd->cur_frame > sd->frame_count)
- sd->cur_frame = sd->cur_frame % sd->frame_count;
-
- evas_object_image_animated_frame_set(img_obj, sd->cur_frame);
-
- sd->duration = evas_object_image_animated_frame_duration_get
- (img_obj, sd->cur_frame, 0);
-
- if (sd->duration > 0)
- ecore_timer_interval_set(sd->timer, sd->duration);
-
- return ECORE_CALLBACK_RENEW;
-}
-
-static Eina_Bool
_icon_standard_set(Evas_Object *obj,
const char *name)
{
ecore_event_handler_del(sd->thumb.eeh);
#endif
- if (sd->timer)
- ecore_timer_del(sd->timer);
-
_edje_signals_free(sd);
ELM_WIDGET_CLASS(_elm_icon_parent_sc)->base.del(obj);
}
EAPI void
-elm_icon_animated_set(Evas_Object *obj, Eina_Bool anim)
+elm_icon_animated_set(Evas_Object *obj,
+ Eina_Bool anim)
{
- Evas_Object *img_obj;
-
ELM_ICON_CHECK(obj);
- ELM_ICON_DATA_GET(obj, sd);
-
- anim = !!anim;
- if (sd->anim == anim) return;
-
- img_obj = elm_image_object_get(obj);
- if (!evas_object_image_animated_get(img_obj)) return;
- if (anim)
- {
- sd->frame_count = evas_object_image_animated_frame_count_get(img_obj);
- sd->cur_frame = 1;
- sd->duration = evas_object_image_animated_frame_duration_get
- (img_obj, sd->cur_frame, 0);
- evas_object_image_animated_frame_set(img_obj, sd->cur_frame);
- }
- else
- {
- sd->frame_count = -1;
- sd->cur_frame = -1;
- sd->duration = -1;
- }
- sd->anim = anim;
-
- return;
+ return elm_image_animated_set(obj, anim);
}
EAPI Eina_Bool
elm_icon_animated_get(const Evas_Object *obj)
{
ELM_ICON_CHECK(obj) EINA_FALSE;
- ELM_ICON_DATA_GET(obj, sd);
- return sd->anim;
+ return elm_image_animated_get(obj);
}
EAPI void
Eina_Bool play)
{
ELM_ICON_CHECK(obj);
- ELM_ICON_DATA_GET(obj, sd);
-
- if (!sd->anim) return;
- if (sd->play == play) return;
- if (play)
- {
- sd->timer = ecore_timer_add(sd->duration, _elm_icon_animate_cb, sd);
- }
- else
- {
- if (sd->timer)
- {
- ecore_timer_del(sd->timer);
- sd->timer = NULL;
- }
- }
- sd->play = play;
+ elm_image_animated_play_set(obj, play);
}
EAPI Eina_Bool
elm_icon_animated_play_get(const Evas_Object *obj)
{
ELM_ICON_CHECK(obj) EINA_FALSE;
- ELM_ICON_DATA_GET(obj, sd);
- return sd->play;
+ return elm_image_animated_play_get(obj);
}
EAPI Eina_Bool
evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
}
+static Eina_Bool
+_elm_image_animate_cb(void *data)
+{
+ Elm_Image_Smart_Data *sd = data;
+
+ if (!sd->anim) return ECORE_CALLBACK_CANCEL;
+
+ sd->cur_frame++;
+ if (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 Evas_Object *
_img_new(Evas_Object *obj)
{
if (ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->file_set
(obj, drop->data, NULL))
{
- printf("dnd: %s, %s, %s", elm_widget_type_get(elm_obj), SIG_DND, drop->data);
+ printf("dnd: %s, %s, %s", elm_widget_type_get(elm_obj),
+ SIG_DND, (char *)drop->data);
evas_object_smart_callback_call(elm_obj, SIG_DND, drop->data);
return EINA_TRUE;
{
ELM_IMAGE_DATA_GET(obj, sd);
+ if (sd->anim_timer)
+ ecore_timer_del(sd->anim_timer);
+
evas_object_del(sd->img);
if (sd->prev_img) evas_object_del(sd->prev_img);
return ELM_IMAGE_CLASS(ELM_WIDGET_DATA(sd)->api)->aspect_fixed_get(obj);
}
+
+EAPI Eina_Bool
+elm_image_animated_available_get(const Evas_Object *obj)
+{
+ ELM_IMAGE_CHECK(obj) EINA_FALSE;
+ ELM_IMAGE_DATA_GET(obj, sd);
+
+ if (sd->edje) return EINA_FALSE;
+
+ return evas_object_image_animated_get(elm_image_object_get(obj));
+}
+
+EAPI void
+elm_image_animated_set(Evas_Object *obj,
+ Eina_Bool anim)
+{
+ ELM_IMAGE_CHECK(obj);
+ ELM_IMAGE_DATA_GET(obj, sd);
+
+ anim = !!anim;
+ if (sd->anim == anim) return;
+
+ if (sd->edje) return;
+
+ sd->img = elm_image_object_get(obj);
+ 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;
+ }
+ sd->anim = anim;
+
+ return;
+}
+
+EAPI Eina_Bool
+elm_image_animated_get(const Evas_Object *obj)
+{
+ ELM_IMAGE_CHECK(obj) EINA_FALSE;
+ ELM_IMAGE_DATA_GET(obj, sd);
+
+ return sd->anim;
+}
+
+EAPI void
+elm_image_animated_play_set(Evas_Object *obj,
+ Eina_Bool play)
+{
+ ELM_IMAGE_CHECK(obj);
+ ELM_IMAGE_DATA_GET(obj, sd);
+
+ if (!sd->anim) return;
+ if (sd->play == play) return;
+
+ if (sd->edje) return;
+
+ if (play)
+ {
+ sd->anim_timer = ecore_timer_add
+ (sd->frame_duration, _elm_image_animate_cb, sd);
+ }
+ else
+ {
+ if (sd->anim_timer)
+ {
+ ecore_timer_del(sd->anim_timer);
+ sd->anim_timer = NULL;
+ }
+ }
+ sd->play = play;
+}
+
+EAPI Eina_Bool
+elm_image_animated_play_get(const Evas_Object *obj)
+{
+ ELM_IMAGE_CHECK(obj) EINA_FALSE;
+ ELM_IMAGE_DATA_GET(obj, sd);
+
+ return sd->play;
+}
EAPI Eina_Bool elm_image_aspect_fixed_get(const Evas_Object *obj);
/**
+ * Get whether an image object supports animation or not.
+ *
+ * @param obj The image object
+ * @return @c EINA_TRUE if the image supports animation,
+ * @c EINA_FALSE otherwise.
+ *
+ * This function returns if this Elementary image object's internal
+ * image can be animated. Currently Evas only supports GIF
+ * animation. If the return value is @b EINA_FALSE, other
+ * @c elm_image_animated_xxx API calls won't work.
+ *
+ * @see elm_image_animated_set()
+ *
+ * @ingroup Image
+ * @since 1.1
+ */
+EAPI Eina_Bool elm_image_animated_available_get(const Evas_Object *obj);
+
+/**
+ * Set whether an image object (which supports animation) is to
+ * animate itself or not.
+ *
+ * @param obj The image object
+
+ * @param animated @c EINA_TRUE if the object is to animate itself,
+ * @c EINA_FALSE otherwise. Default is @c EINA_FALSE.
+ *
+ * An image object, even if it supports animation, will be displayed
+ * by default without animation. Call this function with @a animated
+ * set to @c EINA_TRUE to enable its animation. To start or stop the
+ * animation, actually, use elm_image_animated_play_set().
+ *
+ * @see elm_image_animated_get()
+ * @see elm_image_animated_available_get()
+ * @see elm_image_animated_play_set()
+ *
+ * @ingroup Image
+ * @since 1.1
+ */
+EAPI void elm_image_animated_set(Evas_Object *obj, Eina_Bool animated);
+
+/**
+ * Get whether an image object has animation enabled or not.
+ *
+ * @param obj The image object
+ *
+ * @return @c EINA_TRUE if the image has animation enabled,
+ * @c EINA_FALSE otherwise.
+ *
+ * @see elm_image_animated_set()
+ *
+ * @ingroup Image
+ * @since 1.1
+ */
+EAPI Eina_Bool elm_image_animated_get(const Evas_Object *obj);
+
+/**
+ * Start or stop an image object's animation.
+ *
+ * @param obj The image object
+ * @param play @c EINA_TRUE to start the animation, @c EINA_FALSE
+ * otherwise. Default is @c EINA_FALSE.
+ *
+ * To actually start playing any image object's animation, if it
+ * supports it, one must do something like:
+ *
+ * @code
+ * if (elm_image_animated_available_get(img))
+ * {
+ * elm_image_animated_set(img, EINA_TRUE);
+ * elm_image_animated_play_set(img, EINA_TRUE);
+ * }
+ * @endcode
+ *
+ * elm_image_animated_set() will enable animation on the image, <b>but
+ * not start it yet</b>. This is the function one uses to start and
+ * stop animations on image objects.
+ *
+ * @see elm_image_animated_available_get()
+ * @see elm_image_animated_set()
+ * @see elm_image_animated_play_get()
+ *
+ * @ingroup Image
+ * @since 1.1
+ */
+EAPI void elm_image_animated_play_set(Evas_Object *obj, Eina_Bool play);
+
+/**
+ * Get whether an image object is under animation or not.
+ *
+ * @param obj The image object
+ * @return @c EINA_TRUE, if the image is being animated, @c EINA_FALSE
+ * otherwise.
+ *
+ * @see elm_image_animated_play_get()
+ *
+ * @ingroup Image
+ * @since 1.1
+ */
+EAPI Eina_Bool elm_image_animated_play_get(const Evas_Object *obj);
+
+/**
* @}
*/
Eina_List *edje_signals;
+ int frame_count;
+ int cur_frame;
+ double frame_duration;
+
Eina_Bool aspect_fixed : 1;
Eina_Bool fill_inside : 1;
Eina_Bool scale_down : 1;
Eina_Bool show : 1;
Eina_Bool edit : 1;
Eina_Bool edje : 1;
+ Eina_Bool anim : 1;
+ Eina_Bool play : 1;
+
+ Ecore_Timer *anim_timer;
};
/**