On Tue, Aug 29, 2017 at 11:27 PM, Jean-Philippe André <j...@videolan.org> wrote:
> 2017-08-30 10:49 GMT+09:00 Jean-Philippe André <j...@videolan.org>:
>
>>
>>
>> 2017-08-29 22:04 GMT+09:00 Gustavo Sverzut Barbieri <barbi...@gmail.com>:
>>
>>> On Tue, Aug 29, 2017 at 4:29 AM, Jean-Philippe ANDRÉ <j...@videolan.org>
>>> wrote:
>>> > jpeg pushed a commit to branch master.
>>> >
>>> > http://git.enlightenment.org/core/efl.git/commit/?id=233068c
>>> 30c90c7cafbdcd7108f78ea0d353d26ad
>>> >
>>> > commit 233068c30c90c7cafbdcd7108f78ea0d353d26ad
>>> > Author: Jean-Philippe Andre <jp.an...@samsung.com>
>>> > Date:   Tue Aug 29 14:29:45 2017 +0900
>>> >
>>> >     widget: Simplify code with rectangle (EO)
>>> >
>>> >     This replaces x,y,w,h with a rectangle in parts of the focus_region
>>> >     code.
>>> >
>>> >     Ref T5363
>>> > ---
>>> >  src/lib/elementary/efl_ui_text.c | 14 +++++++-------
>>> >  src/lib/elementary/elm_conform.c | 10 +++++-----
>>> >  src/lib/elementary/elm_entry.c   | 22 ++++++++--------------
>>> >  src/lib/elementary/elm_gengrid.c | 11 ++++++-----
>>> >  src/lib/elementary/elm_panel.c   | 15 +++++----------
>>> >  src/lib/elementary/elm_widget.c  | 30 ++++++++++++++++--------------
>>> >  src/lib/elementary/elm_widget.eo |  8 +++-----
>>> >  src/lib/elementary/elm_widget.h  |  2 +-
>>> >  8 files changed, 51 insertions(+), 61 deletions(-)
>>> >
>>> > diff --git a/src/lib/elementary/efl_ui_text.c
>>> b/src/lib/elementary/efl_ui_text.c
>>> > index dc3fadb605..46da72ea5e 100644
>>> > --- a/src/lib/elementary/efl_ui_text.c
>>> > +++ b/src/lib/elementary/efl_ui_text.c
>>> > @@ -1203,28 +1203,28 @@ _efl_ui_text_elm_widget_on_focus(Eo *obj,
>>> Efl_Ui_Text_Data *sd, Elm_Object_Item
>>> >  }
>>> >
>>> >  EOLIAN static Eina_Bool
>>> > -_efl_ui_text_elm_widget_focus_region_get(Eo *obj EINA_UNUSED,
>>> Efl_Ui_Text_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w,
>>> Evas_Coord *h)
>>> > +_efl_ui_text_elm_widget_focus_region_get(Eo *obj EINA_UNUSED,
>>> Efl_Ui_Text_Data *sd, Eina_Rectangle *r)
>>> >  {
>>> >     Evas_Coord edje_x, edje_y, elm_x, elm_y;
>>> >
>>> > +   EINA_SAFETY_ON_NULL_RETURN_VAL(r, EINA_FALSE);
>>> >     efl_text_cursor_geometry_get(obj,
>>> >           efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN),
>>> >           EFL_TEXT_CURSOR_TYPE_BEFORE,
>>> > -         x, y, w, h,
>>> > +         &r->x, &r->y, &r->w, &r->h,
>>>
>>> these API should change to return a Eina_Rectangle on the stack, much
>>> simpler... also set could receive it as parameter:
>>>
>>> Eina_Rectanle r = efl_text_cursor_geometry_get(o, ...);
>>> r = eina_rectangle_move(r, +10, -10);
>>> efl_text_..._geometry_set(o, ..., r);
>>
>>
>> In this case there is a bool return value as well. That bool is required
>> for the logic.
>> I considered returning on the stack and using w<=0 or h<=0 as equivalent
>> to "false" return, but didn't do it to make sure the logic remains the
>> same. This might still be doable in a later patch.
>>
>
> Actually I will do and test just that.
>
> Besides that, I think we need an int 2d vector type. Right now we have:
>
> Eina_Rectangle { int x,y,w,h; }
> Eina_Vector2  { double x,y; }
> Evas_Coord_Size { int w,h; }
> Evas_Coord_Point { int x,y; }
>
> Any idea for a clear name? What comes to mind are:
> Eina_Vector2i { int x,y; }
> Eina_Size { int w,h; }
> Eina_Position { int x,y; }
>
> Anything with unions would be confusing I think.
>
> Anyway if we agree on a good 2d int type we can add a few convenience
> functions to eina_rectangle (move does not exist) and that new type, and
> then swicth all size, position and geometry APIs to those structs. I
> believe having those structs on the stack would be nicer than pointers to
> x,y,w,h (less likely to crash, all values initialized, less code, etc...)

I like your names and proposals... and I knew "move" doesn't exist...

when I did the python bindings (v1) it was all about those kind of
helpers, you could easily "center" 2 objects, align to
top-left/top-right/bottom-left/bottom-right...

I'm all for packing stuff that belongs together... together... That's
why I pushed for Eina_Slice, to make clear the 2 pointers are related.
Same for geometry/size/position... Would do the same for colors (as
someone asked the other day in the list).

Not to say that in our declarations, it's cleaner to read:

    Eina_Rectangle a, b;

    bla_get(&a, &b);

Than:

   int ax, ay, aw, ah, bx, by, bw, bh;

   bla_get(&ax, &aw, &ay, &ah, &bx, &by, &bw, &bh);


(maybe you didn't notice, but there is a bug in what I wrote ;-))




-- 
Gustavo Sverzut Barbieri
--------------------------------------
Mobile: +55 (16) 99354-9890

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to