Index: src/lib/elc_ctxpopup.c =================================================================== --- src/lib/elc_ctxpopup.c (revision 83456) +++ src/lib/elc_ctxpopup.c (working copy) @@ -12,300 +12,300 @@ EAPI const char ELM_CTXPOPUP_SMART_NAME[] = "elm_c static const char SIG_DISMISSED[] = "dismissed"; static const Evas_Smart_Cb_Description _smart_callbacks[] = { - {SIG_DISMISSED, ""}, - {NULL, NULL} + {SIG_DISMISSED, ""}, + {NULL, NULL} }; -static void + static void _elm_ctxpopup_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list) { - Eina_Bool *ret = va_arg(*list, Eina_Bool *); - *ret = EINA_TRUE; + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + *ret = EINA_TRUE; } -static void + static void _elm_ctxpopup_smart_focus_direction_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list) { - Eina_Bool *ret = va_arg(*list, Eina_Bool *); - *ret = EINA_FALSE; + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + *ret = EINA_FALSE; } -static void + static void _elm_ctxpopup_smart_focus_next(Eo *obj EINA_UNUSED, void *_pd, va_list *list) { - Elm_Ctxpopup_Smart_Data *sd = _pd; + Elm_Ctxpopup_Smart_Data *sd = _pd; - Elm_Focus_Direction dir = va_arg(*list, Elm_Focus_Direction); - Evas_Object **next = va_arg(*list, Evas_Object **); - Eina_Bool *ret = va_arg(*list, Eina_Bool *); - if (ret) *ret = EINA_FALSE; + Elm_Focus_Direction dir = va_arg(*list, Elm_Focus_Direction); + Evas_Object **next = va_arg(*list, Evas_Object **); + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + if (ret) *ret = EINA_FALSE; - if (!sd) - return; + if (!sd) + return; - if (!elm_widget_focus_next_get(sd->box, dir, next)) - { - elm_widget_focused_object_clear(sd->box); - elm_widget_focus_next_get(sd->box, dir, next); - } + if (!elm_widget_focus_next_get(sd->box, dir, next)) + { + elm_widget_focused_object_clear(sd->box); + elm_widget_focus_next_get(sd->box, dir, next); + } - if (ret) *ret = EINA_TRUE; + if (ret) *ret = EINA_TRUE; } -static void + static void _elm_ctxpopup_smart_event(Eo *obj, void *_pd, va_list *list) { - Evas_Object *src = va_arg(*list, Evas_Object *); - (void)src; - Evas_Callback_Type type = va_arg(*list, Evas_Callback_Type); - void *event_info = va_arg(*list, void *); - Eina_Bool *ret = va_arg(*list, Eina_Bool *); - if (ret) *ret = EINA_FALSE; + Evas_Object *src = va_arg(*list, Evas_Object *); + (void)src; + Evas_Callback_Type type = va_arg(*list, Evas_Callback_Type); + void *event_info = va_arg(*list, void *); + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + if (ret) *ret = EINA_FALSE; - Evas_Event_Key_Down *ev = event_info; + Evas_Event_Key_Down *ev = event_info; - Elm_Ctxpopup_Smart_Data *sd = _pd; + Elm_Ctxpopup_Smart_Data *sd = _pd; - if (elm_widget_disabled_get(obj)) return; - if (type != EVAS_CALLBACK_KEY_DOWN) return; - if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; + if (elm_widget_disabled_get(obj)) return; + if (type != EVAS_CALLBACK_KEY_DOWN) return; + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; - if (!strcmp(ev->keyname, "Tab")) - { - if (evas_key_modifier_is_set(ev->modifiers, "Shift")) - elm_widget_focus_cycle(sd->box, ELM_FOCUS_PREVIOUS); - else - elm_widget_focus_cycle(sd->box, ELM_FOCUS_NEXT); - if (ret) *ret = EINA_TRUE; - return; - } + if (!strcmp(ev->keyname, "Tab")) + { + if (evas_key_modifier_is_set(ev->modifiers, "Shift")) + elm_widget_focus_cycle(sd->box, ELM_FOCUS_PREVIOUS); + else + elm_widget_focus_cycle(sd->box, ELM_FOCUS_NEXT); + if (ret) *ret = EINA_TRUE; + return; + } - if (strcmp(ev->keyname, "Escape")) return; + if (strcmp(ev->keyname, "Escape")) return; - evas_object_hide(obj); - ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; - if (ret) *ret = EINA_TRUE; + evas_object_hide(obj); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + if (ret) *ret = EINA_TRUE; } -static void + static void _x_pos_adjust(Evas_Coord_Point *pos, - Evas_Coord_Point *base_size, - Evas_Coord_Rectangle *hover_area) + Evas_Coord_Point *base_size, + Evas_Coord_Rectangle *hover_area) { - pos->x -= (base_size->x / 2); + pos->x -= (base_size->x / 2); - if (pos->x < hover_area->x) - pos->x = hover_area->x; - else if ((pos->x + base_size->x) > (hover_area->x + hover_area->w)) - pos->x = (hover_area->x + hover_area->w) - base_size->x; + if (pos->x < hover_area->x) + pos->x = hover_area->x; + else if ((pos->x + base_size->x) > (hover_area->x + hover_area->w)) + pos->x = (hover_area->x + hover_area->w) - base_size->x; - if (base_size->x > hover_area->w) - base_size->x -= (base_size->x - hover_area->w); + if (base_size->x > hover_area->w) + base_size->x -= (base_size->x - hover_area->w); - if (pos->x < hover_area->x) - pos->x = hover_area->x; + if (pos->x < hover_area->x) + pos->x = hover_area->x; } -static void + static void _y_pos_adjust(Evas_Coord_Point *pos, - Evas_Coord_Point *base_size, - Evas_Coord_Rectangle *hover_area) + Evas_Coord_Point *base_size, + Evas_Coord_Rectangle *hover_area) { - pos->y -= (base_size->y / 2); + pos->y -= (base_size->y / 2); - if (pos->y < hover_area->y) - pos->y = hover_area->y; - else if ((pos->y + base_size->y) > (hover_area->y + hover_area->h)) - pos->y = hover_area->y + hover_area->h - base_size->y; + if (pos->y < hover_area->y) + pos->y = hover_area->y; + else if ((pos->y + base_size->y) > (hover_area->y + hover_area->h)) + pos->y = hover_area->y + hover_area->h - base_size->y; - if (base_size->y > hover_area->h) - base_size->y -= (base_size->y - hover_area->h); + if (base_size->y > hover_area->h) + base_size->y -= (base_size->y - hover_area->h); - if (pos->y < hover_area->y) - pos->y = hover_area->y; + if (pos->y < hover_area->y) + pos->y = hover_area->y; } -static Elm_Ctxpopup_Direction + static Elm_Ctxpopup_Direction _base_geometry_calc(Evas_Object *obj, - Evas_Coord_Rectangle *rect) + Evas_Coord_Rectangle *rect) { - Elm_Ctxpopup_Direction dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN; - Evas_Coord_Rectangle hover_area; - Evas_Coord_Point pos = {0, 0}; - Evas_Coord_Point arrow_size; - Evas_Coord_Point base_size; - Evas_Coord_Point max_size; - Evas_Coord_Point min_size; - Evas_Coord_Point temp; - int idx; + Elm_Ctxpopup_Direction dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN; + Evas_Coord_Rectangle hover_area; + Evas_Coord_Point pos = {0, 0}; + Evas_Coord_Point arrow_size; + Evas_Coord_Point base_size; + Evas_Coord_Point max_size; + Evas_Coord_Point min_size; + Evas_Coord_Point temp; + int idx; - ELM_CTXPOPUP_DATA_GET(obj, sd); - Elm_Widget_Smart_Data *wd = eo_data_get(obj, ELM_OBJ_WIDGET_CLASS); + ELM_CTXPOPUP_DATA_GET(obj, sd); + Elm_Widget_Smart_Data *wd = eo_data_get(obj, ELM_OBJ_WIDGET_CLASS); - if (!rect) return ELM_CTXPOPUP_DIRECTION_DOWN; + if (!rect) return ELM_CTXPOPUP_DIRECTION_DOWN; - edje_object_part_geometry_get - (sd->arrow, "ctxpopup_arrow", NULL, NULL, &arrow_size.x, &arrow_size.y); - evas_object_resize(sd->arrow, arrow_size.x, arrow_size.y); + edje_object_part_geometry_get + (sd->arrow, "ctxpopup_arrow", NULL, NULL, &arrow_size.x, &arrow_size.y); + evas_object_resize(sd->arrow, arrow_size.x, arrow_size.y); - //Initialize Area Rectangle. - evas_object_geometry_get - (sd->parent, &hover_area.x, &hover_area.y, &hover_area.w, - &hover_area.h); + //Initialize Area Rectangle. + evas_object_geometry_get + (sd->parent, &hover_area.x, &hover_area.y, &hover_area.w, + &hover_area.h); - evas_object_geometry_get(obj, &pos.x, &pos.y, NULL, NULL); + evas_object_geometry_get(obj, &pos.x, &pos.y, NULL, NULL); - //recalc the edje - edje_object_size_min_calc - (wd->resize_obj, &base_size.x, &base_size.y); - evas_object_smart_calculate(wd->resize_obj); + //recalc the edje + edje_object_size_min_calc + (wd->resize_obj, &base_size.x, &base_size.y); + evas_object_smart_calculate(wd->resize_obj); - //Limit to Max Size - evas_object_size_hint_max_get(obj, &max_size.x, &max_size.y); + //Limit to Max Size + evas_object_size_hint_max_get(obj, &max_size.x, &max_size.y); - if ((max_size.y > 0) && (base_size.y > max_size.y)) - base_size.y = max_size.y; + if ((max_size.y > 0) && (base_size.y > max_size.y)) + base_size.y = max_size.y; - if ((max_size.x > 0) && (base_size.x > max_size.x)) - base_size.x = max_size.x; + if ((max_size.x > 0) && (base_size.x > max_size.x)) + base_size.x = max_size.x; - //Limit to Min Size - evas_object_size_hint_min_get(obj, &min_size.x, &min_size.y); + //Limit to Min Size + evas_object_size_hint_min_get(obj, &min_size.x, &min_size.y); - if ((min_size.y > 0) && (base_size.y < min_size.y)) - base_size.y = min_size.y; + if ((min_size.y > 0) && (base_size.y < min_size.y)) + base_size.y = min_size.y; - if ((min_size.x > 0) && (base_size.x < min_size.x)) - base_size.x = min_size.x; + if ((min_size.x > 0) && (base_size.x < min_size.x)) + base_size.x = min_size.x; - //Check the Which direction is available. - //If find a avaialble direction, it adjusts position and size. - for (idx = 0; idx < 4; idx++) - { - switch (sd->dir_priority[idx]) - { - case ELM_CTXPOPUP_DIRECTION_UP: - temp.y = (pos.y - base_size.y); - if ((temp.y - arrow_size.y) < hover_area.y) - continue; + //Check the Which direction is available. + //If find a avaialble direction, it adjusts position and size. + for (idx = 0; idx < 4; idx++) + { + switch (sd->dir_priority[idx]) + { + case ELM_CTXPOPUP_DIRECTION_UP: + temp.y = (pos.y - base_size.y); + if ((temp.y - arrow_size.y) < hover_area.y) + continue; - _x_pos_adjust(&pos, &base_size, &hover_area); - pos.y -= base_size.y; - dir = ELM_CTXPOPUP_DIRECTION_UP; - break; + _x_pos_adjust(&pos, &base_size, &hover_area); + pos.y -= base_size.y; + dir = ELM_CTXPOPUP_DIRECTION_UP; + break; - case ELM_CTXPOPUP_DIRECTION_LEFT: - temp.x = (pos.x - base_size.x); - if ((temp.x - arrow_size.x) < hover_area.x) - continue; + case ELM_CTXPOPUP_DIRECTION_LEFT: + temp.x = (pos.x - base_size.x); + if ((temp.x - arrow_size.x) < hover_area.x) + continue; - _y_pos_adjust(&pos, &base_size, &hover_area); - pos.x -= base_size.x; - dir = ELM_CTXPOPUP_DIRECTION_LEFT; - break; + _y_pos_adjust(&pos, &base_size, &hover_area); + pos.x -= base_size.x; + dir = ELM_CTXPOPUP_DIRECTION_LEFT; + break; - case ELM_CTXPOPUP_DIRECTION_RIGHT: - temp.x = (pos.x + base_size.x); - if ((temp.x + arrow_size.x) > - (hover_area.x + hover_area.w)) - continue; + case ELM_CTXPOPUP_DIRECTION_RIGHT: + temp.x = (pos.x + base_size.x); + if ((temp.x + arrow_size.x) > + (hover_area.x + hover_area.w)) + continue; - _y_pos_adjust(&pos, &base_size, &hover_area); - dir = ELM_CTXPOPUP_DIRECTION_RIGHT; - break; + _y_pos_adjust(&pos, &base_size, &hover_area); + dir = ELM_CTXPOPUP_DIRECTION_RIGHT; + break; - case ELM_CTXPOPUP_DIRECTION_DOWN: - temp.y = (pos.y + base_size.y); - if ((temp.y + arrow_size.y) > - (hover_area.y + hover_area.h)) - continue; + case ELM_CTXPOPUP_DIRECTION_DOWN: + temp.y = (pos.y + base_size.y); + if ((temp.y + arrow_size.y) > + (hover_area.y + hover_area.h)) + continue; - _x_pos_adjust(&pos, &base_size, &hover_area); - dir = ELM_CTXPOPUP_DIRECTION_DOWN; - break; + _x_pos_adjust(&pos, &base_size, &hover_area); + dir = ELM_CTXPOPUP_DIRECTION_DOWN; + break; - default: - continue; - } - break; - } + default: + continue; + } + break; + } - //In this case, all directions are invalid because of lack of space. - if (idx == 4) - { - Evas_Coord length[2]; + //In this case, all directions are invalid because of lack of space. + if (idx == 4) + { + Evas_Coord length[2]; - if (!sd->horizontal) - { - length[0] = pos.y - hover_area.y; - length[1] = (hover_area.y + hover_area.h) - pos.y; + if (!sd->horizontal) + { + length[0] = pos.y - hover_area.y; + length[1] = (hover_area.y + hover_area.h) - pos.y; - // ELM_CTXPOPUP_DIRECTION_UP - if (length[0] > length[1]) - { - _x_pos_adjust(&pos, &base_size, &hover_area); - pos.y -= base_size.y; - dir = ELM_CTXPOPUP_DIRECTION_UP; - if (pos.y < (hover_area.y + arrow_size.y)) - { - base_size.y -= ((hover_area.y + arrow_size.y) - pos.y); - pos.y = hover_area.y + arrow_size.y; - } - } - //ELM_CTXPOPUP_DIRECTION_DOWN - else - { - _x_pos_adjust(&pos, &base_size, &hover_area); - dir = ELM_CTXPOPUP_DIRECTION_DOWN; - if ((pos.y + arrow_size.y + base_size.y) > - (hover_area.y + hover_area.h)) - base_size.y -= - ((pos.y + arrow_size.y + base_size.y) - - (hover_area.y + hover_area.h)); - } - } - else - { - length[0] = pos.x - hover_area.x; - length[1] = (hover_area.x + hover_area.w) - pos.x; + // ELM_CTXPOPUP_DIRECTION_UP + if (length[0] > length[1]) + { + _x_pos_adjust(&pos, &base_size, &hover_area); + pos.y -= base_size.y; + dir = ELM_CTXPOPUP_DIRECTION_UP; + if (pos.y < (hover_area.y + arrow_size.y)) + { + base_size.y -= ((hover_area.y + arrow_size.y) - pos.y); + pos.y = hover_area.y + arrow_size.y; + } + } + //ELM_CTXPOPUP_DIRECTION_DOWN + else + { + _x_pos_adjust(&pos, &base_size, &hover_area); + dir = ELM_CTXPOPUP_DIRECTION_DOWN; + if ((pos.y + arrow_size.y + base_size.y) > + (hover_area.y + hover_area.h)) + base_size.y -= + ((pos.y + arrow_size.y + base_size.y) - + (hover_area.y + hover_area.h)); + } + } + else + { + length[0] = pos.x - hover_area.x; + length[1] = (hover_area.x + hover_area.w) - pos.x; - //ELM_CTXPOPUP_DIRECTION_LEFT - if (length[0] > length[1]) - { - _y_pos_adjust(&pos, &base_size, &hover_area); - pos.x -= base_size.x; - dir = ELM_CTXPOPUP_DIRECTION_LEFT; - if (pos.x < (hover_area.x + arrow_size.x)) - { - base_size.x -= ((hover_area.x + arrow_size.x) - pos.x); - pos.x = hover_area.x + arrow_size.x; - } - } - //ELM_CTXPOPUP_DIRECTION_RIGHT - else - { - _y_pos_adjust(&pos, &base_size, &hover_area); - dir = ELM_CTXPOPUP_DIRECTION_RIGHT; - if (pos.x + (arrow_size.x + base_size.x) > - hover_area.x + hover_area.w) - base_size.x -= - ((pos.x + arrow_size.x + base_size.x) - - (hover_area.x + hover_area.w)); - } - } - } + //ELM_CTXPOPUP_DIRECTION_LEFT + if (length[0] > length[1]) + { + _y_pos_adjust(&pos, &base_size, &hover_area); + pos.x -= base_size.x; + dir = ELM_CTXPOPUP_DIRECTION_LEFT; + if (pos.x < (hover_area.x + arrow_size.x)) + { + base_size.x -= ((hover_area.x + arrow_size.x) - pos.x); + pos.x = hover_area.x + arrow_size.x; + } + } + //ELM_CTXPOPUP_DIRECTION_RIGHT + else + { + _y_pos_adjust(&pos, &base_size, &hover_area); + dir = ELM_CTXPOPUP_DIRECTION_RIGHT; + if (pos.x + (arrow_size.x + base_size.x) > + hover_area.x + hover_area.w) + base_size.x -= + ((pos.x + arrow_size.x + base_size.x) - + (hover_area.x + hover_area.w)); + } + } + } - //Final position and size. - rect->x = pos.x; - rect->y = pos.y; - rect->w = base_size.x; - rect->h = base_size.y; + //Final position and size. + rect->x = pos.x; + rect->y = pos.y; + rect->w = base_size.x; + rect->h = base_size.y; - return dir; + return dir; } -static void + static void _arrow_update(Evas_Object *obj, Elm_Ctxpopup_Direction dir, Evas_Coord_Rectangle base_size) @@ -335,13 +335,13 @@ _arrow_update(Evas_Object *obj, if (base_size.h > 0) { - if (y < ((arrow_size.h * 0.5) + base_size.y)) + if (y < (arrow_size.h + base_size.y)) y = 0; - else if (y > base_size.y + base_size.h - (arrow_size.h * 0.5)) - y = base_size.h - arrow_size.h; + else if (y > base_size.y + base_size.h - arrow_size.h) + y = base_size.h - (arrow_size.h * 2); else - y = y - base_size.y - (arrow_size.h * 0.5); - drag = (double)(y) / (double)(base_size.h - arrow_size.h); + y = y - base_size.y - arrow_size.h; + drag = (double)(y) / (double)(base_size.h - (arrow_size.h * 2)); edje_object_part_drag_value_set (wd->resize_obj, (elm_widget_mirrored_get(obj) ? "elm.swallow.arrow_right" : @@ -358,13 +358,13 @@ _arrow_update(Evas_Object *obj, if (base_size.h > 0) { - if (y < ((arrow_size.h * 0.5) + base_size.y)) + if (y < (arrow_size.h + base_size.y)) y = 0; - else if (y > (base_size.y + base_size.h - (arrow_size.h * 0.5))) + else if (y > (base_size.y + base_size.h - arrow_size.h)) y = base_size.h - arrow_size.h; else - y = y - base_size.y - (arrow_size.h * 0.5); - drag = (double)(y) / (double)(base_size.h - arrow_size.h); + y = y - base_size.y - arrow_size.h; + drag = (double)(y) / (double)(base_size.h - (arrow_size.h * 2)); edje_object_part_drag_value_set (wd->resize_obj, (elm_widget_mirrored_get(obj) ? "elm.swallow.arrow_left" : @@ -380,13 +380,13 @@ _arrow_update(Evas_Object *obj, if (base_size.w > 0) { - if (x < ((arrow_size.w * 0.5) + base_size.x)) + if (x < (arrow_size.w + base_size.x)) x = 0; - else if (x > (base_size.x + base_size.w - (arrow_size.w * 0.5))) - x = base_size.w - arrow_size.w; - else - x = x - base_size.x - (arrow_size.w * 0.5); - drag = (double)(x) / (double)(base_size.w - arrow_size.w); + else if (x > (base_size.x + base_size.w - arrow_size.w)) + x = base_size.w - (arrow_size.w * 2); + else + x = x - base_size.x - arrow_size.w; + drag = (double)(x) / (double)(base_size.w - (arrow_size.w * 2)); edje_object_part_drag_value_set (wd->resize_obj, "elm.swallow.arrow_up", drag, 1); @@ -401,12 +401,12 @@ _arrow_update(Evas_Object *obj, if (base_size.w > 0) { - if (x < ((arrow_size.w * 0.5) + base_size.x)) + if (x < (arrow_size.w + base_size.x)) x = 0; - else if (x > (base_size.x + base_size.w - (arrow_size.w * 0.5))) - x = base_size.w - arrow_size.w; - else x = x - base_size.x - (arrow_size.w * 0.5); - drag = (double)(x) / (double)(base_size.w - arrow_size.w); + else if (x > (base_size.x + base_size.w - arrow_size.w)) + x = base_size.w - (arrow_size.w * 2); + else x = x - base_size.x - arrow_size.w; + drag = (double)(x) / (double)(base_size.w - (arrow_size.w * 2)); edje_object_part_drag_value_set (wd->resize_obj, "elm.swallow.arrow_down", drag, 0);