Grid management

This code snippet shows how to change the virtual size of the grid and how to remove objects from it.
static void grid_test(Evas_Object *parent) {
	Evas_Object *grid = elm_grid_add(parent);
	elm_win_resize_object_add(parent, grid);
	evas_object_show(grid);

	//change virtual width and height of the grid (default is 100x100)
	elm_grid_size_set(grid, 10, 10);

	//get grid's size
	Evas_Coord x, y;
	elm_grid_size_get(grid, &x, &y);
	dlog_print(DLOG_INFO, LOG_TAG, "Grid size: x = %d y = %d", x, y);

	//add two buttons to the grid
	Evas_Object *top_btn = elm_button_add(grid);
	elm_grid_pack(grid, top_btn, 3, 0, 4, 1); //relative to new virtual size
	elm_object_text_set(top_btn, "top");
	evas_object_show(top_btn);

	Evas_Object *bottom_btn = elm_button_add(grid);
	elm_grid_pack(grid, bottom_btn, 3, 9, 4, 1);
	elm_object_text_set(bottom_btn, "bottom");
	evas_object_show(bottom_btn);

	//unpack the bottom button
	elm_grid_unpack(grid, bottom_btn);

	//clean the whole grid (remove all of the children)
	//elm_grid_clear(grid, EINA_TRUE);
}

Responses

0 Replies