From 8a76cf09347a8269fb705aaccfbee0324d0175ab Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 7 Nov 2011 16:04:25 +0900 Subject: [PATCH] [ctxpopup] sync formatting with upstream --- src/lib/elc_ctxpopup.c | 312 ++++++++++--------------------------------------- 1 file changed, 64 insertions(+), 248 deletions(-) diff --git a/src/lib/elc_ctxpopup.c b/src/lib/elc_ctxpopup.c index b8a2f55..3f836df 100644 --- a/src/lib/elc_ctxpopup.c +++ b/src/lib/elc_ctxpopup.c @@ -36,7 +36,8 @@ struct _Widget_Data static const char *widtype = NULL; -static void _freeze_on(void *data __UNUSED__, Evas_Object *obj, +static void _freeze_on(void *data __UNUSED__, + Evas_Object *obj, void *event_info __UNUSED__); static void _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__); @@ -243,15 +244,15 @@ _adjust_pos_x(Evas_Coord_Point *pos, Evas_Coord_Point *base_size, pos->x -= (base_size->x / 2); if (pos->x < hover_area->x) - 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; + 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); + base_size->x -= (base_size->x - hover_area->w); if (pos->x < hover_area->x) - pos->x = hover_area->x; + pos->x = hover_area->x; } static void @@ -261,15 +262,15 @@ _adjust_pos_y(Evas_Coord_Point *pos, Evas_Coord_Point *base_size, pos->y -= (base_size->y / 2); if (pos->y < hover_area->y) - 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; + 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); + base_size->y -= (base_size->y - hover_area->h); if (pos->y < hover_area->y) - pos->y = hover_area->y; + pos->y = hover_area->y; } static void @@ -333,19 +334,19 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect) 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; + base_size.y = max_size.y; if ((max_size.x > 0) && (base_size.x > max_size.x)) - 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); if ((min_size.y > 0) && (base_size.y < min_size.y)) - 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; + base_size.x = min_size.x; //Check the Which direction is available. //If find a avaialble direction, it adjusts position and size. @@ -356,7 +357,7 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect) case ELM_CTXPOPUP_DIRECTION_UP: temp.y = (pos.y - base_size.y); if ((temp.y - arrow_size.y) < hover_area.y) - continue; + continue; _adjust_pos_x(&pos, &base_size, &hover_area); pos.y -= base_size.y; arrow = ELM_CTXPOPUP_DIRECTION_UP; @@ -364,7 +365,7 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect) case ELM_CTXPOPUP_DIRECTION_LEFT: temp.x = (pos.x - base_size.x); if ((temp.x - arrow_size.x) < hover_area.x) - continue; + continue; _adjust_pos_y(&pos, &base_size, &hover_area); pos.x -= base_size.x; arrow = ELM_CTXPOPUP_DIRECTION_LEFT; @@ -373,7 +374,7 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect) temp.x = (pos.x + base_size.x); if ((temp.x + arrow_size.x) > (hover_area.x + hover_area.w)) - continue; + continue; _adjust_pos_y(&pos, &base_size, &hover_area); arrow = ELM_CTXPOPUP_DIRECTION_RIGHT; break; @@ -381,7 +382,7 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect) temp.y = (pos.y + base_size.y); if ((temp.y + arrow_size.y) > (hover_area.y + hover_area.h)) - continue; + continue; _adjust_pos_x(&pos, &base_size, &hover_area); arrow = ELM_CTXPOPUP_DIRECTION_DOWN; break; @@ -516,7 +517,7 @@ _update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir) edje_object_part_swallow(wd->base, "elm.swallow.arrow_right", wd->arrow); if (base_size.h > 0) - { + { if (y < (arrow_size.h * 0.5) + base_size.y) y = 0; else if (y > (base_size.y + base_size.h - (arrow_size.h * 0.5))) @@ -524,7 +525,7 @@ _update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir) else y = y - base_size.y - (arrow_size.h * 0.5); edje_object_part_drag_value_set(wd->base, "elm.swallow.arrow_right", 0, (double) (y) / (double) (base_size.h - arrow_size.h)); - } + } break; case ELM_CTXPOPUP_DIRECTION_DOWN: edje_object_signal_emit(wd->arrow, "elm,state,top", "elm"); @@ -536,14 +537,16 @@ _update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir) edje_object_part_swallow(wd->base, "elm.swallow.arrow_up", wd->arrow); if (base_size.w > 0) { - if (x < (arrow_size.w * 0.5) + base_size.x) + if (x < ((arrow_size.w * 0.5) + 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); - edje_object_part_drag_value_set(wd->base, "elm.swallow.arrow_up", - (double) (x) / (double) (base_size.w - arrow_size.w), 1); + edje_object_part_drag_value_set(wd->base, + "elm.swallow.arrow_up", + (double) (x) / (double) (base_size.w - arrow_size.w), + 1); } break; case ELM_CTXPOPUP_DIRECTION_UP: @@ -556,7 +559,7 @@ _update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir) edje_object_part_swallow(wd->base, "elm.swallow.arrow_down", wd->arrow); if (base_size.w > 0) { - if (x < (arrow_size.w * 0.5) + base_size.x) + if (x < ((arrow_size.w * 0.5) + 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; @@ -611,16 +614,16 @@ _sizing_eval(Evas_Object *obj) if (!wd->horizontal) { if (_box_size.x > box_size.x) - box_size.x = _box_size.x; + box_size.x = _box_size.x; if (_box_size.y != -1) - box_size.y += _box_size.y; + box_size.y += _box_size.y; } else { if (_box_size.x != -1) - box_size.x += _box_size.x; + box_size.x += _box_size.x; if (_box_size.y > box_size.y) - box_size.y = _box_size.y; + box_size.y = _box_size.y; } } @@ -635,14 +638,14 @@ _sizing_eval(Evas_Object *obj) //TODO: compress item - different from opensource if (!wd->horizontal && !wd->content) - _compress_item(obj); + _compress_item(obj); _update_arrow(obj, wd->dir); _shift_base_by_arrow(wd->arrow, wd->dir, &rect); //resize scroller according to final size. if (!wd->content) - evas_object_smart_calculate(wd->scr); + evas_object_smart_calculate(wd->scr); evas_object_move(wd->base, rect.x, rect.y); evas_object_resize(wd->base, rect.w, rect.h); @@ -718,20 +721,20 @@ _theme_hook(Evas_Object *obj) EINA_LIST_FOREACH(wd->items, elist, item) { if (item->label && item->icon) - _elm_theme_object_set(obj, item->base.view, "ctxpopup", - "icon_text_style_item", - elm_widget_style_get(obj)); + _elm_theme_object_set(obj, item->base.view, "ctxpopup", + "icon_text_style_item", + elm_widget_style_get(obj)); else if (item->label) - _elm_theme_object_set(obj, item->base.view, "ctxpopup", "text_style_item", - elm_widget_style_get(obj)); + _elm_theme_object_set(obj, item->base.view, "ctxpopup", "text_style_item", + elm_widget_style_get(obj)); else if (item->icon) _elm_theme_object_set(obj, item->base.view, "ctxpopup", "icon_style_item", elm_widget_style_get(obj)); if (item->label) - edje_object_part_text_set(item->base.view, "elm.text", item->label); + edje_object_part_text_set(item->base.view, "elm.text", item->label); if (item->disabled) - edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm"); + edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm"); /* * For separator, if the first item has visible separator, @@ -764,11 +767,10 @@ _theme_hook(Evas_Object *obj) if (wd->scr) { - if (!strncmp(elm_object_style_get(obj), "default", - strlen("default"))) - elm_object_style_set(wd->scr, "ctxpopup"); + if (!strncmp(elm_object_style_get(obj), "default", strlen("default"))) + elm_object_style_set(wd->scr, "ctxpopup"); else - elm_object_style_set(wd->scr, elm_object_style_get(obj)); + elm_object_style_set(wd->scr, elm_object_style_get(obj)); } if (wd->visible) @@ -1029,9 +1031,9 @@ _remove_items(Widget_Data *wd) EINA_LIST_FOREACH(wd->items, elist, item) { if (item->label) - eina_stringshare_del(item->label); + eina_stringshare_del(item->label); if (item->icon) - evas_object_del(item->icon); + evas_object_del(item->icon); wd->items = eina_list_remove(wd->items, item); free(item); } @@ -1039,14 +1041,6 @@ _remove_items(Widget_Data *wd) wd->items = NULL; } -/** - * Add a new Ctxpopup object to the parent. - * - * @param parent Parent object - * @return New object or @c NULL, if it cannot be created - * - * @ingroup Ctxpopup - */ EAPI Evas_Object * elm_ctxpopup_add(Evas_Object *parent) { @@ -1112,14 +1106,6 @@ elm_ctxpopup_add(Evas_Object *parent) return obj; } -/** - * Get the icon object for the given ctxpopup item. - * - * @param item Ctxpopup item - * @return icon object or @c NULL, if the item does not have icon or an error occurred - * - * @ingroup Ctxpopup - */ EAPI Evas_Object * elm_ctxpopup_item_icon_get(const Elm_Object_Item *it) { @@ -1128,19 +1114,6 @@ elm_ctxpopup_item_icon_get(const Elm_Object_Item *it) return item->icon; } -/** - * Sets the side icon associated with the ctxpopup item - * - * Once the icon object is set, a previously set one will be deleted. - * You probably don't want, then, to have the same icon object - * set for more than one item of the list (when replacing one of its - * instances). - * - * @param item Ctxpopup item - * @param icon Icon object to be set - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_item_icon_set(Elm_Object_Item *it, Evas_Object *icon) { @@ -1161,15 +1134,6 @@ elm_ctxpopup_item_icon_set(Elm_Object_Item *it, Evas_Object *icon) } } -/** - * Get the label object for the given ctxpopup item. - * - * @param item Ctxpopup item - * @return label object or @c NULL, if the item does not have label or an error occured - * - * @ingroup Ctxpopup - * - */ EAPI const char * elm_ctxpopup_item_label_get(const Elm_Object_Item *it) { @@ -1178,14 +1142,6 @@ elm_ctxpopup_item_label_get(const Elm_Object_Item *it) return item->label; } -/** - * (Re)set the label on the given ctxpopup item. - * - * @param item Ctxpopup item - * @param label String to set as label - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_item_label_set(Elm_Object_Item *it, const char *label) { @@ -1206,19 +1162,6 @@ elm_ctxpopup_item_label_set(Elm_Object_Item *it, const char *label) } } -/** - * Set the Ctxpopup's parent - * Set the parent object (it would much probably be the - * window that the ctxpopup is in). - * - * @param obj The ctxpopup object - * @param area The parent to use - * - * @note elm_ctxpopup_add() will automatically call this function - * with its @c parent argument. - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_hover_parent_set(Evas_Object *obj, Evas_Object *hover_parent) { @@ -1244,15 +1187,6 @@ elm_ctxpopup_hover_parent_set(Evas_Object *obj, Evas_Object *hover_parent) wd->hover_parent = hover_parent; } -/** - * Get the Ctxpopup's parent - * - * @param obj The ctxpopup object - * - * @see elm_ctxpopup_hover_parent_set() for more information - * - * @ingroup Ctxpopup - */ EAPI Evas_Object * elm_ctxpopup_hover_parent_get(const Evas_Object *obj) { @@ -1266,13 +1200,6 @@ elm_ctxpopup_hover_parent_get(const Evas_Object *obj) return wd->hover_parent; } -/** - * Clear all items in the given ctxpopup object. - * - * @param obj Ctxpopup object - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_clear(Evas_Object * obj) { @@ -1285,14 +1212,6 @@ elm_ctxpopup_clear(Evas_Object * obj) _list_del(wd); } -/** - * Change the ctxpopup's orientation to horizontal or vertical. - * - * @param obj Ctxpopup object - * @param horizontal @c EINA_TRUE for horizontal mode, @c EINA_FALSE for vertical - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) { @@ -1319,9 +1238,9 @@ elm_ctxpopup_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) EINA_LIST_FOREACH(wd->items, elist, item) { if (idx++ == 0) - edje_object_signal_emit(item->base.view, "elm,state,default", "elm"); + edje_object_signal_emit(item->base.view, "elm,state,default", "elm"); else - edje_object_signal_emit(item->base.view, "elm,state,vertical", "elm"); + edje_object_signal_emit(item->base.view, "elm,state,vertical", "elm"); } } else @@ -1332,9 +1251,9 @@ elm_ctxpopup_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) EINA_LIST_FOREACH(wd->items, elist, item) { if (idx++ == 0) - edje_object_signal_emit(item->base.view, "elm,state,default", "elm"); + edje_object_signal_emit(item->base.view, "elm,state,default", "elm"); else - edje_object_signal_emit(item->base.view, "elm,state,horizontal", "elm"); + edje_object_signal_emit(item->base.view, "elm,state,horizontal", "elm"); } } @@ -1342,14 +1261,6 @@ elm_ctxpopup_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) _sizing_eval(obj); } -/** - * Get the value of current ctxpopup object's orientation. - * - * @param obj Ctxpopup object - * @return @c EINA_TRUE for horizontal mode, @c EINA_FALSE for vertical mode (or errors) - * - * @ingroup Ctxpopup - */ EAPI Eina_Bool elm_ctxpopup_horizontal_get(const Evas_Object *obj) { @@ -1363,21 +1274,6 @@ elm_ctxpopup_horizontal_get(const Evas_Object *obj) return wd->horizontal; } -/** - * Add a new item to a ctxpopup object. - * - * Both a item list and a content could not be set at the same time! - * once you set add a item, the previous content will be removed. - * - * @param obj Ctxpopup object - * @param icon Icon to be set on new item - * @param label The Label of the new item - * @param func Convenience function called when item selected - * @param data Data passed to @p func above - * @return A handle to the item added or @c NULL, on errors - * - * @ingroup Ctxpopup - */ EAPI Elm_Object_Item * elm_ctxpopup_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, @@ -1396,20 +1292,20 @@ elm_ctxpopup_item_append(Evas_Object *obj, const char *label, //The first item is appended. if (wd->content) - evas_object_del(elm_ctxpopup_content_unset(obj)); + evas_object_del(elm_ctxpopup_content_unset(obj)); if (!wd->items) - _list_new(obj); + _list_new(obj); item->func = func; item->base.data = data; if (icon && label) - _item_new(item, "icon_text_style_item"); + _item_new(item, "icon_text_style_item"); else if (label) - _item_new(item, "text_style_item"); + _item_new(item, "text_style_item"); else - _item_new(item, "icon_style_item"); + _item_new(item, "icon_style_item"); _item_icon_set(item, icon); _item_label_set(item, label); @@ -1425,13 +1321,6 @@ elm_ctxpopup_item_append(Evas_Object *obj, const char *label, return (Elm_Object_Item*) item; } -/** - * Delete the given item in a ctxpopup object. - * - * @param item Ctxpopup item to be deleted - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_item_del(Elm_Object_Item *it) { @@ -1444,31 +1333,23 @@ elm_ctxpopup_item_del(Elm_Object_Item *it) if (!wd) return; if (item->icon) - evas_object_del(item->icon); + evas_object_del(item->icon); if (item->base.view) - evas_object_del(item->base.view); + evas_object_del(item->base.view); eina_stringshare_del(item->label); wd->items = eina_list_remove(wd->items, item); if (eina_list_count(wd->items) < 1) - wd->items = NULL; + wd->items = NULL; if (wd->visible) - _sizing_eval(item->base.widget); + _sizing_eval(item->base.widget); free(item); } -/** - * Set the ctxpopup item's state as disabled or enabled. - * - * @param item Ctxpopup item to be enabled/disabled - * @param disabled @c EINA_TRUE to disable it, @c EINA_FALSE to enable it - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled) { @@ -1481,24 +1362,16 @@ elm_ctxpopup_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled) if (!wd) return; if (disabled == item->disabled) - return; + return; if (disabled) - edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm"); + edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm"); else - edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm"); + edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm"); item->disabled = !!disabled; } -/** - * Get the ctxpopup item's disabled/enabled state. - * - * @param item Ctxpopup item to be enabled/disabled - * @return disabled @c EINA_TRUE, if disabled, @c EINA_FALSE otherwise - * - * @ingroup Ctxpopup - */ EAPI Eina_Bool elm_ctxpopup_item_disabled_get(const Elm_Object_Item *it) { @@ -1507,19 +1380,6 @@ elm_ctxpopup_item_disabled_get(const Elm_Object_Item *it) return item->disabled; } -/** - * Once the content object is set, a previously set one will be deleted. - * If you want to keep that old content object, use the - * elm_ctxpopup_content_unset() function - * - * Both a item list and a content could not be set at the same time! - * once you set a content, the previous list items will be removed. - * - * @param obj Ctxpopup object - * @param content Content to be swallowed - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_content_set(Evas_Object *obj, Evas_Object *content) { @@ -1529,13 +1389,13 @@ elm_ctxpopup_content_set(Evas_Object *obj, Evas_Object *content) wd = elm_widget_data_get(obj); if ((!wd) || (!content)) - return; + return; if (wd->items) - elm_ctxpopup_clear(obj); + elm_ctxpopup_clear(obj); if (wd->content) - evas_object_del(wd->content); + evas_object_del(wd->content); evas_object_event_callback_add(content, EVAS_CALLBACK_DEL, _content_del, obj); @@ -1547,19 +1407,9 @@ elm_ctxpopup_content_set(Evas_Object *obj, Evas_Object *content) wd->content = content; if (wd->visible) - _sizing_eval(obj); + _sizing_eval(obj); } -/** - * Unset the ctxpopup content - * - * Unparent and return the content object which was set for this widget - * - * @param obj Ctxpopup object - * @return The content that was being used - * - * @ingroup Ctxpopup - */ EAPI Evas_Object * elm_ctxpopup_content_unset(Evas_Object *obj) { @@ -1584,18 +1434,6 @@ elm_ctxpopup_content_unset(Evas_Object *obj) return content; } -/** - * Set the direction priority of a ctxpopup. - * This functions gives a chance to user to set the priority of ctxpopup showing direction. - * - * @param obj Ctxpopup object - * @param first 1st priority of direction - * @param second 2nd priority of direction - * @param third 3th priority of direction - * @param fourth 4th priority of direction - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_direction_priority_set(Evas_Object *obj, Elm_Ctxpopup_Direction first, @@ -1618,19 +1456,6 @@ elm_ctxpopup_direction_priority_set(Evas_Object *obj, _sizing_eval(obj); } -/** - * Get the direction priority of a ctxpopup. - * - * @param obj Ctxpopup object - * @param first 1st priority of direction to be returned - * @param second 2nd priority of direction to be returned - * @param third 3th priority of direction to be returned - * @param fourth 4th priority of direction to be returned - * - * @see elm_ctxpopup_direction_priority_set for more information. - * - * @ingroup Ctxpopup - */ EAPI void elm_ctxpopup_direction_priority_get(Evas_Object *obj, Elm_Ctxpopup_Direction *first, @@ -1650,15 +1475,6 @@ elm_ctxpopup_direction_priority_get(Evas_Object *obj, if (fourth) *fourth = wd->dir_priority[3]; } -/** - * @brief Get the current direction of a ctxpopup. - * - * @param obj Ctxpopup object - * @return current direction of a ctxpopup - * - * @warning Once the ctxpopup showed up, the direction would be determined - */ - EAPI Elm_Ctxpopup_Direction elm_ctxpopup_direction_get(const Evas_Object *obj) { -- 2.7.4