Evas_Object *area_rect;
Eina_List *items;
Elm_Ctxpopup_Arrow arrow_dir;
+ Elm_Ctxpopup_Arrow arrow_priority[4];
int btn_cnt;
Elm_Transit *transit;
- Elm_Ctxpopup_Arrow arrow_priority[4];
Evas_Coord max_sc_w, max_sc_h;
+ char *title;
Eina_Bool scroller_disabled :1;
Eina_Bool horizontal :1;
Eina_Bool visible :1;
void *event_info);
static void _ctxpopup_move(void *data, Evas *e, Evas_Object *obj,
void *event_info);
+static void _ctxpopup_changed_size_hints(void *data, Evas *e, Evas_Object *obj,
+ void *event_info);
static void _ctxpopup_scroller_resize(void *data, Evas *e, Evas_Object *obj,
void *event_info);
static void _item_obj_create(Elm_Ctxpopup_Item *item, char *group_name);
static void _reset_scroller_size(Widget_Data *wd);
static void _hide_ctxpopup(Evas_Object *obj);
-
static void _reset_scroller_size(Widget_Data *wd)
{
wd->finished = EINA_FALSE;
wd->max_sc_w = -1;
}
-static void _delete_area_rect_callbacks(Widget_Data *wd) {
- if (!wd->area_rect)
- return;
+static void _delete_area_rect_callbacks(Widget_Data *wd)
+{
+ if (!wd->area_rect) return;
evas_object_event_callback_del(wd->area_rect, EVAS_CALLBACK_DEL,
_area_rect_del);
_area_rect_resize);
}
-static void _area_rect_resize(void *data, Evas *e, Evas_Object *obj,
- void *event_info) {
+static void _area_rect_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
Widget_Data *wd = elm_widget_data_get(data);
if(wd->visible) {
_reset_scroller_size(wd);
}
}
-static void _area_rect_move(void *data, Evas *e, Evas_Object *obj,
- void *event_info) {
+static void _area_rect_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
Widget_Data *wd = elm_widget_data_get(data);
if(wd->visible) {
_reset_scroller_size(wd);
}
}
-static void _area_rect_del(void *data, Evas *e, Evas_Object *obj,
- void *event_info) {
+static void _area_rect_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
Widget_Data *wd = elm_widget_data_get(data);
wd->area_rect = NULL;
}
-static void _show_effect_done(void *data, Elm_Transit *transit) {
-
+static void _show_effect_done(void *data, Elm_Transit *transit)
+{
//TODO: Consider implementing effect in edc.
Widget_Data *wd = data;
elm_transit_fx_clear(transit);
edje_object_signal_emit(wd->base, "elm,state,show", "elm");
}
-static void _show_effect(Widget_Data* wd) {
-
+static void _show_effect(Widget_Data* wd)
+{
//TODO: Consider implementing effect in edc.
if (wd->transit) {
elm_transit_stop(wd->transit);
elm_transit_completion_callback_set(wd->transit, _hide_effect_done, obj);
}
- if(!wd->position_forced)
- elm_transit_fx_insert(wd->arrow, elm_fx_color_add(wd->arrow, 255, 255, 255, 255, 0, 0, 0, 0));
-
- elm_transit_fx_insert(wd->transit, elm_fx_color_add(wd->base, 255, 255, 255, 255, 0, 0, 0, 0));
+// elm_transit_fx_insert(wd->transit, elm_fx_color_add(wd->base, 255, 255, 255, 255, 0, 0, 0, 0));
switch(wd->arrow_dir) {
case ELM_FX_WIPE_DIR_UP:
elm_transit_run(wd->transit, 0.3);
}
-static void _separator_obj_del(Widget_Data *wd, Elm_Ctxpopup_Item *remove_item) {
+static void _separator_obj_del(Widget_Data *wd, Elm_Ctxpopup_Item *remove_item)
+{
Eina_List *elist, *cur_list, *prev_list;
Elm_Ctxpopup_Item *separator;
- if ((!remove_item) || (!wd))
- return;
+ if ((!remove_item) || (!wd)) return;
+
elist = wd->items;
cur_list = eina_list_data_find_list(elist, remove_item);
- if (!cur_list)
- return;
+
+ if (!cur_list) return;
+
prev_list = eina_list_prev(cur_list);
- if (!prev_list)
- return;
+
+ if (!prev_list) return;
+
separator = (Elm_Ctxpopup_Item *) eina_list_data_get(prev_list);
- if (!separator)
- return;
+
+ if (!separator)return;
+
wd->items = eina_list_remove(wd->items, separator);
evas_object_del(separator->base);
free(separator);
}
-static void _btn_layout_create(Evas_Object *obj) {
+static void _btn_layout_create(Evas_Object *obj)
+{
Widget_Data *wd = elm_widget_data_get(obj);
wd->btn_layout = edje_object_add(evas_object_evas_get(obj));
edje_object_part_swallow(wd->base, "elm.swallow.btns", wd->btn_layout);
}
-static void _separator_obj_add(Evas_Object *obj) {
+static void _separator_obj_add(Evas_Object *obj)
+{
Elm_Ctxpopup_Item *item;
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
- if (!wd)
- return;
- if (eina_list_count(wd->items) == 0)
- return;
+ if (!wd) return;
+ if (eina_list_count(wd->items) == 0) return;
item = ELM_NEW(Elm_Ctxpopup_Item);
- if (!item)
- return;
+ if (!item) return;
item->base = edje_object_add(evas_object_evas_get(wd->base));
+
if (!item->base) {
free(item);
return;
wd->items = eina_list_append(wd->items, item);
}
-static void _item_sizing_eval(Elm_Ctxpopup_Item *item) {
+static void _item_sizing_eval(Elm_Ctxpopup_Item *item)
+{
Evas_Coord min_w = -1, min_h = -1, max_w = -1, max_h = -1;
+ Evas_Coord x, y, w, h;
- if (!item)
- return;
+ if (!item) return;
- if (!item->separator)
- elm_coords_finger_size_adjust(1, &min_w, 1, &min_h);
+ if (!item->separator) elm_coords_finger_size_adjust(1, &min_w, 1, &min_h);
- Evas_Coord x, y, w, h;
evas_object_geometry_get(item->base, &x, &y, &w, &h);
-
- edje_object_size_min_restricted_calc(item->base, &min_w, &min_h, min_w,
- min_h);
-
+ edje_object_size_min_restricted_calc(item->base, &min_w, &min_h, min_w, min_h);
evas_object_size_hint_min_set(item->base, min_w, min_h);
evas_object_size_hint_max_set(item->base, max_w, max_h);
}
static void _adjust_pos_x(Evas_Coord_Point *pos, Evas_Coord_Point *base_size,
- Evas_Coord_Rectangle *area_rect) {
+ Evas_Coord_Rectangle *area_rect)
+{
pos->x -= (base_size->x / 2);
- if (pos->x < area_rect->x) {
- pos->x = area_rect->x;
- } else if ((pos->x + base_size->x) > (area_rect->x + area_rect->w)) {
+ if (pos->x < area_rect->x) pos->x = area_rect->x;
+ else if ((pos->x + base_size->x) > (area_rect->x + area_rect->w))
pos->x = (area_rect->x + area_rect->w) - base_size->x;
- }
if (base_size->x > area_rect->w)
base_size->x -= (base_size->x - area_rect->w);
}
static void _adjust_pos_y(int indicator_h, Evas_Coord_Point *pos,
- Evas_Coord_Point *base_size, Evas_Coord_Rectangle *area_rect) {
+ Evas_Coord_Point *base_size, Evas_Coord_Rectangle *area_rect)
+{
pos->y -= (base_size->y / 2);
- if (pos->y < area_rect->y) {
- pos->y = area_rect->y;
- } else if ((pos->y + base_size->y) > (area_rect->y + area_rect->h)) {
+ if (pos->y < area_rect->y) pos->y = area_rect->y;
+ else if ((pos->y + base_size->y) > (area_rect->y + area_rect->h))
pos->y = area_rect->y + area_rect->h - base_size->y;
- }
- if (base_size->y > area_rect->h) {
+ if (base_size->y > area_rect->h)
base_size->y -= (base_size->y - area_rect->h);
- }
- if (pos->y < area_rect->y) {
- pos->y = area_rect->y;
- }
+
+ if (pos->y < area_rect->y) pos->y = area_rect->y;
}
-static int _get_indicator_h(Evas_Object *parent) {
-
+static int _get_indicator_h(Evas_Object *parent)
+{
Ecore_X_Window zone, xwin;
int h = 0;
- if (elm_win_indicator_state_get(parent) != 1) {
+ if (elm_win_indicator_state_get(parent) != 1)
return 0;
- }
xwin = elm_win_xwindow_get(parent);
zone = ecore_x_e_illume_zone_get(xwin);
return h;
}
-static Elm_Ctxpopup_Arrow _calc_base_geometry(Evas_Object *obj,
- Evas_Coord_Rectangle *rect) {
+static void _ctxpopup_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
+ if (!wd) return;
+ if(wd->visible)_sizing_eval(obj);
+}
+static Elm_Ctxpopup_Arrow _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
+{
Widget_Data *wd;
Evas_Coord_Point pos;
Evas_Coord_Point base_size;
Evas_Coord_Point max_size;
+ Evas_Coord_Point min_size;
Evas_Coord_Rectangle area_rect;
Evas_Coord_Point parent_size;
Evas_Coord_Point arrow_size;
Evas_Coord finger_size;
Evas_Coord indicator_h;
Evas_Coord_Point temp;
- int idx;
Evas_Coord min_calc_h;
Evas_Coord min_calc_w;
+ int idx;
wd = elm_widget_data_get(obj);
- if ((!wd) || (!rect)) {
- return ELM_CTXPOPUP_ARROW_DOWN;
- }
+ if ((!wd) || (!rect)) return ELM_CTXPOPUP_ARROW_DOWN;
indicator_h = _get_indicator_h(wd->parent);
finger_size = elm_finger_size_get();
&arrow_size.x, &arrow_size.y);
evas_object_resize(wd->arrow, arrow_size.x, arrow_size.y);
+ //Initialize Area Rectangle.
if (wd->area_rect)
evas_object_geometry_get(wd->area_rect, &area_rect.x, &area_rect.y,
&area_rect.w, &area_rect.h);
else {
- evas_object_geometry_get(wd->parent, NULL, NULL, &parent_size.x,
- &parent_size.y);
+ evas_object_geometry_get(wd->parent, NULL, NULL, &parent_size.x, &parent_size.y);
area_rect.x = 0;
area_rect.y = 0;
area_rect.w = parent_size.x;
area_rect.y = indicator_h;
area_rect.h -= temp.y;
}
+
evas_object_geometry_get(obj, &pos.x, &pos.y, NULL, NULL);
edje_object_size_min_calc(wd->base, &base_size.x, &base_size.y);
min_calc_w = base_size.x;
min_calc_h = base_size.y;
- edje_object_size_max_get(wd->base, &max_size.x, &max_size.y);
- max_size.x *= elm_scale_get();
- max_size.y *= elm_scale_get();
-
- if (base_size.y > max_size.y)
- base_size.y = max_size.y;
-
- if (base_size.x > max_size.x)
- base_size.x = max_size.x;
+ //Limit to Max Size
+ evas_object_size_hint_max_get(obj, &max_size.x, &max_size.y);
+
+ if( max_size.y > 0 )
+ if(base_size.y > max_size.y) base_size.y = max_size.y;
+
+ if( max_size.x > 0 )
+ if(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);
+ fprintf(stderr, "2. %d %d\n", min_size.x, min_size.y);
+
+ if( min_size.y > 0 ) {
+ if(base_size.y < min_size.y) base_size.y = min_size.y;
+ if(min_calc_h < min_size.y) min_calc_h = min_size.y;
+ }
+
+ if( min_size.x > 0 ) {
+ if(base_size.x < min_size.x) base_size.x = min_size.x;
+ if(min_calc_w < min_size.x) min_calc_w = min_size.x;
+ }
+ //In case of position forced. It shows up just like popup.
if (wd->position_forced) {
//TODO: calculate the size of ctxpopup
rect->x = pos.x;
rect->y = pos.y;
rect->w = base_size.x;
rect->h = base_size.y;
-
return ELM_CTXPOPUP_ARROW_UP;
}
+ //Check the Which direction is available.
+ //If find a avaialble direction, it adjusts position and size.
for (idx = 0; idx < 4; ++idx) {
switch (wd->arrow_priority[idx]) {
- case ELM_CTXPOPUP_ARROW_DOWN:
- temp.y = pos.y - base_size.y;
- if ((temp.y - arrow_size.y - finger_size) < area_rect.y)
- continue;
- _adjust_pos_x(&pos, &base_size, &area_rect);
- pos.y -= (base_size.y + finger_size);
- arrow = ELM_CTXPOPUP_ARROW_DOWN;
- break;
- case ELM_CTXPOPUP_ARROW_RIGHT:
- temp.x = (pos.x - base_size.x);
- if ((temp.x - arrow_size.x - finger_size) < area_rect.x)
- continue;
- _adjust_pos_y(indicator_h, &pos, &base_size, &area_rect);
- pos.x -= (base_size.x + finger_size);
- arrow = ELM_CTXPOPUP_ARROW_RIGHT;
- break;
- case ELM_CTXPOPUP_ARROW_LEFT:
- temp.x = (pos.x + base_size.x);
- if ((temp.x + arrow_size.x + finger_size) > (area_rect.x
- + area_rect.w))
- continue;
- _adjust_pos_y(indicator_h, &pos, &base_size, &area_rect);
- pos.x += finger_size;
- arrow = ELM_CTXPOPUP_ARROW_LEFT;
- break;
- case ELM_CTXPOPUP_ARROW_UP:
- temp.y = (pos.y + base_size.y);
- if ((temp.y + arrow_size.y + finger_size) > (area_rect.y
- + area_rect.h))
- continue;
- _adjust_pos_x(&pos, &base_size, &area_rect);
- pos.y += finger_size;
- arrow = ELM_CTXPOPUP_ARROW_UP;
- break;
- default:
- break;
+ case ELM_CTXPOPUP_ARROW_DOWN:
+ temp.y = pos.y - base_size.y;
+ if ((temp.y - arrow_size.y - finger_size) < area_rect.y) continue;
+ _adjust_pos_x(&pos, &base_size, &area_rect);
+ pos.y -= (base_size.y + finger_size);
+ arrow = ELM_CTXPOPUP_ARROW_DOWN;
+ break;
+ case ELM_CTXPOPUP_ARROW_RIGHT:
+ temp.x = (pos.x - base_size.x);
+ if ((temp.x - arrow_size.x - finger_size) < area_rect.x) continue;
+ _adjust_pos_y(indicator_h, &pos, &base_size, &area_rect);
+ pos.x -= (base_size.x + finger_size);
+ arrow = ELM_CTXPOPUP_ARROW_RIGHT;
+ break;
+ case ELM_CTXPOPUP_ARROW_LEFT:
+ temp.x = (pos.x + base_size.x);
+ if ((temp.x + arrow_size.x + finger_size) > (area_rect.x + area_rect.w)) continue;
+ _adjust_pos_y(indicator_h, &pos, &base_size, &area_rect);
+ pos.x += finger_size;
+ arrow = ELM_CTXPOPUP_ARROW_LEFT;
+ break;
+ case ELM_CTXPOPUP_ARROW_UP:
+ temp.y = (pos.y + base_size.y);
+ if ((temp.y + arrow_size.y + finger_size) > (area_rect.y + area_rect.h)) continue;
+ _adjust_pos_x(&pos, &base_size, &area_rect);
+ pos.y += finger_size;
+ arrow = ELM_CTXPOPUP_ARROW_UP;
+ break;
+ default:
+ break;
}
break;
}
length[0] = pos.y - area_rect.y;
length[1] = (area_rect.y + area_rect.h) - pos.y;
- int idx;
- if (length[0] > length[1])
- idx = ELM_CTXPOPUP_ARROW_DOWN;
- else
- idx = ELM_CTXPOPUP_ARROW_UP;
+ if (length[0] > length[1]) idx = ELM_CTXPOPUP_ARROW_DOWN;
+ else idx = ELM_CTXPOPUP_ARROW_UP;
//TODO 2: determine x , y
switch (idx) {
- case ELM_CTXPOPUP_ARROW_DOWN:
- _adjust_pos_x(&pos, &base_size, &area_rect);
- pos.y -= (base_size.y + finger_size);
- arrow = ELM_CTXPOPUP_ARROW_DOWN;
- if (pos.y < area_rect.y + arrow_size.y) {
- base_size.y -= ((area_rect.y + arrow_size.y) - pos.y);
- pos.y = area_rect.y + arrow_size.y;
- }
- break;
- case ELM_CTXPOPUP_ARROW_RIGHT:
- _adjust_pos_y(indicator_h, &pos, &base_size, &area_rect);
- pos.x -= (base_size.x + finger_size);
- arrow = ELM_CTXPOPUP_ARROW_RIGHT;
- if (pos.x < area_rect.x + arrow_size.x) {
- base_size.x -= ((area_rect.x + arrow_size.x) - pos.x);
- pos.x = area_rect.x + arrow_size.x;
- }
- break;
- case ELM_CTXPOPUP_ARROW_LEFT:
- _adjust_pos_y(indicator_h, &pos, &base_size, &area_rect);
- pos.x += finger_size;
- arrow = ELM_CTXPOPUP_ARROW_LEFT;
- if (pos.x + arrow_size.x + base_size.x > area_rect.x + area_rect.w) {
- base_size.x -= ((pos.x + arrow_size.x + base_size.x)
+ case ELM_CTXPOPUP_ARROW_DOWN:
+ _adjust_pos_x(&pos, &base_size, &area_rect);
+ pos.y -= (base_size.y + finger_size);
+ arrow = ELM_CTXPOPUP_ARROW_DOWN;
+ if (pos.y < area_rect.y + arrow_size.y) {
+ base_size.y -= ((area_rect.y + arrow_size.y) - pos.y);
+ pos.y = area_rect.y + arrow_size.y;
+ }
+ break;
+ case ELM_CTXPOPUP_ARROW_RIGHT:
+ _adjust_pos_y(indicator_h, &pos, &base_size, &area_rect);
+ pos.x -= (base_size.x + finger_size);
+ arrow = ELM_CTXPOPUP_ARROW_RIGHT;
+ if (pos.x < area_rect.x + arrow_size.x) {
+ base_size.x -= ((area_rect.x + arrow_size.x) - pos.x);
+ pos.x = area_rect.x + arrow_size.x;
+ }
+ break;
+ case ELM_CTXPOPUP_ARROW_LEFT:
+ _adjust_pos_y(indicator_h, &pos, &base_size, &area_rect);
+ pos.x += finger_size;
+ arrow = ELM_CTXPOPUP_ARROW_LEFT;
+ if (pos.x + arrow_size.x + base_size.x > area_rect.x + area_rect.w) {
+ base_size.x -= ((pos.x + arrow_size.x + base_size.x)
- (area_rect.x + area_rect.w));
- }
- break;
- case ELM_CTXPOPUP_ARROW_UP:
- _adjust_pos_x(&pos, &base_size, &area_rect);
- pos.y += finger_size;
- arrow = ELM_CTXPOPUP_ARROW_UP;
- if (pos.y + arrow_size.y + base_size.y > area_rect.y + area_rect.h) {
- base_size.y -= ((pos.y + arrow_size.y + base_size.y)
- - (area_rect.y + area_rect.h));
- }
- break;
- default:
- break;
+ }
+ break;
+ case ELM_CTXPOPUP_ARROW_UP:
+ _adjust_pos_x(&pos, &base_size, &area_rect);
+ pos.y += finger_size;
+ arrow = ELM_CTXPOPUP_ARROW_UP;
+ if (pos.y + arrow_size.y + base_size.y > area_rect.y + area_rect.h) {
+ base_size.y -= ((pos.y + arrow_size.y + base_size.y) - (area_rect.y + area_rect.h));
+ }
+ break;
+ default:
+ break;
}
}
+ //Final position and size.
rect->x = pos.x;
rect->y = pos.y;
rect->w = base_size.x;
rect->h = base_size.y;
+ //resize scroller according to final size.
if (!wd->content) {
evas_object_geometry_get(wd->box, NULL, NULL, &temp.x, &temp.y);
evas_object_size_hint_min_set(wd->scroller, temp.x + (base_size.x - min_calc_w), temp.y + (base_size.y - min_calc_h));
return arrow;
}
-static void _update_arrow_obj(Evas_Object *obj, Elm_Ctxpopup_Arrow arrow_dir) {
+static void _update_arrow_obj(Evas_Object *obj, Elm_Ctxpopup_Arrow arrow_dir)
+{
Evas_Coord x, y;
Evas_Coord_Rectangle arrow_size;
Evas_Coord_Rectangle area_rect;
Evas_Coord parent_w, parent_h;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd)
- return;
+ if (!wd) return;
evas_object_geometry_get(obj, &x, &y, NULL, NULL);
evas_object_geometry_get(wd->arrow, NULL, NULL, &arrow_size.w,
&arrow_size.h);
switch (arrow_dir) {
- case ELM_CTXPOPUP_ARROW_LEFT: {
- edje_object_signal_emit(wd->arrow, "elm,state,left", "elm");
- arrow_size.y = (y - (arrow_size.h * 0.5));
- arrow_size.x = (x + elm_finger_size_get());
- break;
- }
- case ELM_CTXPOPUP_ARROW_RIGHT: {
- edje_object_signal_emit(wd->arrow, "elm,state,right", "elm");
- arrow_size.y = (y - (arrow_size.h * 0.5));
- arrow_size.x = (x - elm_finger_size_get() - arrow_size.w);
- break;
- }
- case ELM_CTXPOPUP_ARROW_UP: {
- edje_object_signal_emit(wd->arrow, "elm,state,top", "elm");
- arrow_size.x = (x - (arrow_size.w * 0.5));
- arrow_size.y = (y + elm_finger_size_get());
- break;
- }
- case ELM_CTXPOPUP_ARROW_DOWN: {
- edje_object_signal_emit(wd->arrow, "elm,state,bottom", "elm");
- arrow_size.x = (x - (arrow_size.w * 0.5));
- arrow_size.y = (y - elm_finger_size_get() - arrow_size.h);
- break;
- }
- default:
- break;
+ case ELM_CTXPOPUP_ARROW_LEFT: {
+ edje_object_signal_emit(wd->arrow, "elm,state,left", "elm");
+ arrow_size.y = (y - (arrow_size.h * 0.5));
+ arrow_size.x = (x + elm_finger_size_get());
+ break;
+ }
+ case ELM_CTXPOPUP_ARROW_RIGHT: {
+ edje_object_signal_emit(wd->arrow, "elm,state,right", "elm");
+ arrow_size.y = (y - (arrow_size.h * 0.5));
+ arrow_size.x = (x - elm_finger_size_get() - arrow_size.w);
+ break;
+ }
+ case ELM_CTXPOPUP_ARROW_UP: {
+ edje_object_signal_emit(wd->arrow, "elm,state,top", "elm");
+ arrow_size.x = (x - (arrow_size.w * 0.5));
+ arrow_size.y = (y + elm_finger_size_get());
+ break;
+ }
+ case ELM_CTXPOPUP_ARROW_DOWN: {
+ edje_object_signal_emit(wd->arrow, "elm,state,bottom", "elm");
+ arrow_size.x = (x - (arrow_size.w * 0.5));
+ arrow_size.y = (y - elm_finger_size_get() - arrow_size.h);
+ break;
+ }
+ default:
+ break;
}
//Adjust arrow position to prevent out of area
- if (wd->area_rect) {
+ if (wd->area_rect)
evas_object_geometry_get(wd->area_rect, &area_rect.x, &area_rect.y,
&area_rect.w, &area_rect.h);
- } else {
+ else {
evas_object_geometry_get(wd->parent, NULL, NULL, &parent_w, &parent_h);
area_rect.x = 0;
area_rect.y = 0;
}
//TODO: Temporary Code. make it more flexible
- if ((arrow_size.x - (arrow_size.w / 2)) < area_rect.x) {
+ if ((arrow_size.x - (arrow_size.w / 2)) < area_rect.x)
arrow_size.x = area_rect.x + (arrow_size.w / 2);
- } else if ((arrow_size.x + arrow_size.w) > (area_rect.x + area_rect.w)) {
+ else if ((arrow_size.x + arrow_size.w) > (area_rect.x + area_rect.w))
arrow_size.x = (area_rect.x + area_rect.w) - arrow_size.w
- (arrow_size.w / 2);
- }
/*
//TODO: Temporary Code. make it more flexible
if ((arrow_size.y - (arrow_size.h / 2)) < area_rect.y) {
evas_object_move(wd->arrow, arrow_size.x, arrow_size.y);
}
-static void _sizing_eval(Evas_Object *obj) {
+static void _sizing_eval(Evas_Object *obj)
+{
Widget_Data *wd;
Eina_List *elist;
Elm_Ctxpopup_Item *item;
Evas_Coord_Point _box_size = { 0, 0 };
wd = (Widget_Data *) elm_widget_data_get(obj);
-
- if ((!wd) || (!wd->parent))
- return;
-
+ if ((!wd) || (!wd->parent)) return;
int idx = 0;
EINA_LIST_FOREACH(wd->items, elist, item)
}
static void _shift_base_by_arrow(Evas_Object *arrow,
- Elm_Ctxpopup_Arrow arrow_dir, Evas_Coord_Rectangle *rect) {
+ Elm_Ctxpopup_Arrow arrow_dir, Evas_Coord_Rectangle *rect)
+{
Evas_Coord arrow_w, arrow_h;
evas_object_geometry_get(arrow, NULL, NULL, &arrow_w, &arrow_h);
static void _del_pre_hook(Evas_Object *obj) {
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
- if (!wd) return;
+ if (!wd) return;
evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_RESIZE,
_parent_resize, obj);
}
-static void _del_hook(Evas_Object *obj) {
-
+static void _del_hook(Evas_Object *obj)
+{
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
if (!wd) return;
free(wd);
}
-static void _theme_hook(Evas_Object *obj) {
+static void _theme_hook(Evas_Object *obj)
+{
Eina_List *elist;
Elm_Ctxpopup_Item *item;
-
char buf[256];
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
- if (!wd)
- return;
+ if (!wd) return;
//Items
EINA_LIST_FOREACH(wd->items, elist, item)
_elm_theme_object_set(obj, item->base, "ctxpopup", "separator",
elm_widget_style_get(obj));
if (wd->horizontal)
- edje_object_signal_emit(item->base, "elm,state,horizontal",
- "elm");
+ edje_object_signal_emit(item->base, "elm,state,horizontal", "elm");
}
else
{
elm_widget_style_get(obj));
}
if (item->label)
- edje_object_part_text_set(item->base, "elm.text", item->label);
+ edje_object_part_text_set(item->base, "elm.text", item->label);
if (item->disabled)
- edje_object_signal_emit(item->base, "elm,state,disabled", "elm");
+ edje_object_signal_emit(item->base, "elm,state,disabled", "elm");
}
edje_object_message_signal_process(item->base);
}
elm_widget_style_get(obj));
}
- _elm_theme_object_set(obj, wd->bg, "ctxpopup", "bg", elm_widget_style_get(
- obj));
- _elm_theme_object_set(obj, wd->base, "ctxpopup", "base",
- elm_widget_style_get(obj));
+ _elm_theme_object_set(obj, wd->bg, "ctxpopup", "bg", elm_widget_style_get(obj));
+ _elm_theme_object_set(obj, wd->base, "ctxpopup", "base", elm_widget_style_get(obj));
_elm_theme_object_set(obj, wd->arrow, "ctxpopup", "arrow",
elm_widget_style_get(obj));
}
static void _bg_clicked_cb(void *data, Evas_Object *obj, const char *emission,
- const char *source) {
+ const char *source)
+{
evas_object_hide(data);
}
static void _parent_resize(void *data, Evas *e, Evas_Object *obj,
- void *event_info) {
-
+ void *event_info)
+{
Evas_Coord w, h;
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(data);
}
static void _ctxpopup_show(void *data, Evas *e, Evas_Object *obj,
- void *event_info) {
+ void *event_info)
+{
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
if(wd == NULL) return;
evas_object_smart_callback_call(obj, "hide", NULL);
}
-static void _ctxpopup_hide(void *data, Evas *e, Evas_Object *obj,
- void *event_info) {
+static void _ctxpopup_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
Widget_Data *wd = (Widget_Data*) elm_widget_data_get(obj);
if(wd == NULL) return;
}
static void _ctxpopup_scroller_resize(void *data, Evas *e, Evas_Object * obj,
- void *event_info) {
-
- Evas_Coord w, h;
+ void *event_info)
+{
Widget_Data *wd;
+ Evas_Coord w, h;
wd = elm_widget_data_get(data);
if(wd == NULL) return;
- if(!wd->visible) return ;
- if(wd->finished) return ;
+ if(!wd->visible) return;
+ if(wd->finished) return;
evas_object_geometry_get(wd->scroller, 0, 0, &w, &h);
}
static void _ctxpopup_move(void *data, Evas *e, Evas_Object *obj,
- void *event_info) {
+ void *event_info)
+{
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
if(wd == NULL) return;
}
static void _ctxpopup_item_select(void *data, Evas_Object *obj,
- const char *emission, const char *source) {
+ const char *emission, const char *source)
+{
Elm_Ctxpopup_Item *item = (Elm_Ctxpopup_Item *) data;
- if (!item)
- return;
- if (item->disabled)
- return;
- if (item->func) {
+ if (!item) return;
+ if (item->disabled) return;
+ if (item->func)
item->func(item->data, item->ctxpopup, item);
- }
_ctxpopup_hide(item->ctxpopup, NULL, item->ctxpopup, NULL);
}
-static void _item_obj_create(Elm_Ctxpopup_Item *item, char *group_name) {
+static void _item_obj_create(Elm_Ctxpopup_Item *item, char *group_name)
+{
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(item->ctxpopup);
- if (!wd)
- return;
+ if (!wd) return;
item->base = edje_object_add(evas_object_evas_get(wd->base));
_elm_theme_object_set(item->ctxpopup, item->base, "ctxpopup", group_name,
elm_widget_style_get(item->ctxpopup));
* @ingroup Ctxpopup
*/
EAPI Evas_Object *
-elm_ctxpopup_item_icon_get(Elm_Ctxpopup_Item *item) {
- if (!item)
- return NULL;
+elm_ctxpopup_item_icon_get(Elm_Ctxpopup_Item *item)
+{
+ if (!item) return NULL;
return item->icon;
}
* @ingroup Ctxpopup
*/
EAPI void elm_ctxpopup_scroller_disabled_set(Evas_Object *obj,
- Eina_Bool disabled) {
+ Eina_Bool disabled)
+{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
- if (!wd)
- return;
- if (wd->scroller_disabled == disabled)
- return;
+ if (!wd) return;
+ if (wd->scroller_disabled == disabled) return;
if (disabled)
elm_object_scroll_freeze_push(wd->scroller);
*
*/
EAPI const char *
-elm_ctxpopup_item_label_get(Elm_Ctxpopup_Item *item) {
- if (!item)
- return NULL;
+elm_ctxpopup_item_label_get(Elm_Ctxpopup_Item *item)
+{
+ if (!item) return NULL;
return item->label;
}
* @ingroup Ctxpopup
*/
EAPI Evas_Object *
-elm_ctxpopup_add(Evas_Object *parent) {
+elm_ctxpopup_add(Evas_Object *parent)
+{
Evas_Object *obj;
Evas *e;
Widget_Data *wd;
evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _ctxpopup_show, NULL);
evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _ctxpopup_hide, NULL);
evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _ctxpopup_move, NULL);
-
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _ctxpopup_changed_size_hints, NULL);
+
return obj;
}
*
* @ingroup Ctxpopup
*/
-EAPI void elm_ctxpopup_clear(Evas_Object *obj) {
+EAPI void elm_ctxpopup_clear(Evas_Object *obj)
+{
ELM_CHECK_WIDTYPE(obj, widtype);
Eina_List *elist;
Elm_Ctxpopup_Item *item;
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
- if (!wd)
- return;
+ if (!wd) return;
EINA_LIST_FOREACH(wd->items, elist, item)
{
*
* @ingroup Ctxpopup
*/
-EAPI void elm_ctxpopup_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) {
+EAPI void elm_ctxpopup_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
+{
ELM_CHECK_WIDTYPE(obj, widtype);
Eina_List *elist;
Elm_Ctxpopup_Item *item;
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
- if (!wd)
- return;
+ if (!wd) return;
- if (wd->horizontal == horizontal)
- return;
+ if (wd->horizontal == horizontal) return;
wd->horizontal = horizontal;
if (!horizontal) {
elm_box_horizontal_set(wd->box, EINA_FALSE);
elm_scroller_bounce_set(wd->scroller, EINA_FALSE, EINA_TRUE);
-EINA_LIST_FOREACH (wd->items, elist, item)
- edje_object_signal_emit(item->base, "elm,state,vertical", "elm");
-}
-else
-{
- elm_box_horizontal_set(wd->box, EINA_TRUE);
- elm_scroller_bounce_set(wd->scroller, EINA_TRUE, EINA_FALSE);
- EINA_LIST_FOREACH(wd->items, elist, item)
- edje_object_signal_emit(item->base, "elm,state,horizontal", "elm");
-}
+ EINA_LIST_FOREACH (wd->items, elist, item)
+ edje_object_signal_emit(item->base, "elm,state,vertical", "elm");
+ }
+ else
+ {
+ elm_box_horizontal_set(wd->box, EINA_TRUE);
+ elm_scroller_bounce_set(wd->scroller, EINA_TRUE, EINA_FALSE);
+ EINA_LIST_FOREACH(wd->items, elist, item)
+ edje_object_signal_emit(item->base, "elm,state,horizontal", "elm");
+ }
}
/**
*
* @ingroup Ctxpopup
*/
-EAPI Eina_Bool elm_ctxpopup_horizontal_get(Evas_Object *obj) {
+EAPI Eina_Bool elm_ctxpopup_horizontal_get(Evas_Object *obj)
+{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
-
- if (!wd)
- return EINA_FALSE;
-
+ if (!wd) return EINA_FALSE;
return wd->horizontal;
}
*
* @ingroup Ctxpopup
*/
-EAPI void elm_ctxpopup_item_icon_set(Elm_Ctxpopup_Item *item, Evas_Object *icon) {
+EAPI void elm_ctxpopup_item_icon_set(Elm_Ctxpopup_Item *item, Evas_Object *icon)
+{
Widget_Data *wd;
- if (!item)
- return;
+ if (!item) return;
wd = (Widget_Data *) elm_widget_data_get(item->ctxpopup);
- if (!wd)
- return;
- if (item->icon == icon)
- return;
+ if (!wd) return;
+ if (item->icon == icon) return;
if (item->icon) {
elm_widget_sub_object_del(item->base, item->icon);
evas_object_del(item->icon);
* @ingroup Ctxpopup
*/
EAPI void elm_ctxpopup_item_label_set(Elm_Ctxpopup_Item *item,
- const char *label) {
+ const char *label)
+{
Widget_Data *wd;
if (!item)
*/
EAPI Elm_Ctxpopup_Item *
elm_ctxpopup_item_add(Evas_Object *obj, Evas_Object *icon, const char *label,
- Evas_Smart_Cb func, void *data) {
+ Evas_Smart_Cb func, void *data)
+{
ELM_CHECK_WIDTYPE(obj, widtype)NULL;
Elm_Ctxpopup_Item *item;
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
*
* @ingroup Ctxpopup
*/
-EAPI void elm_ctxpopup_item_del(Elm_Ctxpopup_Item *item) {
-
+EAPI void elm_ctxpopup_item_del(Elm_Ctxpopup_Item *item)
+{
Widget_Data *wd;
Evas_Object *obj;
* @ingroup Ctxpopup
*/
EAPI void elm_ctxpopup_item_disabled_set(Elm_Ctxpopup_Item *item,
- Eina_Bool disabled) {
+ Eina_Bool disabled)
+{
Widget_Data *wd;
- if (!item)
- return;
- if (disabled == item->disabled)
- return;
- wd = (Widget_Data *) elm_widget_data_get(item->ctxpopup);
+ if (!item) return;
+ if (disabled == item->disabled) return;
+ wd = (Widget_Data *) elm_widget_data_get(item->ctxpopup);
+
if (disabled)
edje_object_signal_emit(item->base, "elm,state,disabled", "elm");
else
* @ingroup Ctxpopup
*/
EAPI void elm_ctxpopup_screen_dimmed_disabled_set(Evas_Object *obj,
- Eina_Bool disabled) {
+ Eina_Bool disabled)
+{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
* @ingroup Ctxpopup
*/
EAPI void elm_ctxpopup_button_append(Evas_Object *obj, const char *label,
- Evas_Smart_Cb func, const void *data) {
+ Evas_Smart_Cb func, const void *data)
+{
ELM_CHECK_WIDTYPE(obj, widtype);
char buf[256];
Evas_Object *btn;
Evas_Coord w, h;
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
- if (!wd)
- return;
-
- if (!wd->btn_layout) {
- _btn_layout_create(obj);
- }
+ if (!wd) return;
+ if (!wd->btn_layout) _btn_layout_create(obj);
++wd->btn_cnt;
sprintf(buf, "buttons%d", wd->btn_cnt);
edje_object_part_swallow(wd->btn_layout, buf, btn);
edje_object_part_geometry_get(wd->btn_layout, buf, NULL, NULL, &w, &h);
- //TODO: remove this line!!
- evas_object_size_hint_max_set(wd->btn_layout, -1, 60 * elm_scale_get());
+ evas_object_size_hint_max_set(wd->btn_layout, -1, h);
if (wd->visible) {
_reset_scroller_size(wd);
*/
EAPI void elm_ctxpopup_arrow_priority_set(Evas_Object *obj,
Elm_Ctxpopup_Arrow first, Elm_Ctxpopup_Arrow second,
- Elm_Ctxpopup_Arrow third, Elm_Ctxpopup_Arrow fourth) {
+ Elm_Ctxpopup_Arrow third, Elm_Ctxpopup_Arrow fourth)
+{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
*
* @ingroup Ctxpopup
*/
-EAPI void elm_ctxpopup_content_set(Evas_Object *obj, Evas_Object *content) {
+EAPI void elm_ctxpopup_content_set(Evas_Object *obj, Evas_Object *content)
+{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
Evas_Coord w, h;
* @ingroup Ctxpopup
*/
EAPI Evas_Object *
-elm_ctxpopup_content_unset(Evas_Object *obj) {
+elm_ctxpopup_content_unset(Evas_Object *obj)
+{
ELM_CHECK_WIDTYPE(obj, widtype)NULL;
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
Evas_Object *content;
content = wd->content;
wd->content = NULL;
- if (content)
- edje_object_part_unswallow(wd->base, content);
+ if (content) edje_object_part_unswallow(wd->base, content);
elm_widget_sub_object_del(obj, content);
edje_object_signal_emit(wd->base, "elm,state,content,disable", "elm");
*
* @ingroup Ctxpopup
*/
-EAPI void elm_ctxpopup_position_forced_set(Evas_Object *obj, Eina_Bool forced) {
+EAPI void elm_ctxpopup_position_forced_set(Evas_Object *obj, Eina_Bool forced)
+{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
wd->position_forced = forced;
- if (forced)
- evas_object_hide(wd->arrow);
+ if (forced) evas_object_hide(wd->arrow);
if (wd->visible) {
_reset_scroller_size(wd);
*
* @ingroup Ctxpopup
*/
-EAPI Eina_Bool elm_ctxpopup_position_forced_get(Evas_Object *obj) {
+EAPI Eina_Bool elm_ctxpopup_position_forced_get(Evas_Object *obj)
+{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
EAPI Elm_Ctxpopup_Item *
elm_ctxpopup_icon_add(Evas_Object *obj, Evas_Object *icon, Evas_Smart_Cb func,
- void *data) {
+ void *data)
+{
return elm_ctxpopup_item_add(obj, icon, NULL, func, data);
}
EAPI Elm_Ctxpopup_Item *
elm_ctxpopup_label_add(Evas_Object *obj, const char *label, Evas_Smart_Cb func,
- void *data) {
+ void *data)
+{
return elm_ctxpopup_item_add(obj, NULL, label, func, data);
}
*
* @ingroup Ctxpopup
*/
-EAPI void elm_ctxpopup_area_set(Evas_Object *obj, Evas_Object *area) {
+EAPI void elm_ctxpopup_area_set(Evas_Object *obj, Evas_Object *area)
+{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
}
+EAPI void elm_ctxpopup_title_set(Evas_Object *obj, const char *title )
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
+ if(!wd) return;
+ if(!title) return;
+
+ if(wd->title) eina_stringshare_del(wd->title);
+ wd->title = eina_stringshare_add(title);
+ edje_object_part_text_set(wd->base, "elm.title", title);
+
+}
+
+EAPI const char* elm_ctxpopup_title_get(Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
+ return wd->title;
+}
+
+