slideshow_example.c
#include <Elementary.h>
#define IMG_NUM 8
static Evas_Object *slideshow, *bt_start, *bt_stop;
static Elm_Slideshow_Item_Class itc;
static void
_notify_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
evas_object_show(data);
}
/* jump to next item, cyclically */
static void
_next(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_next(data);
}
static void
_previous(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_previous(data);
}
static void
_first(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_item_show(data);
}
static void
_last(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_item_show(data);
}
static void
_mouse_in_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_notify_timeout_set(data, 0.0);
evas_object_show(data);
}
static void
_mouse_out_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_notify_timeout_set(data, 3.0);
}
/* transition changed */
static void
_transition_select(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
elm_slideshow_transition_set(slideshow, data);
elm_object_text_set(obj, data);
}
static void
_layout_select(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
elm_slideshow_layout_set(slideshow, data);
elm_object_text_set(obj, data);
}
/* start the show! */
static void
_start(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
elm_object_disabled_set(bt_start, EINA_TRUE);
elm_object_disabled_set(bt_stop, EINA_FALSE);
}
static void
_stop(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_slideshow_timeout_set(slideshow, 0.0);
elm_object_disabled_set(bt_start, EINA_FALSE);
elm_object_disabled_set(bt_stop, EINA_TRUE);
}
/* slideshow transition time has changed */
static void
_spin(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
if (elm_slideshow_timeout_get(slideshow) > 0)
elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
}
/* get our images to make slideshow items */
static Evas_Object *
_get(void *data, Evas_Object *obj)
{
Evas_Object *photo = elm_photo_add(obj);
elm_photo_file_set(photo, data);
elm_photo_fill_inside_set(photo, EINA_TRUE);
elm_object_style_set(photo, "shadow");
return photo;
}
/* ordering alphabetically */
static int
_cmp_func(const void *data1, const void *data2)
{
const char *img_path1, *img_path2;
const Elm_Object_Item *slide_it1 = data1;
const Elm_Object_Item *slide_it2 = data2;
img_path1 = elm_object_item_data_get(slide_it1);
img_path2 = elm_object_item_data_get(slide_it2);
return strcasecmp(img_path1, img_path2);
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *win, *notify, *bx, *bt, *hv, *spin;
Elm_Object_Item *slide_first = NULL, *slide_last = NULL, *slide_it = NULL;
const char *transition, *layout;
const Eina_List *l, *list;
const char *data_dir;
char img[IMG_NUM][PATH_MAX];
char *img_files[] =
{
"logo.png", "plant_01.jpg", "rock_01.jpg", "rock_02.jpg", "sky_01.jpg",
"wood_01.jpg", "mystrale.jpg", "mystrale_2.jpg"
};
int i = 0;
elm_app_info_set(elm_main, "elementary", "images");
data_dir = elm_app_data_dir_get();
for (i = 0; i < IMG_NUM; i++)
snprintf(img[i], PATH_MAX, "%s/images/%s", data_dir, img_files[i]);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("slideshow", "Slideshow example");
elm_win_autodel_set(win, EINA_TRUE);
slideshow = elm_slideshow_add(win);
elm_slideshow_loop_set(slideshow, EINA_TRUE);
evas_object_size_hint_weight_set(slideshow,
EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, slideshow);
evas_object_show(slideshow);
itc.func.get = _get;
itc.func.del = NULL;
for (i = 0; i < IMG_NUM; i++)
{
slide_it = elm_slideshow_item_sorted_insert(slideshow, &itc, img[i],
_cmp_func);
if (!slide_first) slide_first = slide_it;
}
slide_last = slide_it;
list = elm_slideshow_items_get(slideshow);
printf("List of items in the slideshow:\n");
EINA_LIST_FOREACH(list, l, slide_it)
printf("\t%s\n",
(const char *)elm_object_item_data_get(slide_it));
notify = elm_notify_add(win);
elm_notify_align_set(notify, 0.5, 1.0);
evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_notify_timeout_set(notify, 3.0);
evas_object_show(notify);
bx = elm_box_add(win);
elm_box_horizontal_set(bx, EINA_TRUE);
elm_object_content_set(notify, bx);
evas_object_show(bx);
evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_IN,
_mouse_in_cb, notify);
evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_OUT,
_mouse_out_cb, notify);
bt = elm_button_add(win);
elm_object_text_set(bt, "First");
evas_object_smart_callback_add(bt, "clicked", _first, slide_first);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Previous");
evas_object_smart_callback_add(bt, "clicked", _previous, slideshow);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Next");
evas_object_smart_callback_add(bt, "clicked", _next, slideshow);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Last");
evas_object_smart_callback_add(bt, "clicked", _last, slide_last);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
hv = elm_hoversel_add(win);
elm_box_pack_end(bx, hv);
elm_hoversel_hover_parent_set(hv, win);
EINA_LIST_FOREACH(elm_slideshow_transitions_get(slideshow), l, transition)
elm_hoversel_item_add(hv, transition, NULL, 0, _transition_select,
transition);
elm_object_text_set(hv, eina_list_data_get(
elm_slideshow_transitions_get(slideshow)));
evas_object_show(hv);
hv = elm_hoversel_add(win);
elm_box_pack_end(bx, hv);
elm_hoversel_hover_parent_set(hv, win);
EINA_LIST_FOREACH(elm_slideshow_layouts_get(slideshow), l, layout)
elm_hoversel_item_add(hv, layout, NULL, 0, _layout_select, layout);
elm_object_text_set(hv, elm_slideshow_layout_get(slideshow));
evas_object_show(hv);
spin = elm_spinner_add(win);
elm_spinner_label_format_set(spin, "%2.0f s");
evas_object_smart_callback_add(spin, "changed", _spin, spin);
elm_spinner_step_set(spin, 1);
elm_spinner_min_max_set(spin, 1, 30);
elm_spinner_value_set(spin, 3);
elm_box_pack_end(bx, spin);
evas_object_show(spin);
bt = elm_button_add(win);
bt_start = bt;
elm_object_text_set(bt, "Start");
evas_object_smart_callback_add(bt, "clicked", _start, spin);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
bt_stop = bt;
elm_object_text_set(bt, "Stop");
evas_object_smart_callback_add(bt, "clicked", _stop, spin);
elm_box_pack_end(bx, bt);
elm_object_disabled_set(bt, EINA_TRUE);
evas_object_show(bt);
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_UP,
_notify_show, notify);
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE,
_notify_show, notify);
evas_object_resize(win, 600, 400);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()
EVAS_HINT_EXPAND
#define EVAS_HINT_EXPAND
Use with evas_object_size_hint_weight_set(), evas_object_size_hint_weight_get(), evas_object_size_hin...
Definition Evas_Common.h:297
EVAS_CALLBACK_MOUSE_MOVE
@ EVAS_CALLBACK_MOUSE_MOVE
Mouse Move Event.
Definition Evas_Common.h:424
EVAS_CALLBACK_MOUSE_IN
@ EVAS_CALLBACK_MOUSE_IN
Mouse In Event.
Definition Evas_Common.h:420
EVAS_CALLBACK_MOUSE_UP
@ EVAS_CALLBACK_MOUSE_UP
Mouse Button Up Event.
Definition Evas_Common.h:423
EVAS_CALLBACK_MOUSE_OUT
@ EVAS_CALLBACK_MOUSE_OUT
Mouse Out Event.
Definition Evas_Common.h:421
Eina_List
struct _Eina_List Eina_List
Type for a generic double linked list.
Definition eina_list.h:304
EINA_LIST_FOREACH
#define EINA_LIST_FOREACH(list, l, _data)
Definition for the macro to iterate over a list.
Definition eina_list.h:1415
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition eina_types.h:539
EINA_FALSE
#define EINA_FALSE
boolean value FALSE (numerical value 0)
Definition eina_types.h:533
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition eina_types.h:339
elm_app_info_set
void elm_app_info_set(void *mainfunc, const char *dom, const char *checkfile)
Re-locate the application somewhere else after compilation, if the developer wishes for easier distri...
Definition elm_main.c:496
elm_app_data_dir_get
const char * elm_app_data_dir_get(void)
Get the application's run time data prefix directory, as set by elm_app_info_set() and the way (envir...
Definition elm_main.c:586
elm_box_horizontal_set
void elm_box_horizontal_set(Elm_Box *obj, Eina_Bool horizontal)
Set the horizontal orientation.
Definition elm_box_eo.legacy.c:27
elm_box_add
Evas_Object * elm_box_add(Evas_Object *parent)
Add a new box to the parent.
Definition elm_box.c:363
elm_box_pack_end
void elm_box_pack_end(Elm_Box *obj, Efl_Canvas_Object *subobj)
Add an object at the end of the pack list.
Definition elm_box_eo.legacy.c:57
elm_button_add
Evas_Object * elm_button_add(Evas_Object *parent)
Add a new button to the parent's canvas.
Definition efl_ui_button.c:459
ELM_MAIN
#define ELM_MAIN()
macro to be used after the elm_main() function
Definition elm_general.h:556
elm_object_item_data_get
void * elm_object_item_data_get(const Elm_Object_Item *it)
Get the data associated with an object item.
Definition efl_ui_widget.c:3796
elm_object_disabled_set
void elm_object_disabled_set(Evas_Object *obj, Eina_Bool disabled)
Set the disabled state of an Elementary object.
Definition elm_main.c:1613
elm_policy_set
Eina_Bool elm_policy_set(unsigned int policy, int value)
Set a new policy's value (for a given policy group/identifier).
Definition elm_main.c:1380
Elm_Object_Item
Eo Elm_Object_Item
An Elementary Object item handle.
Definition elm_object_item.h:6
elm_run
void elm_run(void)
Run Elementary's main loop.
Definition elm_main.c:1357
ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
@ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
quit when the application's last window is closed
Definition elm_general.h:248
ELM_POLICY_QUIT
@ ELM_POLICY_QUIT
under which circumstances the application should quit automatically.
Definition elm_general.h:227
elm_hoversel_add
Evas_Object * elm_hoversel_add(Evas_Object *parent)
Add a new Hoversel object.
Definition elc_hoversel.c:703
elm_notify_align_set
void elm_notify_align_set(Elm_Notify *obj, double horizontal, double vertical)
Set the alignment of the notify object.
Definition elm_notify_eo.legacy.c:3
elm_notify_add
Evas_Object * elm_notify_add(Evas_Object *parent)
Add a new notify to the parent.
Definition elm_notify.c:478
elm_notify_timeout_set
void elm_notify_timeout_set(Elm_Notify *obj, double timeout)
Set the time interval after which the notify window is going to be hidden.
Definition elm_notify_eo.legacy.c:27
elm_photo_file_set
Eina_Bool elm_photo_file_set(Eo *obj, const char *file)
Set the file that will be used as the photo widget's image.
Definition elm_photo.c:409
elm_photo_fill_inside_set
void elm_photo_fill_inside_set(Evas_Object *obj, Eina_Bool fill)
Set if the photo should be completely visible or not.
Definition elm_photo.c:452
elm_photo_add
Evas_Object * elm_photo_add(Evas_Object *parent)
Add a new photo to the parent.
Definition elm_photo.c:310
elm_slideshow_add
Evas_Object * elm_slideshow_add(Evas_Object *parent)
Add a new slideshow widget to the given parent Elementary (container) object.
Definition elm_slideshow.c:356
Elm_Slideshow_Item_Class
struct _Elm_Slideshow_Item_Class Elm_Slideshow_Item_Class
Slideshow item class definition struct.
Definition elm_slideshow_common.h:13
elm_spinner_value_get
double elm_spinner_value_get(const Evas_Object *obj)
Control the value the spinner displays.
Definition elm_spinner.c:1387
elm_spinner_add
Evas_Object * elm_spinner_add(Evas_Object *parent)
Add a new spinner widget to the given parent Elementary (container) object.
Definition elm_spinner.c:1350
elm_spinner_label_format_set
void elm_spinner_label_format_set(Elm_Spinner *obj, const char *fmt)
Control the format string of the displayed label.
Definition elm_spinner_eo.legacy.c:63
elm_spinner_min_max_set
void elm_spinner_min_max_set(Evas_Object *obj, double min, double max)
Control the minimum and maximum values for the spinner.
Definition elm_spinner.c:1357
elm_spinner_step_set
void elm_spinner_step_set(Evas_Object *obj, double step)
Control the step used to increment or decrement the spinner value.
Definition elm_spinner.c:1369
elm_spinner_value_set
void elm_spinner_value_set(Evas_Object *obj, double val)
Control the value the spinner displays.
Definition elm_spinner.c:1381
elm_object_style_set
Eina_Bool elm_object_style_set(Evas_Object *obj, const char *style)
Set the style to used by a given widget.
Definition elm_main.c:1583
elm_win_util_standard_add
Evas_Object * elm_win_util_standard_add(const char *name, const char *title)
Adds a window object with standard setup.
Definition efl_ui_win.c:9587
elm_win_resize_object_add
void elm_win_resize_object_add(Eo *obj, Evas_Object *subobj)
Add subobj as a resize object of window obj.
Definition efl_ui_win.c:9002
elm_win_autodel_set
void elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
Set the window's autodel state.
Definition efl_ui_win.c:6199
Evas
Eo Evas
An opaque handle to an Evas canvas.
Definition Evas_Common.h:163
evas_object_show
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition evas_object_main.c:1814
evas_object_event_callback_add
EVAS_API void evas_object_event_callback_add(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
Add (register) a callback function to a given Evas object event.
Definition evas_callbacks.c:478
evas_object_size_hint_weight_set
EVAS_API void evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's weight.
Definition evas_object_main.c:2638
Evas_Object
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition Evas_Common.h:185
evas_object_resize
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition evas_object_main.c:1236
evas_object_smart_callback_add
EVAS_API void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition evas_object_smart.c:1040