Elm slideshow as edje external, by Masaki.
SVN revision: 47780
This commit is contained in:
parent
10baacf024
commit
07702cd2f3
|
@ -27,7 +27,8 @@ ico_slider.png \
|
|||
ico_spinner.png \
|
||||
ico_thumb.png \
|
||||
ico_toggle.png \
|
||||
ico_toolbar.png
|
||||
ico_toolbar.png \
|
||||
ico_slideshow.png
|
||||
|
||||
icons.edj: Makefile $(EXTRA_DIST)
|
||||
$(EDJE_CC) $(EDJE_FLAGS) \
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
|
@ -29,3 +29,5 @@ ICON("spinner")
|
|||
ICON("thumb")
|
||||
ICON("toggle")
|
||||
ICON("toolbar")
|
||||
ICON("slideshow")
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ elm_slider.c \
|
|||
elm_spinner.c \
|
||||
elm_thumb.c \
|
||||
elm_toggle.c \
|
||||
elm_toolbar.c
|
||||
elm_toolbar.c \
|
||||
elm_slideshow.c
|
||||
|
||||
elm_la_LIBADD = $(top_builddir)/src/lib/libelementary.la
|
||||
elm_la_LDFLAGS = $(all_libraries) -no-undefined @lt_enable_auto_import@ -module -avoid-version -shared -fPIC
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
#include "private.h"
|
||||
|
||||
typedef struct _Elm_Params_Slideshow
|
||||
{
|
||||
int timeout;
|
||||
const char *transition;
|
||||
Eina_Bool loop:1;
|
||||
Eina_Bool timeout_exists:1;
|
||||
Eina_Bool loop_exists:1;
|
||||
} Elm_Params_Slideshow;
|
||||
|
||||
static const char *transitions[] = { "fade", "black_fade", "horizontal", "vertical",
|
||||
"square"};
|
||||
|
||||
static void
|
||||
external_slideshow_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
|
||||
{
|
||||
const Elm_Params_Slideshow *p;
|
||||
|
||||
if (to_params) p = to_params;
|
||||
else if (from_params) p = from_params;
|
||||
else return;
|
||||
|
||||
if (p->timeout_exists)
|
||||
elm_slideshow_timeout_set(obj , p->timeout);
|
||||
if (p->loop_exists)
|
||||
elm_slideshow_loop_set(obj, p->loop);
|
||||
if (p->transition) {
|
||||
elm_slideshow_transition_set(obj, p->transition);
|
||||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
external_slideshow_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
|
||||
{
|
||||
if (!strcmp(param->name, "timeout"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
|
||||
{
|
||||
elm_slideshow_timeout_set(obj, param->i);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(param->name, "loop"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
||||
{
|
||||
elm_slideshow_loop_set(obj, param->i);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(param->name, "transition"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
||||
{
|
||||
elm_slideshow_transition_set(obj, param->s);
|
||||
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_slideshow_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
|
||||
{
|
||||
if (!strcmp(param->name, "timeout"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
|
||||
{
|
||||
param->i = elm_slideshow_timeout_get(obj);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(param->name, "loop"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
||||
{
|
||||
param->i = elm_slideshow_loop_get(obj);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(param->name, "transition"))
|
||||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
||||
{
|
||||
param->s = elm_slideshow_transition_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_slideshow_params_parse(void *data, Evas_Object *obj, const Eina_List *params)
|
||||
{
|
||||
Elm_Params_Slideshow *mem;
|
||||
Edje_External_Param *param;
|
||||
const Eina_List *l;
|
||||
|
||||
mem = calloc(1, sizeof(Elm_Params_Slideshow));
|
||||
if (!mem)
|
||||
return NULL;
|
||||
|
||||
EINA_LIST_FOREACH(params, l, param)
|
||||
{
|
||||
if (!strcmp(param->name, "timeout"))
|
||||
{
|
||||
mem->timeout = param->i;
|
||||
mem->timeout_exists = EINA_TRUE;
|
||||
}
|
||||
else if (!strcmp(param->name, "loop"))
|
||||
{
|
||||
mem->loop = param->i;
|
||||
mem->loop_exists = EINA_TRUE;
|
||||
}
|
||||
else if (!strcmp(param->name, "transition"))
|
||||
{
|
||||
mem->transition = param->s;
|
||||
}
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
static void
|
||||
external_slideshow_params_free(void *params)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static Edje_External_Param_Info external_slideshow_params[] = {
|
||||
EDJE_EXTERNAL_PARAM_INFO_INT("timeout"),
|
||||
EDJE_EXTERNAL_PARAM_INFO_BOOL("loop"),
|
||||
EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("transition", "fade", transitions),
|
||||
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
|
||||
};
|
||||
|
||||
DEFINE_EXTERNAL_ICON_ADD(slideshow, "slideshow");
|
||||
DEFINE_EXTERNAL_TYPE_SIMPLE(slideshow, "Slideshow");
|
|
@ -17,3 +17,5 @@ DEFINE_TYPE(spinner)
|
|||
DEFINE_TYPE(thumb)
|
||||
DEFINE_TYPE(toggle)
|
||||
DEFINE_TYPE(toolbar)
|
||||
DEFINE_TYPE(slideshow)
|
||||
|
||||
|
|
|
@ -1026,9 +1026,11 @@ extern "C" {
|
|||
EAPI void elm_slideshow_previous(Evas_Object *obj);
|
||||
EAPI const Eina_List *elm_slideshow_transitions_get(const Evas_Object *obj);
|
||||
EAPI void elm_slideshow_transition_set(Evas_Object *obj, const char *);
|
||||
EAPI const char *elm_slideshow_transition_get(const Evas_Object *obj);
|
||||
EAPI void elm_slideshow_timeout_set(Evas_Object *obj ,int timeout);
|
||||
EAPI int elm_slideshow_timeout_get(const Evas_Object *obj);
|
||||
EAPI void elm_slideshow_loop_set(Evas_Object *obj, int loop);
|
||||
EAPI void elm_slideshow_loop_set(Evas_Object *obj, Eina_Bool loop);
|
||||
EAPI Eina_Bool elm_slideshow_loop_get(const Evas_Object *obj);
|
||||
EAPI void elm_slideshow_clear(Evas_Object *obj);
|
||||
EAPI const Eina_List *elm_slideshow_items_get(const Evas_Object *obj);
|
||||
EAPI void elm_slideshow_item_del(Elm_Slideshow_Item *item);
|
||||
|
|
|
@ -38,13 +38,13 @@ struct _Widget_Data
|
|||
Eina_List *items_built;
|
||||
Elm_Slideshow_Item *current;
|
||||
Elm_Slideshow_Item *previous;
|
||||
int loop;
|
||||
|
||||
Eina_List *transitions;
|
||||
const char *transition;
|
||||
|
||||
Ecore_Timer *timer;
|
||||
int timeout;
|
||||
Eina_Bool loop:1;
|
||||
};
|
||||
|
||||
static const char *widtype = NULL;
|
||||
|
@ -412,6 +412,21 @@ elm_slideshow_transition_set(Evas_Object *obj, const char *transition)
|
|||
eina_stringshare_replace(&wd->transition, transition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the transition to use
|
||||
*
|
||||
* @param obj The slideshow object
|
||||
* @return the transition set
|
||||
*/
|
||||
EAPI const char *
|
||||
elm_slideshow_transition_get(const Evas_Object *obj)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return NULL;
|
||||
return wd->transition;
|
||||
}
|
||||
|
||||
/**
|
||||
* The slideshow can go to the next item automatically after a few seconds.
|
||||
* This method set the timeout to use. A timeout <=0 disable the timer.
|
||||
|
@ -451,10 +466,10 @@ elm_slideshow_timeout_get(const Evas_Object *obj)
|
|||
* Set if the first item should follow the last and vice versa
|
||||
*
|
||||
* @param obj The slideshow object
|
||||
* @param loop if 1, the first item will follow the last and vice versa
|
||||
* @param loop if EINA_TRUE, the first item will follow the last and vice versa
|
||||
*/
|
||||
EAPI void
|
||||
elm_slideshow_loop_set(Evas_Object *obj, int loop)
|
||||
elm_slideshow_loop_set(Evas_Object *obj, Eina_Bool loop)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
|
@ -462,6 +477,21 @@ elm_slideshow_loop_set(Evas_Object *obj, int loop)
|
|||
wd->loop = loop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if the first item should follow the last and vice versa
|
||||
*
|
||||
* @param obj The slideshow object
|
||||
* @returns Returns the loop flag
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
elm_slideshow_loop_get(const Evas_Object *obj)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return EINA_FALSE;
|
||||
return wd->loop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all the items
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue