Languages

Menu
Sites
Language
Genlist item layout broken when selected
When "type2" item gets tapped (highlighted), its layout is changed as shown on the screenshot (the second item with "None"):
After the item is "released", the proper layout is restored. In other words, this happens only when the item is being highlighted.
This occurs only on Z1 (real device). In emulator everything is fine. Also, this does not happen with other items (of "full" and "default" item types).
This is how the Genlist and its items are created:
static char* gl_text_get_cb(void* data, Evas_Object* obj, const char* part) {
    if ((int)data == STL_FORM_PARENT) {
		if (!strcmp(part, "elm.text")) {
			return strdup("None");
		} else if (!strcmp(part, "elm.text.sub")) {
			return strdup("Parent");
		}
	} else if ((int)data == STL_FORM_COLOR) {
		if (!strcmp(part, "elm.text")) {
			return strdup("Color");
		}
	}
	return NULL;
}

static Evas_Object* gl_content_get_cb(void* data, Evas_Object* obj, const char* part) {
	if ((int)data == STL_FORM_NAME) {
		if (!strcmp(part, "elm.swallow.content")) {
			return create_editfield(obj);
		}
	} else if ((int)data == STL_FORM_PARENT) {
		if (!strcmp(part, "elm.swallow.icon.0")) {
			Evas_Object* bg = elm_bg_add(obj);
			elm_bg_color_set(bg, 66, 162, 206);
			evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
			evas_object_size_hint_min_set(bg, ELM_SCALE_SIZE(15), ELM_SCALE_SIZE(15));
			evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
			return bg;
		}
	} else if ((int)data == STL_FORM_COLOR) {
		if (!strcmp(part, "elm.swallow.end")) {
			Evas_Object* bg = elm_bg_add(obj);
			elm_bg_color_set(bg, 66, 162, 206);
			evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
			evas_object_size_hint_min_set(bg, ELM_SCALE_SIZE(24), ELM_SCALE_SIZE(24));
			evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
			return bg;
		}
	}
	return NULL;
}

static void gl_select_cb(void* data, Evas_Object* obj, void* event_info) {
	Elm_Object_Item* item = event_info;
	elm_genlist_item_selected_set(item, EINA_FALSE);
}

...

        Evas_Object* genlist = elm_genlist_add(nf);
        elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
	evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);

	Elm_Genlist_Item_Class* name_class = elm_genlist_item_class_new();
	name_class->item_style = "full";
	name_class->func.content_get = gl_content_get_cb;
	elm_genlist_item_append(genlist, name_class, (void*)STL_FORM_NAME, NULL, ELM_GENLIST_ITEM_NONE, gl_select_cb, NULL);

	Elm_Genlist_Item_Class* parent_class = elm_genlist_item_class_new();
	parent_class->item_style = "type2";
	parent_class->func.text_get = gl_text_get_cb;
	parent_class->func.content_get = gl_content_get_cb;
	elm_genlist_item_append(genlist, parent_class, (void*)STL_FORM_PARENT, NULL, ELM_GENLIST_ITEM_NONE, gl_select_cb, NULL);

	Elm_Genlist_Item_Class* color_class = elm_genlist_item_class_new();
	color_class->item_style = "default";
	color_class->func.text_get = gl_text_get_cb;
	color_class->func.content_get = gl_content_get_cb;
	elm_genlist_item_append(genlist, color_class, (void*)STL_FORM_COLOR, NULL, ELM_GENLIST_ITEM_NONE, gl_select_cb, NULL);

        evas_object_show(genlist);
        elm_genlist_item_class_free(name_class);
	elm_genlist_item_class_free(parent_class);
	elm_genlist_item_class_free(color_class);
View Selected Answer

Responses

3 Replies
K Johnson

I've tried to implement similar thing and got broken design as your's one. I've used Samsung Z1 with Tizen 2.4. I guess it's a bug. You may report it as a bug in bug tracker here in this link.

Mark as answer
K Johnson

I've tested this on Tizen Version 3.0 also. It works perfectly on that. So, I guess the problem has been fixed since Tizen 3.0.

Andriy Lesyuk

Thanks for looking into this, K! Much appreciated!