1 #include <Elementary.h>
3 #include "elm_widget_ctxpopup.h"
5 EAPI const char ELM_CTXPOPUP_SMART_NAME[] = "elm_ctxpopup";
7 static const char SIG_DISMISSED[] = "dismissed";
8 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
13 EVAS_SMART_SUBCLASS_NEW
14 (ELM_CTXPOPUP_SMART_NAME, _elm_ctxpopup, Elm_Ctxpopup_Smart_Class,
15 Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks);
17 _elm_ctxpopup_smart_focus_next(const Evas_Object *obj,
18 Elm_Focus_Direction dir,
21 ELM_CTXPOPUP_DATA_GET(obj, sd);
26 if (!elm_widget_focus_next_get(sd->box, dir, next))
28 elm_widget_focused_object_clear(sd->box);
29 elm_widget_focus_next_get(sd->box, dir, next);
36 _elm_ctxpopup_smart_event(Evas_Object *obj,
37 Evas_Object *src __UNUSED__,
38 Evas_Callback_Type type,
41 Evas_Event_Key_Down *ev = event_info;
43 ELM_CTXPOPUP_DATA_GET(obj, sd);
45 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
46 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
47 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
49 if (!strcmp(ev->keyname, "Tab"))
51 if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
52 elm_widget_focus_cycle(sd->box, ELM_FOCUS_PREVIOUS);
54 elm_widget_focus_cycle(sd->box, ELM_FOCUS_NEXT);
58 if (strcmp(ev->keyname, "Escape")) return EINA_FALSE;
60 evas_object_hide(obj);
61 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
66 _freeze_on_cb(void *data __UNUSED__,
68 void *event_info __UNUSED__)
70 ELM_CTXPOPUP_DATA_GET(obj, sd);
72 if ((!sd) || (!sd->scr)) return;
73 elm_object_scroll_freeze_push(sd->scr);
77 _freeze_off_cb(void *data __UNUSED__,
79 void *event_info __UNUSED__)
81 ELM_CTXPOPUP_DATA_GET(obj, sd);
83 if ((!sd) || (!sd->scr)) return;
84 elm_object_scroll_freeze_pop(sd->scr);
88 _hold_on_cb(void *data __UNUSED__,
90 void *event_info __UNUSED__)
92 ELM_CTXPOPUP_DATA_GET(obj, sd);
94 if ((!sd) || (!sd->scr)) return;
95 elm_object_scroll_hold_push(sd->scr);
99 _hold_off_cb(void *data __UNUSED__,
101 void *event_info __UNUSED__)
103 ELM_CTXPOPUP_DATA_GET(obj, sd);
105 if ((!sd) || (!sd->scr)) return;
106 elm_object_scroll_hold_pop(sd->scr);
110 _x_pos_adjust(Evas_Coord_Point *pos,
111 Evas_Coord_Point *base_size,
112 Evas_Coord_Rectangle *hover_area)
114 pos->x -= (base_size->x / 2);
116 if (pos->x < hover_area->x)
117 pos->x = hover_area->x;
118 else if ((pos->x + base_size->x) > (hover_area->x + hover_area->w))
119 pos->x = (hover_area->x + hover_area->w) - base_size->x;
121 if (base_size->x > hover_area->w)
122 base_size->x -= (base_size->x - hover_area->w);
124 if (pos->x < hover_area->x)
125 pos->x = hover_area->x;
129 _y_pos_adjust(Evas_Coord_Point *pos,
130 Evas_Coord_Point *base_size,
131 Evas_Coord_Rectangle *hover_area)
133 pos->y -= (base_size->y / 2);
135 if (pos->y < hover_area->y)
136 pos->y = hover_area->y;
137 else if ((pos->y + base_size->y) > (hover_area->y + hover_area->h))
138 pos->y = hover_area->y + hover_area->h - base_size->y;
140 if (base_size->y > hover_area->h)
141 base_size->y -= (base_size->y - hover_area->h);
143 if (pos->y < hover_area->y)
144 pos->y = hover_area->y;
148 _item_select_cb(void *data, Evas_Object *obj __UNUSED__,
149 const char *emission __UNUSED__,
150 const char *source __UNUSED__)
152 Elm_Ctxpopup_Item *item = data;
155 if (elm_widget_item_disabled_get(item)) return;
158 item->func((void*)item->base.data, WIDGET(item), data);
162 _item_new(Elm_Ctxpopup_Item *item,
165 ELM_CTXPOPUP_DATA_GET(WIDGET(item), sd);
168 VIEW(item) = edje_object_add(evas_object_evas_get(sd->box));
169 edje_object_mirrored_set(VIEW(item), elm_widget_mirrored_get(WIDGET(item)));
170 _elm_theme_object_set(WIDGET(item), VIEW(item), "ctxpopup", group_name,
171 elm_widget_style_get(WIDGET(item)));
172 edje_object_signal_callback_add(VIEW(item), "elm,action,click", "",
173 _item_select_cb, item);
174 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
175 evas_object_show(VIEW(item));
179 _item_icon_set(Elm_Ctxpopup_Item *item,
183 evas_object_del(item->icon);
188 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
189 edje_object_message_signal_process(VIEW(item));
193 _item_label_set(Elm_Ctxpopup_Item *item,
196 if (!eina_stringshare_replace(&item->label, label))
199 edje_object_part_text_set(VIEW(item), "elm.text", label);
200 edje_object_message_signal_process(VIEW(item));
204 _item_del_pre_hook(Elm_Object_Item *it)
206 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
208 ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
209 if (!sd) return EINA_FALSE;
211 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
213 if (ctxpopup_it->icon)
214 evas_object_del(ctxpopup_it->icon);
215 if (VIEW(ctxpopup_it))
216 evas_object_del(VIEW(ctxpopup_it));
218 eina_stringshare_del(ctxpopup_it->label);
219 sd->items = eina_list_remove(sd->items, ctxpopup_it);
221 if (eina_list_count(sd->items) < 1)
223 evas_object_hide(WIDGET(ctxpopup_it));
226 if (sd->visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it));
232 _items_remove(Elm_Ctxpopup_Smart_Data *sd)
235 Elm_Ctxpopup_Item *item;
237 if (!sd->items) return;
239 EINA_LIST_FOREACH(sd->items, elist, item)
241 _item_del_pre_hook((Elm_Object_Item *)item);
248 _scroller_size_reset(Elm_Ctxpopup_Smart_Data *sd)
250 sd->finished = EINA_FALSE;
256 _item_sizing_eval(Elm_Ctxpopup_Item *item)
258 Evas_Coord min_w = -1, min_h = -1, max_w = -1, max_h = -1;
262 edje_object_size_min_restricted_calc(VIEW(item), &min_w, &min_h, min_w,
264 evas_object_size_hint_min_set(VIEW(item), min_w, min_h);
265 evas_object_size_hint_max_set(VIEW(item), max_w, max_h);
268 static Elm_Ctxpopup_Direction
269 _base_geometry_calc(Evas_Object *obj,
270 Evas_Coord_Rectangle *rect)
272 Elm_Ctxpopup_Direction dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
273 Evas_Coord_Rectangle hover_area;
274 Evas_Coord_Point pos = {0, 0};
275 Evas_Coord_Point arrow_size;
276 Evas_Coord_Point base_size;
277 Evas_Coord_Point max_size;
278 Evas_Coord_Point min_size;
279 Evas_Coord_Point temp;
282 ELM_CTXPOPUP_DATA_GET(obj, sd);
284 if (!rect) return ELM_CTXPOPUP_DIRECTION_DOWN;
286 edje_object_part_geometry_get
287 (sd->arrow, "ctxpopup_arrow", NULL, NULL, &arrow_size.x, &arrow_size.y);
288 evas_object_resize(sd->arrow, arrow_size.x, arrow_size.y);
290 //Initialize Area Rectangle.
291 evas_object_geometry_get
292 (sd->parent, &hover_area.x, &hover_area.y, &hover_area.w,
295 evas_object_geometry_get(obj, &pos.x, &pos.y, NULL, NULL);
298 edje_object_size_min_calc
299 (ELM_WIDGET_DATA(sd)->resize_obj, &base_size.x, &base_size.y);
300 evas_object_smart_calculate(ELM_WIDGET_DATA(sd)->resize_obj);
303 evas_object_size_hint_max_get(obj, &max_size.x, &max_size.y);
305 if ((max_size.y > 0) && (base_size.y > max_size.y))
306 base_size.y = max_size.y;
308 if ((max_size.x > 0) && (base_size.x > max_size.x))
309 base_size.x = max_size.x;
312 evas_object_size_hint_min_get(obj, &min_size.x, &min_size.y);
314 if ((min_size.y > 0) && (base_size.y < min_size.y))
315 base_size.y = min_size.y;
317 if ((min_size.x > 0) && (base_size.x < min_size.x))
318 base_size.x = min_size.x;
320 //Check the Which direction is available.
321 //If find a avaialble direction, it adjusts position and size.
322 for (idx = 0; idx < 4; idx++)
324 switch (sd->dir_priority[idx])
326 case ELM_CTXPOPUP_DIRECTION_UNKNOWN:
328 case ELM_CTXPOPUP_DIRECTION_UP:
329 temp.y = (pos.y - base_size.y);
330 if ((temp.y - arrow_size.y) < hover_area.y)
333 _x_pos_adjust(&pos, &base_size, &hover_area);
334 pos.y -= base_size.y;
335 dir = ELM_CTXPOPUP_DIRECTION_UP;
338 case ELM_CTXPOPUP_DIRECTION_LEFT:
339 temp.x = (pos.x - base_size.x);
340 if ((temp.x - arrow_size.x) < hover_area.x)
343 _y_pos_adjust(&pos, &base_size, &hover_area);
344 pos.x -= base_size.x;
345 dir = ELM_CTXPOPUP_DIRECTION_LEFT;
348 case ELM_CTXPOPUP_DIRECTION_RIGHT:
349 temp.x = (pos.x + base_size.x);
350 if ((temp.x + arrow_size.x) >
351 (hover_area.x + hover_area.w))
354 _y_pos_adjust(&pos, &base_size, &hover_area);
355 dir = ELM_CTXPOPUP_DIRECTION_RIGHT;
358 case ELM_CTXPOPUP_DIRECTION_DOWN:
359 temp.y = (pos.y + base_size.y);
360 if ((temp.y + arrow_size.y) >
361 (hover_area.y + hover_area.h))
364 _x_pos_adjust(&pos, &base_size, &hover_area);
365 dir = ELM_CTXPOPUP_DIRECTION_DOWN;
374 //In this case, all directions are invalid because of lack of space.
377 Evas_Coord length[2];
381 length[0] = pos.y - hover_area.y;
382 length[1] = (hover_area.y + hover_area.h) - pos.y;
384 // ELM_CTXPOPUP_DIRECTION_UP
385 if (length[0] > length[1])
387 _x_pos_adjust(&pos, &base_size, &hover_area);
388 pos.y -= base_size.y;
389 dir = ELM_CTXPOPUP_DIRECTION_UP;
390 if (pos.y < (hover_area.y + arrow_size.y))
392 base_size.y -= ((hover_area.y + arrow_size.y) - pos.y);
393 pos.y = hover_area.y + arrow_size.y;
396 //ELM_CTXPOPUP_DIRECTION_DOWN
399 _x_pos_adjust(&pos, &base_size, &hover_area);
400 dir = ELM_CTXPOPUP_DIRECTION_DOWN;
401 if ((pos.y + arrow_size.y + base_size.y) >
402 (hover_area.y + hover_area.h))
404 ((pos.y + arrow_size.y + base_size.y) -
405 (hover_area.y + hover_area.h));
410 length[0] = pos.x - hover_area.x;
411 length[1] = (hover_area.x + hover_area.w) - pos.x;
413 //ELM_CTXPOPUP_DIRECTION_LEFT
414 if (length[0] > length[1])
416 _y_pos_adjust(&pos, &base_size, &hover_area);
417 pos.x -= base_size.x;
418 dir = ELM_CTXPOPUP_DIRECTION_LEFT;
419 if (pos.x < (hover_area.x + arrow_size.x))
421 base_size.x -= ((hover_area.x + arrow_size.x) - pos.x);
422 pos.x = hover_area.x + arrow_size.x;
425 //ELM_CTXPOPUP_DIRECTION_RIGHT
428 _y_pos_adjust(&pos, &base_size, &hover_area);
429 dir = ELM_CTXPOPUP_DIRECTION_RIGHT;
430 if (pos.x + (arrow_size.x + base_size.x) >
431 hover_area.x + hover_area.w)
433 ((pos.x + arrow_size.x + base_size.x) -
434 (hover_area.x + hover_area.w));
439 //Final position and size.
442 rect->w = base_size.x;
443 rect->h = base_size.y;
449 _arrow_update(Evas_Object *obj,
450 Elm_Ctxpopup_Direction dir,
451 Evas_Coord_Rectangle base_size)
453 Evas_Coord_Rectangle arrow_size;
457 ELM_CTXPOPUP_DATA_GET(obj, sd);
459 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
460 evas_object_geometry_get
461 (sd->arrow, NULL, NULL, &arrow_size.w, &arrow_size.h);
463 /* arrow is not being kept as sub-object on purpose, here. the
464 * design of the widget does not help with the contrary */
468 case ELM_CTXPOPUP_DIRECTION_RIGHT:
469 edje_object_signal_emit(sd->arrow, "elm,state,left", "elm");
470 edje_object_part_swallow
471 (ELM_WIDGET_DATA(sd)->resize_obj,
472 (elm_widget_mirrored_get(obj) ? "elm.swallow.arrow_right" :
473 "elm.swallow.arrow_left"), sd->arrow);
477 if (y < ((arrow_size.h * 0.5) + base_size.y))
479 else if (y > base_size.y + base_size.h - (arrow_size.h * 0.5))
480 y = base_size.h - arrow_size.h;
482 y = y - base_size.y - (arrow_size.h * 0.5);
483 drag = (double)(y) / (double)(base_size.h - arrow_size.h);
484 edje_object_part_drag_value_set
485 (ELM_WIDGET_DATA(sd)->resize_obj,
486 (elm_widget_mirrored_get(obj) ? "elm.swallow.arrow_right" :
487 "elm.swallow.arrow_left"), 1, drag);
491 case ELM_CTXPOPUP_DIRECTION_LEFT:
492 edje_object_signal_emit(sd->arrow, "elm,state,right", "elm");
493 edje_object_part_swallow
494 (ELM_WIDGET_DATA(sd)->resize_obj,
495 (elm_widget_mirrored_get(obj) ? "elm.swallow.arrow_left" :
496 "elm.swallow.arrow_right"), sd->arrow);
500 if (y < ((arrow_size.h * 0.5) + base_size.y))
502 else if (y > (base_size.y + base_size.h - (arrow_size.h * 0.5)))
503 y = base_size.h - arrow_size.h;
505 y = y - base_size.y - (arrow_size.h * 0.5);
506 drag = (double)(y) / (double)(base_size.h - arrow_size.h);
507 edje_object_part_drag_value_set
508 (ELM_WIDGET_DATA(sd)->resize_obj,
509 (elm_widget_mirrored_get(obj) ? "elm.swallow.arrow_left" :
510 "elm.swallow.arrow_right"), 0, drag);
514 case ELM_CTXPOPUP_DIRECTION_DOWN:
515 edje_object_signal_emit(sd->arrow, "elm,state,top", "elm");
516 edje_object_part_swallow
517 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.swallow.arrow_up",
522 if (x < ((arrow_size.w * 0.5) + base_size.x))
524 else if (x > (base_size.x + base_size.w - (arrow_size.w * 0.5)))
525 x = base_size.w - arrow_size.w;
527 x = x - base_size.x - (arrow_size.w * 0.5);
528 drag = (double)(x) / (double)(base_size.w - arrow_size.w);
529 edje_object_part_drag_value_set
530 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.swallow.arrow_up", drag,
535 case ELM_CTXPOPUP_DIRECTION_UP:
536 edje_object_signal_emit(sd->arrow, "elm,state,bottom", "elm");
537 edje_object_part_swallow
538 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.swallow.arrow_down",
543 if (x < ((arrow_size.w * 0.5) + base_size.x))
545 else if (x > (base_size.x + base_size.w - (arrow_size.w * 0.5)))
546 x = base_size.w - arrow_size.w;
547 else x = x - base_size.x - (arrow_size.w * 0.5);
548 drag = (double)(x) / (double)(base_size.w - arrow_size.w);
549 edje_object_part_drag_value_set
550 (ELM_WIDGET_DATA(sd)->resize_obj, "elm.swallow.arrow_down",
559 //should be here for getting accurate geometry value
560 evas_object_smart_calculate(ELM_WIDGET_DATA(sd)->resize_obj);
564 _show_signals_emit(Evas_Object *obj,
565 Elm_Ctxpopup_Direction dir)
567 ELM_CTXPOPUP_DATA_GET(obj, sd);
569 if (!sd->visible) return;
573 case ELM_CTXPOPUP_DIRECTION_UP:
574 elm_layout_signal_emit(obj, "elm,state,show,up", "elm");
577 case ELM_CTXPOPUP_DIRECTION_LEFT:
578 elm_layout_signal_emit(obj,
579 (elm_widget_mirrored_get(obj) ? "elm,state,show,right" :
580 "elm,state,show,left"), "elm");
583 case ELM_CTXPOPUP_DIRECTION_RIGHT:
584 elm_layout_signal_emit(obj,
585 (elm_widget_mirrored_get(obj) ? "elm,state,show,left" :
586 "elm,state,show,right"), "elm");
589 case ELM_CTXPOPUP_DIRECTION_DOWN:
590 elm_layout_signal_emit(obj, "elm,state,show,down", "elm");
597 edje_object_signal_emit(sd->bg, "elm,state,show", "elm");
598 elm_layout_signal_emit(obj, "elm,state,show", "elm");
602 _hide_signals_emit(Evas_Object *obj,
603 Elm_Ctxpopup_Direction dir)
605 ELM_CTXPOPUP_DATA_GET(obj, sd);
607 if (!sd->visible) return;
611 case ELM_CTXPOPUP_DIRECTION_UP:
612 elm_layout_signal_emit(obj, "elm,state,hide,up", "elm");
615 case ELM_CTXPOPUP_DIRECTION_LEFT:
616 elm_layout_signal_emit(obj,
617 (elm_widget_mirrored_get(obj) ? "elm,state,hide,right" :
618 "elm,state,hide,left"), "elm");
621 case ELM_CTXPOPUP_DIRECTION_RIGHT:
622 elm_layout_signal_emit(obj,
623 (elm_widget_mirrored_get(obj) ? "elm,state,hide,left" :
624 "elm,state,hide,right"), "elm");
627 case ELM_CTXPOPUP_DIRECTION_DOWN:
628 elm_layout_signal_emit(obj, "elm,state,hide,down", "elm");
635 edje_object_signal_emit(sd->bg, "elm,state,hide", "elm");
639 _base_shift_by_arrow(Evas_Object *arrow,
640 Elm_Ctxpopup_Direction dir,
641 Evas_Coord_Rectangle *rect)
643 Evas_Coord arrow_w, arrow_h;
645 evas_object_geometry_get(arrow, NULL, NULL, &arrow_w, &arrow_h);
649 case ELM_CTXPOPUP_DIRECTION_RIGHT:
653 case ELM_CTXPOPUP_DIRECTION_LEFT:
657 case ELM_CTXPOPUP_DIRECTION_DOWN:
661 case ELM_CTXPOPUP_DIRECTION_UP:
670 //TODO: compress item - different from opensource
672 _compress_item(Evas_Object *obj)
675 Elm_Ctxpopup_Item *item;
677 ELM_CTXPOPUP_DATA_GET(obj, sd);
680 EINA_LIST_FOREACH(sd->items, elist, item)
682 edje_object_signal_emit(item->base.view, "elm,state,compress", "elm");
687 _elm_ctxpopup_smart_sub_object_add(Evas_Object *obj,
690 Elm_Widget_Smart_Class *parent_parent;
692 parent_parent = (Elm_Widget_Smart_Class *)((Evas_Smart_Class *)
693 _elm_ctxpopup_parent_sc)->parent;
695 /* skipping layout's code, which registers size hint changing
696 * callback on sub objects. a hack to make ctxpopup live, as it is,
697 * on the new classing schema. this widget needs a total
699 if (!parent_parent->sub_object_add(obj, sobj))
706 _elm_ctxpopup_smart_sizing_eval(Evas_Object *obj)
709 Elm_Ctxpopup_Item *item;
710 Evas_Coord_Rectangle rect = { 0, 0, 1, 1 };
711 Evas_Coord_Point box_size = { 0, 0 };
712 Evas_Coord_Point _box_size = { 0, 0 };
714 ELM_CTXPOPUP_DATA_GET(obj, sd);
717 EINA_LIST_FOREACH(sd->items, elist, item)
719 _item_sizing_eval(item);
720 evas_object_size_hint_min_get(VIEW(item), &_box_size.x, &_box_size.y);
723 if (_box_size.x > box_size.x)
724 box_size.x = _box_size.x;
725 if (_box_size.y != -1)
726 box_size.y += _box_size.y;
730 if (_box_size.x != -1)
731 box_size.x += _box_size.x;
732 if (_box_size.y > box_size.y)
733 box_size.y = _box_size.y;
737 if (!sd->arrow) return; /* simple way to flag "under deletion" */
739 if ((!sd->content) && (sd->scr))
741 evas_object_size_hint_min_set(sd->box, box_size.x, box_size.y);
742 elm_scroller_content_min_limit(sd->scr, EINA_TRUE, EINA_TRUE);
743 evas_object_size_hint_min_set(sd->scr, box_size.x, box_size.y);
747 sd->dir = _base_geometry_calc(obj, &rect);
749 //TODO: compress item - different from opensource
750 if (!sd->horizontal && !sd->content)
753 _arrow_update(obj, sd->dir, rect);
754 _base_shift_by_arrow(sd->arrow, sd->dir, &rect);
756 //resize scroller according to final size
757 if ((!sd->content) && (sd->scr))
759 elm_scroller_content_min_limit(sd->scr, EINA_FALSE, EINA_FALSE);
760 evas_object_smart_calculate(sd->scr);
763 evas_object_move(ELM_WIDGET_DATA(sd)->resize_obj, rect.x, rect.y);
764 evas_object_resize(ELM_WIDGET_DATA(sd)->resize_obj, rect.w, rect.h);
766 _show_signals_emit(obj, sd->dir);
770 _on_parent_del(void *data,
772 Evas_Object *obj __UNUSED__,
773 void *event_info __UNUSED__)
775 evas_object_del(data);
779 _on_parent_move(void *data,
781 Evas_Object *obj __UNUSED__,
782 void *event_info __UNUSED__)
784 ELM_CTXPOPUP_DATA_GET(data, sd);
787 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
791 _scroller_size_reset(sd);
792 elm_layout_sizing_eval(data);
797 _on_parent_resize(void *data,
799 Evas_Object *obj __UNUSED__,
800 void *event_info __UNUSED__)
802 ELM_CTXPOPUP_DATA_GET(data, sd);
804 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
806 evas_object_hide(data);
807 evas_object_smart_callback_call(data, SIG_DISMISSED, NULL);
811 _parent_detach(Evas_Object *obj)
813 ELM_CTXPOPUP_DATA_GET(obj, sd);
815 if (!sd->parent) return;
817 evas_object_event_callback_del_full
818 (sd->parent, EVAS_CALLBACK_DEL, _on_parent_del, obj);
819 evas_object_event_callback_del_full
820 (sd->parent, EVAS_CALLBACK_MOVE, _on_parent_move, obj);
821 evas_object_event_callback_del_full
822 (sd->parent, EVAS_CALLBACK_RESIZE, _on_parent_resize, obj);
826 _on_content_resized(void *data,
828 Evas_Object *obj __UNUSED__,
829 void *event_info __UNUSED__)
831 ELM_CTXPOPUP_DATA_GET(data, sd);
833 elm_box_recalculate(sd->box);
834 elm_layout_sizing_eval(data);
837 //FIXME: lost the content size when theme hook is called.
839 _elm_ctxpopup_smart_theme(Evas_Object *obj)
842 Elm_Ctxpopup_Item *item;
846 ELM_CTXPOPUP_DATA_GET(obj, sd);
848 if (!ELM_WIDGET_CLASS(_elm_ctxpopup_parent_sc)->theme(obj))
851 rtl = elm_widget_mirrored_get(obj);
853 elm_widget_theme_object_set
854 (obj, sd->bg, "ctxpopup", "bg", elm_widget_style_get(obj));
855 elm_widget_theme_object_set
856 (obj, sd->arrow, "ctxpopup", "arrow", elm_widget_style_get(obj));
859 EINA_LIST_FOREACH(sd->items, elist, item)
861 edje_object_mirrored_set(VIEW(item), rtl);
863 if (item->label && item->icon)
864 _elm_theme_object_set
865 (obj, VIEW(item), "ctxpopup", "icon_text_style_item", elm_widget_style_get(obj));
866 else if (item->label)
869 _elm_theme_object_set(obj, VIEW(item), "ctxpopup", "text_style_item",
870 elm_widget_style_get(obj));
872 _elm_theme_object_set(obj, VIEW(item), "ctxpopup", "text_style_item_horizontal",
873 elm_widget_style_get(obj));
876 _elm_theme_object_set
877 (obj, VIEW(item), "ctxpopup", "icon_style_item", elm_widget_style_get(obj));
879 edje_object_part_text_set(VIEW(item), "elm.text", item->label);
881 if (elm_widget_item_disabled_get(item))
882 edje_object_signal_emit(VIEW(item), "elm,state,disabled", "elm");
885 * For separator, if the first item has visible separator,
886 * then it should be aligned with edge of the base part.
887 * In some cases, it gives improper display. Ex) rounded corner
888 * So the first item separator should be invisible.
891 edje_object_signal_emit(VIEW(item), "elm,state,default", "elm");
893 edje_object_signal_emit(VIEW(item), "elm,state,separator", "elm");
895 edje_object_message_signal_process(VIEW(item));
898 if (evas_object_visible_get(sd->bg))
899 edje_object_signal_emit(sd->bg, "elm,state,show", "elm");
903 if (!strncmp(elm_object_style_get(obj), "default", strlen("default")))
904 elm_object_style_set(sd->scr, "ctxpopup");
906 elm_object_style_set(sd->scr, elm_object_style_get(obj));
909 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
913 _scroller_size_reset(sd);
914 _elm_ctxpopup_smart_sizing_eval(obj);
920 /* kind of a big and tricky override here: an internal box will hold
921 * the actual content. content aliases won't be of much help here */
923 _elm_ctxpopup_smart_content_set(Evas_Object *obj,
925 Evas_Object *content)
927 Evas_Coord min_w = -1, min_h = -1;
929 ELM_CTXPOPUP_DATA_GET(obj, sd);
931 if ((part) && (strcmp(part, "default")))
932 return ELM_CONTAINER_CLASS(_elm_ctxpopup_parent_sc)->content_set
933 (obj, part, content);
935 if (!content) return EINA_FALSE;
937 if (content == sd->content) return EINA_TRUE;
939 if (sd->items) elm_ctxpopup_clear(obj);
940 if (sd->content) evas_object_del(sd->content);
945 sd->box = elm_box_add(obj);
946 evas_object_size_hint_weight_set(sd->box, EVAS_HINT_EXPAND,
948 evas_object_event_callback_add
949 (sd->box, EVAS_CALLBACK_RESIZE, _on_content_resized, obj);
950 ELM_CONTAINER_CLASS(_elm_ctxpopup_parent_sc)->content_set
951 (obj, "elm.swallow.content", sd->box);
954 evas_object_size_hint_weight_set
955 (content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
956 evas_object_size_hint_fill_set
957 (content, EVAS_HINT_FILL, EVAS_HINT_FILL);
959 /* since it's going to be a box content, not a layout's... */
960 evas_object_show(content);
962 evas_object_size_hint_min_get(content, &min_w, &min_h);
963 evas_object_size_hint_min_set(sd->box, min_w, min_h);
964 elm_box_pack_end(sd->box, content);
966 sd->content = content;
967 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
969 if (sd->visible) elm_layout_sizing_eval(obj);
975 _elm_ctxpopup_smart_content_get(const Evas_Object *obj,
978 ELM_CTXPOPUP_DATA_GET(obj, sd);
980 if ((part) && (strcmp(part, "default")))
981 return ELM_CONTAINER_CLASS(_elm_ctxpopup_parent_sc)->content_get
988 _elm_ctxpopup_smart_content_unset(Evas_Object *obj,
991 Evas_Object *content;
993 ELM_CTXPOPUP_DATA_GET(obj, sd);
995 if ((part) && (strcmp(part, "default")))
996 return ELM_CONTAINER_CLASS(_elm_ctxpopup_parent_sc)->content_unset
999 content = sd->content;
1000 if (!content) return NULL;
1002 evas_object_del(sd->box);
1005 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1007 if (sd->visible) elm_layout_sizing_eval(obj);
1013 _item_text_set_hook(Elm_Object_Item *it,
1017 Elm_Ctxpopup_Item *ctxpopup_it;
1019 if ((part) && (strcmp(part, "default"))) return;
1021 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1023 _item_label_set(ctxpopup_it, label);
1027 _item_text_get_hook(const Elm_Object_Item *it,
1030 Elm_Ctxpopup_Item *ctxpopup_it;
1032 if (part && strcmp(part, "default")) return NULL;
1034 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1035 return ctxpopup_it->label;
1039 _item_content_set_hook(Elm_Object_Item *it,
1041 Evas_Object *content)
1043 Elm_Ctxpopup_Item *ctxpopup_it;
1045 if ((part) && (strcmp(part, "icon"))) return;
1047 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1049 ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
1051 _item_icon_set(ctxpopup_it, content);
1052 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1056 _scroller_size_reset(sd);
1057 _elm_ctxpopup_smart_sizing_eval(WIDGET(ctxpopup_it));
1061 static Evas_Object *
1062 _item_content_get_hook(const Elm_Object_Item *it,
1065 Elm_Ctxpopup_Item *ctxpopup_it;
1067 if (part && strcmp(part, "icon")) return NULL;
1069 ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1070 return ctxpopup_it->icon;
1074 _item_disable_hook(Elm_Object_Item *it)
1076 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1078 ELM_CTXPOPUP_DATA_GET(WIDGET(it), sd);
1081 if (elm_widget_item_disabled_get(it))
1082 edje_object_signal_emit(VIEW(ctxpopup_it), "elm,state,disabled", "elm");
1084 edje_object_signal_emit(VIEW(ctxpopup_it), "elm,state,enabled", "elm");
1088 _item_signal_emit_hook(Elm_Object_Item *it,
1089 const char *emission,
1092 Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
1094 edje_object_signal_emit(VIEW(ctxpopup_it), emission, source);
1098 _bg_clicked_cb(void *data,
1099 Evas_Object *obj __UNUSED__,
1100 const char *emission __UNUSED__,
1101 const char *source __UNUSED__)
1103 ELM_CTXPOPUP_DATA_GET(data, sd);
1105 _hide_signals_emit(data, sd->dir);
1109 _on_show(void *data __UNUSED__,
1112 void *event_info __UNUSED__)
1115 Elm_Ctxpopup_Item *item;
1118 ELM_CTXPOPUP_DATA_GET(obj, sd);
1120 if ((!sd->items) && (!sd->content)) return;
1122 sd->visible = EINA_TRUE;
1124 evas_object_show(sd->bg);
1125 evas_object_show(sd->arrow);
1127 edje_object_signal_emit(sd->bg, "elm,state,show", "elm");
1128 elm_layout_signal_emit(obj, "elm,state,show", "elm");
1130 EINA_LIST_FOREACH(sd->items, elist, item)
1132 if (item->label && !item->icon)
1135 _elm_theme_object_set(obj, VIEW(item), "ctxpopup", "text_style_item",
1136 elm_widget_style_get(obj));
1138 _elm_theme_object_set(obj, VIEW(item), "ctxpopup", "text_style_item_horizontal",
1139 elm_widget_style_get(obj));
1143 edje_object_signal_emit(VIEW(item), "elm,state,default", "elm");
1145 edje_object_signal_emit(VIEW(item), "elm,state,separator", "elm");
1148 elm_layout_sizing_eval(obj);
1150 elm_object_focus_set(obj, EINA_TRUE);
1154 _on_hide(void *data __UNUSED__,
1157 void *event_info __UNUSED__)
1159 ELM_CTXPOPUP_DATA_GET(obj, sd);
1161 if (!sd->visible) return;
1163 evas_object_hide(sd->bg);
1164 evas_object_hide(sd->arrow);
1166 _scroller_size_reset(sd);
1168 sd->visible = EINA_FALSE;
1172 _on_move(void *data __UNUSED__,
1175 void *event_info __UNUSED__)
1177 ELM_CTXPOPUP_DATA_GET(obj, sd);
1179 if (sd->visible) evas_object_show(sd->arrow);
1181 _scroller_size_reset(sd);
1182 _elm_ctxpopup_smart_sizing_eval(obj);
1186 _hide_finished_cb(void *data,
1187 Evas_Object *obj __UNUSED__,
1188 const char *emission __UNUSED__,
1189 const char *source __UNUSED__)
1191 evas_object_hide(data);
1192 evas_object_smart_callback_call(data, SIG_DISMISSED, NULL);
1196 _scroller_resize(void *data, Evas *e __UNUSED__,
1198 void *event_info __UNUSED__)
1202 ELM_CTXPOPUP_DATA_GET(data, sd);
1204 if (!sd->visible) return;
1205 if (sd->finished) return;
1207 evas_object_geometry_get(obj, 0, 0, &w, &h);
1209 if (w != 0 && h != 0)
1211 if ((w <= sd->max_sc_w) && (h <= sd->max_sc_h))
1213 _elm_ctxpopup_smart_sizing_eval(data);
1214 sd->finished = EINA_TRUE;
1219 if (sd->max_sc_w < w)
1221 if (sd->max_sc_h < h)
1224 _elm_ctxpopup_smart_sizing_eval(data);
1228 _ctxpopup_restack_cb(void *data __UNUSED__,
1231 void *event_info __UNUSED__)
1233 ELM_CTXPOPUP_DATA_GET(obj, sd);
1235 evas_object_layer_set(sd->bg, evas_object_layer_get(obj));
1239 _list_del(Elm_Ctxpopup_Smart_Data *sd)
1241 if (!sd->scr) return;
1243 edje_object_part_unswallow(ELM_WIDGET_DATA(sd)->resize_obj, sd->scr);
1244 evas_object_del(sd->scr);
1246 evas_object_del(sd->box);
1251 _list_new(Evas_Object *obj)
1253 ELM_CTXPOPUP_DATA_GET(obj, sd);
1257 sd->scr = elm_scroller_add(obj);
1258 elm_object_style_set(sd->scr, "ctxpopup");
1259 evas_object_size_hint_align_set(sd->scr, EVAS_HINT_FILL, EVAS_HINT_FILL);
1260 evas_object_event_callback_add(sd->scr, EVAS_CALLBACK_RESIZE,
1261 _scroller_resize, obj);
1262 edje_object_part_swallow(ELM_WIDGET_DATA(sd)->resize_obj, "elm.swallow.content", sd->scr);
1267 sd->box = elm_box_add(obj);
1268 evas_object_size_hint_weight_set(sd->box, EVAS_HINT_EXPAND,
1270 evas_object_event_callback_add
1271 (sd->box, EVAS_CALLBACK_RESIZE, _on_content_resized, obj);
1272 ELM_CONTAINER_CLASS(_elm_ctxpopup_parent_sc)->content_set
1273 (obj, "elm.swallow.content", sd->box);
1276 elm_object_content_set(sd->scr, sd->box);
1277 elm_ctxpopup_horizontal_set(obj, sd->horizontal);
1281 _elm_ctxpopup_smart_disable(Evas_Object *obj)
1284 Elm_Object_Item *it;
1286 ELM_CTXPOPUP_DATA_GET(obj, sd);
1288 if (!ELM_WIDGET_CLASS(_elm_ctxpopup_parent_sc)->disable(obj))
1291 EINA_LIST_FOREACH(sd->items, l, it)
1292 elm_object_item_disabled_set(it, elm_widget_disabled_get(obj));
1298 _elm_ctxpopup_smart_add(Evas_Object *obj)
1300 EVAS_SMART_DATA_ALLOC(obj, Elm_Ctxpopup_Smart_Data);
1302 ELM_WIDGET_CLASS(_elm_ctxpopup_parent_sc)->base.add(obj);
1304 elm_layout_theme_set(obj, "ctxpopup", "base", elm_widget_style_get(obj));
1305 elm_layout_signal_callback_add
1306 (obj, "elm,action,hide,finished", "", _hide_finished_cb, obj);
1309 priv->bg = edje_object_add(evas_object_evas_get(obj));
1310 elm_widget_theme_object_set(obj, priv->bg, "ctxpopup", "bg", "default");
1311 edje_object_signal_callback_add
1312 (priv->bg, "elm,action,click", "", _bg_clicked_cb, obj);
1314 evas_object_stack_below(priv->bg, obj);
1317 priv->arrow = edje_object_add(evas_object_evas_get(obj));
1318 elm_widget_theme_object_set
1319 (obj, priv->arrow, "ctxpopup", "arrow", "default");
1321 priv->dir_priority[0] = ELM_CTXPOPUP_DIRECTION_UP;
1322 priv->dir_priority[1] = ELM_CTXPOPUP_DIRECTION_LEFT;
1323 priv->dir_priority[2] = ELM_CTXPOPUP_DIRECTION_RIGHT;
1324 priv->dir_priority[3] = ELM_CTXPOPUP_DIRECTION_DOWN;
1325 priv->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1327 evas_object_event_callback_add
1328 (obj, EVAS_CALLBACK_RESTACK, _ctxpopup_restack_cb, obj);
1330 evas_object_smart_callback_add
1331 (obj, "scroll-freeze-on", _freeze_on_cb, obj);
1332 evas_object_smart_callback_add
1333 (obj, "scroll-freeze-off", _freeze_off_cb, obj);
1334 evas_object_smart_callback_add
1335 (obj, "scroll-hold-on", _hold_on_cb, obj);
1336 evas_object_smart_callback_add
1337 (obj, "scroll-hold-off", _hold_off_cb, obj);
1339 priv->box = elm_box_add(obj);
1340 evas_object_size_hint_weight_set
1341 (priv->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1343 evas_object_event_callback_add
1344 (priv->box, EVAS_CALLBACK_RESIZE, _on_content_resized, obj);
1346 /* box will be our content placeholder, thus the parent's version call */
1347 ELM_CONTAINER_CLASS(_elm_ctxpopup_parent_sc)->content_set
1348 (obj, "elm.swallow.content", priv->box);
1350 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _on_show, NULL);
1351 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _on_hide, NULL);
1352 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _on_move, NULL);
1354 elm_widget_can_focus_set(obj, EINA_TRUE);
1358 _elm_ctxpopup_smart_del(Evas_Object *obj)
1360 ELM_CTXPOPUP_DATA_GET(obj, sd);
1362 evas_object_event_callback_del_full
1363 (sd->box, EVAS_CALLBACK_RESIZE, _on_content_resized, obj);
1364 _parent_detach(obj);
1366 elm_ctxpopup_clear(obj);
1367 evas_object_del(sd->arrow);
1368 sd->arrow = NULL; /* stops _sizing_eval() from going on on deletion */
1370 evas_object_del(sd->bg);
1373 ELM_WIDGET_CLASS(_elm_ctxpopup_parent_sc)->base.del(obj);
1377 _elm_ctxpopup_smart_parent_set(Evas_Object *obj,
1378 Evas_Object *parent)
1380 //default parent is to be hover parent
1381 elm_ctxpopup_hover_parent_set(obj, parent);
1385 _elm_ctxpopup_smart_set_user(Elm_Ctxpopup_Smart_Class *sc)
1387 ELM_WIDGET_CLASS(sc)->base.add = _elm_ctxpopup_smart_add;
1388 ELM_WIDGET_CLASS(sc)->base.del = _elm_ctxpopup_smart_del;
1390 ELM_WIDGET_CLASS(sc)->parent_set = _elm_ctxpopup_smart_parent_set;
1391 ELM_WIDGET_CLASS(sc)->disable = _elm_ctxpopup_smart_disable;
1392 ELM_WIDGET_CLASS(sc)->event = _elm_ctxpopup_smart_event;
1393 ELM_WIDGET_CLASS(sc)->theme = _elm_ctxpopup_smart_theme;
1394 ELM_WIDGET_CLASS(sc)->sub_object_add = _elm_ctxpopup_smart_sub_object_add;
1395 ELM_WIDGET_CLASS(sc)->focus_next = _elm_ctxpopup_smart_focus_next;
1396 ELM_WIDGET_CLASS(sc)->focus_direction = NULL;
1398 ELM_CONTAINER_CLASS(sc)->content_get = _elm_ctxpopup_smart_content_get;
1399 ELM_CONTAINER_CLASS(sc)->content_set = _elm_ctxpopup_smart_content_set;
1400 ELM_CONTAINER_CLASS(sc)->content_unset = _elm_ctxpopup_smart_content_unset;
1402 ELM_LAYOUT_CLASS(sc)->sizing_eval = _elm_ctxpopup_smart_sizing_eval;
1405 EAPI const Elm_Ctxpopup_Smart_Class *
1406 elm_ctxpopup_smart_class_get(void)
1408 static Elm_Ctxpopup_Smart_Class _sc =
1409 ELM_CTXPOPUP_SMART_CLASS_INIT_NAME_VERSION(ELM_CTXPOPUP_SMART_NAME);
1410 static const Elm_Ctxpopup_Smart_Class *class = NULL;
1411 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
1416 _elm_ctxpopup_smart_set(&_sc);
1417 esc->callbacks = _smart_callbacks;
1424 elm_ctxpopup_add(Evas_Object *parent)
1428 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
1430 obj = elm_widget_add(_elm_ctxpopup_smart_class_new(), parent);
1431 if (!obj) return NULL;
1433 if (!elm_widget_sub_object_add(parent, obj))
1434 ERR("could not add %p as sub object of %p", obj, parent);
1440 elm_ctxpopup_hover_parent_set(Evas_Object *obj,
1441 Evas_Object *parent)
1443 Evas_Coord x, y, w, h;
1445 ELM_CTXPOPUP_CHECK(obj);
1446 ELM_CTXPOPUP_DATA_GET(obj, sd);
1448 if (!parent) return;
1450 _parent_detach(obj);
1452 evas_object_event_callback_add
1453 (parent, EVAS_CALLBACK_DEL, _on_parent_del, obj);
1454 evas_object_event_callback_add
1455 (parent, EVAS_CALLBACK_MOVE, _on_parent_move, obj);
1456 evas_object_event_callback_add
1457 (parent, EVAS_CALLBACK_RESIZE, _on_parent_resize, obj);
1459 sd->parent = parent;
1462 evas_object_geometry_get(parent, &x, &y, &w, &h);
1463 evas_object_move(sd->bg, x, y);
1464 evas_object_resize(sd->bg, w, h);
1466 if (sd->visible) elm_layout_sizing_eval(obj);
1470 elm_ctxpopup_hover_parent_get(const Evas_Object *obj)
1472 ELM_CTXPOPUP_CHECK(obj) NULL;
1473 ELM_CTXPOPUP_DATA_GET(obj, sd);
1479 elm_ctxpopup_clear(Evas_Object *obj)
1481 ELM_CTXPOPUP_CHECK(obj);
1482 ELM_CTXPOPUP_DATA_GET(obj, sd);
1486 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1490 elm_ctxpopup_horizontal_set(Evas_Object *obj,
1491 Eina_Bool horizontal)
1494 Elm_Ctxpopup_Item *item;
1497 ELM_CTXPOPUP_CHECK(obj);
1498 ELM_CTXPOPUP_DATA_GET(obj, sd);
1500 sd->horizontal = !!horizontal;
1507 elm_box_horizontal_set(sd->box, EINA_FALSE);
1508 elm_scroller_bounce_set(sd->scr, EINA_FALSE, EINA_TRUE);
1512 elm_box_horizontal_set(sd->box, EINA_TRUE);
1513 elm_scroller_bounce_set(sd->scr, EINA_TRUE, EINA_FALSE);
1516 EINA_LIST_FOREACH(sd->items, elist, item)
1518 if (item->label && !item->icon && !horizontal)
1519 _elm_theme_object_set(obj, VIEW(item), "ctxpopup", "text_style_item",
1520 elm_widget_style_get(obj));
1521 else if (item->label && !item->icon && horizontal)
1522 _elm_theme_object_set(obj, VIEW(item), "ctxpopup", "text_style_item_horizontal",
1523 elm_widget_style_get(obj));
1526 edje_object_signal_emit(VIEW(item), "elm,state,default", "elm");
1528 edje_object_signal_emit(VIEW(item), "elm,state,separator", "elm");
1530 _item_disable_hook(item);
1533 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1535 if (sd->visible) elm_layout_sizing_eval(obj);
1539 elm_ctxpopup_horizontal_get(const Evas_Object *obj)
1541 ELM_CTXPOPUP_CHECK(obj) EINA_FALSE;
1542 ELM_CTXPOPUP_DATA_GET(obj, sd);
1544 return sd->horizontal;
1547 EAPI Elm_Object_Item *
1548 elm_ctxpopup_item_append(Evas_Object *obj,
1554 Elm_Ctxpopup_Item *item;
1555 Evas_Object *content;
1557 ELM_CTXPOPUP_CHECK(obj) NULL;
1558 ELM_CTXPOPUP_DATA_GET(obj, sd);
1560 item = elm_widget_item_new(obj, Elm_Ctxpopup_Item);
1561 if (!item) return NULL;
1563 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
1564 elm_widget_item_disable_hook_set(item, _item_disable_hook);
1565 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
1566 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
1567 elm_widget_item_content_set_hook_set(item, _item_content_set_hook);
1568 elm_widget_item_content_get_hook_set(item, _item_content_get_hook);
1569 elm_widget_item_signal_emit_hook_set(item, _item_signal_emit_hook);
1571 //The first item is appended.
1572 content = elm_object_content_unset(obj);
1573 if (content) evas_object_del(content);
1579 item->base.data = data;
1582 _item_new(item, "icon_text_style_item");
1585 if (!sd->horizontal)
1586 _item_new(item, "text_style_item");
1588 _item_new(item, "text_style_item_horizontal");
1591 _item_new(item, "icon_style_item");
1593 _item_icon_set(item, icon);
1594 _item_label_set(item, label);
1595 elm_box_pack_end(sd->box, VIEW(item));
1596 sd->items = eina_list_append(sd->items, item);
1598 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1602 _scroller_size_reset(sd);
1603 _elm_ctxpopup_smart_sizing_eval(obj);
1607 return (Elm_Object_Item *)item;
1611 elm_ctxpopup_direction_priority_set(Evas_Object *obj,
1612 Elm_Ctxpopup_Direction first,
1613 Elm_Ctxpopup_Direction second,
1614 Elm_Ctxpopup_Direction third,
1615 Elm_Ctxpopup_Direction fourth)
1617 ELM_CTXPOPUP_CHECK(obj);
1618 ELM_CTXPOPUP_DATA_GET(obj, sd);
1620 sd->dir_priority[0] = first;
1621 sd->dir_priority[1] = second;
1622 sd->dir_priority[2] = third;
1623 sd->dir_priority[3] = fourth;
1625 if (sd->visible) elm_layout_sizing_eval(obj);
1629 elm_ctxpopup_direction_priority_get(Evas_Object *obj,
1630 Elm_Ctxpopup_Direction *first,
1631 Elm_Ctxpopup_Direction *second,
1632 Elm_Ctxpopup_Direction *third,
1633 Elm_Ctxpopup_Direction *fourth)
1635 ELM_CTXPOPUP_CHECK(obj);
1636 ELM_CTXPOPUP_DATA_GET(obj, sd);
1638 if (first) *first = sd->dir_priority[0];
1639 if (second) *second = sd->dir_priority[1];
1640 if (third) *third = sd->dir_priority[2];
1641 if (fourth) *fourth = sd->dir_priority[3];
1644 EAPI Elm_Ctxpopup_Direction
1645 elm_ctxpopup_direction_get(const Evas_Object *obj)
1647 ELM_CTXPOPUP_CHECK(obj) ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1648 ELM_CTXPOPUP_DATA_GET(obj, sd);
1654 elm_ctxpopup_dismiss(Evas_Object *obj)
1656 ELM_CTXPOPUP_CHECK(obj);
1657 ELM_CTXPOPUP_DATA_GET(obj, sd);
1659 _hide_signals_emit(obj, sd->dir);