EAPI const char ELM_CTXPOPUP_SMART_NAME[] = "elm_ctxpopup";
static const char SIG_DISMISSED[] = "dismissed";
+static const char SIG_LANG_CHANGED[] = "language,changed";
+
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
{SIG_DISMISSED, ""},
+ {SIG_LANG_CHANGED, ""},
{NULL, NULL}
};
+static void
+_elm_ctxpopup_smart_translate(Eo *obj, void *_pd, va_list *list)
+{
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
+ Elm_Ctxpopup_Smart_Data *sd = _pd;
+ Eina_List *l;
+ Elm_Ctxpopup_Item *it;
+
+ evas_object_hide(obj);
+
+ EINA_LIST_FOREACH(sd->items, l, it)
+ elm_widget_item_translate(it);
+
+ if (ret) *ret = EINA_TRUE;
+}
static void
_elm_ctxpopup_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
_elm_ctxpopup_smart_focus_direction_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
{
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
- *ret = EINA_FALSE;
+ *ret = EINA_TRUE;
}
static void
Elm_Ctxpopup_Smart_Data *sd = _pd;
Elm_Focus_Direction dir = va_arg(*list, Elm_Focus_Direction);
- Evas_Object **next = va_arg(*list, Evas_Object **);
+ Evas_Object **next = va_arg(*list, Evas_Object **);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
if (ret) *ret = EINA_FALSE;
}
static void
+_elm_ctxpopup_smart_focus_direction(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
+{
+ Elm_Ctxpopup_Smart_Data *sd = _pd;
+
+ Evas_Object *base = va_arg(*list, Evas_Object *);
+ double degree = va_arg(*list, double);
+ Evas_Object **direction = va_arg(*list, Evas_Object **);
+ double *weight = va_arg(*list, double *);
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
+ if (ret) *ret = EINA_FALSE;
+ Eina_Bool int_ret;
+
+ Eina_List *l = NULL;
+ void *(*list_data_get)(const Eina_List *list);
+
+ if (!sd)
+ return;
+
+ list_data_get = eina_list_data_get;
+
+ l = eina_list_append(l, sd->box);
+
+ int_ret = elm_widget_focus_list_direction_get
+ (obj, base, l, list_data_get, degree, direction, weight);
+ if (ret) *ret = int_ret;
+ eina_list_free(l);
+}
+
+
+static void
_elm_ctxpopup_smart_event(Eo *obj, void *_pd, va_list *list)
{
Evas_Object *src = va_arg(*list, Evas_Object *);
int idx;
ELM_CTXPOPUP_DATA_GET(obj, sd);
- Elm_Widget_Smart_Data *wd = eo_data_get(obj, ELM_OBJ_WIDGET_CLASS);
+ Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
- if (!rect) return ELM_CTXPOPUP_DIRECTION_DOWN;
+ if (!rect || !sd->parent) return ELM_CTXPOPUP_DIRECTION_DOWN;
edje_object_part_geometry_get
(sd->arrow, "ctxpopup_arrow", NULL, NULL, &arrow_size.x, &arrow_size.y);
evas_object_geometry_get
(sd->parent, &hover_area.x, &hover_area.y, &hover_area.w,
&hover_area.h);
+ if (!strcmp(evas_object_type_get(sd->parent), "elm_win"))
+ hover_area.x = hover_area.y = 0;
evas_object_geometry_get(obj, &pos.x, &pos.y, NULL, NULL);
double drag;
ELM_CTXPOPUP_DATA_GET(obj, sd);
- Elm_Widget_Smart_Data *wd = eo_data_get(obj, ELM_OBJ_WIDGET_CLASS);
+ Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
evas_object_geometry_get(obj, &x, &y, NULL, NULL);
evas_object_geometry_get
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Eina_Bool int_ret;
- eo_do_super(obj, elm_wdg_sub_object_add(sobj, &int_ret));
+ eo_do_super(obj, MY_CLASS, elm_wdg_sub_object_add(sobj, &int_ret));
if (ret) *ret = int_ret;
}
Evas_Coord_Point list_size = { 0, 0 };
Elm_Ctxpopup_Smart_Data *sd = _pd;
- Elm_Widget_Smart_Data *wd = eo_data_get(obj, ELM_OBJ_WIDGET_CLASS);
+ Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
if (!sd->arrow) return; /* simple way to flag "under deletion" */
+ if (!sd->parent) return; /* do not calculate sizes unless parent is set */
//Base
sd->dir = _base_geometry_calc(obj, &rect);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
if (ret) *ret = EINA_FALSE;
- eo_do_super(obj, elm_wdg_theme(&int_ret));
+ eo_do_super(obj, MY_CLASS, elm_wdg_theme(&int_ret));
if (!int_ret) return;
elm_widget_theme_object_set
if ((part) && (strcmp(part, "default")))
{
- eo_do_super(obj, elm_obj_container_content_set(part, content, &int_ret));
+ eo_do_super(obj, MY_CLASS, elm_obj_container_content_set(part, content, &int_ret));
goto end;
}
if ((part) && (strcmp(part, "default")))
{
- eo_do_super(obj, elm_obj_container_content_get(part, ret));
+ eo_do_super(obj, MY_CLASS, elm_obj_container_content_get(part, ret));
return;
}
if ((part) && (strcmp(part, "default")))
{
- eo_do_super(obj, elm_obj_container_content_unset(part, &content));
+ eo_do_super(obj, MY_CLASS, elm_obj_container_content_unset(part, &content));
goto end;
}
{
elm_list_go(sd->list);
sd->visible = EINA_TRUE;
- elm_object_focus_set(obj, EINA_TRUE);
+ elm_object_focus_set(sd->list, EINA_TRUE);
return;
}
void *event_info __UNUSED__)
{
ELM_CTXPOPUP_DATA_GET(obj, sd);
-
- evas_object_layer_set(sd->bg, evas_object_layer_get(obj));
+ evas_object_stack_below(sd->bg, obj);
}
static void
if (eina_list_count(elm_list_items_get(list)) < 2)
{
elm_object_item_del(ctxpopup_it->list_item);
+ sd->items = eina_list_remove(sd->items, ctxpopup_it);
evas_object_hide(WIDGET(ctxpopup_it));
return EINA_TRUE;
}
elm_object_item_del(ctxpopup_it->list_item);
+ sd->items = eina_list_remove(sd->items, ctxpopup_it);
if (sd->list_visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it));
return EINA_TRUE;
if (ret) *ret = EINA_FALSE;
Eina_Bool int_ret;
- eo_do_super(obj, elm_wdg_disable(&int_ret));
+ eo_do_super(obj, MY_CLASS, elm_wdg_disable(&int_ret));
if (!int_ret) return;
elm_object_disabled_set(sd->list, elm_widget_disabled_get(obj));
{
Elm_Ctxpopup_Smart_Data *priv = _pd;
- eo_do_super(obj, evas_obj_smart_add());
+ eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
+
+ if (!elm_layout_theme_set
+ (obj, "ctxpopup", "base", elm_widget_style_get(obj)))
+ CRITICAL("Failed to set layout!");
- elm_layout_theme_set(obj, "ctxpopup", "base", elm_widget_style_get(obj));
elm_layout_signal_callback_add
(obj, "elm,action,hide,finished", "", _hide_finished_cb, obj);
/* box will be our content placeholder, thus the parent's version call */
Eina_Bool ret;
- eo_do_super(obj, elm_obj_container_content_set("elm.swallow.content", priv->box, &ret));
+ eo_do_super(obj, MY_CLASS, elm_obj_container_content_set("elm.swallow.content", priv->box, &ret));
evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _on_show, NULL);
evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _on_hide, NULL);
_elm_ctxpopup_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
{
Elm_Ctxpopup_Smart_Data *sd = _pd;
+ Elm_Ctxpopup_Item *it;
evas_object_event_callback_del_full
(sd->box, EVAS_CALLBACK_RESIZE, _on_content_resized, obj);
evas_object_del(sd->bg);
sd->bg = NULL;
- eo_do_super(obj, evas_obj_smart_del());
+ EINA_LIST_FREE(sd->items, it)
+ elm_widget_item_free(it);
+
+ eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
}
static void
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
Evas_Object *obj = eo_add(MY_CLASS, parent);
eo_unref(obj);
+
+ /* access: parent could be any object such as elm_list which does
+ not know elc_ctxpopup as its child object in the focus_next(); */
+ Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS);
+ wd->highlight_root = EINA_TRUE;
+
return obj;
}
static void
_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
{
- eo_do_super(obj, eo_constructor());
+ eo_do_super(obj, MY_CLASS, eo_constructor());
eo_do(obj,
evas_obj_type_set(MY_CLASS_NAME),
evas_obj_smart_callbacks_descriptions_set(_smart_callbacks, NULL));
- if (!elm_widget_sub_object_add(eo_parent_get(obj), obj))
- ERR("could not add %p as sub object of %p", obj, eo_parent_get(obj));
+ elm_widget_sub_object_add(eo_parent_get(obj), obj);
}
EAPI void
//Update Background
evas_object_geometry_get(parent, &x, &y, &w, &h);
+ if (!strcmp(evas_object_type_get(parent), "elm_win"))
+ x = y = 0;
evas_object_move(sd->bg, x, y);
evas_object_resize(sd->bg, w, h);
}
static void
+_item_wrap_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Elm_Ctxpopup_Item *item = data;
+ item->wcb.org_func_cb((void *)item->wcb.org_data, item->wcb.cobj, item);
+}
+
+static void
_item_append(Eo *obj, void *_pd, va_list *list)
{
const char *label = va_arg(*list, const char *);
elm_layout_content_set(obj, "default", sd->list);
}
+ item->wcb.org_func_cb = func;
+ item->wcb.org_data = data;
+ item->wcb.cobj = obj;
item->list_item =
- elm_list_item_append(sd->list, label, icon, NULL, func, data);
+ elm_list_item_append(sd->list, label, icon, NULL, _item_wrap_cb, item);
+ sd->items = eina_list_append(sd->items, item);
sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_NEXT_MANAGER_IS), _elm_ctxpopup_smart_focus_next_manager_is),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_NEXT), _elm_ctxpopup_smart_focus_next),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_ctxpopup_smart_focus_direction_manager_is),
+ EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_DIRECTION), _elm_ctxpopup_smart_focus_direction),
+ EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_TRANSLATE), _elm_ctxpopup_smart_translate),
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SET), _elm_ctxpopup_smart_content_set),
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_GET), _elm_ctxpopup_smart_content_get),
EO_OP_FUNC_SENTINEL
};
eo_class_funcs_set(klass, func_desc);
+
+ evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
}
static const Eo_Op_Description op_desc[] = {
EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_HOVER_PARENT_SET, "Set the Ctxpopup's parent."),