语言

Menu
Sites
Language
Using custom icon of genlist with box issue

Hello,

I wanna set a custom icon of genlist as label with background.

So, I used box with bg, label.(Please, see code below for this.)

When I just image, it look fine. But, When I used box, see (imgur.com/4ojxh2i)

 

The labels are moved left like a default genlist without icon in compare with the default genlist with image icon.

Why would this happen?

static Evas_Object *
_gl_icon_get(void *data, Evas_Object *obj, const char *part)
{
    if (strcmp(part, "elm.icon")) return NULL;
	item_data *id = (item_data *)data;


	Evas_Object *box = elm_box_add(obj);
	evas_object_show(box);

	Evas_Object *bg = elm_bg_add(box);
	char buf[256];
	snprintf(buf, sizeof(buf), "%s/white_circle.png",ICON_DIR);
	elm_bg_file_set(bg, buf, NULL);
	elm_bg_option_set(bg, ELM_BG_OPTION_CENTER);
	evas_object_show(bg);

	Evas_Object *time_label = elm_label_add(box);
	snprintf(buf, sizeof(buf),
			"<font=Sans:style=Bold font_size=48>%s</font>"
			"<font=Sans:style=Regular font_size=16><br>MIN</font>",
			times[id->index]);
	elm_object_text_set(time_label, buf);
	evas_object_show(time_label);
	elm_object_part_content_set(bg, "overlay", time_label);
	elm_box_pack_end(box, bg);

	return box;
}

 

Thank you.

 

编辑者为: Kim 03 9月, 2015

响应

1 回复
colin Rao

Hi,

Possible, the genlist only accept the image/icon widget for this part "elm.icon". Is it ok to new a image widget with bg, and set text as overlay on bg? :)