elementry/ctxpopup - fixed indentation

SVN revision: 62430
This commit is contained in:
ChunEon Park 2011-08-14 03:47:51 +00:00
parent 134a0dd77a
commit 321835b3da
1 changed files with 59 additions and 58 deletions

View File

@ -2,6 +2,7 @@
#include "elm_priv.h" #include "elm_priv.h"
typedef struct _Widget_Data Widget_Data; typedef struct _Widget_Data Widget_Data;
typedef struct _Elm_Ctxpopup_Item Elm_Ctxpopup_Item;
struct _Elm_Ctxpopup_Item struct _Elm_Ctxpopup_Item
{ {
@ -162,7 +163,7 @@ _hover_parent_callbacks_del(Evas_Object *obj)
Widget_Data *wd = elm_widget_data_get(obj); Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->hover_parent)) if ((!wd) || (!wd->hover_parent))
return; return;
evas_object_event_callback_del_full(wd->hover_parent, EVAS_CALLBACK_DEL, evas_object_event_callback_del_full(wd->hover_parent, EVAS_CALLBACK_DEL,
_hover_parent_del, obj); _hover_parent_del, obj);
@ -233,15 +234,15 @@ _adjust_pos_x(Evas_Coord_Point *pos, Evas_Coord_Point *base_size,
pos->x -= (base_size->x / 2); pos->x -= (base_size->x / 2);
if (pos->x < hover_area->x) 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)) 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) 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) if (pos->x < hover_area->x)
pos->x = hover_area->x; pos->x = hover_area->x;
} }
static void static void
@ -251,15 +252,15 @@ _adjust_pos_y(Evas_Coord_Point *pos, Evas_Coord_Point *base_size,
pos->y -= (base_size->y / 2); pos->y -= (base_size->y / 2);
if (pos->y < hover_area->y) 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)) 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) 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) if (pos->y < hover_area->y)
pos->y = hover_area->y; pos->y = hover_area->y;
} }
static void static void
@ -272,7 +273,7 @@ _ctxpopup_changed_size_hints(void *data __UNUSED__, Evas *e __UNUSED__,
if (!wd) return; if (!wd) return;
if (wd->visible) if (wd->visible)
_sizing_eval(obj); _sizing_eval(obj);
} }
static Elm_Ctxpopup_Direction static Elm_Ctxpopup_Direction
@ -293,7 +294,7 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
wd = elm_widget_data_get(obj); wd = elm_widget_data_get(obj);
if ((!wd) || (!rect)) if ((!wd) || (!rect))
return ELM_CTXPOPUP_DIRECTION_DOWN; return ELM_CTXPOPUP_DIRECTION_DOWN;
edje_object_part_geometry_get(wd->arrow, "ctxpopup_arrow", NULL, NULL, edje_object_part_geometry_get(wd->arrow, "ctxpopup_arrow", NULL, NULL,
&arrow_size.x, &arrow_size.y); &arrow_size.x, &arrow_size.y);
@ -301,8 +302,8 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
//Initialize Area Rectangle. //Initialize Area Rectangle.
if (wd->hover_parent) if (wd->hover_parent)
evas_object_geometry_get(wd->hover_parent, &hover_area.x, &hover_area.y, evas_object_geometry_get(wd->hover_parent, &hover_area.x, &hover_area.y,
&hover_area.w, &hover_area.h); &hover_area.w, &hover_area.h);
else else
{ {
evas_object_geometry_get(wd->parent, &parent_size.x, &parent_size.y, evas_object_geometry_get(wd->parent, &parent_size.x, &parent_size.y,
@ -323,19 +324,19 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
evas_object_size_hint_max_get(obj, &max_size.x, &max_size.y); evas_object_size_hint_max_get(obj, &max_size.x, &max_size.y);
if ((max_size.y > 0) && (base_size.y > 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)) 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 //Limit to Min Size
evas_object_size_hint_min_get(obj, &min_size.x, &min_size.y); evas_object_size_hint_min_get(obj, &min_size.x, &min_size.y);
if ((min_size.y > 0) && (base_size.y < 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)) 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. //Check the Which direction is available.
//If find a avaialble direction, it adjusts position and size. //If find a avaialble direction, it adjusts position and size.
@ -346,7 +347,7 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
case ELM_CTXPOPUP_DIRECTION_UP: case ELM_CTXPOPUP_DIRECTION_UP:
temp.y = (pos.y - base_size.y); temp.y = (pos.y - base_size.y);
if ((temp.y - arrow_size.y) < hover_area.y) if ((temp.y - arrow_size.y) < hover_area.y)
continue; continue;
_adjust_pos_x(&pos, &base_size, &hover_area); _adjust_pos_x(&pos, &base_size, &hover_area);
pos.y -= base_size.y; pos.y -= base_size.y;
dir = ELM_CTXPOPUP_DIRECTION_UP; dir = ELM_CTXPOPUP_DIRECTION_UP;
@ -354,7 +355,7 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
case ELM_CTXPOPUP_DIRECTION_LEFT: case ELM_CTXPOPUP_DIRECTION_LEFT:
temp.x = (pos.x - base_size.x); temp.x = (pos.x - base_size.x);
if ((temp.x - arrow_size.x) < hover_area.x) if ((temp.x - arrow_size.x) < hover_area.x)
continue; continue;
_adjust_pos_y(&pos, &base_size, &hover_area); _adjust_pos_y(&pos, &base_size, &hover_area);
pos.x -= base_size.x; pos.x -= base_size.x;
dir = ELM_CTXPOPUP_DIRECTION_LEFT; dir = ELM_CTXPOPUP_DIRECTION_LEFT;
@ -363,7 +364,7 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
temp.x = (pos.x + base_size.x); temp.x = (pos.x + base_size.x);
if ((temp.x + arrow_size.x) > if ((temp.x + arrow_size.x) >
(hover_area.x + hover_area.w)) (hover_area.x + hover_area.w))
continue; continue;
_adjust_pos_y(&pos, &base_size, &hover_area); _adjust_pos_y(&pos, &base_size, &hover_area);
dir = ELM_CTXPOPUP_DIRECTION_RIGHT; dir = ELM_CTXPOPUP_DIRECTION_RIGHT;
break; break;
@ -371,7 +372,7 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
temp.y = (pos.y + base_size.y); temp.y = (pos.y + base_size.y);
if ((temp.y + arrow_size.y) > if ((temp.y + arrow_size.y) >
(hover_area.y + hover_area.h)) (hover_area.y + hover_area.h))
continue; continue;
_adjust_pos_x(&pos, &base_size, &hover_area); _adjust_pos_x(&pos, &base_size, &hover_area);
dir = ELM_CTXPOPUP_DIRECTION_DOWN; dir = ELM_CTXPOPUP_DIRECTION_DOWN;
break; break;
@ -399,8 +400,8 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
dir = ELM_CTXPOPUP_DIRECTION_UP; dir = ELM_CTXPOPUP_DIRECTION_UP;
if (pos.y < (hover_area.y + arrow_size.y)) if (pos.y < (hover_area.y + arrow_size.y))
{ {
base_size.y -= ((hover_area.y + arrow_size.y) - pos.y); base_size.y -= ((hover_area.y + arrow_size.y) - pos.y);
pos.y = hover_area.y + arrow_size.y; pos.y = hover_area.y + arrow_size.y;
} }
} }
//ELM_CTXPOPUP_DIRECTION_DOWN //ELM_CTXPOPUP_DIRECTION_DOWN
@ -558,16 +559,16 @@ _sizing_eval(Evas_Object *obj)
if (!wd->horizontal) if (!wd->horizontal)
{ {
if (_box_size.x > box_size.x) if (_box_size.x > box_size.x)
box_size.x = _box_size.x; box_size.x = _box_size.x;
if (_box_size.y != -1) if (_box_size.y != -1)
box_size.y += _box_size.y; box_size.y += _box_size.y;
} }
else else
{ {
if (_box_size.x != -1) if (_box_size.x != -1)
box_size.x += _box_size.x; box_size.x += _box_size.x;
if (_box_size.y > box_size.y) if (_box_size.y > box_size.y)
box_size.y = _box_size.y; box_size.y = _box_size.y;
} }
} }
@ -584,7 +585,7 @@ _sizing_eval(Evas_Object *obj)
//resize scroller according to final size. //resize scroller according to final size.
if (!wd->content) 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_move(wd->base, rect.x, rect.y);
evas_object_resize(wd->base, rect.w, rect.h); evas_object_resize(wd->base, rect.w, rect.h);
@ -659,20 +660,20 @@ _theme_hook(Evas_Object *obj)
EINA_LIST_FOREACH(wd->items, elist, item) EINA_LIST_FOREACH(wd->items, elist, item)
{ {
if (item->label && item->icon) if (item->label && item->icon)
_elm_theme_object_set(obj, item->base.view, "ctxpopup", _elm_theme_object_set(obj, item->base.view, "ctxpopup",
"icon_text_style_item", "icon_text_style_item",
elm_widget_style_get(obj)); elm_widget_style_get(obj));
else if (item->label) else if (item->label)
_elm_theme_object_set(obj, item->base.view, "ctxpopup", "text_style_item", _elm_theme_object_set(obj, item->base.view, "ctxpopup", "text_style_item",
elm_widget_style_get(obj)); elm_widget_style_get(obj));
else if (item->icon) else if (item->icon)
_elm_theme_object_set(obj, item->base.view, "ctxpopup", "icon_style_item", _elm_theme_object_set(obj, item->base.view, "ctxpopup", "icon_style_item",
elm_widget_style_get(obj)); elm_widget_style_get(obj));
if (item->label) 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) 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");
edje_object_message_signal_process(item->base.view); edje_object_message_signal_process(item->base.view);
} }
@ -724,7 +725,7 @@ _content_set_hook(Evas_Object *obj, const char *part __UNUSED__,
wd->content = content; wd->content = content;
if (wd->visible) if (wd->visible)
_sizing_eval(obj); _sizing_eval(obj);
} }
static Evas_Object * static Evas_Object *
@ -834,7 +835,7 @@ _ctxpopup_hide(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
wd = elm_widget_data_get(obj); wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->visible)) if ((!wd) || (!wd->visible))
return; return;
_hide(obj); _hide(obj);
} }
@ -864,9 +865,9 @@ _scroller_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj,
} }
if (wd->max_sc_w < w) if (wd->max_sc_w < w)
wd->max_sc_w = w; wd->max_sc_w = w;
if (wd->max_sc_h < h) if (wd->max_sc_h < h)
wd->max_sc_h = h; wd->max_sc_h = h;
_sizing_eval(data); _sizing_eval(data);
} }
@ -882,7 +883,7 @@ _ctxpopup_move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
if (!wd) return; if (!wd) return;
if (wd->visible) if (wd->visible)
evas_object_show(wd->arrow); evas_object_show(wd->arrow);
_scroller_size_reset(wd); _scroller_size_reset(wd);
_sizing_eval(obj); _sizing_eval(obj);
@ -898,7 +899,7 @@ _item_select_cb(void *data, Evas_Object *obj __UNUSED__,
if (item->disabled) return; if (item->disabled) return;
if (item->func) if (item->func)
item->func((void*) item->base.data, item->base.widget, data); item->func((void*) item->base.data, item->base.widget, data);
} }
static void static void
@ -918,7 +919,7 @@ static void
_item_label_set(Elm_Ctxpopup_Item *item, const char *label) _item_label_set(Elm_Ctxpopup_Item *item, const char *label)
{ {
if (!eina_stringshare_replace(&item->label, label)) if (!eina_stringshare_replace(&item->label, label))
return; return;
edje_object_part_text_set(item->base.view, "elm.text", label); edje_object_part_text_set(item->base.view, "elm.text", label);
edje_object_message_signal_process(item->base.view); edje_object_message_signal_process(item->base.view);
@ -994,9 +995,9 @@ _remove_items(Widget_Data *wd)
EINA_LIST_FOREACH(wd->items, elist, item) EINA_LIST_FOREACH(wd->items, elist, item)
{ {
if (item->label) if (item->label)
eina_stringshare_del(item->label); eina_stringshare_del(item->label);
if (item->icon) if (item->icon)
evas_object_del(item->icon); evas_object_del(item->icon);
wd->items = eina_list_remove(wd->items, item); wd->items = eina_list_remove(wd->items, item);
free(item); free(item);
} }
@ -1239,20 +1240,20 @@ elm_ctxpopup_item_append(Evas_Object *obj, const char *label,
//The first item is appended. //The first item is appended.
if (wd->content) if (wd->content)
evas_object_del(elm_object_content_unset(obj)); evas_object_del(elm_object_content_unset(obj));
if (!wd->items) if (!wd->items)
_list_new(obj); _list_new(obj);
item->func = func; item->func = func;
item->base.data = data; item->base.data = data;
if (icon && label) if (icon && label)
_item_new(item, "icon_text_style_item"); _item_new(item, "icon_text_style_item");
else if (label) else if (label)
_item_new(item, "text_style_item"); _item_new(item, "text_style_item");
else else
_item_new(item, "icon_style_item"); _item_new(item, "icon_style_item");
_item_icon_set(item, icon); _item_icon_set(item, icon);
_item_label_set(item, label); _item_label_set(item, label);
@ -1282,17 +1283,17 @@ elm_ctxpopup_item_del(Elm_Object_Item *it)
if (ctxpopup_it->icon) if (ctxpopup_it->icon)
evas_object_del(ctxpopup_it->icon); evas_object_del(ctxpopup_it->icon);
if (ctxpopup_it->base.view) if (ctxpopup_it->base.view)
evas_object_del(ctxpopup_it->base.view); evas_object_del(ctxpopup_it->base.view);
eina_stringshare_del(ctxpopup_it->label); eina_stringshare_del(ctxpopup_it->label);
wd->items = eina_list_remove(wd->items, ctxpopup_it); wd->items = eina_list_remove(wd->items, ctxpopup_it);
if (eina_list_count(wd->items) < 1) if (eina_list_count(wd->items) < 1)
wd->items = NULL; wd->items = NULL;
if (wd->visible) if (wd->visible)
_sizing_eval(ctxpopup_it->base.widget); _sizing_eval(ctxpopup_it->base.widget);
free(ctxpopup_it); free(ctxpopup_it);
} }
@ -1311,12 +1312,12 @@ elm_ctxpopup_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled)
ctxpopup_it = ELM_CAST(it); ctxpopup_it = ELM_CAST(it);
if (disabled == ctxpopup_it->disabled) if (disabled == ctxpopup_it->disabled)
return; return;
if (disabled) if (disabled)
edje_object_signal_emit(ctxpopup_it->base.view, "elm,state,disabled", "elm"); edje_object_signal_emit(ctxpopup_it->base.view, "elm,state,disabled", "elm");
else else
edje_object_signal_emit(ctxpopup_it->base.view, "elm,state,enabled", "elm"); edje_object_signal_emit(ctxpopup_it->base.view, "elm,state,enabled", "elm");
ctxpopup_it->disabled = !!disabled; ctxpopup_it->disabled = !!disabled;
} }
@ -1360,7 +1361,7 @@ elm_ctxpopup_direction_priority_set(Evas_Object *obj,
wd->dir_priority[3] = fourth; wd->dir_priority[3] = fourth;
if (wd->visible) if (wd->visible)
_sizing_eval(obj); _sizing_eval(obj);
} }
EAPI void EAPI void