diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-09-13 16:49:04 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-09-13 18:03:34 +0900 |
commit | 13da5e980eb43288b9b9f502cb6a7a000e1f26ea (patch) | |
tree | e37670643988bb990b3101257332c490a2e21131 | |
parent | 0c46fc71033edda92f4e86b86f6d1d62751f8998 (diff) | |
download | efl-13da5e980eb43288b9b9f502cb6a7a000e1f26ea.tar.gz |
efl_gfx: Use Eina.Rectangle for geometry (EO)
This saves a few lines already (without even having the proper helpers
for stack rectangles).
-rw-r--r-- | src/bin/elementary/test_evas_map.c | 2 | ||||
-rw-r--r-- | src/bin/elementary/test_photocam.c | 9 | ||||
-rw-r--r-- | src/bin/elementary/test_ui_box.c | 18 | ||||
-rw-r--r-- | src/examples/evas/evas-3d-cube-rotate.c | 2 | ||||
-rw-r--r-- | src/examples/evas/evas-map-utils-eo.c | 9 | ||||
-rw-r--r-- | src/lib/edje/edje_part.c | 22 | ||||
-rw-r--r-- | src/lib/edje/edje_private.h | 7 | ||||
-rw-r--r-- | src/lib/efl/interfaces/efl_gfx.eo | 6 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_textpath.c | 21 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_win.c | 21 | ||||
-rw-r--r-- | src/lib/elementary/elm_menu.c | 4 | ||||
-rw-r--r-- | src/lib/elementary/elm_widget.c | 6 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_gfx_map.c | 4 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_image.c | 4 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_main.c | 30 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_vg_node.c | 11 | ||||
-rw-r--r-- | src/tests/elementary/elm_test_focus_common.c | 10 |
17 files changed, 82 insertions, 104 deletions
diff --git a/src/bin/elementary/test_evas_map.c b/src/bin/elementary/test_evas_map.c index 7f4e8481e7..5a7bfe4374 100644 --- a/src/bin/elementary/test_evas_map.c +++ b/src/bin/elementary/test_evas_map.c @@ -41,7 +41,7 @@ _image_resize_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, { Evas_Coord w, h; - efl_gfx_geometry_get(obj, NULL, NULL, &w, &h); + efl_gfx_size_get(obj, &w, &h); _map_set(obj, w, h); } diff --git a/src/bin/elementary/test_photocam.c b/src/bin/elementary/test_photocam.c index 490255b6da..c7a8ea2c34 100644 --- a/src/bin/elementary/test_photocam.c +++ b/src/bin/elementary/test_photocam.c @@ -763,12 +763,11 @@ _zoomable_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev) static void _zoomable_move_resize_cb(void *data, const Efl_Event *ev) { - int x, y, w, h; - - efl_gfx_geometry_get(ev->object, &x, &y, &w, &h); + Eina_Rectangle r; - efl_gfx_size_set(data, w, h); - efl_gfx_position_set(data, x, y); + r = efl_gfx_geometry_get(ev->object); + efl_gfx_size_set(data, r.w, r.h); + efl_gfx_position_set(data, r.x, r.y); } static void diff --git a/src/bin/elementary/test_ui_box.c b/src/bin/elementary/test_ui_box.c index 1929369c52..7d8d33b3f6 100644 --- a/src/bin/elementary/test_ui_box.c +++ b/src/bin/elementary/test_ui_box.c @@ -170,7 +170,7 @@ _custom_layout_update(Eo *pack, const void *data EINA_UNUSED) { Eina_Iterator *it = efl_content_iterate(pack); int count = efl_content_count(pack), i = 0; - int px, py, pw, ph; + Eina_Rectangle rp; Eo *sobj; // Note: This is a TERRIBLE layout. Just an example of the API, not showing @@ -178,16 +178,18 @@ _custom_layout_update(Eo *pack, const void *data EINA_UNUSED) if (!count) return; - efl_gfx_geometry_get(pack, &px, &py, &pw, &ph); + rp = efl_gfx_geometry_get(pack); EINA_ITERATOR_FOREACH(it, sobj) { - int x, y, h, w, mw, mh; + Eina_Rectangle r; + int mw, mh; + efl_gfx_size_hint_combined_min_get(sobj, &mw, &mh); - x = (pw / count) * i; - y = (ph / count) * i; - w = mw; - h = mh; - efl_gfx_geometry_set(sobj, x + px, y + py, w, h); + r.x = (rp.w / count) * i; + r.y = (rp.h / count) * i; + r.w = mw; + r.h = mh; + efl_gfx_geometry_set(sobj, r); i++; } eina_iterator_free(it); diff --git a/src/examples/evas/evas-3d-cube-rotate.c b/src/examples/evas/evas-3d-cube-rotate.c index 79ff7932a3..8ddd326da0 100644 --- a/src/examples/evas/evas-3d-cube-rotate.c +++ b/src/examples/evas/evas-3d-cube-rotate.c @@ -262,7 +262,7 @@ main(void) /* Add an image object for 3D scene rendering. */ image = efl_add(EFL_CANVAS_SCENE3D_CLASS, evas); - efl_gfx_geometry_set(image, 0, 0, WIDTH, HEIGHT); + efl_gfx_geometry_set(image, (Eina_Rectangle) { 0, 0, WIDTH, HEIGHT }); evas_object_show(image); /* Set the image object as render target for 3D scene. */ diff --git a/src/examples/evas/evas-map-utils-eo.c b/src/examples/evas/evas-map-utils-eo.c index 36912eb71c..2c701a03ac 100644 --- a/src/examples/evas/evas-map-utils-eo.c +++ b/src/examples/evas/evas-map-utils-eo.c @@ -70,7 +70,8 @@ _anim_cb(void *data) { App_Data *ad = data; Evas_Object *o; - int r, g, b, a, x, y, w, h, f; + Eina_Rectangle r; + int r, g, b, a, f; int win_w, win_h, mx, my; f = ad->frame; @@ -127,12 +128,12 @@ _anim_cb(void *data) o = evas_object_name_find(ad->canvas, "obj4"); - efl_gfx_geometry_get(o, &x, &y, &w, &h); + r = efl_gfx_geometry_get(o); efl_gfx_map_reset(o); efl_gfx_map_smooth_set(o, ad->smooth); efl_gfx_map_alpha_set(o, ad->alpha); - efl_gfx_map_coord_absolute_set(o, 0, x, y + h, 0); - efl_gfx_map_coord_absolute_set(o, 1, x + w, y + h, 0); + efl_gfx_map_coord_absolute_set(o, 0, r.x, r.y + r.h, 0); + efl_gfx_map_coord_absolute_set(o, 1, r.x + r.w, r.y + r.h, 0); efl_gfx_map_coord_absolute_set(o, 2, win_w - 10, win_h - 30, 0); efl_gfx_map_coord_absolute_set(o, 3, (win_w / 2) + 10, win_h - 30, 0); efl_gfx_map_uv_set(o, 0, 0, 1); diff --git a/src/lib/edje/edje_part.c b/src/lib/edje/edje_part.c index 061df2120e..b9790d8e5d 100644 --- a/src/lib/edje/edje_part.c +++ b/src/lib/edje/edje_part.c @@ -100,27 +100,17 @@ _efl_canvas_layout_part_efl_object_finalize(Eo *obj, Efl_Canvas_Layout_Part_Data return efl_finalize(efl_super(obj, MY_CLASS)); } -EOLIAN void -_efl_canvas_layout_part_efl_gfx_geometry_get(Eo *obj, Efl_Canvas_Layout_Part_Data *pd, int *x, int *y, int *w, int *h) +EOLIAN Eina_Rectangle +_efl_canvas_layout_part_efl_gfx_geometry_get(Eo *obj, Efl_Canvas_Layout_Part_Data *pd) { Edje_Real_Part *rp = pd->rp; - PROXY_CALL_BEGIN(pd); + Eina_Rectangle r = { 0, }; + PROXY_CALL_BEGIN(pd); _edje_recalc_do(pd->ed); - if (!rp) - { - if (x) *x = 0; - if (y) *y = 0; - if (w) *w = 0; - if (h) *h = 0; - RETURN_VOID; - } + if (!rp) RETURN_VAL(r); - if (x) *x = rp->x; - if (y) *y = rp->y; - if (w) *w = rp->w; - if (h) *h = rp->h; - RETURN_VOID; + RETURN_VAL(rp->rect); } EOLIAN static void diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 89867977a1..b98e02af13 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -2034,7 +2034,12 @@ struct _Edje_Real_Part } typedata; // 4 FLOAT_T description_pos; // 8 Edje_Rectangle req; // 16 - int x, y, w, h; // 16 + union { + struct { + int x, y, w, h; // 16 + }; + Eina_Rectangle rect; + }; Evas_Object_Pointer_Mode pointer_mode; #ifdef EDJE_CALC_CACHE unsigned short state; // 2 diff --git a/src/lib/efl/interfaces/efl_gfx.eo b/src/lib/efl/interfaces/efl_gfx.eo index f35fa3fc1b..1670ddc3c6 100644 --- a/src/lib/efl/interfaces/efl_gfx.eo +++ b/src/lib/efl/interfaces/efl_gfx.eo @@ -1,3 +1,4 @@ +import eina_types; import efl_gfx_types; interface Efl.Gfx { @@ -45,10 +46,7 @@ interface Efl.Gfx { @property geometry { [[Rectangular geometry that combines both position and size.]] values { - x: int; [[X coordinate]] - y: int; [[Y coordinate]] - w: int; [[Width]] - h: int; [[Height]] + rect: Eina.Rectangle; [[The X,Y position and W,H size, in pixels.]] } } @property color { diff --git a/src/lib/elementary/efl_ui_textpath.c b/src/lib/elementary/efl_ui_textpath.c index 5eb5ac0ee2..b92331ccd1 100644 --- a/src/lib/elementary/efl_ui_textpath.c +++ b/src/lib/elementary/efl_ui_textpath.c @@ -163,8 +163,8 @@ static void _text_on_line_draw(Efl_Ui_Textpath_Data *pd, int w1, int w2, int cmp, Evas_Map *map, Efl_Ui_Textpath_Line line) { double x1, x2, y1, y2; - Evas_Coord x, y, w, h; double line_len, len, sina, cosa; + Eina_Rectangle r; x1 = line.start.x; y1 = line.start.y; @@ -179,23 +179,22 @@ _text_on_line_draw(Efl_Ui_Textpath_Data *pd, int w1, int w2, int cmp, Evas_Map * y2 = y1 + len * (y2 - y1) / line_len; } - efl_gfx_geometry_get(pd->text_obj, &x, &y, &w, &h); - len = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)); sina = (y2 - y1) / len; cosa = (x2 - x1) / len; - h = h / 2; - evas_map_point_coord_set(map, cmp + 3, x1 - h * sina, y1 + h * cosa, 0); - evas_map_point_coord_set(map, cmp + 2, x2 - h * sina, y2 + h * cosa, 0); - evas_map_point_coord_set(map, cmp + 1, x2 + h * sina, y2 - h * cosa, 0); - evas_map_point_coord_set(map, cmp + 0, x1 + h * sina, y1 - h * cosa, 0); + r = efl_gfx_geometry_get(pd->text_obj); + r.h /= 2; + evas_map_point_coord_set(map, cmp + 3, x1 - r.h * sina, y1 + r.h * cosa, 0); + evas_map_point_coord_set(map, cmp + 2, x2 - r.h * sina, y2 + r.h * cosa, 0); + evas_map_point_coord_set(map, cmp + 1, x2 + r.h * sina, y2 - r.h * cosa, 0); + evas_map_point_coord_set(map, cmp + 0, x1 + r.h * sina, y1 - r.h * cosa, 0); - h *= 2; + r.h *= 2; evas_map_point_image_uv_set(map, cmp + 0, w1, 0); evas_map_point_image_uv_set(map, cmp + 1, w2, 0); - evas_map_point_image_uv_set(map, cmp + 2, w2, h); - evas_map_point_image_uv_set(map, cmp + 3, w1, h); + evas_map_point_image_uv_set(map, cmp + 2, w2, r.h); + evas_map_point_image_uv_set(map, cmp + 3, w1, r.h); } static int diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index 3d0a2d6f09..69401220f4 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -1037,26 +1037,25 @@ static void _elm_win_focus_highlight_anim_setup(Efl_Ui_Win_Data *sd, Evas_Object *obj) { - Eina_Rectangle rt; - Evas_Coord px, py, pw, ph; + Eina_Rectangle rt, rp; Edje_Message_Int_Set *m; Evas_Object *target = sd->focus_highlight.cur.target; - evas_object_geometry_get(obj, &px, &py, &pw, &ph); + rp = efl_gfx_geometry_get(obj); rt = elm_widget_focus_highlight_geometry_get(target); - efl_gfx_geometry_set(obj, rt.x, rt.y, rt.w, rt.h); + efl_gfx_geometry_set(obj, rt); - if ((px == rt.x) && (py == rt.y) && (pw == rt.w) && (ph == rt.h)) return; + if (eina_rectangle_equal(&rp, &rt)) return; if (!_elm_config->focus_highlight_clip_disable) evas_object_clip_unset(obj); m = alloca(sizeof(*m) + (sizeof(int) * 8)); m->count = 8; - m->val[0] = px - rt.x; - m->val[1] = py - rt.y; - m->val[2] = pw; - m->val[3] = ph; + m->val[0] = rp.x - rt.x; + m->val[1] = rp.y - rt.y; + m->val[2] = rp.w; + m->val[3] = rp.h; m->val[4] = 0; m->val[5] = 0; m->val[6] = rt.w; @@ -1069,10 +1068,8 @@ _elm_win_focus_highlight_simple_setup(Efl_Ui_Win_Data *sd, Evas_Object *obj) { Evas_Object *clip, *target = sd->focus_highlight.cur.target; - Eina_Rectangle r; - r = elm_widget_focus_highlight_geometry_get(target); - efl_gfx_geometry_set(obj, r.x, r.y, r.w, r.h); + efl_gfx_geometry_set(obj, elm_widget_focus_highlight_geometry_get(target)); if (!_elm_config->focus_highlight_clip_disable) { diff --git a/src/lib/elementary/elm_menu.c b/src/lib/elementary/elm_menu.c index fee91547a5..76e7ba9d35 100644 --- a/src/lib/elementary/elm_menu.c +++ b/src/lib/elementary/elm_menu.c @@ -184,6 +184,7 @@ _sizing_eval(Evas_Object *obj) Elm_Object_Item *eo_item; Evas_Coord x_p, y_p, w_p, h_p, x2, y2, w2, h2, bw, bh; Elm_Widget_Smart_Data *hover; + Eina_Rectangle r; ELM_MENU_DATA_GET(obj, sd); @@ -210,7 +211,8 @@ _sizing_eval(Evas_Object *obj) if (y_p + h_p + bh > y2 + h2) y_p -= y_p + h_p + bh - (y2 + h2); if (y_p < y2) y_p = y2; - efl_gfx_geometry_set(sd->location, x_p, y_p, bw, h_p); + r = (Eina_Rectangle) { x_p, y_p, bw, h_p }; + efl_gfx_geometry_set(sd->location, r); evas_object_size_hint_min_set(sd->location, bw, h_p); evas_object_size_hint_max_set(sd->location, bw, h_p); elm_hover_target_set(sd->hv, sd->location); diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c index b59f92ee6c..477ce26c6b 100644 --- a/src/lib/elementary/elm_widget.c +++ b/src/lib/elementary/elm_widget.c @@ -6515,11 +6515,7 @@ _elm_widget_efl_ui_focus_user_manager_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_ EOLIAN static Eina_Rectangle _elm_widget_efl_ui_focus_object_focus_geometry_get(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED) { - Eina_Rectangle rect; - - efl_gfx_geometry_get(obj, &rect.x , &rect.y, &rect.w, &rect.h); - - return rect; + return efl_gfx_geometry_get(obj); } EOLIAN static void diff --git a/src/lib/evas/canvas/efl_gfx_map.c b/src/lib/evas/canvas/efl_gfx_map.c index bb21a0999c..5f434b76ad 100644 --- a/src/lib/evas/canvas/efl_gfx_map.c +++ b/src/lib/evas/canvas/efl_gfx_map.c @@ -269,9 +269,7 @@ _map_calc(Eo *eo_obj, Evas_Object_Protected_Data *obj, Efl_Gfx_Map_Data *pd) pivot->changed = EINA_FALSE; if (!pivot->is_canvas) { - efl_gfx_geometry_get(pivot->eo_obj, - &pivot->geometry.x, &pivot->geometry.y, - &pivot->geometry.w, &pivot->geometry.h); + pivot->geometry = efl_gfx_geometry_get(pivot->eo_obj); } else { diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index 097fb9de5f..e3f428d91b 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c @@ -601,7 +601,7 @@ _efl_canvas_image_internal_efl_gfx_fill_fill_auto_set(Eo *eo_obj, Evas_Image_Dat { Evas_Coord w, h; - efl_gfx_geometry_get(eo_obj, NULL, NULL, &w, &h); + efl_gfx_size_get(eo_obj, &w, &h); _evas_image_fill_set(eo_obj, o, 0, 0, w, h); evas_object_event_callback_add(eo_obj, EVAS_CALLBACK_RESIZE, @@ -3526,7 +3526,7 @@ evas_object_image_filled_resize_listener(void *data EINA_UNUSED, Evas *e EINA_UN Evas_Image_Data *o = efl_data_scope_get(obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS); Evas_Coord w, h; - efl_gfx_geometry_get(obj, NULL, NULL, &w, &h); + efl_gfx_size_get(obj, &w, &h); if (w < 1) w = 1; if (h < 1) h = 1; _evas_image_fill_set(obj, o, 0, 0, w, h); diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index 056adff0aa..e8efe87265 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -1156,11 +1156,10 @@ end: } EOLIAN static void -_efl_canvas_object_efl_gfx_geometry_set(Eo *obj, Evas_Object_Protected_Data *pd EINA_UNUSED, - int x, int y, int w, int h) +_efl_canvas_object_efl_gfx_geometry_set(Eo *obj, Evas_Object_Protected_Data *pd EINA_UNUSED, Eina_Rectangle r) { - efl_gfx_position_set(obj, x, y); - efl_gfx_size_set(obj, w, h); + efl_gfx_position_set(obj, r.x, r.y); + efl_gfx_size_set(obj, r.w, r.h); } EAPI void @@ -1169,7 +1168,7 @@ evas_object_geometry_set(Evas_Object *eo_obj, Evas_Coord x, Evas_Coord y, Evas_C MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ); return; MAGIC_CHECK_END(); - efl_gfx_geometry_set(eo_obj, x, y, w, h); + efl_gfx_geometry_set(eo_obj, (Eina_Rectangle) { x, y, w, h }); } EAPI void @@ -1317,25 +1316,20 @@ _efl_canvas_object_efl_gfx_size_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, evas_object_inform_call_resize(eo_obj); } -EOLIAN void -_efl_canvas_object_efl_gfx_geometry_get(Eo *obj, Evas_Object_Protected_Data *pd EINA_UNUSED, - int *x, int *y, int *w, int *h) +EOLIAN Eina_Rectangle +_efl_canvas_object_efl_gfx_geometry_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj) { - efl_gfx_position_get(obj, x, y); - efl_gfx_size_get(obj, w, h); + return obj->cur->geometry; } EAPI void evas_object_geometry_get(const Evas_Object *eo_obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { - MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ); - if (x) *x = 0; - if (y) *y = 0; - if (w) *w = 0; - if (h) *h = 0; - return; - MAGIC_CHECK_END(); - efl_gfx_geometry_get(eo_obj, x, y, w, h); + Eina_Rectangle r = efl_gfx_geometry_get(eo_obj); + if (x) *x = r.x; + if (y) *y = r.y; + if (w) *w = r.w; + if (h) *h = r.h; } EOLIAN static void diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index b64af96807..f6ce22d4eb 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -223,12 +223,13 @@ _efl_vg_efl_gfx_size_get(Eo *obj, if (h) *h = r.h; } -EOLIAN static void -_efl_vg_efl_gfx_geometry_get(Eo *obj, Efl_VG_Data *pd EINA_UNUSED, - int *x, int *y, int *w, int *h) +EOLIAN static Eina_Rectangle +_efl_vg_efl_gfx_geometry_get(Eo *obj, Efl_VG_Data *pd EINA_UNUSED) { - efl_gfx_position_get(obj, x, y); - efl_gfx_size_get(obj, w, h); + Eina_Rectangle r = { 0, }; + efl_gfx_position_get(obj, &r.x, &r.y); + efl_gfx_size_get(obj, &r.w, &r.h); + return r; } // Parent should be a container otherwise dismissing the stacking operation diff --git a/src/tests/elementary/elm_test_focus_common.c b/src/tests/elementary/elm_test_focus_common.c index 128e1c00ac..f75730b9dd 100644 --- a/src/tests/elementary/elm_test_focus_common.c +++ b/src/tests/elementary/elm_test_focus_common.c @@ -91,14 +91,10 @@ _focus_test_size(Eo *obj EINA_UNUSED, Focus_Test_Data *pd, Eina_Rectangle rect) pd->rect = rect; } - -EOLIAN static void -_focus_test_efl_gfx_geometry_get(Eo *obj EINA_UNUSED, Focus_Test_Data *pd, int *x, int *y, int *w, int *h) +EOLIAN static Eina_Rectangle +_focus_test_efl_gfx_geometry_get(Eo *obj EINA_UNUSED, Focus_Test_Data *pd) { - *x = pd->rect.x; - *y = pd->rect.y; - *w = pd->rect.w; - *h = pd->rect.h; + return pd->rect; } |