forked from enlightenment/efl
Tooltip / Mouse Cursor support for elm_genlist / elm_gengrid items
This patch add tooltip and mouse cursor support for items of genlist and gengrid and extends the elementary tests for tooltips and cursor By: Thiago Ribeiro Masaki <masaki@profusion.mobi> SVN revision: 52805
This commit is contained in:
parent
d3fcfa2689
commit
1014a0c5dc
|
@ -2,6 +2,94 @@
|
|||
#include <Elementary_Cursor.h>
|
||||
#ifndef ELM_LIB_QUICKLAUNCH
|
||||
|
||||
typedef struct _Testitem
|
||||
{
|
||||
Elm_Gengrid_Item *item;
|
||||
const char *path;
|
||||
int mode;
|
||||
int onoff;
|
||||
} Testitem;
|
||||
|
||||
static Elm_Gengrid_Item_Class gic;
|
||||
|
||||
char *
|
||||
grd_lbl_get(void *data, Evas_Object *obj, const char *part)
|
||||
{
|
||||
const Testitem *ti = data;
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "Photo %s", ti->path);
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
grd_icon_get(void *data, Evas_Object *obj, const char *part)
|
||||
{
|
||||
const Testitem *ti = data;
|
||||
if (!strcmp(part, "elm.swallow.icon"))
|
||||
{
|
||||
Evas_Object *icon = elm_bg_add(obj);
|
||||
elm_bg_file_set(icon, ti->path, NULL);
|
||||
evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL,
|
||||
1, 1);
|
||||
evas_object_show(icon);
|
||||
return icon;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Elm_Genlist_Item_Class itct;
|
||||
|
||||
static void
|
||||
glt_exp(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Genlist_Item *it = event_info;
|
||||
Evas_Object *gl = elm_genlist_item_genlist_get(it);
|
||||
int val = (int)elm_genlist_item_data_get(it);
|
||||
Elm_Genlist_Item *it1, *it2, *it3;
|
||||
|
||||
val *= 10;
|
||||
it1 = elm_genlist_item_append(gl, &itct, (void *)(val + 1), it,
|
||||
ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||
it2 = elm_genlist_item_append(gl, &itct, (void *)(val + 2), it,
|
||||
ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||
it3 = elm_genlist_item_append(gl, &itct, (void *)(val + 3), it,
|
||||
ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
|
||||
|
||||
elm_genlist_item_cursor_set(it1, ELM_CURSOR_HAND2);
|
||||
elm_genlist_item_cursor_set(it2, ELM_CURSOR_HAND2);
|
||||
elm_genlist_item_cursor_set(it3, ELM_CURSOR_HAND1);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
glt_con(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Genlist_Item *it = event_info;
|
||||
elm_genlist_item_subitems_clear(it);
|
||||
}
|
||||
|
||||
static void
|
||||
glt_exp_req(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Genlist_Item *it = event_info;
|
||||
elm_genlist_item_expanded_set(it, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
glt_con_req(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Genlist_Item *it = event_info;
|
||||
elm_genlist_item_expanded_set(it, 0);
|
||||
}
|
||||
|
||||
char *
|
||||
glt_label_get(void *data, Evas_Object *obj, const char *part)
|
||||
{
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "Item mode %i", (int)data);
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
void
|
||||
test_cursor(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
|
@ -66,9 +154,25 @@ test_cursor(void *data, Evas_Object *obj, void *event_info)
|
|||
void
|
||||
test_cursor2(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Object *win, *bg, *bx, *o;
|
||||
Evas_Object *win, *bg, *bx, *o, *grid, *gl;
|
||||
Elm_Genlist_Item *it1, *it2, *it3;
|
||||
Elm_Toolbar_Item *tit;
|
||||
Elm_List_Item *lit;
|
||||
char buf[PATH_MAX];
|
||||
static Testitem ti[144];
|
||||
int i, n;
|
||||
const char *img[9] =
|
||||
{
|
||||
"panel_01.jpg",
|
||||
"plant_01.jpg",
|
||||
"rock_01.jpg",
|
||||
"rock_02.jpg",
|
||||
"sky_01.jpg",
|
||||
"sky_02.jpg",
|
||||
"sky_03.jpg",
|
||||
"sky_04.jpg",
|
||||
"wood_01.jpg",
|
||||
};
|
||||
|
||||
win = elm_win_add(NULL, "cursor", ELM_WIN_BASIC);
|
||||
elm_win_title_set(win, "Cursor 2");
|
||||
|
@ -112,6 +216,62 @@ test_cursor2(void *data, Evas_Object *obj, void *event_info)
|
|||
elm_list_go(o);
|
||||
evas_object_show(o);
|
||||
|
||||
gl = elm_genlist_add(win);
|
||||
evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_show(gl);
|
||||
|
||||
itct.item_style = "default";
|
||||
itct.func.label_get = glt_label_get;
|
||||
|
||||
it1 = elm_genlist_item_append(gl, &itct, (void *) 1, NULL,
|
||||
ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
|
||||
it2 = elm_genlist_item_append(gl, &itct, (void *) 2, NULL,
|
||||
ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
|
||||
it3 = elm_genlist_item_append(gl, &itct, (void *) 3, NULL,
|
||||
ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||
|
||||
elm_genlist_item_cursor_set(it1, ELM_CURSOR_HAND1);
|
||||
elm_genlist_item_cursor_set(it2, ELM_CURSOR_HAND1);
|
||||
elm_genlist_item_cursor_set(it3, ELM_CURSOR_CROSS);
|
||||
|
||||
evas_object_smart_callback_add(gl, "expand,request", glt_exp_req, gl);
|
||||
evas_object_smart_callback_add(gl, "contract,request", glt_con_req, gl);
|
||||
evas_object_smart_callback_add(gl, "expanded", glt_exp, gl);
|
||||
evas_object_smart_callback_add(gl, "clicked", NULL, gl);
|
||||
evas_object_smart_callback_add(gl, "contracted", glt_con, gl);
|
||||
|
||||
elm_box_pack_end(bx, gl);
|
||||
|
||||
grid = elm_gengrid_add(win);
|
||||
elm_gengrid_item_size_set(grid, 130, 130);
|
||||
elm_gengrid_horizontal_set(grid, EINA_FALSE);
|
||||
elm_gengrid_multi_select_set(grid, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_fill_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
||||
gic.item_style = "default";
|
||||
gic.func.label_get = grd_lbl_get;
|
||||
gic.func.icon_get = grd_icon_get;
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < 3 * 3; i++)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/images/%s", PACKAGE_DATA_DIR, img[n]);
|
||||
n = (n + 1) % 9;
|
||||
ti[i].mode = i;
|
||||
ti[i].path = eina_stringshare_add(buf);
|
||||
ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL, NULL);
|
||||
if (n % 2)
|
||||
elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_HAND1);
|
||||
else
|
||||
elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_CLOCK);
|
||||
if (!(i % 5))
|
||||
elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
|
||||
}
|
||||
elm_box_pack_end(bx, grid);
|
||||
evas_object_show(grid);
|
||||
|
||||
evas_object_resize(win, 320, 480);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,150 @@
|
|||
#endif
|
||||
#ifndef ELM_LIB_QUICKLAUNCH
|
||||
|
||||
typedef struct _Testitem
|
||||
{
|
||||
Elm_Gengrid_Item *item;
|
||||
const char *path;
|
||||
int mode;
|
||||
int onoff;
|
||||
} Testitem;
|
||||
|
||||
static Elm_Gengrid_Item_Class gic;
|
||||
|
||||
char *
|
||||
grdt_lbl_get(void *data, Evas_Object *obj, const char *part)
|
||||
{
|
||||
const Testitem *ti = data;
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "Photo %s", ti->path);
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
grdt_icon_get(void *data, Evas_Object *obj, const char *part)
|
||||
{
|
||||
const Testitem *ti = data;
|
||||
if (!strcmp(part, "elm.swallow.icon"))
|
||||
{
|
||||
Evas_Object *icon = elm_bg_add(obj);
|
||||
elm_bg_file_set(icon, ti->path, NULL);
|
||||
evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
evas_object_show(icon);
|
||||
return icon;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
test_gengrid_tooltip(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Object *win, *bg, *grid;
|
||||
static Testitem ti[144];
|
||||
int i, n;
|
||||
char buf[PATH_MAX];
|
||||
const char *img[9] =
|
||||
{
|
||||
"panel_01.jpg",
|
||||
"plant_01.jpg",
|
||||
"rock_01.jpg",
|
||||
"rock_02.jpg",
|
||||
"sky_01.jpg",
|
||||
"sky_02.jpg",
|
||||
"sky_03.jpg",
|
||||
"sky_04.jpg",
|
||||
"wood_01.jpg",
|
||||
};
|
||||
|
||||
win = elm_win_add(NULL, "grid", ELM_WIN_BASIC);
|
||||
elm_win_title_set(win, "Tooltip");
|
||||
elm_win_autodel_set(win, 1);
|
||||
|
||||
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);
|
||||
|
||||
grid = elm_gengrid_add(win);
|
||||
elm_gengrid_item_size_set(grid, 130, 130);
|
||||
elm_gengrid_horizontal_set(grid, EINA_FALSE);
|
||||
elm_gengrid_multi_select_set(grid, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
||||
gic.item_style = "default";
|
||||
gic.func.label_get = grdt_lbl_get;
|
||||
gic.func.icon_get = grdt_icon_get;
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < 3 * 3; i++)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/images/%s", PACKAGE_DATA_DIR, img[n]);
|
||||
n = (n + 1) % 9;
|
||||
ti[i].mode = i;
|
||||
ti[i].path = eina_stringshare_add(buf);
|
||||
ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL, NULL);
|
||||
if (n % 2)
|
||||
elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing X");
|
||||
else
|
||||
elm_gengrid_item_tooltip_text_set(ti[i].item, "Testing Y");
|
||||
if (!(i % 5))
|
||||
elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
|
||||
}
|
||||
|
||||
evas_object_show(grid);
|
||||
elm_win_resize_object_add(win, grid);
|
||||
|
||||
evas_object_resize(win, 400, 400);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
||||
static Elm_Genlist_Item_Class itct;
|
||||
|
||||
static void
|
||||
gltt_exp(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Genlist_Item *it = event_info;
|
||||
Evas_Object *gl = elm_genlist_item_genlist_get(it);
|
||||
int val = (int)elm_genlist_item_data_get(it);
|
||||
Elm_Genlist_Item *it1, *it2, *it3;
|
||||
|
||||
val *= 10;
|
||||
it1 = elm_genlist_item_append(gl, &itct, (void *)(val + 1),it, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||
it2 = elm_genlist_item_append(gl, &itct, (void *)(val + 2), it, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||
it3 = elm_genlist_item_append(gl, &itct, (void *)(val + 3), it, ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
|
||||
|
||||
elm_genlist_item_tooltip_text_set(it1, "Testing A");
|
||||
elm_genlist_item_tooltip_text_set(it2, "Testing B");
|
||||
elm_genlist_item_tooltip_text_set(it3, "Testing C");
|
||||
}
|
||||
static void
|
||||
gltt_con(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Genlist_Item *it = event_info;
|
||||
elm_genlist_item_subitems_clear(it);
|
||||
}
|
||||
|
||||
static void
|
||||
gltt_exp_req(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Genlist_Item *it = event_info;
|
||||
elm_genlist_item_expanded_set(it, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
gltt_con_req(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Elm_Genlist_Item *it = event_info;
|
||||
elm_genlist_item_expanded_set(it, 0);
|
||||
}
|
||||
|
||||
char *
|
||||
gltt_label_get(void *data, Evas_Object *obj, const char *part)
|
||||
{
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "Item mode %i", (int)data);
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_tt_item_icon(void *data __UNUSED__, Evas_Object *obj, void *item __UNUSED__)
|
||||
{
|
||||
|
@ -178,10 +322,13 @@ _tt_visible_lock_toggle(void *data __UNUSED__, Evas_Object *obj, void *event_inf
|
|||
void
|
||||
test_tooltip(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst;
|
||||
Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst, *gl;
|
||||
Elm_Genlist_Item *it1, *it2, *it3;
|
||||
Elm_Toolbar_Item *ti;
|
||||
Elm_List_Item *li;
|
||||
|
||||
test_gengrid_tooltip(NULL, NULL, NULL);
|
||||
|
||||
win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC);
|
||||
elm_win_title_set(win, "Tooltip");
|
||||
elm_win_autodel_set(win, 1);
|
||||
|
@ -290,8 +437,33 @@ test_tooltip(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf
|
|||
elm_box_pack_end(bx, lst);
|
||||
evas_object_show(lst);
|
||||
|
||||
gl = elm_genlist_add(win);
|
||||
evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
||||
itct.item_style = "default";
|
||||
itct.func.label_get = gltt_label_get;
|
||||
|
||||
it1 = elm_genlist_item_append(gl, &itct, (void *)1, NULL, ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
|
||||
it2 = elm_genlist_item_append(gl, &itct, (void *)2, NULL, ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
|
||||
it3 = elm_genlist_item_append(gl, &itct, (void *)3, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
||||
|
||||
elm_genlist_item_tooltip_text_set(it1, "Testing 1");
|
||||
elm_genlist_item_tooltip_text_set(it2, "Testing 2");
|
||||
elm_genlist_item_tooltip_text_set(it3, "Testing 3");
|
||||
|
||||
evas_object_smart_callback_add(gl, "expand,request", gltt_exp_req, gl);
|
||||
evas_object_smart_callback_add(gl, "contract,request", gltt_con_req, gl);
|
||||
evas_object_smart_callback_add(gl, "expanded", gltt_exp, gl);
|
||||
evas_object_smart_callback_add(gl, "clicked", NULL, gl);
|
||||
evas_object_smart_callback_add(gl, "contracted", gltt_con, gl);
|
||||
|
||||
elm_box_pack_end(bx, gl);
|
||||
evas_object_show(gl);
|
||||
|
||||
|
||||
evas_object_show(win);
|
||||
|
||||
evas_object_resize(win, 400, 500);
|
||||
evas_object_resize(win, 400, 680);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <Elementary.h>
|
||||
#include <Elementary_Cursor.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
/**
|
||||
|
@ -157,6 +158,16 @@ struct _Elm_Gengrid_Item
|
|||
Evas_Coord x, y, dx, dy;
|
||||
int relcount;
|
||||
|
||||
struct
|
||||
{
|
||||
const void *data;
|
||||
Elm_Tooltip_Item_Content_Cb content_cb;
|
||||
Evas_Smart_Cb del_cb;
|
||||
const char *style;
|
||||
} tooltip;
|
||||
|
||||
const char *mouse_cursor;
|
||||
|
||||
Eina_Bool want_unrealize : 1;
|
||||
Eina_Bool realized : 1;
|
||||
Eina_Bool dragging : 1;
|
||||
|
@ -549,6 +560,18 @@ _item_realize(Elm_Gengrid_Item *item)
|
|||
edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
|
||||
|
||||
evas_object_show(item->base.view);
|
||||
|
||||
if (item->tooltip.content_cb)
|
||||
{
|
||||
elm_widget_item_tooltip_content_cb_set(item,
|
||||
item->tooltip.content_cb,
|
||||
item->tooltip.data, NULL);
|
||||
elm_widget_item_tooltip_style_set(item, item->tooltip.style);
|
||||
}
|
||||
|
||||
if (item->mouse_cursor)
|
||||
elm_widget_item_cursor_set(item, item->mouse_cursor);
|
||||
|
||||
item->realized = EINA_TRUE;
|
||||
item->want_unrealize = EINA_FALSE;
|
||||
}
|
||||
|
@ -663,6 +686,7 @@ _item_create(Widget_Data *wd, const Elm_Gengrid_Item_Class *gic, const void *dat
|
|||
item->base.data = data;
|
||||
item->func.func = func;
|
||||
item->func.data = func_data;
|
||||
item->mouse_cursor = NULL;
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -679,6 +703,8 @@ _item_del(Elm_Gengrid_Item *item)
|
|||
item->wd->items = eina_list_remove(item->wd->items, item);
|
||||
if (item->long_timer) ecore_timer_del(item->long_timer);
|
||||
elm_widget_item_del(item);
|
||||
if (item->tooltip.del_cb)
|
||||
item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1481,6 +1507,23 @@ elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
|
|||
return item->disabled;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_elm_gengrid_item_label_create(void *data, Evas_Object *obj, void *item __UNUSED__)
|
||||
{
|
||||
Evas_Object *label = elm_label_add(obj);
|
||||
if (!label)
|
||||
return NULL;
|
||||
elm_object_style_set(label, "tooltip");
|
||||
elm_label_label_set(label, data);
|
||||
return label;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_gengrid_item_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
eina_stringshare_del(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text to be shown in the gengrid item.
|
||||
*
|
||||
|
@ -1495,7 +1538,8 @@ elm_gengrid_item_disabled_get(const Elm_Gengrid_Item *item)
|
|||
EAPI void
|
||||
elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item, const char *text)
|
||||
{
|
||||
elm_widget_item_tooltip_text_set(item, text);
|
||||
text = eina_stringshare_add(text);
|
||||
elm_gengrid_item_tooltip_content_cb_set(item, _elm_gengrid_item_label_create, text, _elm_gengrid_item_label_del_cb);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1521,7 +1565,29 @@ elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item, const char *text)
|
|||
EAPI void
|
||||
elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
|
||||
{
|
||||
elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
|
||||
EINA_SAFETY_ON_NULL_GOTO(item, error);
|
||||
|
||||
if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
|
||||
return;
|
||||
|
||||
if (item->tooltip.del_cb)
|
||||
item->tooltip.del_cb((void *)item->tooltip.data,
|
||||
item->base.widget, item);
|
||||
item->tooltip.content_cb = func;
|
||||
item->tooltip.data = data;
|
||||
item->tooltip.del_cb = del_cb;
|
||||
if (item->base.view)
|
||||
{
|
||||
elm_widget_item_tooltip_content_cb_set(item,
|
||||
item->tooltip.content_cb,
|
||||
item->tooltip.data, NULL);
|
||||
elm_widget_item_tooltip_style_set(item, item->tooltip.style);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
if (del_cb) del_cb((void *)data, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1540,7 +1606,16 @@ elm_gengrid_item_tooltip_content_cb_set(Elm_Gengrid_Item *item, Elm_Tooltip_Item
|
|||
EAPI void
|
||||
elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
|
||||
{
|
||||
elm_widget_item_tooltip_unset(item);
|
||||
if (item->base.view && item->tooltip.content_cb)
|
||||
elm_widget_item_tooltip_unset(item);
|
||||
|
||||
if (item->tooltip.del_cb)
|
||||
item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
|
||||
item->tooltip.del_cb = NULL;
|
||||
item->tooltip.content_cb = NULL;
|
||||
item->tooltip.data = NULL;
|
||||
if (item->tooltip.style)
|
||||
elm_gengrid_item_tooltip_style_set(item, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1558,7 +1633,8 @@ elm_gengrid_item_tooltip_unset(Elm_Gengrid_Item *item)
|
|||
EAPI void
|
||||
elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item, const char *style)
|
||||
{
|
||||
elm_widget_item_tooltip_style_set(item, style);
|
||||
eina_stringshare_replace(&item->tooltip.style, style);
|
||||
if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1573,7 +1649,7 @@ elm_gengrid_item_tooltip_style_set(Elm_Gengrid_Item *item, const char *style)
|
|||
EAPI const char *
|
||||
elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
|
||||
{
|
||||
return elm_widget_item_tooltip_style_get(item);
|
||||
return item->tooltip.style;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1588,7 +1664,8 @@ elm_gengrid_item_tooltip_style_get(const Elm_Gengrid_Item *item)
|
|||
EAPI void
|
||||
elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item, const char *cursor)
|
||||
{
|
||||
elm_widget_item_cursor_set(item, cursor);
|
||||
eina_stringshare_replace(&item->mouse_cursor, cursor);
|
||||
if (item->base.view) elm_widget_item_cursor_set(item, cursor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1602,7 +1679,14 @@ elm_gengrid_item_cursor_set(Elm_Gengrid_Item *item, const char *cursor)
|
|||
EAPI void
|
||||
elm_gengrid_item_cursor_unset(Elm_Gengrid_Item *item)
|
||||
{
|
||||
elm_widget_item_cursor_unset(item);
|
||||
if (!item->mouse_cursor)
|
||||
return;
|
||||
|
||||
if (item->base.view)
|
||||
elm_widget_item_cursor_unset(item);
|
||||
|
||||
eina_stringshare_del(item->mouse_cursor);
|
||||
item->mouse_cursor = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <Elementary.h>
|
||||
#include <Elementary_Cursor.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
/**
|
||||
|
@ -310,6 +311,17 @@ struct _Elm_Genlist_Item
|
|||
Elm_Genlist_Item *rel;
|
||||
int relcount;
|
||||
int walking;
|
||||
|
||||
struct
|
||||
{
|
||||
const void *data;
|
||||
Elm_Tooltip_Item_Content_Cb content_cb;
|
||||
Evas_Smart_Cb del_cb;
|
||||
const char *style;
|
||||
} tooltip;
|
||||
|
||||
const char *mouse_cursor;
|
||||
|
||||
Eina_Bool before : 1;
|
||||
|
||||
Eina_Bool want_unrealize : 1;
|
||||
|
@ -526,6 +538,10 @@ _item_del(Elm_Genlist_Item *it)
|
|||
if (it->parent)
|
||||
it->parent->items = eina_list_remove(it->parent->items, it);
|
||||
if (it->long_timer) ecore_timer_del(it->long_timer);
|
||||
|
||||
if (it->tooltip.del_cb)
|
||||
it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
|
||||
|
||||
elm_widget_item_del(it);
|
||||
}
|
||||
|
||||
|
@ -972,6 +988,18 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc)
|
|||
}
|
||||
if (!calc) evas_object_show(it->base.view);
|
||||
}
|
||||
|
||||
if (it->tooltip.content_cb)
|
||||
{
|
||||
elm_widget_item_tooltip_content_cb_set(it,
|
||||
it->tooltip.content_cb,
|
||||
it->tooltip.data, NULL);
|
||||
elm_widget_item_tooltip_style_set(it, it->tooltip.style);
|
||||
}
|
||||
|
||||
if (it->mouse_cursor)
|
||||
elm_widget_item_cursor_set(it, it->mouse_cursor);
|
||||
|
||||
it->realized = EINA_TRUE;
|
||||
it->want_unrealize = EINA_FALSE;
|
||||
}
|
||||
|
@ -1565,6 +1593,7 @@ _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
|
|||
it->flags = flags;
|
||||
it->func.func = func;
|
||||
it->func.data = func_data;
|
||||
it->mouse_cursor = NULL;
|
||||
return it;
|
||||
}
|
||||
|
||||
|
@ -2897,6 +2926,23 @@ elm_genlist_item_update(Elm_Genlist_Item *it)
|
|||
it->wd->update_job = ecore_job_add(_update_job, it->wd);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_elm_genlist_item_label_create(void *data, Evas_Object *obj, void *item __UNUSED__)
|
||||
{
|
||||
Evas_Object *label = elm_label_add(obj);
|
||||
if (!label)
|
||||
return NULL;
|
||||
elm_object_style_set(label, "tooltip");
|
||||
elm_label_label_set(label, data);
|
||||
return label;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_genlist_item_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
eina_stringshare_del(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text to be shown in the genlist item.
|
||||
*
|
||||
|
@ -2911,7 +2957,8 @@ elm_genlist_item_update(Elm_Genlist_Item *it)
|
|||
EAPI void
|
||||
elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item, const char *text)
|
||||
{
|
||||
elm_widget_item_tooltip_text_set(item, text);
|
||||
text = eina_stringshare_add(text);
|
||||
elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create, text, _elm_genlist_item_label_del_cb);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2937,7 +2984,31 @@ elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item, const char *text)
|
|||
EAPI void
|
||||
elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
|
||||
{
|
||||
elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
|
||||
EINA_SAFETY_ON_NULL_GOTO(item, error);
|
||||
|
||||
if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
|
||||
return;
|
||||
|
||||
if (item->tooltip.del_cb)
|
||||
item->tooltip.del_cb((void *)item->tooltip.data,
|
||||
item->base.widget, item);
|
||||
|
||||
item->tooltip.content_cb = func;
|
||||
item->tooltip.data = data;
|
||||
item->tooltip.del_cb = del_cb;
|
||||
|
||||
if (item->base.view)
|
||||
{
|
||||
elm_widget_item_tooltip_content_cb_set(item,
|
||||
item->tooltip.content_cb,
|
||||
item->tooltip.data, NULL);
|
||||
elm_widget_item_tooltip_style_set(item, item->tooltip.style);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
if (del_cb) del_cb((void *)data, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2956,7 +3027,16 @@ elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item, Elm_Tooltip_Item
|
|||
EAPI void
|
||||
elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
|
||||
{
|
||||
elm_widget_item_tooltip_unset(item);
|
||||
if (item->base.view && item->tooltip.content_cb)
|
||||
elm_widget_item_tooltip_unset(item);
|
||||
|
||||
if (item->tooltip.del_cb)
|
||||
item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
|
||||
item->tooltip.del_cb = NULL;
|
||||
item->tooltip.content_cb = NULL;
|
||||
item->tooltip.data = NULL;
|
||||
if (item->tooltip.style)
|
||||
elm_genlist_item_tooltip_style_set(item, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2974,7 +3054,8 @@ elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
|
|||
EAPI void
|
||||
elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item, const char *style)
|
||||
{
|
||||
elm_widget_item_tooltip_style_set(item, style);
|
||||
eina_stringshare_replace(&item->tooltip.style, style);
|
||||
if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2989,7 +3070,7 @@ elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item, const char *style)
|
|||
EAPI const char *
|
||||
elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
|
||||
{
|
||||
return elm_widget_item_tooltip_style_get(item);
|
||||
return item->tooltip.style;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3004,7 +3085,8 @@ elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
|
|||
EAPI void
|
||||
elm_genlist_item_cursor_set(Elm_Genlist_Item *item, const char *cursor)
|
||||
{
|
||||
elm_widget_item_cursor_set(item, cursor);
|
||||
eina_stringshare_replace(&item->mouse_cursor, cursor);
|
||||
if (item->base.view) elm_widget_item_cursor_set(item, cursor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3018,7 +3100,14 @@ elm_genlist_item_cursor_set(Elm_Genlist_Item *item, const char *cursor)
|
|||
EAPI void
|
||||
elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
|
||||
{
|
||||
elm_widget_item_cursor_unset(item);
|
||||
if (!item->mouse_cursor)
|
||||
return;
|
||||
|
||||
if (item->base.view)
|
||||
elm_widget_item_cursor_unset(item);
|
||||
|
||||
eina_stringshare_del(item->mouse_cursor);
|
||||
item->mouse_cursor = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue