forked from enlightenment/efl
Elm_thumb as an edje external.
There's a bug while adding it at Editje: it will draw itself over the part moving knob. Fixing it later. SVN revision: 47632
This commit is contained in:
parent
341d5cff52
commit
8483246729
|
@ -19,6 +19,7 @@ ico_notepad.png \
|
|||
ico_radio.png \
|
||||
ico_scrolled_entry.png \
|
||||
ico_slider.png \
|
||||
ico_thumb.png \
|
||||
ico_toggle.png \
|
||||
ico_toolbar.png
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 147 B |
|
@ -20,5 +20,6 @@ ICON("notepad")
|
|||
ICON("radio")
|
||||
ICON("scrolled_entry")
|
||||
ICON("slider")
|
||||
ICON("thumb")
|
||||
ICON("toggle")
|
||||
ICON("toolbar")
|
||||
|
|
|
@ -36,6 +36,7 @@ elm_notepad.c \
|
|||
elm_radio.c \
|
||||
elm_scrolled_entry.c \
|
||||
elm_slider.c \
|
||||
elm_thumb.c \
|
||||
elm_toggle.c \
|
||||
elm_toolbar.c
|
||||
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "private.h"
|
||||
|
||||
typedef struct _Elm_Params_Thumb
|
||||
{
|
||||
const char *animate;
|
||||
Eina_Bool keep_aspect:1;
|
||||
Eina_Bool aspect_exists:1;
|
||||
} Elm_Params_Thumb;
|
||||
|
||||
static const char* choices[] = {"loop", "start", "stop"};
|
||||
/* static const char* default_anim = choices[0]; */
|
||||
|
||||
static Elm_Thumb_Animation_Setting
|
||||
_anim_setting_get(const char *anim_str)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
assert(sizeof(choices)/sizeof(choices[0]) == ELM_THUMB_ANIMATION_LAST);
|
||||
|
||||
for (i = 0; i < sizeof(choices); i++)
|
||||
{
|
||||
if (strcmp(anim_str, choices[i]) == 0)
|
||||
return i;
|
||||
}
|
||||
return ELM_THUMB_ANIMATION_LAST;
|
||||
}
|
||||
|
||||
static void
|
||||
external_thumb_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
|
||||
{
|
||||
const Elm_Params_Thumb *p;
|
||||
|
||||
if (to_params) p = to_params;
|
||||
else if (from_params) p = from_params;
|
||||
else return;
|
||||
|
||||
if (p->animate)
|
||||
{
|
||||
Elm_Thumb_Animation_Setting set = _anim_setting_get(p->animate);
|
||||
if (set == ELM_THUMB_ANIMATION_LAST) return;
|
||||
elm_thumb_animate_set(obj, set);
|
||||
}
|
||||
if (p->aspect_exists && p->keep_aspect)
|
||||
elm_thumb_keep_aspect_set(obj, p->keep_aspect);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
external_thumb_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
|
||||
{
|
||||
if (!strcmp(param->name, "animate"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
||||
{
|
||||
Elm_Thumb_Animation_Setting set = _anim_setting_get(param->s);
|
||||
if (set == ELM_THUMB_ANIMATION_LAST) return EINA_FALSE;
|
||||
elm_thumb_animate_set(obj, set);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(param->name, "aspect"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
||||
{
|
||||
elm_thumb_keep_aspect_set(obj, param->i);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
ERR("unknown parameter '%s' of type '%s'",
|
||||
param->name, edje_external_param_type_str(param->type));
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
external_thumb_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
|
||||
{
|
||||
if (!strcmp(param->name, "animate"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
||||
{
|
||||
Elm_Thumb_Animation_Setting anim_set = elm_thumb_animate_get(obj);
|
||||
|
||||
if (anim_set == ELM_THUMB_ANIMATION_LAST)
|
||||
return EINA_FALSE;
|
||||
|
||||
param->s = choices[anim_set];
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(param->name, "aspect"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
||||
{
|
||||
param->i = elm_thumb_keep_aspect_get(obj);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
ERR("unknown parameter '%s' of type '%s'",
|
||||
param->name, edje_external_param_type_str(param->type));
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void *
|
||||
external_thumb_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
|
||||
{
|
||||
Elm_Params_Thumb *mem;
|
||||
Edje_External_Param *param;
|
||||
const Eina_List *l;
|
||||
|
||||
mem = calloc(1, sizeof(Elm_Params_Thumb));
|
||||
if (!mem)
|
||||
return NULL;
|
||||
|
||||
EINA_LIST_FOREACH(params, l, param)
|
||||
{
|
||||
if (!strcmp(param->name, "animate"))
|
||||
mem->animate = eina_stringshare_add(param->s);
|
||||
else if (!strcmp(param->name, "aspect"))
|
||||
{
|
||||
mem->keep_aspect = !!param->i;
|
||||
mem->aspect_exists = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
static void
|
||||
external_thumb_params_free(void *params)
|
||||
{
|
||||
Elm_Params_Thumb *mem = params;
|
||||
|
||||
if (mem->animate)
|
||||
eina_stringshare_del(mem->animate);
|
||||
free(mem);
|
||||
}
|
||||
|
||||
static Edje_External_Param_Info external_thumb_params[] =
|
||||
{
|
||||
EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("animate", "loop", choices),
|
||||
EDJE_EXTERNAL_PARAM_INFO_BOOL("aspect"),
|
||||
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
|
||||
};
|
||||
|
||||
DEFINE_EXTERNAL_ICON_ADD(thumb, "thumb")
|
||||
|
||||
static Evas_Object *
|
||||
external_thumb_add(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *edje, const Eina_List *params __UNUSED__, const char *part_name)
|
||||
{
|
||||
Evas_Object *parent, *obj;
|
||||
parent = elm_widget_parent_widget_get(edje);
|
||||
if (!parent) parent = edje;
|
||||
elm_need_ethumb(); /* extra command needed */
|
||||
obj = elm_thumb_add(parent);
|
||||
external_signals_proxy(obj, edje, part_name);
|
||||
return obj;
|
||||
}
|
||||
DEFINE_EXTERNAL_TYPE(thumb, "Thumbnail")
|
|
@ -8,5 +8,6 @@ DEFINE_TYPE(notepad)
|
|||
DEFINE_TYPE(radio)
|
||||
DEFINE_TYPE(scrolled_entry)
|
||||
DEFINE_TYPE(slider)
|
||||
DEFINE_TYPE(thumb)
|
||||
DEFINE_TYPE(toggle)
|
||||
DEFINE_TYPE(toolbar)
|
||||
|
|
|
@ -192,7 +192,8 @@ extern "C" {
|
|||
{
|
||||
ELM_THUMB_ANIMATION_START = 0, /* Play animation once */
|
||||
ELM_THUMB_ANIMATION_LOOP, /* Keep playing animation until stop is requested */
|
||||
ELM_THUMB_ANIMATION_STOP
|
||||
ELM_THUMB_ANIMATION_STOP,
|
||||
ELM_THUMB_ANIMATION_LAST
|
||||
} Elm_Thumb_Animation_Setting;
|
||||
|
||||
#ifndef ELM_LIB_QUICKLAUNCH
|
||||
|
@ -658,7 +659,7 @@ extern "C" {
|
|||
};
|
||||
EAPI Evas_Object *elm_anchorview_add(Evas_Object *parent);
|
||||
EAPI void elm_anchorview_text_set(Evas_Object *obj, const char *text);
|
||||
EAPI const char *elm_anchorview_text_get(Evas_Object *obj);
|
||||
EAPI const char *elm_anchorview_text_get(const Evas_Object *obj);
|
||||
|
||||
EAPI void elm_anchorview_hover_parent_set(Evas_Object *obj, Evas_Object *parent);
|
||||
EAPI void elm_anchorview_hover_style_set(Evas_Object *obj, const char *style);
|
||||
|
@ -685,7 +686,7 @@ extern "C" {
|
|||
};
|
||||
EAPI Evas_Object *elm_anchorblock_add(Evas_Object *parent);
|
||||
EAPI void elm_anchorblock_text_set(Evas_Object *obj, const char *text);
|
||||
EAPI const char *elm_anchorblock_text_get(Evas_Object *obj);
|
||||
EAPI const char *elm_anchorblock_text_get(const Evas_Object *obj);
|
||||
EAPI void elm_anchorblock_hover_parent_set(Evas_Object *obj, Evas_Object *parent);
|
||||
EAPI void elm_anchorblock_hover_style_set(Evas_Object *obj, const char *style);
|
||||
EAPI void elm_anchorblock_hover_end(Evas_Object *obj);
|
||||
|
@ -717,9 +718,11 @@ extern "C" {
|
|||
EAPI void elm_thumb_file_set(Evas_Object *obj, const char *file, const char *key);
|
||||
EAPI void elm_thumb_file_get(const Evas_Object *obj, const char **file, const char **key);
|
||||
EAPI void elm_thumb_keep_aspect_set(Evas_Object *obj, Eina_Bool setting);
|
||||
EAPI Eina_Bool elm_thumb_keep_aspect_get(const Evas_Object *obj);
|
||||
EAPI void elm_thumb_align_set(Evas_Object *obj, float x_align, float y_align);
|
||||
EAPI void elm_thumb_align_get(const Evas_Object *obj, float *x, float *y);
|
||||
EAPI void elm_thumb_animate(Evas_Object *obj, Elm_Thumb_Animation_Setting s);
|
||||
EAPI void elm_thumb_animate_set(Evas_Object *obj, Elm_Thumb_Animation_Setting s);
|
||||
EAPI Elm_Thumb_Animation_Setting elm_thumb_animate_get(const Evas_Object *obj);
|
||||
EAPI Eina_Bool elm_thumb_ethumb_client_connected(void);
|
||||
#ifdef ELM_ETHUMB
|
||||
EAPI Ethumb_Client *elm_thumb_ethumb_client_get(void);
|
||||
|
|
|
@ -219,7 +219,7 @@ elm_anchorblock_text_set(Evas_Object *obj, const char *text)
|
|||
* @ingroup Anchorblock
|
||||
*/
|
||||
EAPI const char*
|
||||
elm_anchorblock_text_get(Evas_Object *obj)
|
||||
elm_anchorblock_text_get(const Evas_Object *obj)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
|
|
|
@ -213,7 +213,7 @@ elm_anchorview_text_set(Evas_Object *obj, const char *text)
|
|||
* @ingroup Anchorview
|
||||
*/
|
||||
EAPI const char*
|
||||
elm_anchorview_text_get(Evas_Object *obj)
|
||||
elm_anchorview_text_get(const Evas_Object *obj)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
|
|
|
@ -43,6 +43,7 @@ struct _Widget_Data
|
|||
const char *key;
|
||||
Ecore_Event_Handler *eeh;
|
||||
int id;
|
||||
Elm_Thumb_Animation_Setting anim_setting;
|
||||
Eina_Bool on_hold : 1;
|
||||
Eina_Bool is_video : 1;
|
||||
Eina_Bool is_generating : 1;
|
||||
|
@ -566,7 +567,9 @@ elm_thumb_file_get(const Evas_Object *obj, const char **file, const char **key)
|
|||
}
|
||||
|
||||
/**
|
||||
* Start animation if the thumbnail is an animated video.
|
||||
* Set the animation state for the thumb object. If its content is an animated
|
||||
* video, you may start/stop the animation or tell it to play continuously and
|
||||
* looping.
|
||||
*
|
||||
* @param obj The thumb object.
|
||||
* @param setting The animation setting.
|
||||
|
@ -576,10 +579,18 @@ elm_thumb_file_get(const Evas_Object *obj, const char **file, const char **key)
|
|||
* @ingroup Thumb
|
||||
*/
|
||||
EAPI void
|
||||
elm_thumb_animate(Evas_Object *obj, Elm_Thumb_Animation_Setting setting)
|
||||
elm_thumb_animate_set(Evas_Object *obj, Elm_Thumb_Animation_Setting setting)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
|
||||
if (setting < ELM_THUMB_ANIMATION_START ||
|
||||
setting >= ELM_THUMB_ANIMATION_LAST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
wd->anim_setting = setting;
|
||||
if (setting == ELM_THUMB_ANIMATION_LOOP)
|
||||
edje_object_signal_emit(wd->children.view, "animate_loop", "");
|
||||
else if (setting == ELM_THUMB_ANIMATION_START)
|
||||
|
@ -588,6 +599,26 @@ elm_thumb_animate(Evas_Object *obj, Elm_Thumb_Animation_Setting setting)
|
|||
edje_object_signal_emit(wd->children.view, "animate_stop", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation state for the thumb object.
|
||||
*
|
||||
* @param obj The thumb object.
|
||||
* @return getting The animation setting or @c ELM_THUMB_ANIMATION_LAST,
|
||||
* on errors.
|
||||
*
|
||||
* @see elm_thumb_file_get()
|
||||
*
|
||||
* @ingroup Thumb
|
||||
*/
|
||||
EAPI Elm_Thumb_Animation_Setting
|
||||
elm_thumb_animate_get(const Evas_Object *obj)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) ELM_THUMB_ANIMATION_LAST;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
|
||||
return wd->anim_setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the thumbnail exhibition should keep the image or video aspect.
|
||||
*
|
||||
|
@ -610,6 +641,25 @@ elm_thumb_keep_aspect_set(Evas_Object *obj, Eina_Bool setting)
|
|||
wd->keep_aspect = setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get back the aspect info set with @c elm_thumb_keep_aspect_set().
|
||||
*
|
||||
* @param obj The thumb object.
|
||||
* @return Whether the thumb object keeps or not the aspect for its content.
|
||||
*
|
||||
* @see elm_thumb_file_get()
|
||||
* @see elm_thumb_align_get()
|
||||
*
|
||||
* @ingroup Thumb
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
elm_thumb_keep_aspect_get(const Evas_Object *obj)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
return wd->keep_aspect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image/video's alignment within the thumbnail.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue