forked from enlightenment/efl
efl_gfx: Use Eina.Rectangle for geometry (EO)
This saves a few lines already (without even having the proper helpers for stack rectangles).
This commit is contained in:
parent
0c46fc7103
commit
13da5e980e
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
Eina_Rectangle r;
|
||||
|
||||
efl_gfx_geometry_get(ev->object, &x, &y, &w, &h);
|
||||
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue