This example will arrange rectangles of different sizes(and colors) in a table.
While it's possible to create the same layout we are doing here by positioning each rectangle independently, using a table makes it a lot easier, since the table will control layout of all the objects, allowing you to move, resize or hide the entire table.
We'll start with creating the table, setting it to EVAS_OBJECT_TABLE_HOMOGENEOUS_NONE to have maximum flexibility and setting its padding to 0:
evas_object_table_padding_set(table, 0, 0);
We then create each rectangle and add it to the table:
evas_object_table_pack(table, rect, 1, 1, 2, 1);
evas_object_table_pack(table, rect, 1, 2, 1, 2);
evas_object_table_pack(table, rect, 2, 2, 1, 1);
evas_object_table_pack(table, rect, 2, 3, 1, 1);
- Note
- Each rectangle has a different minimum size based on how many rows and columns it will occupy.
The full source for this example follow:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Ecore.h>
#include <stdlib.h>
#define WIDTH 100
#define HEIGHT 150
struct test_data
{
Ecore_Evas *ee;
};
static struct test_data d = {0};
static void
_on_destroy(Ecore_Evas *ee EINA_UNUSED)
{
}
static void
_canvas_resize_cb(Ecore_Evas *ee)
{
int w, h;
}
int
main(void)
{
return EXIT_FAILURE;
if (!d.ee)
goto error;
evas_object_table_padding_set(table, 0, 0);
evas_object_table_pack(table, rect, 1, 1, 2, 1);
evas_object_table_pack(table, rect, 1, 2, 1, 2);
evas_object_table_pack(table, rect, 2, 2, 1, 1);
evas_object_table_pack(table, rect, 2, 3, 1, 1);
return 0;
error:
fprintf(stderr, "error: Requires at least one Evas engine built and linked"
" to ecore-evas for this example to run properly.\n");
return -1;
}