New widget: Hoverlist.

This is one more widget whose idea came from Samsung Electronics.  Its
first name was "context popup". There was no common agreement on a
name for it, so... Trator mode, for now (using hoversel as a pattern).
If you have a better name suggestion for it, just change it -- but
soon, due to releasing plans (in a mailbox near in a jiffy).

While for hoversels you populate slots with thingies to later choose
one of them, which will hover up for you, with hoverlists you get a
single hovering list. It will smartly place this -- unique -- list
onto a fitting place inside its parent widget view. Just call
evas_object_show() on it, anytime you want (like for notifies).



SVN revision: 53644
This commit is contained in:
Gustavo Lima Chaves 2010-10-19 20:21:53 +00:00
parent c530774aaf
commit a8ac37368d
12 changed files with 1895 additions and 4 deletions

View File

@ -206,8 +206,11 @@ color_picker_alpha.png \
color_picker_alpha_bg.png \
color_picker_brightness.png \
color_picker_color.png \
color_picker_opacity.png
color_picker_opacity.png \
icon_arrow_down_left.png \
icon_arrow_down_right.png \
icon_arrow_up_left.png \
icon_arrow_up_right.png
default.edj: Makefile $(EXTRA_DIST)
$(EDJE_CC) $(EDJE_FLAGS) \

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -91,7 +91,8 @@ test_focus.c \
test_focus2.c \
test_flippicker.c \
test_diskpicker.c \
test_colorpicker.c
test_colorpicker.c \
test_hoverlist.c
elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la @ELEMENTARY_EWEATHER_LIBS@
elementary_test_LDFLAGS =

View File

@ -101,6 +101,7 @@ void test_focus2(void *data, Evas_Object *obj, void *event_info);
void test_flippicker(void *data, Evas_Object *obj, void *event_info);
void test_diskpicker(void *data, Evas_Object *obj, void *event_info);
void test_colorpicker(void *data, Evas_Object *obj, void *event_info);
void test_hoverlist(void *data, Evas_Object *obj, void *event_info);
struct elm_test
{
@ -319,6 +320,7 @@ my_win_main(char *autorun)
ADD_TEST("Flippicker", test_flippicker);
ADD_TEST("Diskpicker", test_diskpicker);
ADD_TEST("Colorpicker", test_colorpicker);
ADD_TEST("Hoverlist", test_hoverlist);
#undef ADD_TEST
if (autorun)

View File

@ -0,0 +1,116 @@
#include <Elementary.h>
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#ifndef ELM_LIB_QUICKLAUNCH
static void
_list_item_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
evas_object_show(data);
}
static void
_hoverlist_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
printf("hoverlist item selected: %s\n",
elm_hoverlist_item_label_get(event_info));
}
static void _list_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
elm_list_item_selected_set(event_info, EINA_FALSE);
}
void
test_hoverlist(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *list, *hov1, *hov2, *hov3, *hov4, *ic;
Elm_Hoverlist_Item *it;
win = elm_win_add(NULL, "Contexual Popup 2", ELM_WIN_BASIC);
elm_win_title_set(win, "Contextual Popup 2");
elm_win_autodel_set(win, EINA_TRUE);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
list = elm_list_add(win);
elm_win_resize_object_add(win, list);
elm_list_mode_set(list, ELM_LIST_COMPRESS);
evas_object_smart_callback_add(list, "selected", _list_clicked, NULL);
#define ITEM_NEW(_hov, _icon, _label) \
ic = elm_icon_add(win); \
elm_icon_standard_set(ic, _icon); \
elm_icon_scale_set(ic, EINA_FALSE, EINA_FALSE); \
it = elm_hoverlist_item_append(_hov, _label, ic, _hoverlist_item_cb, NULL);
hov1 = elm_hoverlist_add(win);
ITEM_NEW(hov1, "home", "Go to home folder");
ITEM_NEW(hov1, "file", "Save file");
ITEM_NEW(hov1, "delete", "Delete file");
ITEM_NEW(hov1, "folder", "Navigate to folder");
elm_hoverlist_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(hov1, "edit", "Edit entry");
ITEM_NEW(hov1, "clock", "Set date and time");
ITEM_NEW(hov1, "arrow_up", "Go up");
ITEM_NEW(hov1, "arrow_down", "Go down");
ITEM_NEW(hov1, "arrow_left", "Go left");
elm_hoverlist_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(hov1, "arrow_right", "Go right");
hov2 = elm_hoverlist_add(win);
ITEM_NEW(hov2, "home", NULL);
ITEM_NEW(hov2, "file", NULL);
ITEM_NEW(hov2, "delete", NULL);
ITEM_NEW(hov2, "folder", NULL);
ITEM_NEW(hov2, "edit", NULL);
elm_hoverlist_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(hov2, "clock", NULL);
ITEM_NEW(hov2, "arrow_up", NULL);
ITEM_NEW(hov2, "arrow_down", NULL);
ITEM_NEW(hov2, "arrow_left", NULL);
ITEM_NEW(hov2, "arrow_right", NULL);
hov3 = elm_hoverlist_add(win);
elm_hoverlist_horizontal_set(hov3, EINA_TRUE);
ITEM_NEW(hov3, "home", "Zero");
ITEM_NEW(hov3, "file", "Um");
ITEM_NEW(hov3, "delete", "Dos");
ITEM_NEW(hov3, "folder", "Tri");
ITEM_NEW(hov3, "edit", "Vier");
ITEM_NEW(hov3, "clock", "");
hov4 = elm_hoverlist_add(win);
ITEM_NEW(hov4, NULL, "Eina");
ITEM_NEW(hov4, NULL, "Eet");
ITEM_NEW(hov4, NULL, "Evas");
ITEM_NEW(hov4, NULL, "Ecore");
elm_hoverlist_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(hov4, NULL, "Embryo");
ITEM_NEW(hov4, NULL, "Edje");
#undef ITEM_NEW
elm_list_item_append(list, "Hoverlist with icons and labels", NULL, NULL,
_list_item_cb, hov1);
elm_list_item_append(list, "Hoverlist with icons only", NULL, NULL,
_list_item_cb, hov2);
elm_list_item_append(list, "Hoverlist at horizontal mode", NULL, NULL,
_list_item_cb, hov3);
elm_list_item_append(list, "Hoverlist with no icons", NULL, NULL,
_list_item_cb, hov4);
evas_object_show(list);
elm_list_go(list);
evas_object_resize(win, 300, 300);
evas_object_show(win);
}
#endif

View File

@ -2058,12 +2058,33 @@ extern "C" {
* "changed" - when the color value changes
*/
/* Hoverlist */
typedef struct _Elm_Hoverlist_Item Elm_Hoverlist_Item;
EAPI Evas_Object *elm_hoverlist_add(Evas_Object* parent);
EAPI void elm_hoverlist_hover_end(Evas_Object *obj);
EAPI Evas_Object *elm_hoverlist_item_icon_get(const Elm_Hoverlist_Item *item);
EAPI void elm_hoverlist_item_icon_set(Elm_Hoverlist_Item *item, Evas_Object *icon);
EAPI const char *elm_hoverlist_item_label_get(const Elm_Hoverlist_Item *item);
EAPI void elm_hoverlist_item_label_set(Elm_Hoverlist_Item *item, const char *label);
EAPI void elm_hoverlist_hover_parent_set(Evas_Object *obj, Evas_Object *parent);
EAPI Evas_Object *elm_hoverlist_hover_parent_get(const Evas_Object *obj);
EAPI void elm_hoverlist_clear(Evas_Object* obj);
EAPI void elm_hoverlist_horizontal_set(Evas_Object* obj, Eina_Bool horizontal);
EAPI Eina_Bool elm_hoverlist_horizontal_get(const Evas_Object *obj);
EAPI Elm_Hoverlist_Item *elm_hoverlist_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data);
EAPI void elm_hoverlist_item_del(Elm_Hoverlist_Item *item);
EAPI void elm_hoverlist_item_disabled_set(Elm_Hoverlist_Item *item, Eina_Bool disabled);
EAPI Eina_Bool elm_hoverlist_item_disabled_get(const Elm_Hoverlist_Item *item);
/* smart callbacks called:
* "dismissed" - the hoverlist was dismissed
*/
/* debug
* don't use it unless you are sure
*/
EAPI void elm_object_tree_dump(const Evas_Object *top);
EAPI void elm_object_tree_dot_dump(const Evas_Object *top, const char *file);
#ifdef __cplusplus
}
#endif

View File

@ -93,6 +93,7 @@ elc_fileselector.c \
elc_fileselector_button.c \
elc_fileselector_entry.c \
elc_hoversel.c \
elc_hoverlist.c \
elc_notepad.c \
elc_scrolled_entry.c \
\

View File

@ -0,0 +1,709 @@
#include <Elementary.h>
#include "elm_priv.h"
/* TODO: steal focus when shown? */
/* TODO: event hooks, then */
/**
* @addtogroup Hoverlist
*
* A hoverlist is a widget that, when show, pops up a list of items.
* It automatically chooses an area inside its parent object's view
* (set via elm_hoverlist_add() and elm_hoverlist_hover_parent_set())
* to optimally fit into it. In the default theme, it will also point
* an arrow to the cursor position at the time one shows it. Hoverlist
* items have a label and/or an icon. It is intended for a small
* number of items (hence the use of list, not genlist).
*
* Signals that you can add callbacks for are:
*
* dismissed - the hover was dismissed
*/
typedef struct _Widget_Data Widget_Data;
struct _Elm_Hoverlist_Item
{
Elm_Widget_Item base;
Elm_List_Item *lptr;
const char *label;
Evas_Object *icon;
Evas_Smart_Cb func;
const void *data;
Eina_Bool disabled : 1;
};
struct _Widget_Data
{
Evas_Object *hover_parent;
Evas_Object *list;
Evas_Object *target;
Evas_Object *hover;
Evas *evas;
Eina_List *items;
Eina_Bool scroller_disabled : 1;
Eina_Bool horizontal : 1;
};
static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj);
static void _del_pre_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _hover_clicked_cb(void *data, Evas_Object *obj, void *event_info);
static void _parent_resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void _hoverlist_show(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void _hoverlist_hide(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static const char SIG_DISMISSED[] = "dismissed";
static const Evas_Smart_Cb_Description _signals[] = {
{SIG_DISMISSED, ""},
{NULL, NULL}
};
#define ELM_HOVERLIST_ITEM_CHECK_RETURN(it, ...) \
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
ELM_CHECK_WIDTYPE(item->base.widget, widtype) __VA_ARGS__;
static Elm_Hoverlist_Item *
_item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
{
Elm_Hoverlist_Item *it;
Widget_Data *wd;
wd = elm_widget_data_get(obj);
it = elm_widget_item_new(obj, Elm_Hoverlist_Item);
if (!it)
return NULL;
it->label = eina_stringshare_add(label);
it->icon = icon;
it->func = func;
it->base.data = data;
return it;
}
static inline void
_item_free(Elm_Hoverlist_Item *it)
{
eina_stringshare_del(it->label);
elm_widget_item_del(it);
}
static void
_del_pre_hook(Evas_Object* obj)
{
Widget_Data * wd = elm_widget_data_get(obj);
if (!wd)
return;
evas_object_event_callback_del_full(wd->hover_parent, EVAS_CALLBACK_RESIZE,
_parent_resize_cb, obj);
}
static void
_del_hook(Evas_Object* obj)
{
Elm_Hoverlist_Item *it;
Widget_Data *wd;
wd = elm_widget_data_get(obj);
if (!wd)
return;
EINA_LIST_FREE(wd->items, it)
_item_free(it);
free(wd);
}
static Eina_Bool
_event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
{
if (type != EVAS_CALLBACK_KEY_DOWN)
return EINA_FALSE;
Evas_Event_Key_Down *ev = event_info;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd)
return EINA_FALSE;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
return EINA_FALSE;
if (strcmp(ev->keyname, "Escape"))
return EINA_FALSE;
evas_object_hide(obj);
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
return EINA_TRUE;
}
static void
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd)
return;
if (elm_widget_focus_get(obj))
{
edje_object_signal_emit(wd->list, "elm,action,focus", "elm");
evas_object_focus_set(wd->list, EINA_TRUE);
}
else
{
edje_object_signal_emit(wd->list, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->list, EINA_FALSE);
}
}
static void
_theme_hook(Evas_Object* obj)
{
Widget_Data* wd;
char buf[1024];
wd = elm_widget_data_get(obj);
if (!wd)
return;
elm_widget_style_set(wd->list, "hoverlist");
snprintf(buf, sizeof(buf), "hoverlist/%s", elm_widget_style_get(obj));
elm_object_style_set(wd->hover, buf);
}
static void
_item_func_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
{
Elm_Hoverlist_Item *it;
elm_list_item_selected_set(event_info, EINA_FALSE);
it = data;
if (it->func)
it->func((void *)it->base.data, it->base.widget, it);
}
static void
_hover_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
evas_object_hide(data);
}
void
_content_placement_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
{
const char *new_slot;
Widget_Data *wd;
char buf[1024];
wd = elm_widget_data_get(data);
new_slot = event_info;
snprintf(buf, sizeof(buf), "elm,action,slot,%s,show", new_slot);
elm_widget_signal_emit(wd->hover, buf, "elm");
}
static void
_hoverlist_show(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
Widget_Data* wd;
int px, py;
int w, h;
wd = elm_widget_data_get(obj);
if (eina_list_count(wd->items) < 1)
return;
elm_widget_focus_steal(obj);
evas_pointer_canvas_xy_get(wd->evas, &px, &py);
evas_object_geometry_get(wd->target, NULL, NULL, &w, &h);
evas_object_move(wd->target, px - (w / 2), py - (h / 2));
/* reset list */
elm_list_item_show(eina_list_data_get(elm_list_items_get(wd->list)));
evas_object_show(wd->hover);
}
static void
_hoverlist_hide(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd)
return;
evas_object_hide(wd->hover);
evas_object_smart_callback_call(obj, SIG_DISMISSED, NULL);
}
static void
_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Widget_Data *wd = elm_widget_data_get(data);
if (!wd)
return;
wd->hover_parent = NULL;
}
static void
_parent_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Widget_Data *wd;
int w, h;
wd = elm_widget_data_get(data);
if (!wd)
return;
evas_object_geometry_get(wd->hover_parent, NULL, NULL, &w, &h);
evas_object_size_hint_max_set(wd->list, w * 0.666667, h/2);
}
/**
* Add a new Hoverlist object to the parent.
*
* @param parent Parent object
* @return New object or @c NULL, if it cannot be created
*
* @ingroup Hoverlist
*/
EAPI Evas_Object*
elm_hoverlist_add(Evas_Object* parent)
{
Evas_Object* obj;
Widget_Data* wd;
char buf[1024];
wd = ELM_NEW(Widget_Data);
wd->evas = evas_object_evas_get(parent);
obj = elm_widget_add(wd->evas);
ELM_SET_WIDTYPE(widtype, "hoverlist");
elm_widget_type_set(obj, "hoverlist");
elm_widget_sub_object_add(parent, obj);
elm_widget_data_set(obj, wd);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_can_focus_set(obj, EINA_TRUE);
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_event_hook_set(obj, _event_hook);
wd->list = elm_list_add(obj);
elm_widget_style_set(wd->list, "hoverlist");
elm_list_mode_set(wd->list, ELM_LIST_EXPAND);
evas_object_show(wd->list);
wd->target = elm_icon_add(obj); /* has to be an elm_widget (dummy,
in this case) because we gotta
make it work with
elm_widget_hover_object_set() */
evas_object_resize(wd->target, elm_finger_size_get(),
elm_finger_size_get());
evas_object_show(wd->target);
wd->hover = elm_hover_add(obj);
snprintf(buf, sizeof(buf), "hoverlist/%s", elm_widget_style_get(obj));
elm_object_style_set(wd->hover, buf);
evas_object_smart_callback_add(wd->hover, "smart,changed",
_content_placement_changed_cb, obj);
elm_hoverlist_hover_parent_set(obj, parent);
elm_hover_target_set(wd->hover, wd->target);
evas_object_smart_callback_add(wd->hover, "clicked", _hover_clicked_cb, obj);
elm_hover_content_set(wd->hover, "smart", wd->list);
evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _hoverlist_show,
NULL);
evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _hoverlist_hide,
NULL);
elm_widget_sub_object_add(obj, wd->list);
elm_widget_sub_object_add(obj, wd->hover);
elm_widget_sub_object_add(obj, wd->target);
return obj;
}
/**
* This ends the Hoverlist's popup as if the user had clicked
* outside the hover.
*
* @param obj The hoverlist object
*
* @ingroup Hoverlist
*/
EAPI void
elm_hoverlist_hover_end(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd)
return;
if (!wd->hover)
return;
evas_object_hide(wd->hover);
}
/**
* Get the icon object for the given hoverlist item.
*
* @param item Hoverlist item
* @return icon object or @c NULL, if the item does not have icon or
* an error occured
*
* @ingroup Hoverlist
*/
EAPI Evas_Object *
elm_hoverlist_item_icon_get(const Elm_Hoverlist_Item *item)
{
ELM_HOVERLIST_ITEM_CHECK_RETURN(item, NULL);
return item->icon;
}
/**
* Sets the side icon associated with the hoverlist item.
*
* Once the icon object is set, a previously set one will be deleted.
* You probably don't want, then, to have the <b>same</b> icon object
* set for more than one item of the list (when replacing one of its
* instances).
*
* @param item Hoverlist item
* @param icon Icon object to be set
*
* @ingroup Hoverlist
*/
EAPI void
elm_hoverlist_item_icon_set(Elm_Hoverlist_Item *item, Evas_Object *icon)
{
ELM_HOVERLIST_ITEM_CHECK_RETURN(item);
Widget_Data *wd;
wd = elm_widget_data_get(item->base.widget);
if (!wd)
return;
if (item->icon)
{
evas_object_del(item->icon);
item->icon = NULL;
}
item->icon = icon;
elm_list_item_icon_set(item->lptr, icon);
elm_list_go(wd->list);
}
/**
* Get the label object for the given hoverlist item.
*
* @param item Hoverlist item
* @return label object or @c NULL, if the item does not have label or
* an error occured
*
* @ingroup Hoverlist
*/
EAPI const char *
elm_hoverlist_item_label_get(const Elm_Hoverlist_Item *item)
{
ELM_HOVERLIST_ITEM_CHECK_RETURN(item, NULL);
return item->label;
}
/**
* (Re)set the label on the given hoverlist item.
*
* @param obj Hoverlist item
* @param label String to set as label
*
* @ingroup Hoverlist
*/
EAPI void
elm_hoverlist_item_label_set(Elm_Hoverlist_Item *item, const char *label)
{
ELM_HOVERLIST_ITEM_CHECK_RETURN(item);
Widget_Data *wd;
wd = elm_widget_data_get(item->base.widget);
if (!wd)
return;
if (!eina_stringshare_replace(&item->label, label))
return;
elm_list_item_label_set(item->lptr, label);
elm_list_go(wd->list);
}
/**
* Set the Hoverlist's parent.
*
* Sets the hover's parent object (it would much probably be the
* window that the hoverlist is in). See Hover objects for more
* information.
*
* @param obj The hoverlist object
* @param parent The parent to use
*
* @note elm_hoverlist_add() will automatically call this function
* with its @c parent argument.
*
* @ingroup Hoverlist
*/
EAPI void
elm_hoverlist_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd;
wd = elm_widget_data_get(obj);
if (!wd || !parent)
return;
elm_hover_parent_set(wd->hover, parent);
if (wd->hover_parent)
{
evas_object_event_callback_del_full(wd->hover_parent, EVAS_CALLBACK_DEL,
_parent_del, obj);
evas_object_event_callback_del_full(wd->hover_parent,
EVAS_CALLBACK_RESIZE,
_parent_resize_cb, obj);
}
wd->hover_parent = parent;
evas_object_event_callback_add(wd->hover_parent, EVAS_CALLBACK_DEL,
_parent_del, obj);
evas_object_event_callback_add(wd->hover_parent, EVAS_CALLBACK_RESIZE,
_parent_resize_cb, obj);
_parent_resize_cb(obj, NULL, NULL, NULL);
}
/**
* Get the Hoverlist's parent object.
*
* @param obj The hoverlist object
* @param parent The parent to use
*
* See elm_hoverlist_hover_parent_set() for more information.
*
* @ingroup Hoverlist
*/
EAPI Evas_Object *
elm_hoverlist_hover_parent_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd;
wd = elm_widget_data_get(obj);
if (!wd)
return NULL;
return wd->hover_parent;
}
/**
* Clear all items in the given hoverlist object.
*
* @param obj Hoverlist object
*
* @ingroup Hoverlist
*/
EAPI void
elm_hoverlist_clear(Evas_Object* obj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Elm_Hoverlist_Item *item;
Widget_Data *wd;
wd = elm_widget_data_get(obj);
if (!wd || !wd->items)
return;
EINA_LIST_FREE(wd->items, item)
{
elm_list_item_del(item->lptr);
_item_free(item);
}
evas_object_hide(wd->hover);
}
/**
* Change the hoverlist's orientation to horizontal or vertical.
*
* @param obj Hoverlist object
* @param horizontal @c EINA_TRUE for horizontal mode, @c EINA_FALSE
* for vertical
*
* @ingroup Hoverlist
*/
EAPI void
elm_hoverlist_horizontal_set(Evas_Object* obj, Eina_Bool horizontal)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd;
wd = elm_widget_data_get(obj);
if (!wd)
return;
if (wd->horizontal == horizontal)
return;
wd->horizontal = horizontal;
elm_list_horizontal_set(wd->list, horizontal);
}
/**
* Get the value of current hoverlist object's orientation.
*
* @param obj Hoverlist object
* @return @c EINA_TRUE for horizontal mode, @c EINA_FALSE for
* vertical mode (or errors)
*
* @ingroup Hoverlist
*/
EAPI Eina_Bool
elm_hoverlist_horizontal_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd;
wd = elm_widget_data_get( obj );
if (!wd)
return EINA_FALSE;
return wd->horizontal;
}
/**
* Append a new item to a hoverlist object.
*
* @param obj Hoverlist object
* @param label The label of the new item
* @param icon Icon to be set on new item
* @param func Convenience function called when item selected
* @param data Data passed to @p func above
* @return A handle to the item added or @c NULL, on errors
*
* @ingroup Hoverlist
*/
EAPI Elm_Hoverlist_Item *
elm_hoverlist_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Elm_Hoverlist_Item* item;
Widget_Data* wd;
wd = elm_widget_data_get(obj);
if (!wd)
return NULL;
item = _item_new(obj, label, icon, func, data);
if (!item)
return NULL;
wd->items = eina_list_append(wd->items, item);
item->lptr = elm_list_item_append(wd->list, label, icon, NULL,
_item_func_cb, item);
elm_list_go(wd->list);
return item;
}
/**
* Delete the given item in a hoverlist object.
*
* @param item Hoverlist item to be deleted
*
* @ingroup Hoverlist
*/
EAPI void
elm_hoverlist_item_del(Elm_Hoverlist_Item *item)
{
ELM_HOVERLIST_ITEM_CHECK_RETURN(item);
Widget_Data *wd;
wd = elm_widget_data_get(item->base.widget);
if (!wd)
return;
wd->items = eina_list_remove(wd->items, item);
elm_list_item_del(item->lptr);
item->lptr = NULL;
if (eina_list_count(wd->items) < 1)
evas_object_hide(wd->hover);
_item_free(item);
}
/**
* Set the hoverlist item's state as disabled or enabled
*
* @param item Hoverlist item to be enabled/disabled
* @param disabled @c EINA_TRUE to disable it, @c EINA_FALSE to enable
*
* @ingroup Hoverlist
*/
EAPI void
elm_hoverlist_item_disabled_set(Elm_Hoverlist_Item *item, Eina_Bool disabled)
{
ELM_HOVERLIST_ITEM_CHECK_RETURN(item);
Widget_Data *wd;
wd = elm_widget_data_get(item->base.widget);
if (!wd)
return;
if (disabled == item->disabled)
return;
item->disabled = disabled;
elm_list_item_disabled_set(item->lptr, disabled);
}
/**
* Get the hoverlist item's disabled/enabled state.
*
* @param item Hoverlist item to be enabled/disabled
* @return @c EINA_TRUE, if disabled, @c EINA_FALSE otherwise
*
* @ingroup Hoverlist
*/
EAPI Eina_Bool
elm_hoverlist_item_disabled_get(const Elm_Hoverlist_Item *item)
{
ELM_HOVERLIST_ITEM_CHECK_RETURN(item, EINA_FALSE);
return item->disabled;
}