[UI Sample] Evas Map Mapping Sample Overview
The Evas Map Mapping sample demonstrates how to apply UV mapping to an Evas object (button) by using EFL Evas map util functions.
The sample uses functions, such as evas_map_point_coord_set() for objects to change the map point's coordinate and evas_map_point_image_uv_set() for objects to change the map point's U and V texture source point.
The following figure illustrates the main screen of Evas Map Mapping.
Figure: Evas Map Mapping screen
Implementation
The create_base_gui() function creates the window which consists of a button added by the using elm_button_add(), elm_object_text_set(), evas_object_move(), and evas_object_resize() functions.
It gets an Evas map by using the evas_map_new() function. Then the evas_map_point_coord_set() and evas_map_point_image_uv_set() functions set the map's coordinates and UV. To apply UV mapping, the evas_object_map_set() and evas_object_map_enable_set() functions are used.
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); // Map Evas_Object *btn; Evas_Map *map; // Create a button btn = elm_button_add(ad->conform); elm_object_text_set(btn, "Evas Map<br>"); evas_object_move(btn, 100, 150); evas_object_resize(btn, 200, 200); evas_object_show(btn); // Create an Evas map map = evas_map_new(4); // Set map coordinates evas_map_point_coord_set(map, 0, 150, 100, 0); evas_map_point_coord_set(map, 1, 350, 100, 0); evas_map_point_coord_set(map, 2, 300, 200, 0); evas_map_point_coord_set(map, 3, 100, 400, 0); // Set image UV evas_map_point_image_uv_set(map, 0, 0, 50); evas_map_point_image_uv_set(map, 1, 200, 50); evas_map_point_image_uv_set(map, 2, 200, 100); evas_map_point_image_uv_set(map, 3, 0, 100); // Apply map to button object evas_object_map_set(btn, map); // Free map resource evas_map_free(map); // Enable map feature evas_object_map_enable_set(btn, EINA_TRUE); // Show the window after the base GUI is set up evas_object_show(ad->win); }