forked from enlightenment/efl
format fixup.
This commit is contained in:
parent
46bfe985d9
commit
ce30683587
|
@ -55,30 +55,27 @@ _find_gengrid_parent_item(const Evas_Object *base)
|
|||
static Eina_Bool
|
||||
_can_focus(const Evas_Object *obj)
|
||||
{
|
||||
if (obj && elm_object_focus_allow_get(obj) &&
|
||||
elm_widget_can_focus_get(obj))
|
||||
if (obj && elm_object_focus_allow_get(obj) && elm_widget_can_focus_get(obj))
|
||||
return EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
||||
static Eina_List *
|
||||
_get_contents(const Evas_Object *obj)
|
||||
{
|
||||
Eina_List *res = NULL;
|
||||
if (!obj)
|
||||
return NULL;
|
||||
if (!obj) return NULL;
|
||||
|
||||
if (evas_object_smart_type_check(obj, "elm_layout"))
|
||||
{
|
||||
Evas_Object *edje = elm_layout_edje_get(obj);
|
||||
|
||||
if (edje)
|
||||
{
|
||||
const Eina_List *l = NULL;
|
||||
const char *key;
|
||||
const Eina_List *contents =
|
||||
elm_widget_stringlist_get(
|
||||
edje_object_data_get(edje, "contents"));
|
||||
elm_widget_stringlist_get(edje_object_data_get(edje, "contents"));
|
||||
|
||||
EINA_LIST_FOREACH(contents, l, key)
|
||||
{
|
||||
|
@ -92,10 +89,7 @@ _get_contents(const Evas_Object *obj)
|
|||
res = eina_list_append(res, child);
|
||||
|
||||
l1 = _get_contents(child);
|
||||
if (l1)
|
||||
{
|
||||
res = eina_list_merge(res, l1);
|
||||
}
|
||||
if (l1) res = eina_list_merge(res, l1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,10 +112,7 @@ _gengrid_item_contents_get(const Elm_Gen_Item *it)
|
|||
res = eina_list_append(res, child);
|
||||
|
||||
l1 = _get_contents(child);
|
||||
if (l1)
|
||||
{
|
||||
res = eina_list_merge(res, l1);
|
||||
}
|
||||
if (l1) res = eina_list_merge(res, l1);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
@ -139,7 +130,6 @@ _find_focusable_object(const Elm_Gen_Item *it,
|
|||
if (!it) return NULL;
|
||||
|
||||
contents = _gengrid_item_contents_get(it);
|
||||
|
||||
if (contents)
|
||||
{
|
||||
if (base)
|
||||
|
@ -148,33 +138,27 @@ _find_focusable_object(const Elm_Gen_Item *it,
|
|||
obj = base;
|
||||
}
|
||||
|
||||
if (dir == ELM_FOCUS_LEFT || dir == ELM_FOCUS_UP)
|
||||
if ((dir == ELM_FOCUS_LEFT) || (dir == ELM_FOCUS_UP))
|
||||
{
|
||||
if (l)
|
||||
l = eina_list_prev(l);
|
||||
else
|
||||
l = eina_list_last(contents);
|
||||
if (l) l = eina_list_prev(l);
|
||||
else l = eina_list_last(contents);
|
||||
|
||||
while (l)
|
||||
{
|
||||
obj = eina_list_data_get(l);
|
||||
if (_can_focus(obj))
|
||||
break;
|
||||
if (_can_focus(obj)) break;
|
||||
obj = NULL;
|
||||
l = eina_list_prev(l);
|
||||
}
|
||||
}
|
||||
else if (dir == ELM_FOCUS_RIGHT || dir == ELM_FOCUS_DOWN)
|
||||
else if ((dir == ELM_FOCUS_RIGHT) || (dir == ELM_FOCUS_DOWN))
|
||||
{
|
||||
if (l)
|
||||
l = eina_list_next(l);
|
||||
else
|
||||
l = contents;
|
||||
if (l) l = eina_list_next(l);
|
||||
else l = contents;
|
||||
while (l)
|
||||
{
|
||||
obj = eina_list_data_get(l);
|
||||
if (_can_focus(obj))
|
||||
break;
|
||||
if (_can_focus(obj)) break;
|
||||
obj = NULL;
|
||||
l = eina_list_next(l);
|
||||
}
|
||||
|
@ -221,10 +205,7 @@ _find_item_for_base(const Evas_Object *obj,
|
|||
Elm_Gen_Item *res = NULL;
|
||||
Elm_Gen_Item *it = (Elm_Gen_Item *)(sd->last_selected_item);
|
||||
|
||||
if (it && _check_item_contains(it, base))
|
||||
{
|
||||
res = it;
|
||||
}
|
||||
if (it && (_check_item_contains(it, base))) res = it;
|
||||
else
|
||||
{ // try find in all
|
||||
EINA_INLIST_FOREACH(sd->items, it)
|
||||
|
@ -240,60 +221,47 @@ _find_item_for_base(const Evas_Object *obj,
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_gengrid_self_focus_item_get(
|
||||
const Evas_Object *obj, const Evas_Object *base,
|
||||
_gengrid_self_focus_item_get(const Evas_Object *obj, const Evas_Object *base,
|
||||
// list of Elm_Gen_Items
|
||||
const Eina_List *items, void *(*list_data_get)(const Eina_List *l),
|
||||
double degree, Evas_Object **direction, double *weight)
|
||||
const Eina_List *items,
|
||||
void *(*list_data_get)(const Eina_List *l) EINA_UNUSED,
|
||||
double degree, Evas_Object **direction,
|
||||
double *weight)
|
||||
{
|
||||
Evas_Coord ox, oy;
|
||||
Evas_Coord vw, vh;
|
||||
const Evas_Object *res_obj = NULL;
|
||||
Elm_Focus_Direction dir = ELM_FOCUS_UP;
|
||||
|
||||
unsigned int items_count = 0;
|
||||
unsigned int columns = 0, items_visible = 0;
|
||||
unsigned int items_row = 0, items_col = 0, rows = 0;
|
||||
int new_position = 0;
|
||||
int cx = 0;
|
||||
int cy = 0;
|
||||
|
||||
int focused_pos = 0;
|
||||
|
||||
Elm_Gen_Item *it = NULL;
|
||||
Elm_Gen_Item *it_res = NULL;
|
||||
Eina_List *list = NULL;
|
||||
Eina_List *l = NULL;
|
||||
|
||||
Elm_Gen_Item *focused_item = NULL;
|
||||
|
||||
(void)list_data_get;
|
||||
|
||||
ELM_GENGRID_CHECK(obj) EINA_FALSE;
|
||||
ELM_GENGRID_DATA_GET(obj, sd);
|
||||
|
||||
if (!direction || !weight || !base || !items) return EINA_FALSE;
|
||||
if ((!direction) || (!weight) || (!base) || (!items)) return EINA_FALSE;
|
||||
|
||||
evas_object_geometry_get(sd->pan_obj, &ox, &oy, &vw, &vh);
|
||||
|
||||
focused_item = _find_item_for_base(obj, base);
|
||||
|
||||
if (!focused_item) return EINA_FALSE;
|
||||
|
||||
|
||||
if (degree == 0)
|
||||
dir = ELM_FOCUS_UP;
|
||||
else if (degree == 90)
|
||||
dir = ELM_FOCUS_RIGHT;
|
||||
else if (degree == 180)
|
||||
dir = ELM_FOCUS_DOWN;
|
||||
else if (degree == 270)
|
||||
dir = ELM_FOCUS_LEFT;
|
||||
else
|
||||
return EINA_FALSE;
|
||||
if (degree == 0) dir = ELM_FOCUS_UP;
|
||||
else if (degree == 90) dir = ELM_FOCUS_RIGHT;
|
||||
else if (degree == 180) dir = ELM_FOCUS_DOWN;
|
||||
else if (degree == 270) dir = ELM_FOCUS_LEFT;
|
||||
else return EINA_FALSE;
|
||||
|
||||
res_obj = _find_focusable_object(focused_item, base, dir);
|
||||
if (res_obj && res_obj != base)
|
||||
if (res_obj && (res_obj != base))
|
||||
{
|
||||
*direction = (Evas_Object *)res_obj;
|
||||
*weight = WEIGHT_MAX;
|
||||
|
@ -302,8 +270,8 @@ _gengrid_self_focus_item_get(
|
|||
|
||||
focused_pos = focused_item->position - 1;
|
||||
|
||||
items_count =
|
||||
sd->item_count - eina_list_count(sd->group_items) + sd->items_lost;
|
||||
items_count = sd->item_count -
|
||||
eina_list_count(sd->group_items) + sd->items_lost;
|
||||
if (sd->horizontal)
|
||||
{
|
||||
if (sd->item_height > 0) items_visible = vh / sd->item_height;
|
||||
|
@ -334,14 +302,10 @@ _gengrid_self_focus_item_get(
|
|||
}
|
||||
|
||||
|
||||
if (dir == ELM_FOCUS_UP)
|
||||
cy--;
|
||||
else if (dir == ELM_FOCUS_RIGHT)
|
||||
cx++;
|
||||
else if (dir == ELM_FOCUS_DOWN)
|
||||
cy++;
|
||||
else if (dir == ELM_FOCUS_LEFT)
|
||||
cx--;
|
||||
if (dir == ELM_FOCUS_UP) cy--;
|
||||
else if (dir == ELM_FOCUS_RIGHT) cx++;
|
||||
else if (dir == ELM_FOCUS_DOWN) cy++;
|
||||
else if (dir == ELM_FOCUS_LEFT) cx--;
|
||||
|
||||
if (cx < 0 || cy < 0) return EINA_FALSE;
|
||||
|
||||
|
@ -391,10 +355,7 @@ _gengrid_self_focus_item_get(
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
else return EINA_FALSE;
|
||||
|
||||
if (it_res)
|
||||
{
|
||||
|
@ -407,17 +368,19 @@ _gengrid_self_focus_item_get(
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_gengrid_focus_list_direction_get(
|
||||
const Evas_Object *obj, const Evas_Object *base,
|
||||
_gengrid_focus_list_direction_get(const Evas_Object *obj,
|
||||
const Evas_Object *base,
|
||||
// list of Elm_Gen_Items
|
||||
const Eina_List *items, void *(*list_data_get)(const Eina_List *l),
|
||||
double degree, Evas_Object **direction, double *weight)
|
||||
const Eina_List *items,
|
||||
void *(*list_data_get)(const Eina_List *l),
|
||||
double degree, Evas_Object **direction,
|
||||
double *weight)
|
||||
{
|
||||
const Eina_List *l = NULL;
|
||||
Evas_Object *current_best = NULL;
|
||||
(void)list_data_get;
|
||||
ELM_GENGRID_CHECK(obj) EINA_FALSE;
|
||||
if (!direction || !weight || !base || !items) return EINA_FALSE;
|
||||
|
||||
if ((!direction) || (!weight) || (!base) || (!items)) return EINA_FALSE;
|
||||
|
||||
l = items;
|
||||
current_best = *direction;
|
||||
|
@ -437,15 +400,13 @@ _gengrid_focus_list_direction_get(
|
|||
EINA_LIST_FOREACH(contents, l2, content)
|
||||
{
|
||||
// if better element than set new sd->focused and sd->selected
|
||||
elm_widget_focus_direction_get(content, base, degree, direction,
|
||||
weight);
|
||||
elm_widget_focus_direction_get(content, base, degree,
|
||||
direction, weight);
|
||||
}
|
||||
eina_list_free(contents);
|
||||
}
|
||||
}
|
||||
if (current_best != *direction)
|
||||
return EINA_TRUE;
|
||||
else
|
||||
if (current_best != *direction) return EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
@ -454,11 +415,12 @@ gen_focus_direction(Eo *obj, void *_pd, va_list *list)
|
|||
{
|
||||
Eina_List *items = NULL;
|
||||
const Evas_Object *parent = NULL;
|
||||
|
||||
void *(*list_data_get)(const Eina_List * list);
|
||||
Eina_List *(*list_free)(Eina_List * list);
|
||||
|
||||
Elm_Gengrid_Smart_Data *sd = _pd;
|
||||
Eina_Bool (*list_direction_get)(const Evas_Object * obj, const Evas_Object * base,
|
||||
const Eina_List * items, void * (*list_data_get)(const Eina_List * l),
|
||||
double degree, Evas_Object * *direction, double * weight);
|
||||
|
||||
Evas_Object *base = va_arg(*list, Evas_Object *);
|
||||
double degree = va_arg(*list, double);
|
||||
|
@ -472,15 +434,8 @@ gen_focus_direction(Eo *obj, void *_pd, va_list *list)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
*ret = EINA_FALSE;
|
||||
list_data_get = NULL;
|
||||
|
||||
Eina_Bool (*list_direction_get)(
|
||||
const Evas_Object * obj, const Evas_Object * base,
|
||||
const Eina_List * items, void * (*list_data_get)(const Eina_List * l),
|
||||
double degree, Evas_Object * *direction, double * weight);
|
||||
|
||||
list_direction_get = NULL;
|
||||
list_free = NULL;
|
||||
parent = _find_gengrid_parent_item(base);
|
||||
|
@ -517,23 +472,20 @@ gen_focus_direction(Eo *obj, void *_pd, va_list *list)
|
|||
return;
|
||||
}
|
||||
|
||||
*ret = list_direction_get(obj, base, items, list_data_get, degree, direction,
|
||||
weight);
|
||||
|
||||
*ret = list_direction_get(obj, base, items, list_data_get, degree,
|
||||
direction, weight);
|
||||
if (list_free) list_free(items);
|
||||
}
|
||||
|
||||
// module api funcs needed
|
||||
EAPI int
|
||||
elm_modapi_init(void *m)
|
||||
elm_modapi_init(void *m EINA_UNUSED)
|
||||
{
|
||||
(void) m;
|
||||
return 1; // succeed always
|
||||
}
|
||||
|
||||
EAPI int
|
||||
elm_modapi_shutdown(void *m)
|
||||
elm_modapi_shutdown(void *m EINA_UNUSED)
|
||||
{
|
||||
(void) m;
|
||||
return 1; // succeed always
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue