Ejemplo n.º 1
0
HAPI Evas_Object *layout_create(Evas_Object *conformant, const char *file, const char *group, int rotate)
{
	Evas_Object *layout;

	do {
		int width;
		int height;

		layout = layout_load_edj(conformant, file, group);
		retv_if(NULL == layout, NULL);

		width = menu_screen_get_root_width();
		height = menu_screen_get_root_height() - INDEX_HEIGHT;

		evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
		evas_object_size_hint_min_set(layout, width, height);
		evas_object_size_hint_max_set(layout, width, height);
		evas_object_resize(layout, width, height);
		evas_object_show(layout);

		evas_object_data_set(layout, "win", menu_screen_get_win());
		evas_object_data_set(layout, "rotate", (void *) rotate);
		evas_object_data_set(layout, "width", (void *) width);
		evas_object_data_set(layout, "height", (void *) height);
	} while (0);

	do {
		Evas_Object *all_apps;

		all_apps = all_apps_layout_create(layout, rotate);
		if (NULL == all_apps) {
			_E("Failed to create scroller");
			layout_destroy(layout);
			return NULL;
		}
		evas_object_data_set(layout, "all_apps", all_apps);
		elm_object_part_content_set(layout, "content", all_apps);
	} while (0);

	return layout;
}
Evas_Object *page_create(Evas_Object *scroller, int idx, int rotate)
{
	Evas_Object *page;
	Evas_Object *bg;
	Evas_Object *index;
	Evas_Object *tab;
	Evas_Object *mapbuf;
	Evas_Object *box;

	char *page_edje;
	bool enable_bg_image;

	unsigned int count;
	int page_height;
	int page_width;

	_D("Create a new page[%d]", idx);

	page_edje = evas_object_data_get(scroller, "page_edje");
	enable_bg_image = (bool) evas_object_data_get(scroller, "enable_bg_image");

	page = layout_load_edj(scroller, page_edje, PAGE_GROUP_NAME);
	retv_if(!page, NULL);

	evas_object_event_callback_add(page, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints_cb, NULL);
	edje_object_signal_callback_add(_EDJ(page), "dim,down", "menu", _dim_down_cb, NULL);
	edje_object_signal_callback_add(_EDJ(page), "dim,up", "menu", _dim_up_cb, NULL);

	box = evas_object_data_get(scroller, "box");
	mapbuf = mapbuf_bind(box, page);
	if (!mapbuf) {
		_D("Failed to bind the object with mapbuf");
	}

	bg = evas_object_rectangle_add(menu_screen_get_evas());
	if (!bg) {
		evas_object_del(page);
		return NULL;
	}
	evas_object_color_set(bg, 0, 0, 0, 0);

	page_width = menu_screen_get_root_width();
	page_height = (int) ((double) PROP_PORTRAIT_HEIGHT * ((double) menu_screen_get_root_height()));

	evas_object_size_hint_min_set(bg, page_width, page_height);
	evas_object_size_hint_max_set(bg, page_width, page_height);
	elm_object_part_content_set(page, "bg", bg);

	evas_object_data_set(page, "win", evas_object_data_get(scroller, "win"));
	evas_object_data_set(page, "layout", evas_object_data_get(scroller, "layout"));
	evas_object_data_set(page, "controlbar", evas_object_data_get(scroller, "controlbar"));
	evas_object_data_set(page, "tab", evas_object_data_get(scroller, "tab"));
	evas_object_data_set(page, "scroller", scroller);
	evas_object_data_set(page, "page_edje", page_edje);
	evas_object_data_set(page, "page_max_app", evas_object_data_get(scroller, "page_max_app"));
	evas_object_data_set(page, "bg", bg);
	evas_object_data_set(page, "pending,list", NULL);
	evas_object_data_set(page, "dirty", (void *) 0);

	if (_insert_page_at(scroller, page, idx) != MENU_SCREEN_ERROR_OK) {
		evas_object_del(bg);
		evas_object_del(page);
		return NULL;
	}

	index = evas_object_data_get(scroller, "index");
	if (index) {
		tab = evas_object_data_get(scroller, "tab");
		count = page_scroller_count_page(scroller);
		index_update(tab, index, count);
	}

	return page;
}