[ctxpopup] Add focus_direction.
[framework/uifw/elementary.git] / src / lib / elc_ctxpopup.c
index 3cdaa04..3f7149c 100644 (file)
@@ -5,8 +5,11 @@
 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}
 };
 
@@ -15,6 +18,14 @@ EVAS_SMART_SUBCLASS_NEW
    Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks);
 
 static Eina_Bool
+_elm_ctxpopup_smart_translate(Evas_Object *obj)
+{
+   evas_object_hide(obj);
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
 _elm_ctxpopup_smart_focus_next(const Evas_Object *obj,
                                Elm_Focus_Direction dir,
                                Evas_Object **next)
@@ -43,6 +54,32 @@ _elm_ctxpopup_smart_focus_next(const Evas_Object *obj,
 }
 
 static Eina_Bool
+_elm_ctxpopup_smart_focus_direction(const Evas_Object *obj,
+                                    const Evas_Object *base,
+                                    double degree,
+                                    Evas_Object **direction,
+                                    double *weight)
+{
+   Eina_Bool ret;
+   Eina_List *l = NULL;
+   void *(*list_data_get)(const Eina_List *list);
+
+   ELM_CTXPOPUP_DATA_GET(obj, sd);
+
+   if (!sd)
+     return EINA_FALSE;
+
+   list_data_get = eina_list_data_get;
+
+   l = eina_list_append(l, sd->box);
+   ret = elm_widget_focus_list_direction_get
+      (obj, base, l, list_data_get, degree, direction, weight);
+   eina_list_free(l);
+
+   return ret;
+}
+
+static Eina_Bool
 _elm_ctxpopup_smart_event(Evas_Object *obj,
                           Evas_Object *src __UNUSED__,
                           Evas_Callback_Type type,
@@ -804,6 +841,8 @@ _elm_ctxpopup_smart_sizing_eval(Evas_Object *obj)
    Evas_Coord_Rectangle rect = { 0, 0, 1, 1 };
    Evas_Coord_Point box_size = { 0, 0 };
    Evas_Coord_Point _box_size = { 0, 0 };
+   Evas_Coord maxw = 0;
+   const char *str;
 
    ELM_CTXPOPUP_DATA_GET(obj, sd);
 
@@ -812,6 +851,20 @@ _elm_ctxpopup_smart_sizing_eval(Evas_Object *obj)
      {
         _item_sizing_eval(item);
         evas_object_size_hint_min_get(VIEW(item), &_box_size.x, &_box_size.y);
+
+        str = edje_object_data_get(VIEW(item), "item_max_size");
+        if (str)
+          {
+             maxw = atoi(str);
+             maxw = maxw * elm_widget_scale_get(obj) * elm_config_scale_get();
+
+             if (_box_size.x > maxw)
+               {
+                  edje_object_signal_emit(VIEW(item), "elm,state,text,ellipsis", "elm");
+                  edje_object_message_signal_process(VIEW(item));
+               }
+          }
+
         if (!sd->horizontal)
           {
              if (_box_size.x > box_size.x)
@@ -1520,7 +1573,8 @@ _elm_ctxpopup_smart_set_user(Elm_Ctxpopup_Smart_Class *sc)
    ELM_WIDGET_CLASS(sc)->theme = _elm_ctxpopup_smart_theme;
    ELM_WIDGET_CLASS(sc)->sub_object_add = _elm_ctxpopup_smart_sub_object_add;
    ELM_WIDGET_CLASS(sc)->focus_next = _elm_ctxpopup_smart_focus_next;
-   ELM_WIDGET_CLASS(sc)->focus_direction = NULL;
+   ELM_WIDGET_CLASS(sc)->focus_direction = _elm_ctxpopup_smart_focus_direction;
+   ELM_WIDGET_CLASS(sc)->translate = _elm_ctxpopup_smart_translate;
 
    ELM_CONTAINER_CLASS(sc)->content_get = _elm_ctxpopup_smart_content_get;
    ELM_CONTAINER_CLASS(sc)->content_set = _elm_ctxpopup_smart_content_set;