Entry: Context Menu is now configurable 56/70656/1
authorVaibhav Gupta <g.vaibhav1@samsung.com>
Fri, 11 Dec 2015 06:49:27 +0000 (15:49 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Fri, 20 May 2016 04:49:43 +0000 (13:49 +0900)
Summary:
Added a config variable Context_Menu_Disabled to make the appearance
of the context menu configurable.

@feature

Signed-off-by: Vaibhav Gupta <g.vaibhav1@samsung.com>
Reviewers: Hermet, SanghyeonLee, raster, singh.amitesh

Subscribers: stefan_schmidt, alok25, cedric, thiepha, sachin.dev

Differential Revision: https://phab.enlightenment.org/D2463

Conflicts:
src/lib/elm_entry.c

Change-Id: Id62b73593729aa6916229dd042fcef260254f893

config/default/base.src.in
config/mobile/base.src.in
config/standard/base.src.in
src/bin/test_entry.c
src/lib/elm_config.c
src/lib/elm_config.h
src/lib/elm_entry.c
src/lib/elm_priv.h

index 6f2b1b6..41a00cc 100644 (file)
@@ -54,6 +54,7 @@ group "Elm_Config" struct {
   value "longpress_timeout" double: 1.0;
   value "effect_enable" uchar: 1;
   value "desktop_entry" uchar: 0;
+  value "context_menu_disabled" uchar: 0;
   value "password_show_last" uchar: 0;
   value "password_show_last_timeout" double: 2.0;
   value "glayer_zoom_finger_enable" uchar: 1;
index 9208be8..11b1704 100644 (file)
@@ -54,6 +54,7 @@ group "Elm_Config" struct {
   value "longpress_timeout" double: 1.0;
   value "effect_enable" uchar: 1;
   value "desktop_entry" uchar: 0;
+  value "context_menu_disabled" uchar: 0;
   value "password_show_last" uchar: 1;
   value "password_show_last_timeout" double: 2.0;
   value "glayer_zoom_finger_enable" uchar: 1;
index 4b5d294..4ddc4ec 100644 (file)
@@ -55,6 +55,7 @@ group "Elm_Config" struct {
   value "longpress_timeout" double: 1.0;
   value "effect_enable" uchar: 1;
   value "desktop_entry" uchar: 1;
+  value "context_menu_disabled" uchar: 1;
   value "password_show_last" uchar: 0;
   value "password_show_last_timeout" double: 2.0;
   value "glayer_zoom_finger_enable" uchar: 1;
index aad673b..f79505e 100644 (file)
@@ -85,10 +85,19 @@ my_entry_bt_7(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
    elm_entry_editable_set(en, !elm_entry_editable_get(en));
 }
 
+static void
+changed_cb1(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+   Evas_Object *ck = data;
+   printf("ck %p to %i\n", obj, elm_check_state_get(obj));
+   elm_config_context_menu_disabled_set(elm_check_state_get(obj));
+   printf("ck2 %p is now %i\n", ck, elm_check_state_get(ck));
+}
+
 void
 test_entry(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
 {
-   Evas_Object *win, *bx, *bx2, *bt, *en;
+   Evas_Object *win, *bx, *bx2, *bt, *en, *ck;
    char buf[4096];
 
    win = elm_win_util_standard_add("entry", "Entry");
@@ -207,6 +216,12 @@ test_entry(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_inf
    elm_object_focus_allow_set(bt, EINA_FALSE);
    evas_object_show(bt);
 
+   ck = elm_check_add(win);
+   elm_object_text_set(ck, "Context Menu Disable");
+   evas_object_smart_callback_add(ck, "changed", changed_cb1, ck);
+   elm_box_pack_end(bx, ck);
+   evas_object_show(ck);
+
    elm_box_pack_end(bx, bx2);
    evas_object_show(bx2);
 
index c57aaf2..12ec6e6 100644 (file)
@@ -372,6 +372,7 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, focus_highlight_clip_disable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, focus_move_policy, T_UCHAR);
    ELM_CONFIG_VAL(D, T, focus_autoscroll_mode, T_UCHAR);
+   ELM_CONFIG_VAL(D, T, context_menu_disabled, T_UCHAR);
    ELM_CONFIG_VAL(D, T, slider_indicator_visible_mode, T_INT);
    ELM_CONFIG_VAL(D, T, item_select_on_focus_disable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, first_item_focus_on_first_focus_in, T_UCHAR);
@@ -1415,6 +1416,7 @@ _config_load(void)
    _elm_config->longpress_timeout = 1.0;
    _elm_config->effect_enable = EINA_TRUE;
    _elm_config->desktop_entry = EINA_FALSE;
+   _elm_config->context_menu_disabled = EINA_FALSE;
    _elm_config->is_mirrored = EINA_FALSE; /* Read sys value in env_get() */
    _elm_config->password_show_last = EINA_FALSE;
    _elm_config->password_show_last_timeout = 2.0;
@@ -2099,6 +2101,9 @@ _env_get(void)
    s = getenv("ELM_ICON_SIZE");
    if (s) _elm_config->icon_size = atoi(s);
 
+   s = getenv("ELM_CONTEXT_MENU_DISABLED");
+   if (s) _elm_config->context_menu_disabled = !!atoi(s);
+
    s = getenv("ELM_LONGPRESS_TIMEOUT");
    if (s) _elm_config->longpress_timeout = _elm_atof(s);
    if (_elm_config->longpress_timeout < 0.0)
@@ -2898,6 +2903,18 @@ elm_config_scroll_thumbscroll_sensitivity_friction_get(void)
    return _elm_config->thumbscroll_sensitivity_friction;
 }
 
+EAPI Eina_Bool
+elm_config_context_menu_disabled_get(void)
+{
+       return _elm_config->context_menu_disabled;
+}
+
+EAPI void
+elm_config_context_menu_disabled_set(Eina_Bool enabled)
+{
+       _elm_config->context_menu_disabled = !!enabled;
+}
+
 EAPI void
 elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction)
 {
index fe37966..988d636 100644 (file)
@@ -216,6 +216,26 @@ EAPI double       elm_config_scroll_page_scroll_friction_get(void);
 EAPI void         elm_config_scroll_page_scroll_friction_set(double friction);
 
 /**
+ * Get enable status of context menu disabled.
+ *
+ * @see elm_config_context_menu_disabled_set()
+ * @ingroup Entry
+ * @since 1.17
+ */
+EAPI Eina_Bool elm_config_context_menu_disabled_get(void);
+
+/**
+ * Set enable status of context menu disabled.
+ *
+ * @param enabled enable context menu if @c EINA_TRUE, disable otherwise
+ *
+ * @see elm_config_focus_auto_scroll_bring_in_enabled_get()
+ * @ingroup Entry
+ * @since 1.17
+ */
+EAPI void elm_config_context_menu_disabled_set(Eina_Bool enabled);
+
+/**
  * Get the amount of inertia a scroller will impose at region bring
  * animations.
  *
index 3961de8..7afe532 100644 (file)
@@ -2684,13 +2684,17 @@ _long_press_cb(void *data)
                   _select_word(data, NULL, NULL);
                   elm_widget_scroll_freeze_push(data);
                }
-             if (!_elm_config->desktop_entry)
+             if (!_elm_config->context_menu_disabled &&
+                 !_elm_config->desktop_entry)
                {
                   _menu_call(data);
                }
           }
         //
-        else if (!_elm_config->desktop_entry)
+        /* Context menu will not appear if context menu disabled is set
+         * as false on a long press callback */
+        else if (!_elm_config->context_menu_disabled &&
+                 !_elm_config->desktop_entry)
           _menu_call(data);
      }
 
@@ -2716,7 +2720,9 @@ _key_down_cb(void *data,
    if ((sd->api) && (sd->api->obj_hidemenu) && (!sd->sel_mode))
      sd->api->obj_hidemenu(data);
    //
-   if (!strcmp(ev->key, "Menu"))
+   /* First check if context menu disabled is false or not, and
+    * then check for key id */
+   if ((!_elm_config->context_menu_disabled) && !strcmp(ev->key, "Menu"))
      _menu_call(data);
 }
 
@@ -2742,7 +2748,9 @@ _mouse_down_cb(void *data,
          sd->longpress_timer = ecore_timer_add
            (_elm_config->longpress_timeout, _long_press_cb, data);
       }
-   else if (ev->button == 3)
+    /* If right button is pressed and context menu disabled is true,
+     * then only context menu will appear */
+   else if (ev->button == 3 && (!_elm_config->context_menu_disabled))
      {
         if (_elm_config->desktop_entry)
           {
@@ -2776,11 +2784,16 @@ _mouse_up_cb(void *data,
         if (!_elm_config->desktop_entry && sd->have_selection && !sd->long_pressed)
           elm_entry_select_none(data);
         //
-        //TIZEN_ONLY (20150806): Enable word selection when magnifier is disabled
-        //if ((sd->long_pressed) && (_elm_config->magnifier_enable))
-        //  {
-        //     _magnifier_hide(data);
-        if (sd->long_pressed)
+        /* Since context menu disabled flag was checked at long press start while mouse
+         * down, hence the same should be checked at mouse up from a long press
+         * as well */
+        /* TIZEN_ONLY (20150806): Enable word selection when magnifier is disabled
+        if ((sd->long_pressed) && (!_elm_config->context_menu_disabled) &&
+            (_elm_config->magnifier_enable))
+          {
+             _magnifier_hide(data);
+         */
+        if ((sd->long_pressed) && (!_elm_config->context_menu_disabled))
           {
              if (_elm_config->magnifier_enable)
                _magnifier_hide(data);
@@ -2851,10 +2864,13 @@ _mouse_up_cb(void *data,
           }
         //
      }
-   else if ((ev->button == 3) && (!_elm_config->desktop_entry))
+  /* Since context menu disabled flag was checked at mouse right key down,
+   * hence the same should be stopped at mouse up of right key as well */
+   else if ((ev->button == 3) && (!_elm_config->context_menu_disabled) &&
+            (!_elm_config->desktop_entry))
      {
-        sd->use_down = 1;
-        _menu_call(data);
+         sd->use_down = 1;
+         _menu_call(data);
      }
 }
 
@@ -4426,10 +4442,14 @@ _start_handler_mouse_up_cb(void *data,
    //
    if (_elm_config->magnifier_enable)
      _magnifier_hide(data);
-   // TIZEN ONLY (20150205): Support CopyPaste UI
-   /*if ((!_elm_config->desktop_entry) && (sd->long_pressed))
-     _menu_call(data);*/
-   if (!_elm_config->desktop_entry)
+   /* Context menu should not appear, even in case of selector mode, if the
+    * flag is false (disabled) */
+   /* TIZEN ONLY (20150205): Support CopyPaste UI
+   if ((!_elm_config->context_menu_disabled) &&
+       (!_elm_config->desktop_entry) && (sd->long_pressed))
+     */
+   if ((!_elm_config->context_menu_disabled) &&
+       (!_elm_config->desktop_entry))
      _menu_call(data);
    if (!_elm_config->desktop_entry)
         edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text",
@@ -4623,10 +4643,15 @@ _end_handler_mouse_up_cb(void *data,
    //
    if (_elm_config->magnifier_enable)
      _magnifier_hide(data);
-   // TIZEN ONLY (20150205): Support CopyPaste UI
-   /*if ((!_elm_config->desktop_entry) && (sd->long_pressed))
-     _menu_call(data);*/
-   if (!_elm_config->desktop_entry)
+   /* Context menu appear was checked in case of selector start, and hence
+    * the same should be checked at selector end as well */
+   /* TIZEN ONLY (20150205): Support CopyPaste UI
+   if ((!_elm_config->context_menu_disabled) &&
+       (!_elm_config->desktop_entry) && (sd->long_pressed))
+     _menu_call(data);
+    */
+   if ((!_elm_config->context_menu_disabled) &&
+       (!_elm_config->desktop_entry))
      _menu_call(data);
    if (!_elm_config->desktop_entry)
         edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text",
index 4bba6fa..a7d17d0 100644 (file)
@@ -246,6 +246,7 @@ struct _Elm_Config
    double        longpress_timeout;
    unsigned char effect_enable;
    unsigned char desktop_entry;
+   unsigned char context_menu_disabled;
    unsigned char password_show_last;
    double        password_show_last_timeout;
    unsigned char glayer_zoom_finger_enable;