#include <Elementary.h>
#include "elm_priv.h"
-#undef Elm_Ctxpopup_Item
-
typedef struct _Widget_Data Widget_Data;
typedef struct _Elm_Ctxpopup_Item Elm_Ctxpopup_Item;
static void _hold_on(void *data, Evas_Object *obj, void *event_info);
static void _hold_off(void *data, Evas_Object *obj, void *event_info);
static void _scroller_size_reset(Widget_Data *wd);
+static void _on_focus_hook(void *data, Evas_Object *obj);
+static Eina_Bool _event_hook(Evas_Object *obj,
+ Evas_Object *src,
+ Evas_Callback_Type type,
+ void *event_info);
static void _parent_cut_off(Evas_Object *obj);
static void _parent_resize(void *data,
Evas *e,
static void _adjust_pos_y(Evas_Coord_Point *pos,
Evas_Coord_Point *base_size,
Evas_Coord_Rectangle *hover_area);
-static void _ctxpopup_changed_size_hints(void *data __UNUSED__,
- Evas *e __UNUSED__, Evas_Object *obj,
- void *event_info __UNUSED__);
static Elm_Ctxpopup_Direction _calc_base_geometry(Evas_Object *obj,
Evas_Coord_Rectangle *rect);
static void _update_arrow(Evas_Object *obj,
Elm_Ctxpopup_Direction dir,
Evas_Coord_Rectangle rect);
static void _sizing_eval(Evas_Object *obj);
+static void _hide_signal_emit(Evas_Object *obj,
+ Elm_Ctxpopup_Direction dir);
+static void _show_signal_emit(Evas_Object *obj,
+ Elm_Ctxpopup_Direction dir);
static void _shift_base_by_arrow(Evas_Object *arrow,
Elm_Ctxpopup_Direction dir,
Evas_Coord_Rectangle *rect);
static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _content_set_hook(Evas_Object *obj,
- const char *item __UNUSED__,
+ const char *part,
Evas_Object *content);
static Evas_Object * _content_unset_hook(Evas_Object *obj,
- const char *item __UNUSED__);
+ const char *part__);
static Evas_Object * _content_get_hook(const Evas_Object *obj,
const char *part);
static void _item_text_set_hook(Elm_Object_Item *it,
Evas_Object *content);
static Evas_Object * _item_content_get_hook(const Elm_Object_Item *it,
const char *part);
-static void _item_disable_set_hook(Elm_Object_Item *it);
+static void _item_disable_hook(Elm_Object_Item *it);
static void _item_signal_emit_hook(Elm_Object_Item *it,
const char *emission,
const char *source);
Evas *e,
Evas_Object *obj,
void *event_info);
-static void _hide(Evas_Object *obj);
+static void _hide_finished(void *data,
+ Evas_Object *obj,
+ const char *emission,
+ const char *source __UNUSED__);
static void _ctxpopup_hide(void *data,
Evas *e,
Evas_Object *obj,
Evas *e,
Evas_Object *obj,
void *event_info);
+static void _restack(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _item_select_cb(void *data, Evas_Object *obj,
const char *emission,
const char *source);
static void _list_del(Widget_Data *wd);
static void _list_new(Evas_Object *obj);
static void _remove_items(Widget_Data * wd);
+static void _disable_hook(Evas_Object *obj);
+static void _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source);
+static void _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data);
+static void _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data);
static const char SIG_DISMISSED[] = "dismissed";
{NULL, NULL}
};
-#define ELM_CTXPOPUP_ITEM_CHECK_RETURN(it, ...) \
- ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
- ELM_CHECK_WIDTYPE(item->base.widget, widtype) __VA_ARGS__;
-
static void
_freeze_on(void *data __UNUSED__, Evas_Object *obj,
void *event_info __UNUSED__)
}
static void
+_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+
+ if (elm_widget_focus_get(obj))
+ {
+ //FIXME:
+ }
+ else
+ {
+ //FIXME:
+ }
+}
+
+static Eina_Bool
+_event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__,
+ Evas_Callback_Type type, void *event_info)
+{
+ Evas_Event_Key_Down *ev;
+ Widget_Data *wd;
+
+ if (type != EVAS_CALLBACK_KEY_DOWN)
+ return EINA_FALSE;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return EINA_FALSE;
+
+ ev = event_info;
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
+ if (strcmp(ev->keyname, "Escape")) return EINA_FALSE;
+
+ evas_object_hide(obj);
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ return EINA_TRUE;
+}
+
+static void
_parent_cut_off(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
- _hide(data);
+ evas_object_hide(data);
}
static void
pos->y = hover_area->y;
}
-static void
-_ctxpopup_changed_size_hints(void *data __UNUSED__, Evas *e __UNUSED__,
- Evas_Object *obj, void *event_info __UNUSED__)
-{
- Widget_Data *wd;
-
- wd = elm_widget_data_get(obj);
- if (!wd) return;
-
- if (wd->visible)
- _sizing_eval(obj);
-}
-
static Elm_Ctxpopup_Direction
_calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
{
Evas_Coord_Point min_size;
Evas_Coord_Rectangle hover_area;
Evas_Coord_Point arrow_size;
- Elm_Ctxpopup_Direction dir = ELM_CTXPOPUP_DIRECTION_DOWN;
+ Elm_Ctxpopup_Direction dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
Evas_Coord_Point temp;
int idx;
{
switch (wd->dir_priority[idx])
{
+ case ELM_CTXPOPUP_DIRECTION_UNKNOWN:
case ELM_CTXPOPUP_DIRECTION_UP:
temp.y = (pos.y - base_size.y);
if ((temp.y - arrow_size.y) < hover_area.y)
edje_object_part_swallow(wd->base,
"elm.swallow.arrow_left",
wd->arrow);
-
- // if user does not use dragable part
- arrow_size.y = (y - (arrow_size.h * 0.5));
- arrow_size.x = x;
-
if (base_size.h > 0)
{
if (y < ((arrow_size.h * 0.5) + base_size.y))
edje_object_part_swallow(wd->base,
"elm.swallow.arrow_right",
wd->arrow);
-
- // if user does not use dragable part
- arrow_size.y = (y - (arrow_size.h * 0.5));
- arrow_size.x = (x - arrow_size.w);
-
if (base_size.h > 0)
{
if (y < ((arrow_size.h * 0.5) + base_size.y))
case ELM_CTXPOPUP_DIRECTION_DOWN:
edje_object_signal_emit(wd->arrow, "elm,state,top", "elm");
edje_object_part_swallow(wd->base, "elm.swallow.arrow_up", wd->arrow);
-
- // if user does not use dragable part
- arrow_size.x = (x - (arrow_size.w * 0.5));
- arrow_size.y = y;
-
if (base_size.w > 0)
{
if (x < ((arrow_size.w * 0.5) + base_size.x))
edje_object_part_swallow(wd->base,
"elm.swallow.arrow_down",
wd->arrow);
-
- // if user does not use dragable part
- arrow_size.x = (x - (arrow_size.w * 0.5));
- arrow_size.y = (y - arrow_size.h);
-
if (base_size.w > 0)
{
if (x < ((arrow_size.w * 0.5) + base_size.x))
default:
break;
}
-
- // if user does not use dragable part
- evas_object_move(wd->arrow, arrow_size.x, arrow_size.y);
}
//TODO: compress item - different from opensource
}
static void
+_hide_signal_emit(Evas_Object *obj, Elm_Ctxpopup_Direction dir)
+{
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+ if (!wd->visible) return;
+
+ switch (dir)
+ {
+ case ELM_CTXPOPUP_DIRECTION_UP:
+ edje_object_signal_emit(wd->base, "elm,state,hide,up", "elm");
+ break;
+ case ELM_CTXPOPUP_DIRECTION_LEFT:
+ edje_object_signal_emit(wd->base, "elm,state,hide,left", "elm");
+ break;
+ case ELM_CTXPOPUP_DIRECTION_RIGHT:
+ edje_object_signal_emit(wd->base, "elm,state,hide,right", "elm");
+ break;
+ case ELM_CTXPOPUP_DIRECTION_DOWN:
+ edje_object_signal_emit(wd->base, "elm,state,hide,down", "elm");
+ break;
+ default:
+ break;
+ }
+
+ edje_object_signal_emit(wd->bg, "elm,state,hide", "elm");
+}
+
+static void
+_show_signal_emit(Evas_Object *obj, Elm_Ctxpopup_Direction dir)
+{
+ Widget_Data *wd;
+
+ wd = elm_widget_data_get(obj);
+ if (wd->visible) return;
+
+ switch (dir)
+ {
+ case ELM_CTXPOPUP_DIRECTION_UP:
+ edje_object_signal_emit(wd->base, "elm,state,show,up", "elm");
+ break;
+ case ELM_CTXPOPUP_DIRECTION_LEFT:
+ edje_object_signal_emit(wd->base, "elm,state,show,left", "elm");
+ break;
+ case ELM_CTXPOPUP_DIRECTION_RIGHT:
+ edje_object_signal_emit(wd->base, "elm,state,show,right", "elm");
+ break;
+ case ELM_CTXPOPUP_DIRECTION_DOWN:
+ edje_object_signal_emit(wd->base, "elm,state,show,down", "elm");
+ break;
+ default:
+ break;
+ }
+}
+
+static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd;
if (!wd->horizontal && !wd->content)
_compress_item(obj);
+ _show_signal_emit(obj, wd->dir);
_update_arrow(obj, wd->dir, rect);
_shift_base_by_arrow(wd->arrow, wd->dir, &rect);
Eina_List *elist;
Elm_Ctxpopup_Item *item;
int idx = 0;
+ Eina_Bool rtl;
wd = elm_widget_data_get(obj);
if (!wd) return;
+ _elm_widget_mirrored_reload(obj);
+ rtl = elm_widget_mirrored_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));
+
//Items
EINA_LIST_FOREACH(wd->items, elist, item)
{
+ edje_object_mirrored_set(VIEW(item), rtl);
+
if (item->label && item->icon)
_elm_theme_object_set(obj, VIEW(item), "ctxpopup",
"icon_text_style_item",
edje_object_message_signal_process(VIEW(item));
}
- _elm_theme_object_set(obj, wd->bg, "ctxpopup", "bg",
- elm_widget_style_get(obj));
if (evas_object_visible_get(wd->bg))
edje_object_signal_emit(wd->bg, "elm,state,show", "elm");
- _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));
-
if (wd->scr)
{
if (!strncmp(elm_object_style_get(obj), "default", strlen("default")))
elm_object_style_set(wd->scr, elm_object_style_get(obj));
}
+ wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+
if (wd->visible)
{
_scroller_size_reset(wd);
}
static void
-_content_set_hook(Evas_Object *obj, const char *part,
- Evas_Object *content)
+_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Evas_Coord min_w = -1, min_h = -1;
}
static void
-_item_text_set_hook(Elm_Object_Item *it,
- const char *part,
- const char *label)
+_item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
-
Widget_Data *wd;
Elm_Ctxpopup_Item *ctxpopup_it;
if (part && strcmp(part, "default")) return;
- ctxpopup_it = (Elm_Ctxpopup_Item *) it;
+ ctxpopup_it = (Elm_Ctxpopup_Item *)it;
wd = elm_widget_data_get(WIDGET(ctxpopup_it));
if (!wd) return;
static const char *
_item_text_get_hook(const Elm_Object_Item *it, const char *part)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
Elm_Ctxpopup_Item *ctxpopup_it;
if (part && strcmp(part, "default")) return NULL;
- ctxpopup_it = (Elm_Ctxpopup_Item *) it;
+ ctxpopup_it = (Elm_Ctxpopup_Item *)it;
return ctxpopup_it->label;
}
const char *part,
Evas_Object *content)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
Widget_Data *wd;
Elm_Ctxpopup_Item *ctxpopup_it;
if (part && strcmp(part, "icon")) return;
- ctxpopup_it = (Elm_Ctxpopup_Item *) it;
+ ctxpopup_it = (Elm_Ctxpopup_Item *)it;
wd = elm_widget_data_get(WIDGET(ctxpopup_it));
if (!wd) return;
static Evas_Object *
_item_content_get_hook(const Elm_Object_Item *it, const char *part)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
Elm_Ctxpopup_Item *ctxpopup_it;
if (part && strcmp(part, "icon")) return NULL;
- ctxpopup_it = (Elm_Ctxpopup_Item *) it;
+ ctxpopup_it = (Elm_Ctxpopup_Item *)it;
return ctxpopup_it->icon;
}
static void
-_item_disable_set_hook(Elm_Object_Item *it)
+_item_disable_hook(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
-
Widget_Data *wd;
- Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *) it;
+ Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
wd = elm_widget_data_get(WIDGET(ctxpopup_it));
if (!wd) return;
}
static void
-_item_signal_emit_hook(Elm_Object_Item *it,
- const char *emission,
+_item_signal_emit_hook(Elm_Object_Item *it, const char *emission,
const char *source)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *) it;
+ Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
edje_object_signal_emit(VIEW(ctxpopup_it), emission, source);
}
_bg_clicked_cb(void *data, Evas_Object *obj __UNUSED__,
const char *emission __UNUSED__, const char *source __UNUSED__)
{
- evas_object_hide(data);
+ Widget_Data *wd = elm_widget_data_get(data);
+ if (!wd) return;
+ _hide_signal_emit(data, wd->dir);
}
static void
}
}
+ edje_object_signal_emit(wd->base, "elm,state,show", "elm");
+
_sizing_eval(obj);
+
+ elm_object_focus_set(obj, EINA_TRUE);
}
static void
-_hide(Evas_Object *obj)
+_hide_finished(void *data, Evas_Object *obj __UNUSED__,
+ const char *emission __UNUSED__, const char *source __UNUSED__)
{
- Widget_Data *wd = elm_widget_data_get(obj);
+ evas_object_hide(data);
+ evas_object_smart_callback_call(data, SIG_DISMISSED, NULL);
+}
- if (!wd) return;
+static void
+_ctxpopup_hide(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
+ void *event_info __UNUSED__)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if ((!wd) || (!wd->visible)) return;
evas_object_hide(wd->bg);
evas_object_hide(wd->arrow);
_scroller_size_reset(wd);
- evas_object_smart_callback_call(obj, SIG_DISMISSED, NULL);
wd->visible = EINA_FALSE;
}
static void
-_ctxpopup_hide(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
- void *event_info __UNUSED__)
-{
- Widget_Data *wd;
-
- wd = elm_widget_data_get(obj);
- if ((!wd) || (!wd->visible))
- return;
-
- _hide(obj);
-}
-
-static void
_content_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
}
static void
+_restack(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ evas_object_layer_set(wd->bg,
+ evas_object_layer_get(obj));
+ evas_object_layer_set(wd->base,
+ evas_object_layer_get(obj));
+}
+
+static void
_item_select_cb(void *data, Evas_Object *obj __UNUSED__,
const char *emission __UNUSED__, const char *source __UNUSED__)
{
if (elm_widget_item_disabled_get(item)) return;
if (item->func)
- item->func((void*) item->base.data, WIDGET(item), data);
+ item->func((void*)item->base.data, WIDGET(item), data);
}
static void
_item_icon_set(Elm_Ctxpopup_Item *item, Evas_Object *icon)
{
if (item->icon)
- {
- elm_widget_sub_object_del(VIEW(item), item->icon);
- evas_object_del(item->icon);
- }
+ evas_object_del(item->icon);
item->icon = icon;
if (!icon) return;
if (!wd) return;
VIEW(item) = edje_object_add(evas_object_evas_get(wd->base));
+ edje_object_mirrored_set(VIEW(item), elm_widget_mirrored_get(WIDGET(item)));
_elm_theme_object_set(WIDGET(item), VIEW(item), "ctxpopup", group_name,
elm_widget_style_get(WIDGET(item)));
edje_object_signal_callback_add(VIEW(item), "elm,action,click", "",
if (item->icon)
evas_object_del(item->icon);
wd->items = eina_list_remove(wd->items, item);
- free(item);
+ elm_widget_item_free(item);
}
wd->items = NULL;
}
+static Eina_Bool
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ Widget_Data *wd;
+ Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
+
+ wd = elm_widget_data_get(WIDGET(ctxpopup_it));
+ if (!wd) return EINA_FALSE;
+
+ if (ctxpopup_it->icon)
+ evas_object_del(ctxpopup_it->icon);
+ if (VIEW(ctxpopup_it))
+ evas_object_del(VIEW(ctxpopup_it));
+
+ eina_stringshare_del(ctxpopup_it->label);
+
+ wd->items = eina_list_remove(wd->items, ctxpopup_it);
+
+ wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+
+ if (eina_list_count(wd->items) < 1)
+ {
+ evas_object_hide(WIDGET(ctxpopup_it));
+ return EINA_TRUE;
+ }
+
+ if (wd->visible)
+ _sizing_eval(WIDGET(ctxpopup_it));
+
+ return EINA_TRUE;
+}
+
+static void
+_disable_hook(Evas_Object *obj)
+{
+ Eina_List *l;
+ Elm_Object_Item *it;
+
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+
+ EINA_LIST_FOREACH(wd->items, l, it)
+ elm_object_item_disabled_set(it, elm_widget_disabled_get(obj));
+}
+
+static void
+_signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ edje_object_signal_emit(wd->base, emission, source);
+}
+
+static void
+_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ edje_object_signal_callback_add(wd->base, emission, source, func_cb, data);
+}
+
+static void
+_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ edje_object_signal_callback_del_full(wd->base, emission, source, func_cb, data);
+}
+
EAPI Evas_Object *
elm_ctxpopup_add(Evas_Object *parent)
{
Evas_Object *obj;
Evas *e;
Widget_Data *wd;
- Evas_Coord x, y, w, h;
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
ELM_SET_WIDTYPE(widtype, "ctxpopup");
elm_widget_type_set(obj, "ctxpopup");
- elm_widget_sub_object_add(parent, obj);
elm_widget_data_set(obj, wd);
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
+ elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
+ elm_widget_can_focus_set(obj, EINA_TRUE);
+ elm_widget_event_hook_set(obj, _event_hook);
elm_widget_content_set_hook_set(obj, _content_set_hook);
elm_widget_content_unset_hook_set(obj, _content_unset_hook);
elm_widget_content_get_hook_set(obj, _content_get_hook);
+ elm_widget_disable_hook_set(obj, _disable_hook);
+ elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
+ elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
+ elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
//Background
wd->bg = edje_object_add(e);
elm_widget_sub_object_add(obj, wd->bg);
_elm_theme_object_set(obj, wd->bg, "ctxpopup", "bg", "default");
- evas_object_geometry_get(parent, &x, &y, &w, &h);
- evas_object_move(wd->bg, x, y);
- evas_object_resize(wd->bg, w, h);
- edje_object_signal_callback_add(wd->bg, "elm,action,click", "",
- _bg_clicked_cb, obj);
-
+ edje_object_signal_callback_add(wd->bg,
+ "elm,action,click",
+ "",
+ _bg_clicked_cb,
+ obj);
//Base
wd->base = edje_object_add(e);
elm_widget_sub_object_add(obj, wd->base);
_elm_theme_object_set(obj, wd->base, "ctxpopup", "base", "default");
+ edje_object_signal_callback_add(wd->base, "elm,action,hide,finished", "",
+ _hide_finished, obj);
//Arrow
wd->arrow = edje_object_add(e);
wd->dir_priority[1] = ELM_CTXPOPUP_DIRECTION_LEFT;
wd->dir_priority[2] = ELM_CTXPOPUP_DIRECTION_RIGHT;
wd->dir_priority[3] = ELM_CTXPOPUP_DIRECTION_DOWN;
+ wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
- evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE, _parent_resize,
- obj);
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);
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_RESTACK, _restack, obj);
evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
return obj;
}
-EAPI Evas_Object *
-elm_ctxpopup_item_icon_get(const Elm_Object_Item *it)
-{
- return _item_content_get_hook(it, "icon");
-}
-
-EAPI void
-elm_ctxpopup_item_icon_set(Elm_Object_Item *it, Evas_Object *icon)
-{
- _item_content_set_hook(it, "icon", icon);
-}
-
-EAPI const char *
-elm_ctxpopup_item_label_get(const Elm_Object_Item *it)
-{
- return _item_text_get_hook(it, NULL);
-}
-
-EAPI void
-elm_ctxpopup_item_label_set(Elm_Object_Item *it, const char *label)
-{
- _item_text_set_hook(it, NULL, label);
-}
-
EAPI void
elm_ctxpopup_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
{
Evas_Coord x, y, w, h;
wd = elm_widget_data_get(obj);
- if (!wd) return;
+ if ((!wd) || (!parent)) return;
_parent_cut_off(obj);
_remove_items(wd);
_list_del(wd);
+ wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
}
EAPI void
}
}
+ wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+
if (wd->visible)
_sizing_eval(obj);
}
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd;
+ Evas_Object *content;
Elm_Ctxpopup_Item *item;
wd = elm_widget_data_get(obj);
item = elm_widget_item_new(obj, Elm_Ctxpopup_Item);
if (!item) return NULL;
- elm_widget_item_disable_set_hook_set(item, _item_disable_set_hook);
+ elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
+ elm_widget_item_disable_hook_set(item, _item_disable_hook);
elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
elm_widget_item_content_set_hook_set(item, _item_content_set_hook);
elm_widget_item_signal_emit_hook_set(item, _item_signal_emit_hook);
//The first item is appended.
- if (wd->content)
- evas_object_del(elm_object_content_unset(obj));
+ content = elm_object_content_unset(obj);
+ if (content) evas_object_del(content);
if (!wd->items)
_list_new(obj);
_item_label_set(item, label);
elm_box_pack_end(wd->box, VIEW(item));
wd->items = eina_list_append(wd->items, item);
+ wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
if (wd->visible)
{
_sizing_eval(obj);
}
- return (Elm_Object_Item *) item;
-}
-
-EAPI void
-elm_ctxpopup_item_del(Elm_Object_Item *it)
-{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
-
- Widget_Data *wd;
- Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *) it;
-
- wd = elm_widget_data_get(WIDGET(ctxpopup_it));
- if (!wd) return;
-
- if (ctxpopup_it->icon)
- evas_object_del(ctxpopup_it->icon);
- if (VIEW(ctxpopup_it))
- evas_object_del(VIEW(ctxpopup_it));
-
- eina_stringshare_del(ctxpopup_it->label);
-
- wd->items = eina_list_remove(wd->items, ctxpopup_it);
-
- if (eina_list_count(wd->items) < 1)
- wd->items = NULL;
-
- if (wd->visible)
- _sizing_eval(WIDGET(ctxpopup_it));
-
- free(ctxpopup_it);
-}
-
-EAPI void
-elm_ctxpopup_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled)
-{
- elm_object_item_disabled_set(it, disabled);
-}
-
-EAPI Eina_Bool
-elm_ctxpopup_item_disabled_get(const Elm_Object_Item *it)
-{
- return elm_object_item_disabled_get(it);
-}
-
-EAPI void
-elm_ctxpopup_content_set(Evas_Object *obj, Evas_Object *content)
-{
- elm_object_content_set(obj, content);
-}
-
-EAPI Evas_Object *
-elm_ctxpopup_content_unset(Evas_Object *obj)
-{
- return elm_object_content_unset(obj);
+ return (Elm_Object_Item *)item;
}
EAPI void
if (!wd) return ELM_CTXPOPUP_DIRECTION_UNKNOWN;
return wd->dir;
}
+
+EAPI void
+elm_ctxpopup_dismiss(Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ _hide_signal_emit(obj, wd->dir);
+}