forked from enlightenment/efl
widget: Simplify code with rectangle (EO)
This replaces x,y,w,h with a rectangle in parts of the focus_region code. Ref T5363
This commit is contained in:
parent
d928ba989a
commit
233068c30c
|
@ -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
|
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;
|
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_geometry_get(obj,
|
||||||
efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN),
|
efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN),
|
||||||
EFL_TEXT_CURSOR_TYPE_BEFORE,
|
EFL_TEXT_CURSOR_TYPE_BEFORE,
|
||||||
x, y, w, h,
|
&r->x, &r->y, &r->w, &r->h,
|
||||||
NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (sd->single_line)
|
if (sd->single_line)
|
||||||
{
|
{
|
||||||
evas_object_geometry_get(sd->entry_edje, NULL, NULL, NULL, h);
|
evas_object_geometry_get(sd->entry_edje, NULL, NULL, NULL, &r->h);
|
||||||
if (y) *y = 0;
|
r->y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
evas_object_geometry_get(sd->entry_edje, &edje_x, &edje_y, NULL, NULL);
|
evas_object_geometry_get(sd->entry_edje, &edje_x, &edje_y, NULL, NULL);
|
||||||
|
|
||||||
evas_object_geometry_get(obj, &elm_x, &elm_y, NULL, NULL);
|
evas_object_geometry_get(obj, &elm_x, &elm_y, NULL, NULL);
|
||||||
|
|
||||||
if (x) *x += edje_x - elm_x;
|
r->x += edje_x - elm_x;
|
||||||
if (y) *y += edje_y - elm_y;
|
r->y += edje_y - elm_y;
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -663,14 +663,14 @@ _show_region_job(void *data)
|
||||||
focus_obj = elm_widget_focused_object_get(data);
|
focus_obj = elm_widget_focused_object_get(data);
|
||||||
if (focus_obj)
|
if (focus_obj)
|
||||||
{
|
{
|
||||||
Evas_Coord x, y, w, h;
|
Eina_Rectangle r;
|
||||||
|
|
||||||
elm_widget_focus_region_get(focus_obj, &x, &y, &w, &h);
|
elm_widget_focus_region_get(focus_obj, &r);
|
||||||
|
|
||||||
if (h < _elm_config->finger_size)
|
if (r.h < _elm_config->finger_size)
|
||||||
h = _elm_config->finger_size;
|
r.h = _elm_config->finger_size;
|
||||||
|
|
||||||
elm_widget_show_region_set(focus_obj, x, y, w, h, EINA_TRUE);
|
elm_widget_show_region_set(focus_obj, r.x, r.y, r.w, r.h, EINA_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
sd->show_region_job = NULL;
|
sd->show_region_job = NULL;
|
||||||
|
|
|
@ -1309,12 +1309,13 @@ _elm_entry_elm_widget_on_focus(Eo *obj, Elm_Entry_Data *sd, Elm_Object_Item *ite
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_elm_entry_elm_widget_focus_region_get(Eo *obj, Elm_Entry_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
_elm_entry_elm_widget_focus_region_get(Eo *obj, Elm_Entry_Data *sd, Eina_Rectangle *r)
|
||||||
{
|
{
|
||||||
Evas_Coord cx, cy, cw, ch;
|
Evas_Coord cx, cy, cw, ch;
|
||||||
Evas_Coord edx, edy;
|
Evas_Coord edx, edy;
|
||||||
Evas_Coord elx, ely, elw, elh;
|
Evas_Coord elx, ely, elw, elh;
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(r, EINA_FALSE);
|
||||||
edje_object_part_text_cursor_geometry_get
|
edje_object_part_text_cursor_geometry_get
|
||||||
(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
|
(sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
|
||||||
|
|
||||||
|
@ -1329,19 +1330,12 @@ _elm_entry_elm_widget_focus_region_get(Eo *obj, Elm_Entry_Data *sd, Evas_Coord *
|
||||||
}
|
}
|
||||||
evas_object_geometry_get(obj, &elx, &ely, &elw, &elh);
|
evas_object_geometry_get(obj, &elx, &ely, &elw, &elh);
|
||||||
|
|
||||||
if (x)
|
r->x = cx + edx - elx;
|
||||||
{
|
if ((cw < elw) && (r->x + cw > elw)) r->x = elw - cw;
|
||||||
*x = cx + edx - elx;
|
r->y = cy + edy - ely;
|
||||||
if ((cw < elw) && (*x + cw > elw)) *x = elw - cw;
|
if ((ch < elh) && (r->y + ch > elh)) r->y = elh - ch;
|
||||||
}
|
r->w = cw;
|
||||||
if (y)
|
r->h = ch;
|
||||||
{
|
|
||||||
*y = cy + edy - ely;
|
|
||||||
if ((ch < elh) && (*y + ch > elh)) *y = elh - ch;
|
|
||||||
}
|
|
||||||
if (w) *w = cw;
|
|
||||||
if (h) *h = ch;
|
|
||||||
|
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3540,24 +3540,25 @@ _elm_gengrid_elm_widget_on_focus(Eo *obj, Elm_Gengrid_Data *sd, Elm_Object_Item
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_elm_gengrid_elm_widget_focus_region_get(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
_elm_gengrid_elm_widget_focus_region_get(Eo *obj, Elm_Gengrid_Data *sd, Eina_Rectangle *r)
|
||||||
{
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(r, EINA_FALSE);
|
||||||
if (!sd->focused_item) goto end;
|
if (!sd->focused_item) goto end;
|
||||||
if (elm_object_focus_region_show_mode_get(obj) == ELM_FOCUS_REGION_SHOW_ITEM)
|
if (elm_object_focus_region_show_mode_get(obj) == ELM_FOCUS_REGION_SHOW_ITEM)
|
||||||
{
|
{
|
||||||
Evas_Coord vx, vy;
|
Evas_Coord vx, vy;
|
||||||
ELM_GENGRID_ITEM_DATA_GET(sd->focused_item, focus_it);
|
ELM_GENGRID_ITEM_DATA_GET(sd->focused_item, focus_it);
|
||||||
evas_object_geometry_get(VIEW(focus_it), x, y, w, h);
|
evas_object_geometry_get(VIEW(focus_it), &r->x, &r->y, &r->w, &r->h);
|
||||||
evas_object_geometry_get(obj, &vx, &vy, NULL, NULL);
|
evas_object_geometry_get(obj, &vx, &vy, NULL, NULL);
|
||||||
|
|
||||||
*x -= vx;
|
r->x -= vx;
|
||||||
*y -= vy;
|
r->y -= vy;
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
return elm_obj_widget_focus_region_get(efl_super(obj, MY_CLASS), x, y, w, h);
|
return elm_obj_widget_focus_region_get(efl_super(obj, MY_CLASS), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool _elm_gengrid_smart_focus_next_enable = EINA_FALSE;
|
static Eina_Bool _elm_gengrid_smart_focus_next_enable = EINA_FALSE;
|
||||||
|
|
|
@ -1107,24 +1107,19 @@ _elm_panel_toggle(Eo *obj, Elm_Panel_Data *_pd EINA_UNUSED)
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_elm_panel_elm_widget_focus_region_get(Eo *obj,
|
_elm_panel_elm_widget_focus_region_get(Eo *obj, Elm_Panel_Data *sd, Eina_Rectangle *r)
|
||||||
Elm_Panel_Data *sd,
|
|
||||||
Evas_Coord *x,
|
|
||||||
Evas_Coord *y,
|
|
||||||
Evas_Coord *w,
|
|
||||||
Evas_Coord *h)
|
|
||||||
{
|
{
|
||||||
elm_interface_scrollable_content_pos_get(obj, x, y);
|
elm_interface_scrollable_content_pos_get(obj, &r->x, &r->y);
|
||||||
evas_object_geometry_get(obj, NULL, NULL, w, h);
|
evas_object_geometry_get(obj, NULL, NULL, &r->w, &r->h);
|
||||||
switch (sd->orient)
|
switch (sd->orient)
|
||||||
{
|
{
|
||||||
case ELM_PANEL_ORIENT_TOP:
|
case ELM_PANEL_ORIENT_TOP:
|
||||||
case ELM_PANEL_ORIENT_BOTTOM:
|
case ELM_PANEL_ORIENT_BOTTOM:
|
||||||
*h = *h * sd->content_size_ratio;
|
r->h *= sd->content_size_ratio;
|
||||||
break;
|
break;
|
||||||
case ELM_PANEL_ORIENT_LEFT:
|
case ELM_PANEL_ORIENT_LEFT:
|
||||||
case ELM_PANEL_ORIENT_RIGHT:
|
case ELM_PANEL_ORIENT_RIGHT:
|
||||||
*w = *w * sd->content_size_ratio;
|
r->w *= sd->content_size_ratio;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
|
|
@ -1031,13 +1031,14 @@ _propagate_event_legacy(Eo *parent, const Efl_Event *event, Eo *obj, Elm_Event_C
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_elm_widget_focus_region_show(const Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
|
_elm_widget_focus_region_show(const Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Evas_Coord x, y, w, h, ox, oy;
|
Evas_Coord ox, oy;
|
||||||
|
Eina_Rectangle r;
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
|
|
||||||
o = elm_widget_parent_get(obj);
|
o = elm_widget_parent_get(obj);
|
||||||
if (!o) return;
|
if (!o) return;
|
||||||
|
|
||||||
if (!elm_widget_focus_region_get(obj, &x, &y, &w, &h))
|
if (!elm_widget_focus_region_get(obj, &r))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
|
evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
|
||||||
|
@ -1054,28 +1055,28 @@ _elm_widget_focus_region_show(const Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNU
|
||||||
|
|
||||||
// Get the object's on_focus_region position relative to the scroller.
|
// Get the object's on_focus_region position relative to the scroller.
|
||||||
Evas_Coord rx, ry;
|
Evas_Coord rx, ry;
|
||||||
rx = ox + x - px + sx;
|
rx = ox + r.x - px + sx;
|
||||||
ry = oy + y - py + sy;
|
ry = oy + r.y - py + sy;
|
||||||
|
|
||||||
switch (_elm_config->focus_autoscroll_mode)
|
switch (_elm_config->focus_autoscroll_mode)
|
||||||
{
|
{
|
||||||
case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
|
case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
|
||||||
elm_interface_scrollable_content_region_show(o, rx, ry, w, h);
|
elm_interface_scrollable_content_region_show(o, rx, ry, r.w, r.h);
|
||||||
break;
|
break;
|
||||||
case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
|
case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
|
||||||
elm_interface_scrollable_region_bring_in(o, rx, ry, w, h);
|
elm_interface_scrollable_region_bring_in(o, rx, ry, r.w, r.h);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
elm_widget_focus_region_get(o, &x, &y, &w, &h);
|
elm_widget_focus_region_get(o, &r);
|
||||||
evas_object_geometry_get(o, &ox, &oy, NULL, NULL);
|
evas_object_geometry_get(o, &ox, &oy, NULL, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x += ox - px;
|
r.x += ox - px;
|
||||||
y += oy - py;
|
r.y += oy - py;
|
||||||
ox = px;
|
ox = px;
|
||||||
oy = py;
|
oy = py;
|
||||||
}
|
}
|
||||||
|
@ -3476,12 +3477,13 @@ _elm_widget_show_region_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd
|
||||||
* @ingroup Widget
|
* @ingroup Widget
|
||||||
*/
|
*/
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_elm_widget_focus_region_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
_elm_widget_focus_region_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Rectangle *r)
|
||||||
{
|
{
|
||||||
efl_gfx_size_get(obj, w, h);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(r, EINA_FALSE);
|
||||||
if (x) *x = 0;
|
efl_gfx_size_get(obj, &r->w, &r->h);
|
||||||
if (y) *y = 0;
|
r->x = 0;
|
||||||
if ((*w <= 0) || (*h <= 0)) return EINA_FALSE;
|
r->y = 0;
|
||||||
|
if ((r->w <= 0) || (r->h <= 0)) return EINA_FALSE;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -496,7 +496,6 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible,
|
||||||
[[Pop scroller freeze]]
|
[[Pop scroller freeze]]
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Old focus API. FIXME: Needs massive clean up! */
|
|
||||||
@property focus_region {
|
@property focus_region {
|
||||||
[[Region to show when focus changes within this widget.
|
[[Region to show when focus changes within this widget.
|
||||||
|
|
||||||
|
@ -517,12 +516,11 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible,
|
||||||
return: bool; [[If $false, @.focus_region_show will not do anything.]]
|
return: bool; [[If $false, @.focus_region_show will not do anything.]]
|
||||||
}
|
}
|
||||||
values {
|
values {
|
||||||
x: int; [[X coordinate]]
|
region: Eina.Rectangle; [[The relative region to show.]]
|
||||||
y: int; [[Y coordinate]]
|
|
||||||
w: int; [[Width]]
|
|
||||||
h: int; [[Height]]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Old focus API. FIXME: Needs massive clean up! */
|
||||||
@property focus_order {
|
@property focus_order {
|
||||||
[[Focus order property]]
|
[[Focus order property]]
|
||||||
get {
|
get {
|
||||||
|
|
|
@ -721,7 +721,7 @@ EAPI void elm_widget_disabled_set(Evas_Object *obj, Eina_Bool disabl
|
||||||
EAPI Eina_Bool elm_widget_disabled_get(const Evas_Object *obj);
|
EAPI Eina_Bool elm_widget_disabled_get(const Evas_Object *obj);
|
||||||
EAPI void elm_widget_show_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Eina_Bool forceshow);
|
EAPI void elm_widget_show_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Eina_Bool forceshow);
|
||||||
EAPI void elm_widget_show_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
|
EAPI void elm_widget_show_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
|
||||||
EAPI Eina_Bool elm_widget_focus_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
|
EAPI Eina_Bool elm_widget_focus_region_get(const Evas_Object *obj, Eina_Rectangle *r);
|
||||||
EAPI void elm_widget_focus_region_show(const Evas_Object *obj);
|
EAPI void elm_widget_focus_region_show(const Evas_Object *obj);
|
||||||
EAPI void elm_widget_scroll_hold_push(Evas_Object *obj);
|
EAPI void elm_widget_scroll_hold_push(Evas_Object *obj);
|
||||||
EAPI void elm_widget_scroll_hold_pop(Evas_Object *obj);
|
EAPI void elm_widget_scroll_hold_pop(Evas_Object *obj);
|
||||||
|
|
Loading…
Reference in New Issue