1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
5 typedef struct _Elm_Ctxpopup_Item Elm_Ctxpopup_Item;
7 struct _Elm_Ctxpopup_Item
25 Elm_Ctxpopup_Direction dir;
26 Elm_Ctxpopup_Direction dir_priority[4];
27 Evas_Coord max_sc_w, max_sc_h;
28 Eina_Bool horizontal:1;
33 static const char *widtype = NULL;
35 static void _freeze_on(void *data, Evas_Object *obj, void *event_info);
36 static void _freeze_off(void *data, Evas_Object *obj, void *event_info);
37 static void _hold_on(void *data, Evas_Object *obj, void *event_info);
38 static void _hold_off(void *data, Evas_Object *obj, void *event_info);
39 static void _scroller_size_reset(Widget_Data *wd);
40 static void _on_focus_hook(void *data, Evas_Object *obj);
41 static Eina_Bool _event_hook(Evas_Object *obj,
43 Evas_Callback_Type type,
45 static void _parent_cut_off(Evas_Object *obj);
46 static void _parent_resize(void *data,
50 static void _parent_move(void *data,
54 static void _parent_del(void *data,
58 static void _item_sizing_eval(Elm_Ctxpopup_Item *item);
59 static void _adjust_pos_x(Evas_Coord_Point *pos,
60 Evas_Coord_Point *base_size,
61 Evas_Coord_Rectangle *hover_area);
62 static void _adjust_pos_y(Evas_Coord_Point *pos,
63 Evas_Coord_Point *base_size,
64 Evas_Coord_Rectangle *hover_area);
66 static void _ctxpopup_changed_size_hints(void *data __UNUSED__,
67 Evas *e __UNUSED__, Evas_Object *obj,
68 void *event_info __UNUSED__);
70 >>>>>>> remotes/origin/upstream
71 static Elm_Ctxpopup_Direction _calc_base_geometry(Evas_Object *obj,
72 Evas_Coord_Rectangle *rect);
73 static void _update_arrow(Evas_Object *obj,
74 Elm_Ctxpopup_Direction dir,
75 Evas_Coord_Rectangle rect);
76 static void _sizing_eval(Evas_Object *obj);
79 static void _hide_signal_emit(Evas_Object *obj,
80 Elm_Ctxpopup_Direction dir);
81 static void _show_signal_emit(Evas_Object *obj,
82 Elm_Ctxpopup_Direction dir);
83 >>>>>>> remotes/origin/upstream
84 static void _shift_base_by_arrow(Evas_Object *arrow,
85 Elm_Ctxpopup_Direction dir,
86 Evas_Coord_Rectangle *rect);
87 static void _del_pre_hook(Evas_Object *obj);
88 static void _del_hook(Evas_Object *obj);
89 static void _theme_hook(Evas_Object *obj);
90 static void _content_set_hook(Evas_Object *obj,
92 Evas_Object *content);
93 static Evas_Object * _content_unset_hook(Evas_Object *obj,
95 static Evas_Object * _content_get_hook(const Evas_Object *obj,
97 static void _item_text_set_hook(Elm_Object_Item *it,
100 static const char * _item_text_get_hook(const Elm_Object_Item *it,
102 static void _item_content_set_hook(Elm_Object_Item *it,
104 Evas_Object *content);
105 static Evas_Object * _item_content_get_hook(const Elm_Object_Item *it,
107 static void _item_disable_hook(Elm_Object_Item *it);
108 static void _item_signal_emit_hook(Elm_Object_Item *it,
109 const char *emission,
111 static void _bg_clicked_cb(void *data, Evas_Object *obj,
112 const char *emission,
114 static void _ctxpopup_show(void *data,
120 static void _hide_finished(void *data,
122 const char *emission,
123 const char *source __UNUSED__);
124 >>>>>>> remotes/origin/upstream
125 static void _hide(Evas_Object *obj);
126 static void _ctxpopup_hide(void *data,
130 static void _content_resize(void *data,
134 static void _scroller_resize(void *data,
138 static void _ctxpopup_move(void *data,
142 static void _restack(void *data, Evas *e, Evas_Object *obj, void *event_info);
143 static void _item_select_cb(void *data, Evas_Object *obj,
144 const char *emission,
146 static void _item_icon_set(Elm_Ctxpopup_Item *item, Evas_Object *icon);
147 static void _item_label_set(Elm_Ctxpopup_Item *item, const char *label);
148 static void _item_new(Elm_Ctxpopup_Item *item, char *group_name);
149 static void _content_del(void *data,
153 static void _list_del(Widget_Data *wd);
154 static void _list_new(Evas_Object *obj);
155 static void _remove_items(Widget_Data * wd);
157 static const char SIG_DISMISSED[] = "dismissed";
159 static const Evas_Smart_Cb_Description _signals[] = {
165 _freeze_on(void *data __UNUSED__, Evas_Object *obj,
166 void *event_info __UNUSED__)
168 Widget_Data *wd = elm_widget_data_get(obj);
170 if ((!wd) || (!wd->scr)) return;
171 elm_object_scroll_freeze_push(wd->scr);
175 _freeze_off(void *data __UNUSED__, Evas_Object *obj,
176 void *event_info __UNUSED__)
178 Widget_Data *wd = elm_widget_data_get(obj);
180 if ((!wd) || (!wd->scr)) return;
181 elm_object_scroll_freeze_pop(wd->scr);
185 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
187 Widget_Data *wd = elm_widget_data_get(obj);
189 if ((!wd) || (!wd->scr)) return;
190 elm_object_scroll_hold_push(wd->scr);
194 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
196 Widget_Data *wd = elm_widget_data_get(obj);
198 if ((!wd) || (!wd->scr)) return;
199 elm_object_scroll_hold_pop(wd->scr);
203 _scroller_size_reset(Widget_Data *wd)
205 wd->finished = EINA_FALSE;
211 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
213 Widget_Data *wd = elm_widget_data_get(obj);
216 if (elm_widget_focus_get(obj))
227 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__,
228 Evas_Callback_Type type, void *event_info)
230 Evas_Event_Key_Down *ev;
233 if (type != EVAS_CALLBACK_KEY_DOWN)
235 wd = elm_widget_data_get(obj);
236 if (!wd) return EINA_FALSE;
239 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
240 if (strcmp(ev->keyname, "Escape")) return EINA_FALSE;
242 evas_object_hide(obj);
243 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
248 _parent_cut_off(Evas_Object *obj)
250 Widget_Data *wd = elm_widget_data_get(obj);
254 evas_object_event_callback_del_full(wd->parent,
258 evas_object_event_callback_del_full(wd->parent,
262 evas_object_event_callback_del_full(wd->parent,
263 EVAS_CALLBACK_RESIZE,
267 elm_widget_sub_object_del(wd->parent, obj);
271 _parent_resize(void *data,
273 Evas_Object *obj __UNUSED__,
274 void *event_info __UNUSED__)
276 Widget_Data *wd = elm_widget_data_get(data);
279 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
285 _parent_move(void *data,
287 Evas_Object *obj __UNUSED__,
288 void *event_info __UNUSED__)
290 Widget_Data *wd = elm_widget_data_get(data);
294 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
298 _scroller_size_reset(wd);
304 _parent_del(void *data,
306 Evas_Object *obj __UNUSED__,
307 void *event_info __UNUSED__)
309 evas_object_del(data);
313 _item_sizing_eval(Elm_Ctxpopup_Item *item)
315 Evas_Coord min_w = -1, min_h = -1, max_w = -1, max_h = -1;
319 edje_object_size_min_restricted_calc(VIEW(item), &min_w, &min_h, min_w,
321 evas_object_size_hint_min_set(VIEW(item), min_w, min_h);
322 evas_object_size_hint_max_set(VIEW(item), max_w, max_h);
326 _adjust_pos_x(Evas_Coord_Point *pos, Evas_Coord_Point *base_size,
327 Evas_Coord_Rectangle *hover_area)
329 pos->x -= (base_size->x / 2);
331 if (pos->x < hover_area->x)
332 pos->x = hover_area->x;
333 else if ((pos->x + base_size->x) > (hover_area->x + hover_area->w))
334 pos->x = (hover_area->x + hover_area->w) - base_size->x;
336 if (base_size->x > hover_area->w)
337 base_size->x -= (base_size->x - hover_area->w);
339 if (pos->x < hover_area->x)
340 pos->x = hover_area->x;
344 _adjust_pos_y(Evas_Coord_Point *pos, Evas_Coord_Point *base_size,
345 Evas_Coord_Rectangle *hover_area)
347 pos->y -= (base_size->y / 2);
349 if (pos->y < hover_area->y)
350 pos->y = hover_area->y;
351 else if ((pos->y + base_size->y) > (hover_area->y + hover_area->h))
352 pos->y = hover_area->y + hover_area->h - base_size->y;
354 if (base_size->y > hover_area->h)
355 base_size->y -= (base_size->y - hover_area->h);
357 if (pos->y < hover_area->y)
358 pos->y = hover_area->y;
363 _ctxpopup_changed_size_hints(void *data __UNUSED__, Evas *e __UNUSED__,
364 Evas_Object *obj, void *event_info __UNUSED__)
368 wd = elm_widget_data_get(obj);
376 >>>>>>> remotes/origin/upstream
377 static Elm_Ctxpopup_Direction
378 _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
381 Evas_Coord_Point pos = {0, 0};
382 Evas_Coord_Point base_size;
383 Evas_Coord_Point max_size;
384 Evas_Coord_Point min_size;
385 Evas_Coord_Rectangle hover_area;
386 Evas_Coord_Point arrow_size;
387 Elm_Ctxpopup_Direction dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
388 Evas_Coord_Point temp;
391 wd = elm_widget_data_get(obj);
393 if ((!wd) || (!rect))
394 return ELM_CTXPOPUP_DIRECTION_DOWN;
396 edje_object_part_geometry_get(wd->arrow, "ctxpopup_arrow", NULL, NULL,
397 &arrow_size.x, &arrow_size.y);
398 evas_object_resize(wd->arrow, arrow_size.x, arrow_size.y);
400 //Initialize Area Rectangle.
401 evas_object_geometry_get(wd->parent,
407 evas_object_geometry_get(obj, &pos.x, &pos.y, NULL, NULL);
410 edje_object_size_min_calc(wd->base, &base_size.x, &base_size.y);
411 evas_object_smart_calculate(wd->base);
414 evas_object_size_hint_max_get(obj, &max_size.x, &max_size.y);
416 if ((max_size.y > 0) && (base_size.y > max_size.y))
417 base_size.y = max_size.y;
419 if ((max_size.x > 0) && (base_size.x > max_size.x))
420 base_size.x = max_size.x;
423 evas_object_size_hint_min_get(obj, &min_size.x, &min_size.y);
425 if ((min_size.y > 0) && (base_size.y < min_size.y))
426 base_size.y = min_size.y;
428 if ((min_size.x > 0) && (base_size.x < min_size.x))
429 base_size.x = min_size.x;
431 //Check the Which direction is available.
432 //If find a avaialble direction, it adjusts position and size.
433 for (idx = 0; idx < 4; idx++)
435 switch (wd->dir_priority[idx])
437 case ELM_CTXPOPUP_DIRECTION_UNKNOWN:
438 case ELM_CTXPOPUP_DIRECTION_UP:
439 temp.y = (pos.y - base_size.y);
440 if ((temp.y - arrow_size.y) < hover_area.y)
442 _adjust_pos_x(&pos, &base_size, &hover_area);
443 pos.y -= base_size.y;
444 dir = ELM_CTXPOPUP_DIRECTION_UP;
446 case ELM_CTXPOPUP_DIRECTION_LEFT:
447 temp.x = (pos.x - base_size.x);
448 if ((temp.x - arrow_size.x) < hover_area.x)
450 _adjust_pos_y(&pos, &base_size, &hover_area);
451 pos.x -= base_size.x;
452 dir = ELM_CTXPOPUP_DIRECTION_LEFT;
454 case ELM_CTXPOPUP_DIRECTION_RIGHT:
455 temp.x = (pos.x + base_size.x);
456 if ((temp.x + arrow_size.x) >
457 (hover_area.x + hover_area.w))
459 _adjust_pos_y(&pos, &base_size, &hover_area);
460 dir = ELM_CTXPOPUP_DIRECTION_RIGHT;
462 case ELM_CTXPOPUP_DIRECTION_DOWN:
463 temp.y = (pos.y + base_size.y);
464 if ((temp.y + arrow_size.y) >
465 (hover_area.y + hover_area.h))
467 _adjust_pos_x(&pos, &base_size, &hover_area);
468 dir = ELM_CTXPOPUP_DIRECTION_DOWN;
476 //In this case, all directions are invalid because of lack of space.
479 Evas_Coord length[2];
483 length[0] = pos.y - hover_area.y;
484 length[1] = (hover_area.y + hover_area.h) - pos.y;
486 // ELM_CTXPOPUP_DIRECTION_UP
487 if (length[0] > length[1])
489 _adjust_pos_x(&pos, &base_size, &hover_area);
490 pos.y -= base_size.y;
491 dir = ELM_CTXPOPUP_DIRECTION_UP;
492 if (pos.y < (hover_area.y + arrow_size.y))
494 base_size.y -= ((hover_area.y + arrow_size.y) - pos.y);
495 pos.y = hover_area.y + arrow_size.y;
498 //ELM_CTXPOPUP_DIRECTION_DOWN
501 _adjust_pos_x(&pos, &base_size, &hover_area);
502 dir = ELM_CTXPOPUP_DIRECTION_DOWN;
503 if ((pos.y + arrow_size.y + base_size.y) >
504 (hover_area.y + hover_area.h))
506 ((pos.y + arrow_size.y + base_size.y) -
507 (hover_area.y + hover_area.h));
512 length[0] = pos.x - hover_area.x;
513 length[1] = (hover_area.x + hover_area.w) - pos.x;
515 //ELM_CTXPOPUP_DIRECTION_LEFT
516 if (length[0] > length[1])
518 _adjust_pos_y(&pos, &base_size, &hover_area);
519 pos.x -= base_size.x;
520 dir = ELM_CTXPOPUP_DIRECTION_LEFT;
521 if (pos.x < (hover_area.x + arrow_size.x))
523 base_size.x -= ((hover_area.x + arrow_size.x) - pos.x);
524 pos.x = hover_area.x + arrow_size.x;
527 //ELM_CTXPOPUP_DIRECTION_RIGHT
530 _adjust_pos_y(&pos, &base_size, &hover_area);
531 dir = ELM_CTXPOPUP_DIRECTION_RIGHT;
532 if (pos.x + (arrow_size.x + base_size.x) >
533 hover_area.x + hover_area.w)
535 ((pos.x + arrow_size.x + base_size.x) -
536 (hover_area.x + hover_area.w));
541 //Final position and size.
544 rect->w = base_size.x;
545 rect->h = base_size.y;
551 _update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir,
552 Evas_Coord_Rectangle base_size)
555 Evas_Coord_Rectangle arrow_size;
559 wd = elm_widget_data_get(obj);
562 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
563 evas_object_geometry_get(wd->arrow, NULL, NULL, &arrow_size.w,
566 edje_object_part_unswallow(wd->base, wd->arrow);
570 case ELM_CTXPOPUP_DIRECTION_RIGHT:
571 edje_object_signal_emit(wd->arrow, "elm,state,left", "elm");
572 edje_object_part_swallow(wd->base,
573 "elm.swallow.arrow_left",
577 // if user does not use dragable part
578 arrow_size.y = (y - (arrow_size.h * 0.5));
582 >>>>>>> remotes/origin/upstream
585 if (y < ((arrow_size.h * 0.5) + base_size.y))
587 else if (y > base_size.y + base_size.h - (arrow_size.h * 0.5))
588 y = base_size.h - arrow_size.h;
590 y = y - base_size.y - (arrow_size.h * 0.5);
591 drag = (double) (y) / (double) (base_size.h - arrow_size.h);
592 edje_object_part_drag_value_set(wd->base,
593 "elm.swallow.arrow_left",
598 case ELM_CTXPOPUP_DIRECTION_LEFT:
599 edje_object_signal_emit(wd->arrow, "elm,state,right", "elm");
600 edje_object_part_swallow(wd->base,
601 "elm.swallow.arrow_right",
605 // if user does not use dragable part
606 arrow_size.y = (y - (arrow_size.h * 0.5));
607 arrow_size.x = (x - arrow_size.w);
610 >>>>>>> remotes/origin/upstream
613 if (y < ((arrow_size.h * 0.5) + base_size.y))
615 else if (y > (base_size.y + base_size.h - (arrow_size.h * 0.5)))
616 y = base_size.h - arrow_size.h;
618 y = y - base_size.y - (arrow_size.h * 0.5);
619 drag = (double) (y) / (double) (base_size.h - arrow_size.h);
620 edje_object_part_drag_value_set(wd->base,
621 "elm.swallow.arrow_right",
626 case ELM_CTXPOPUP_DIRECTION_DOWN:
627 edje_object_signal_emit(wd->arrow, "elm,state,top", "elm");
628 edje_object_part_swallow(wd->base, "elm.swallow.arrow_up", wd->arrow);
631 // if user does not use dragable part
632 arrow_size.x = (x - (arrow_size.w * 0.5));
636 >>>>>>> remotes/origin/upstream
639 if (x < ((arrow_size.w * 0.5) + base_size.x))
641 else if (x > (base_size.x + base_size.w - (arrow_size.w * 0.5)))
642 x = base_size.w - arrow_size.w;
644 x = x - base_size.x - (arrow_size.w * 0.5);
645 drag = (double) (x) / (double) (base_size.w - arrow_size.w);
646 edje_object_part_drag_value_set(wd->base,
647 "elm.swallow.arrow_up",
652 case ELM_CTXPOPUP_DIRECTION_UP:
653 edje_object_signal_emit(wd->arrow, "elm,state,bottom", "elm");
654 edje_object_part_swallow(wd->base,
655 "elm.swallow.arrow_down",
659 // if user does not use dragable part
660 arrow_size.x = (x - (arrow_size.w * 0.5));
661 arrow_size.y = (y - arrow_size.h);
664 >>>>>>> remotes/origin/upstream
667 if (x < ((arrow_size.w * 0.5) + base_size.x))
669 else if (x > (base_size.x + base_size.w - (arrow_size.w * 0.5)))
670 x = base_size.w - arrow_size.w;
671 else x = x - base_size.x - (arrow_size.w * 0.5);
672 drag = (double) (x) / (double) (base_size.w - arrow_size.w);
673 edje_object_part_drag_value_set(wd->base,
674 "elm.swallow.arrow_down",
684 // if user does not use dragable part
685 evas_object_move(wd->arrow, arrow_size.x, arrow_size.y);
688 //TODO: compress item - different from opensource
690 _compress_item(Evas_Object *obj)
694 Elm_Ctxpopup_Item *item;
696 wd = elm_widget_data_get(obj);
699 EINA_LIST_FOREACH(wd->items, elist, item)
701 edje_object_signal_emit(item->base.view, "elm,state,compress", "elm");
706 _hide_signal_emit(Evas_Object *obj, Elm_Ctxpopup_Direction dir)
710 wd = elm_widget_data_get(obj);
711 if (!wd->visible) return;
715 case ELM_CTXPOPUP_DIRECTION_UP:
716 edje_object_signal_emit(wd->base, "elm,state,hide,up", "elm");
718 case ELM_CTXPOPUP_DIRECTION_LEFT:
719 edje_object_signal_emit(wd->base, "elm,state,hide,left", "elm");
721 case ELM_CTXPOPUP_DIRECTION_RIGHT:
722 edje_object_signal_emit(wd->base, "elm,state,hide,right", "elm");
724 case ELM_CTXPOPUP_DIRECTION_DOWN:
725 edje_object_signal_emit(wd->base, "elm,state,hide,down", "elm");
731 edje_object_signal_emit(wd->bg, "elm,state,hide", "elm");
735 _show_signal_emit(Evas_Object *obj, Elm_Ctxpopup_Direction dir)
739 wd = elm_widget_data_get(obj);
740 if (wd->visible) return;
744 case ELM_CTXPOPUP_DIRECTION_UP:
745 edje_object_signal_emit(wd->base, "elm,state,show,up", "elm");
747 case ELM_CTXPOPUP_DIRECTION_LEFT:
748 edje_object_signal_emit(wd->base, "elm,state,show,left", "elm");
750 case ELM_CTXPOPUP_DIRECTION_RIGHT:
751 edje_object_signal_emit(wd->base, "elm,state,show,right", "elm");
753 case ELM_CTXPOPUP_DIRECTION_DOWN:
754 edje_object_signal_emit(wd->base, "elm,state,show,down", "elm");
758 >>>>>>> remotes/origin/upstream
763 _sizing_eval(Evas_Object *obj)
767 Elm_Ctxpopup_Item *item;
768 Evas_Coord_Rectangle rect = { 0, 0, 1, 1 };
769 Evas_Coord_Point box_size = { 0, 0 };
770 Evas_Coord_Point _box_size = { 0, 0 };
772 wd = elm_widget_data_get(obj);
775 if (!wd->parent) return;
777 >>>>>>> remotes/origin/upstream
780 EINA_LIST_FOREACH(wd->items, elist, item)
782 _item_sizing_eval(item);
783 evas_object_size_hint_min_get(VIEW(item), &_box_size.x, &_box_size.y);
786 if (_box_size.x > box_size.x)
787 box_size.x = _box_size.x;
788 if (_box_size.y != -1)
789 box_size.y += _box_size.y;
793 if (_box_size.x != -1)
794 box_size.x += _box_size.x;
795 if (_box_size.y > box_size.y)
796 box_size.y = _box_size.y;
802 evas_object_size_hint_min_set(wd->box, box_size.x, box_size.y);
803 evas_object_size_hint_min_set(wd->scr, box_size.x, box_size.y);
807 wd->dir = _calc_base_geometry(obj, &rect);
810 //TODO: compress item - different from opensource
811 if (!wd->horizontal && !wd->content)
815 _show_signal_emit(obj, wd->dir);
816 >>>>>>> remotes/origin/upstream
817 _update_arrow(obj, wd->dir, rect);
818 _shift_base_by_arrow(wd->arrow, wd->dir, &rect);
820 //resize scroller according to final size.
822 evas_object_smart_calculate(wd->scr);
824 evas_object_move(wd->base, rect.x, rect.y);
825 evas_object_resize(wd->base, rect.w, rect.h);
829 _shift_base_by_arrow(Evas_Object *arrow, Elm_Ctxpopup_Direction dir,
830 Evas_Coord_Rectangle *rect)
832 Evas_Coord arrow_w, arrow_h;
834 evas_object_geometry_get(arrow, NULL, NULL, &arrow_w, &arrow_h);
838 case ELM_CTXPOPUP_DIRECTION_RIGHT:
841 case ELM_CTXPOPUP_DIRECTION_LEFT:
844 case ELM_CTXPOPUP_DIRECTION_DOWN:
847 case ELM_CTXPOPUP_DIRECTION_UP:
856 _del_pre_hook(Evas_Object *obj)
860 wd = elm_widget_data_get(obj);
864 evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_RESIZE,
865 _parent_resize, obj);
866 evas_object_event_callback_del_full(wd->box, EVAS_CALLBACK_RESIZE,
867 _content_resize, obj);
870 evas_object_event_callback_del_full(wd->box, EVAS_CALLBACK_RESIZE,
871 _content_resize, obj);
872 >>>>>>> remotes/origin/upstream
873 _parent_cut_off(obj);
877 _del_hook(Evas_Object *obj)
881 wd = elm_widget_data_get(obj);
884 elm_ctxpopup_clear(obj);
885 evas_object_del(wd->arrow);
886 evas_object_del(wd->base);
890 //FIXME: lost the content size when theme hook is called.
892 _theme_hook(Evas_Object *obj)
896 Elm_Ctxpopup_Item *item;
900 >>>>>>> remotes/origin/upstream
903 wd = elm_widget_data_get(obj);
906 _elm_widget_mirrored_reload(obj);
907 rtl = elm_widget_mirrored_get(obj);
909 _elm_theme_object_set(obj, wd->bg, "ctxpopup", "bg",
910 elm_widget_style_get(obj));
911 _elm_theme_object_set(obj, wd->base, "ctxpopup", "base",
912 elm_widget_style_get(obj));
913 _elm_theme_object_set(obj, wd->arrow, "ctxpopup", "arrow",
914 elm_widget_style_get(obj));
917 EINA_LIST_FOREACH(wd->items, elist, item)
919 edje_object_mirrored_set(VIEW(item), rtl);
921 if (item->label && item->icon)
922 _elm_theme_object_set(obj, VIEW(item), "ctxpopup",
923 "icon_text_style_item",
924 elm_widget_style_get(obj));
925 else if (item->label)
926 _elm_theme_object_set(obj, VIEW(item), "ctxpopup", "text_style_item",
927 elm_widget_style_get(obj));
929 _elm_theme_object_set(obj, VIEW(item), "ctxpopup", "icon_style_item",
930 elm_widget_style_get(obj));
932 edje_object_part_text_set(VIEW(item), "elm.text", item->label);
934 if (elm_widget_item_disabled_get(item))
935 edje_object_signal_emit(VIEW(item), "elm,state,disabled", "elm");
939 * For separator, if the first item has visible separator,
940 * then it should be aligned with edge of the base part.
941 * In some cases, it gives improper display. Ex) rounded corner
942 * So the first item separator should be invisible.
945 edje_object_signal_emit(VIEW(item), "elm,state,default", "elm");
949 edje_object_signal_emit(VIEW(item), "elm,state,vertical", "elm");
951 edje_object_signal_emit(VIEW(item), "elm,state,horizontal", "elm");
954 edje_object_message_signal_process(VIEW(item));
957 if (evas_object_visible_get(wd->bg))
958 edje_object_signal_emit(wd->bg, "elm,state,show", "elm");
961 edje_object_message_signal_process(VIEW(item));
964 >>>>>>> remotes/origin/upstream
967 if (!strncmp(elm_object_style_get(obj), "default", strlen("default")))
968 elm_object_style_set(wd->scr, "ctxpopup");
970 elm_object_style_set(wd->scr, elm_object_style_get(obj));
973 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
977 _scroller_size_reset(wd);
983 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
985 ELM_CHECK_WIDTYPE(obj, widtype);
986 Evas_Coord min_w = -1, min_h = -1;
990 if (part && strcmp(part, "default")) return;
992 wd = elm_widget_data_get(obj);
993 if ((!wd) || (!content)) return;
995 if (wd->items) elm_ctxpopup_clear(obj);
996 if (wd->content) evas_object_del(wd->content);
999 wd->box = elm_box_add(obj);
1000 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
1002 evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND,
1004 evas_object_size_hint_fill_set(content, EVAS_HINT_FILL,
1006 evas_object_show(content);
1007 evas_object_size_hint_min_get(content, &min_w, &min_h);
1008 evas_object_size_hint_min_set(wd->box, min_w, min_h);
1009 elm_box_pack_end(wd->box, content);
1011 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE,
1012 _content_resize, obj);
1013 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_DEL,
1016 elm_widget_sub_object_add(obj, wd->box);
1017 edje_object_part_swallow(wd->base, "elm.swallow.content", wd->box);
1019 wd->content = content;
1020 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1026 static Evas_Object *
1027 _content_unset_hook(Evas_Object *obj, const char *part)
1029 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1032 Evas_Object *content;
1033 if (part && strcmp(part, "default")) return NULL;
1034 wd = elm_widget_data_get(obj);
1035 if (!wd) return NULL;
1037 content = wd->content;
1038 if (!content || !wd->box) return NULL;
1040 edje_object_part_unswallow(wd->base, wd->box);
1041 elm_widget_sub_object_del(obj, wd->box);
1042 evas_object_event_callback_del(wd->box, EVAS_CALLBACK_DEL, _content_del);
1043 edje_object_signal_emit(wd->base, "elm,state,content,disable", "elm");
1045 evas_object_del(wd->box);
1048 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1053 static Evas_Object *
1054 _content_get_hook(const Evas_Object *obj, const char *part)
1056 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1058 if (part && strcmp(part, "default")) return NULL;
1059 wd = elm_widget_data_get(obj);
1060 if (!wd) return NULL;
1065 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1068 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1071 >>>>>>> remotes/origin/upstream
1073 Elm_Ctxpopup_Item *ctxpopup_it;
1075 if (part && strcmp(part, "default")) return;
1078 ctxpopup_it = (Elm_Ctxpopup_Item *) it;
1080 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1081 >>>>>>> remotes/origin/upstream
1083 wd = elm_widget_data_get(WIDGET(ctxpopup_it));
1086 _item_label_set(ctxpopup_it, label);
1087 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1091 _scroller_size_reset(wd);
1092 _sizing_eval(WIDGET(ctxpopup_it));
1097 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1100 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1101 Elm_Ctxpopup_Item *ctxpopup_it;
1102 if (part && strcmp(part, "default")) return NULL;
1103 ctxpopup_it = (Elm_Ctxpopup_Item *) it;
1105 Elm_Ctxpopup_Item *ctxpopup_it;
1106 if (part && strcmp(part, "default")) return NULL;
1107 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1108 >>>>>>> remotes/origin/upstream
1109 return ctxpopup_it->label;
1113 _item_content_set_hook(Elm_Object_Item *it,
1115 Evas_Object *content)
1118 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1120 >>>>>>> remotes/origin/upstream
1122 Elm_Ctxpopup_Item *ctxpopup_it;
1124 if (part && strcmp(part, "icon")) return;
1127 ctxpopup_it = (Elm_Ctxpopup_Item *) it;
1129 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1130 >>>>>>> remotes/origin/upstream
1132 wd = elm_widget_data_get(WIDGET(ctxpopup_it));
1135 _item_icon_set(ctxpopup_it, content);
1136 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1140 _scroller_size_reset(wd);
1141 _sizing_eval(WIDGET(ctxpopup_it));
1145 static Evas_Object *
1146 _item_content_get_hook(const Elm_Object_Item *it, const char *part)
1149 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1150 Elm_Ctxpopup_Item *ctxpopup_it;
1151 if (part && strcmp(part, "icon")) return NULL;
1152 ctxpopup_it = (Elm_Ctxpopup_Item *) it;
1154 Elm_Ctxpopup_Item *ctxpopup_it;
1155 if (part && strcmp(part, "icon")) return NULL;
1156 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1157 >>>>>>> remotes/origin/upstream
1158 return ctxpopup_it->icon;
1162 _item_disable_hook(Elm_Object_Item *it)
1165 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1168 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *) it;
1171 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1172 >>>>>>> remotes/origin/upstream
1174 wd = elm_widget_data_get(WIDGET(ctxpopup_it));
1177 if (elm_widget_item_disabled_get(it))
1178 edje_object_signal_emit(VIEW(ctxpopup_it), "elm,state,disabled", "elm");
1180 edje_object_signal_emit(VIEW(ctxpopup_it), "elm,state,enabled", "elm");
1184 _item_signal_emit_hook(Elm_Object_Item *it, const char *emission,
1188 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1189 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *) it;
1191 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1192 >>>>>>> remotes/origin/upstream
1193 edje_object_signal_emit(VIEW(ctxpopup_it), emission, source);
1197 _bg_clicked_cb(void *data, Evas_Object *obj __UNUSED__,
1198 const char *emission __UNUSED__, const char *source __UNUSED__)
1201 evas_object_hide(data);
1203 Widget_Data *wd = elm_widget_data_get(data);
1205 _hide_signal_emit(data, wd->dir);
1206 >>>>>>> remotes/origin/upstream
1210 _ctxpopup_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
1211 void *event_info __UNUSED__)
1216 Elm_Ctxpopup_Item *item;
1219 >>>>>>> remotes/origin/upstream
1221 wd = elm_widget_data_get(obj);
1224 if ((!wd->items) && (!wd->content)) return;
1226 wd->visible = EINA_TRUE;
1228 evas_object_show(wd->bg);
1229 evas_object_show(wd->base);
1230 evas_object_show(wd->arrow);
1232 edje_object_signal_emit(wd->bg, "elm,state,show", "elm");
1235 EINA_LIST_FOREACH(wd->items, elist, item)
1238 edje_object_signal_emit(VIEW(item), "elm,state,default", "elm");
1242 edje_object_signal_emit(VIEW(item), "elm,state,vertical", "elm");
1244 edje_object_signal_emit(VIEW(item), "elm,state,horizontal", "elm");
1248 edje_object_signal_emit(wd->base, "elm,state,show", "elm");
1249 >>>>>>> remotes/origin/upstream
1253 elm_object_focus_set(obj, EINA_TRUE);
1258 _hide(Evas_Object *obj)
1260 Widget_Data *wd = elm_widget_data_get(obj);
1263 _hide_finished(void *data, Evas_Object *obj __UNUSED__,
1264 const char *emission __UNUSED__, const char *source __UNUSED__)
1270 _hide(Evas_Object *obj)
1272 _ctxpopup_hide(NULL, NULL, obj, NULL);
1273 evas_object_smart_callback_call(obj, SIG_DISMISSED, NULL);
1277 _ctxpopup_hide(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
1278 void *event_info __UNUSED__)
1280 Widget_Data *wd = elm_widget_data_get(obj);
1281 >>>>>>> remotes/origin/upstream
1282 if ((!wd) || (!wd->visible)) return;
1284 evas_object_hide(wd->bg);
1285 evas_object_hide(wd->arrow);
1286 evas_object_hide(wd->base);
1288 _scroller_size_reset(wd);
1291 evas_object_smart_callback_call(obj, SIG_DISMISSED, NULL);
1293 >>>>>>> remotes/origin/upstream
1294 wd->visible = EINA_FALSE;
1299 _ctxpopup_hide(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
1300 void *event_info __UNUSED__)
1307 >>>>>>> remotes/origin/upstream
1308 _content_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
1309 void *event_info __UNUSED__)
1311 Widget_Data *wd = elm_widget_data_get(data);
1313 elm_box_recalculate(wd->box);
1318 _scroller_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj,
1319 void *event_info __UNUSED__)
1324 wd = elm_widget_data_get(data);
1326 if (!wd->visible) return;
1327 if (wd->finished) return;
1329 evas_object_geometry_get(obj, 0, 0, &w, &h);
1331 if (w != 0 && h != 0)
1333 if ((w <= wd->max_sc_w) && (h <= wd->max_sc_h))
1336 wd->finished = EINA_TRUE;
1341 if (wd->max_sc_w < w)
1343 if (wd->max_sc_h < h)
1350 _ctxpopup_move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
1351 void *event_info __UNUSED__)
1355 wd = elm_widget_data_get(obj);
1360 evas_object_show(wd->arrow);
1362 _scroller_size_reset(wd);
1367 _restack(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1369 Widget_Data *wd = elm_widget_data_get(obj);
1371 evas_object_layer_set(wd->bg,
1372 evas_object_layer_get(obj));
1373 evas_object_layer_set(wd->base,
1374 evas_object_layer_get(obj));
1378 _item_select_cb(void *data, Evas_Object *obj __UNUSED__,
1379 const char *emission __UNUSED__, const char *source __UNUSED__)
1381 Elm_Ctxpopup_Item *item = data;
1384 if (elm_widget_item_disabled_get(item)) return;
1388 item->func((void*) item->base.data, WIDGET(item), data);
1390 item->func((void*)item->base.data, WIDGET(item), data);
1391 >>>>>>> remotes/origin/upstream
1395 _item_icon_set(Elm_Ctxpopup_Item *item, Evas_Object *icon)
1400 elm_widget_sub_object_del(VIEW(item), item->icon);
1401 evas_object_del(item->icon);
1404 evas_object_del(item->icon);
1405 >>>>>>> remotes/origin/upstream
1410 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
1411 edje_object_message_signal_process(VIEW(item));
1415 _item_label_set(Elm_Ctxpopup_Item *item, const char *label)
1417 if (!eina_stringshare_replace(&item->label, label))
1420 edje_object_part_text_set(VIEW(item), "elm.text", label);
1421 edje_object_message_signal_process(VIEW(item));
1425 _item_new(Elm_Ctxpopup_Item *item, char *group_name)
1429 wd = elm_widget_data_get(WIDGET(item));
1432 VIEW(item) = edje_object_add(evas_object_evas_get(wd->base));
1433 edje_object_mirrored_set(VIEW(item), elm_widget_mirrored_get(WIDGET(item)));
1434 _elm_theme_object_set(WIDGET(item), VIEW(item), "ctxpopup", group_name,
1435 elm_widget_style_get(WIDGET(item)));
1436 edje_object_signal_callback_add(VIEW(item), "elm,action,click", "",
1437 _item_select_cb, item);
1438 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1439 evas_object_show(VIEW(item));
1443 _content_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
1444 void *event_info __UNUSED__)
1446 elm_object_content_unset(data);
1450 _list_del(Widget_Data *wd)
1452 if (!wd->scr) return;
1454 edje_object_part_unswallow(wd->base, wd->scr);
1455 evas_object_del(wd->scr);
1461 _list_new(Evas_Object *obj)
1464 wd = elm_widget_data_get(obj);
1468 wd->scr = elm_scroller_add(obj);
1469 elm_object_style_set(wd->scr, "ctxpopup");
1470 evas_object_size_hint_align_set(wd->scr, EVAS_HINT_FILL, EVAS_HINT_FILL);
1471 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE,
1472 _scroller_resize, obj);
1473 edje_object_part_swallow(wd->base, "elm.swallow.content", wd->scr);
1476 wd->box = elm_box_add(obj);
1477 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
1480 elm_object_content_set(wd->scr, wd->box);
1481 elm_ctxpopup_horizontal_set(obj, wd->horizontal);
1485 _remove_items(Widget_Data *wd)
1488 Elm_Ctxpopup_Item *item;
1490 if (!wd->items) return;
1492 EINA_LIST_FOREACH(wd->items, elist, item)
1495 eina_stringshare_del(item->label);
1497 evas_object_del(item->icon);
1498 wd->items = eina_list_remove(wd->items, item);
1499 elm_widget_item_free(item);
1506 _item_del_pre_hook(Elm_Object_Item *it)
1509 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1512 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *) it;
1515 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1516 >>>>>>> remotes/origin/upstream
1518 wd = elm_widget_data_get(WIDGET(ctxpopup_it));
1519 if (!wd) return EINA_FALSE;
1521 if (ctxpopup_it->icon)
1522 evas_object_del(ctxpopup_it->icon);
1523 if (VIEW(ctxpopup_it))
1524 evas_object_del(VIEW(ctxpopup_it));
1526 eina_stringshare_del(ctxpopup_it->label);
1528 wd->items = eina_list_remove(wd->items, ctxpopup_it);
1530 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1532 if (eina_list_count(wd->items) < 1)
1534 evas_object_hide(WIDGET(ctxpopup_it));
1539 _sizing_eval(WIDGET(ctxpopup_it));
1545 elm_ctxpopup_add(Evas_Object *parent)
1551 Evas_Coord x, y, w, h;
1553 >>>>>>> remotes/origin/upstream
1555 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1557 ELM_SET_WIDTYPE(widtype, "ctxpopup");
1558 elm_widget_type_set(obj, "ctxpopup");
1560 elm_widget_sub_object_add(parent, obj);
1562 >>>>>>> remotes/origin/upstream
1563 elm_widget_data_set(obj, wd);
1564 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1565 elm_widget_del_hook_set(obj, _del_hook);
1566 elm_widget_theme_hook_set(obj, _theme_hook);
1567 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1568 elm_widget_can_focus_set(obj, EINA_TRUE);
1569 elm_widget_event_hook_set(obj, _event_hook);
1570 elm_widget_content_set_hook_set(obj, _content_set_hook);
1571 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
1572 elm_widget_content_get_hook_set(obj, _content_get_hook);
1575 wd->bg = edje_object_add(e);
1576 elm_widget_sub_object_add(obj, wd->bg);
1577 _elm_theme_object_set(obj, wd->bg, "ctxpopup", "bg", "default");
1579 evas_object_geometry_get(parent, &x, &y, &w, &h);
1580 evas_object_move(wd->bg, x, y);
1581 evas_object_resize(wd->bg, w, h);
1582 edje_object_signal_callback_add(wd->bg, "elm,action,click", "",
1583 _bg_clicked_cb, obj);
1586 edje_object_signal_callback_add(wd->bg,
1591 >>>>>>> remotes/origin/upstream
1593 wd->base = edje_object_add(e);
1594 elm_widget_sub_object_add(obj, wd->base);
1595 _elm_theme_object_set(obj, wd->base, "ctxpopup", "base", "default");
1598 edje_object_signal_callback_add(wd->base, "elm,action,hide,finished", "",
1599 _hide_finished, obj);
1600 >>>>>>> remotes/origin/upstream
1603 wd->arrow = edje_object_add(e);
1604 elm_widget_sub_object_add(obj, wd->arrow);
1605 _elm_theme_object_set(obj, wd->arrow, "ctxpopup", "arrow", "default");
1607 wd->dir_priority[0] = ELM_CTXPOPUP_DIRECTION_UP;
1608 wd->dir_priority[1] = ELM_CTXPOPUP_DIRECTION_LEFT;
1609 wd->dir_priority[2] = ELM_CTXPOPUP_DIRECTION_RIGHT;
1610 wd->dir_priority[3] = ELM_CTXPOPUP_DIRECTION_DOWN;
1613 evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE, _parent_resize,
1616 >>>>>>> remotes/origin/upstream
1617 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1619 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _ctxpopup_show,
1621 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _ctxpopup_hide,
1623 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _ctxpopup_move,
1626 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1627 _ctxpopup_changed_size_hints, NULL);
1629 >>>>>>> remotes/origin/upstream
1630 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESTACK, _restack, obj);
1631 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1632 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1633 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1634 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1636 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1638 //default parent is to be hover parent
1639 elm_ctxpopup_hover_parent_set(obj, parent);
1646 elm_ctxpopup_item_icon_get(const Elm_Object_Item *it)
1648 return _item_content_get_hook(it, "icon");
1652 elm_ctxpopup_item_icon_set(Elm_Object_Item *it, Evas_Object *icon)
1654 _item_content_set_hook(it, "icon", icon);
1658 elm_ctxpopup_item_label_get(const Elm_Object_Item *it)
1660 return _item_text_get_hook(it, NULL);
1664 elm_ctxpopup_item_label_set(Elm_Object_Item *it, const char *label)
1666 _item_text_set_hook(it, NULL, label);
1670 >>>>>>> remotes/origin/upstream
1672 elm_ctxpopup_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
1674 ELM_CHECK_WIDTYPE(obj, widtype);
1677 Evas_Coord x, y, w, h;
1679 wd = elm_widget_data_get(obj);
1680 if ((!wd) || (!parent)) return;
1682 _parent_cut_off(obj);
1686 evas_object_event_callback_add(parent,
1690 evas_object_event_callback_add(parent,
1694 evas_object_event_callback_add(parent,
1695 EVAS_CALLBACK_RESIZE,
1700 elm_widget_sub_object_add(parent, obj);
1701 wd->parent = parent;
1704 evas_object_geometry_get(parent, &x, &y, &w, &h);
1705 evas_object_move(wd->bg, x, y);
1706 evas_object_resize(wd->bg, w, h);
1708 if (wd->visible) _sizing_eval(obj);
1712 elm_ctxpopup_hover_parent_get(const Evas_Object *obj)
1714 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1718 wd = elm_widget_data_get(obj);
1719 if (!wd) return NULL;
1725 elm_ctxpopup_clear(Evas_Object * obj)
1727 ELM_CHECK_WIDTYPE(obj, widtype);
1729 Widget_Data *wd = elm_widget_data_get(obj);
1734 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1738 elm_ctxpopup_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1740 ELM_CHECK_WIDTYPE(obj, widtype);
1745 Elm_Ctxpopup_Item *item;
1748 >>>>>>> remotes/origin/upstream
1750 wd = elm_widget_data_get(obj);
1753 wd->horizontal = !!horizontal;
1755 if ((!wd->scr) && (!wd->box))
1760 elm_box_horizontal_set(wd->box, EINA_FALSE);
1761 elm_scroller_bounce_set(wd->scr, EINA_FALSE, EINA_TRUE);
1764 EINA_LIST_FOREACH(wd->items, elist, item)
1767 edje_object_signal_emit(VIEW(item), "elm,state,default", "elm");
1769 edje_object_signal_emit(VIEW(item), "elm,state,vertical", "elm");
1772 >>>>>>> remotes/origin/upstream
1776 elm_box_horizontal_set(wd->box, EINA_TRUE);
1777 elm_scroller_bounce_set(wd->scr, EINA_TRUE, EINA_FALSE);
1780 EINA_LIST_FOREACH(wd->items, elist, item)
1783 edje_object_signal_emit(VIEW(item), "elm,state,default", "elm");
1785 edje_object_signal_emit(VIEW(item), "elm,state,horizontal", "elm");
1788 >>>>>>> remotes/origin/upstream
1791 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1798 elm_ctxpopup_horizontal_get(const Evas_Object *obj)
1800 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1804 wd = elm_widget_data_get(obj);
1805 if (!wd) return EINA_FALSE;
1807 return wd->horizontal;
1810 EAPI Elm_Object_Item *
1811 elm_ctxpopup_item_append(Evas_Object *obj, const char *label,
1812 Evas_Object *icon, Evas_Smart_Cb func,
1815 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1818 Evas_Object *content;
1819 Elm_Ctxpopup_Item *item;
1821 wd = elm_widget_data_get(obj);
1822 if (!wd) return NULL;
1824 item = elm_widget_item_new(obj, Elm_Ctxpopup_Item);
1825 if (!item) return NULL;
1827 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
1828 elm_widget_item_disable_hook_set(item, _item_disable_hook);
1829 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
1830 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
1831 elm_widget_item_content_set_hook_set(item, _item_content_set_hook);
1832 elm_widget_item_content_get_hook_set(item, _item_content_get_hook);
1833 elm_widget_item_signal_emit_hook_set(item, _item_signal_emit_hook);
1835 //The first item is appended.
1836 content = elm_object_content_unset(obj);
1837 if (content) evas_object_del(content);
1843 item->base.data = data;
1846 _item_new(item, "icon_text_style_item");
1848 _item_new(item, "text_style_item");
1850 _item_new(item, "icon_style_item");
1852 _item_icon_set(item, icon);
1853 _item_label_set(item, label);
1854 elm_box_pack_end(wd->box, VIEW(item));
1855 wd->items = eina_list_append(wd->items, item);
1856 wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1860 _scroller_size_reset(wd);
1865 return (Elm_Object_Item *) item;
1869 elm_ctxpopup_item_del(Elm_Object_Item *it)
1871 elm_object_item_del(it);
1875 elm_ctxpopup_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled)
1877 elm_object_item_disabled_set(it, disabled);
1881 elm_ctxpopup_item_disabled_get(const Elm_Object_Item *it)
1883 return elm_object_item_disabled_get(it);
1887 elm_ctxpopup_content_set(Evas_Object *obj, Evas_Object *content)
1889 elm_object_content_set(obj, content);
1893 elm_ctxpopup_content_unset(Evas_Object *obj)
1895 return elm_object_content_unset(obj);
1897 return (Elm_Object_Item *)item;
1898 >>>>>>> remotes/origin/upstream
1902 elm_ctxpopup_direction_priority_set(Evas_Object *obj,
1903 Elm_Ctxpopup_Direction first,
1904 Elm_Ctxpopup_Direction second,
1905 Elm_Ctxpopup_Direction third,
1906 Elm_Ctxpopup_Direction fourth)
1908 ELM_CHECK_WIDTYPE(obj, widtype);
1911 wd = elm_widget_data_get(obj);
1914 wd->dir_priority[0] = first;
1915 wd->dir_priority[1] = second;
1916 wd->dir_priority[2] = third;
1917 wd->dir_priority[3] = fourth;
1924 elm_ctxpopup_direction_priority_get(Evas_Object *obj,
1925 Elm_Ctxpopup_Direction *first,
1926 Elm_Ctxpopup_Direction *second,
1927 Elm_Ctxpopup_Direction *third,
1928 Elm_Ctxpopup_Direction *fourth)
1930 ELM_CHECK_WIDTYPE(obj, widtype);
1933 wd = elm_widget_data_get(obj);
1936 if (first) *first = wd->dir_priority[0];
1937 if (second) *second = wd->dir_priority[1];
1938 if (third) *third = wd->dir_priority[2];
1939 if (fourth) *fourth = wd->dir_priority[3];
1942 EAPI Elm_Ctxpopup_Direction
1943 elm_ctxpopup_direction_get(const Evas_Object *obj)
1945 ELM_CHECK_WIDTYPE(obj, widtype) ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1948 wd = elm_widget_data_get(obj);
1949 if (!wd) return ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1956 elm_ctxpopup_dismiss(Evas_Object *obj)
1958 ELM_CHECK_WIDTYPE(obj, widtype);
1959 Widget_Data *wd = elm_widget_data_get(obj);
1961 _hide_signal_emit(obj, wd->dir);
1963 >>>>>>> remotes/origin/upstream