[UI Sample] Rectangle Sample Overview
The Rectangle sample demonstrates how to display a rectangle on the canvas using EFL Evas object functions. It also moves and resizes the rectangle.
The sample uses functions, such as evas_object_rectangle_add(), for adding an rectangle to the given Evas, and basic object manipulation functions, such as evas_object_move() and evas_object_resize(), for moving and changing the size of the rectangle.
The following figure illustrates the main screen of Rectangle.
Figure: Rectangle screen
Implementation
The create_base_gui() function creates the window which consists of a rectangle (Evas object) added with the evas_object_rectangle_add() function.
It also moves the rectangle to the given x, y coordination inside its canvas viewport using the evas_object_move() function, and changes the size of the image using the evas_object_resize() function.
static void create_base_gui(appdata_s *ad) { // Window ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE); elm_win_autodel_set(ad->win, EINA_TRUE); if (elm_win_wm_rotation_supported_get(ad->win)) { int rots[4] = { 0, 90, 180, 270 }; elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4); } evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL); eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad); // Conformant ad->conform = elm_conformant_add(ad->win); elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW); elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE); evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(ad->win, ad->conform); evas_object_show(ad->conform); // Rectangle Evas *evas = evas_object_evas_get(ad->conform); // Add a rectangle to the given Evas Evas_Object *bg = evas_object_rectangle_add(evas); // Set the general/main color of the given Evas object to the given one evas_object_color_set(bg, 255, 0, 0, 255); // Move the given Evas object to the given location inside its canvas viewport evas_object_move(bg, 50, 50); // Change the size of the given Evas object evas_object_resize(bg, 200, 200); // Make the given Evas object visible evas_object_show(bg); // Show the window after the base GUI is set up evas_object_show(ad->win); }