From: Jaehwan Kim <jae.hwan.kim@samsung.com>
authorJaehwan Kim <jae.hwan.kim@samsung.com>
Thu, 13 Oct 2011 12:07:39 +0000 (12:07 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Thu, 13 Oct 2011 12:07:39 +0000 (12:07 +0000)
Subject: [E-devel] [Patch] ELM_THUMBSCROLL_SENSITIVITY_FRICTION

I talked with you about 4.0, magic number.
I want to change the part that the length of mouse dragging multiply 4.0
to _elm_config->thumbscroll_sensitivity_friction.
4.0 is nice. But some device may want to change the value. It is a kind
of sensitivity. So I added the config "ELM_THUMBSCROLL_SENESITIVITY
_FRICTION". And I change the value mean. If the value is high, it is
more sensitive. The range of the value is from 0.1 to 1.0. It cannot be 0.0.
4.0 changed to 0.25.
Please check this patch.

SVN revision: 64051

config/default/base.src
config/illume/base.src
config/standard/base.src
data/themes/widgets/ctxpopup.edc
src/bin/config.c
src/lib/Elementary.h.in
src/lib/elm_config.c
src/lib/elm_main.c
src/lib/elm_priv.h
src/lib/els_scroller.c

index ed11da8669c1bc67b24775fe586db93009130393..a0de3a2afa4f0b917856ded32d2b081cb22bf952 100644 (file)
@@ -12,6 +12,7 @@ group "Elm_Config" struct {
   value "bring_in_scroll_friction" double: 0.5;
   value "zoom_friction" double: 0.5;
   value "thumbscroll_border_friction" double: 0.5;
+  value "thumbscroll_sensitivity_friction" double: 0.25;
   value "scale" double: 1.0;
   value "bgpixmap" int: 0;
   value "compositing" int: 1;
index c7156755538565b737b525e4662c39491c8b97d7..0af21d83dd13a18cd7200de11accbba991b46247 100644 (file)
@@ -12,6 +12,7 @@ group "Elm_Config" struct {
   value "bring_in_scroll_friction" double: 0.5;
   value "zoom_friction" double: 0.5;
   value "thumbscroll_border_friction" double: 0.5;
+  value "thumbscroll_sensitivity_friction" double: 0.25;
   value "scroll_smooth_amount" double: 1.0;
   value "scroll_smooth_history_weight" double: 0.3;
   value "scroll_smooth_future_time" double: 0.0;
index eaa84da47411f31af23774239ec86a9ac9088777..78c7d75339bcb633ef130fc8bbe10e16a4a5b40d 100644 (file)
@@ -12,6 +12,7 @@ group "Elm_Config" struct {
   value "bring_in_scroll_friction" double: 0.5;
   value "zoom_friction" double: 0.5;
   value "thumbscroll_border_friction" double: 0.5;
+  value "thumbscroll_sensitivity_friction" double: 0.25;
   value "scroll_smooth_amount" double: 0.0;
   value "scroll_smooth_history_weight" double: 0.3;
   value "scroll_smooth_future_time" double: 0.0;
index b97a7558e7c7c9ba23df023fa3844a0cb21a9b97..1fe11a021d6d138e08313d633e4238e471425716 100644 (file)
@@ -914,3 +914,149 @@ group {
       }
    }
 }
+///////////////////////////////////////////////////////////////////////////////
+group {
+   name: "elm/ctxpopup/item_compress/default";
+   images {
+      image: "hoversel_entry_bg.png" COMP;
+   }
+   parts {
+      part { name: "event";
+         mouse_events: 1;
+         description { state: "default" 0.0;
+         }
+      }
+      part { name: "bg";
+         mouse_events: 0;
+         description { state: "default" 0.0;
+            rel1.offset: 2 2;
+            rel2.offset: -3 -3;
+            image { normal:"hoversel_entry_bg.png";
+               border: 0 0 2 2;
+            }
+            fill.smooth: 0;
+            color: 255 255 255 0;
+         }
+         description { state: "clicked" 0.0;
+            inherit: "default" 0.0;
+            color: 255 255 255 255;
+         }
+      }
+      part { name: "elm.swallow.icon";
+         type: SWALLOW;
+         clip_to: "disclip";
+         scale: 1;
+         description { state: "default" 0.0;
+            min: 25 25;
+            max: 25 25;
+            align: 0 0.5;
+            aspect: 1.0 1.0;
+            rel1 { offset: 10 10; }
+            rel2 { offset: 0 -10; }
+         }
+      }
+      part { name: "elm.text";
+         type: TEXT;
+         mouse_events: 0;
+         clip_to: "disclip";
+         scale: 1;
+         description { state: "default" 0.0;
+            min: 1 40;
+            fixed: 0 1;
+            align: 0.5 0.5;
+            rel1 { relative: 1.0 0.0; to: "elm.swallow.icon"; offset: 10 0; }
+            rel2 { relative: 1.0 1.0; }
+            color: 255 255 255 255;
+            text {
+               font: "Sans";
+               size: 10;
+               min: 0 1;
+               align: 0.0 0.5;
+            }
+         }
+         description { state: "clicked" 0.0;
+            inherit: "default" 0.0;
+            color: 0 0 0 255;
+         }
+      }
+      part { name: "over1";
+         mouse_events: 1;
+         repeat_events: 1;
+         ignore_flags: ON_HOLD;
+         description { state: "default" 0.0;
+            color: 255 255 255 0;
+         }
+         description { state: "clicked" 0.0;
+            inherit: "default" 0.0;
+            color: 255 255 255 255;
+         }
+      }
+      part { name: "over2";
+         mouse_events: 1;
+         repeat_events: 1;
+         description { state: "default" 0.0;
+            color: 255 255 255 0;
+         }
+         description { state: "clicked" 0.0;
+            inherit: "default" 0.0;
+            color: 255 255 255 255;
+         }
+      }
+      part { name: "disclip";
+         type: RECT;
+         description { state: "default" 0.0;
+            color: 255 255 255 255;
+         }
+         description { state: "enabled" 0.0;
+            color: 127 127 127 127;
+         }
+      }
+      part { name: "blocker";
+         description { state: "default" 0.0;
+            visible: 0;
+         }
+         description { state: "enabled" 0.0;
+            visible: 1;
+            color: 0 0 0 0;
+         }
+      }
+   }
+   programs {
+      program {
+         name: "item_unclick";
+         signal: "mouse,up,1";
+         source: "over1";
+         action: SIGNAL_EMIT "elm,action,click" "";
+      }
+      program { name: "disable";
+         signal: "elm,state,disabled";
+         source: "elm";
+         action: STATE_SET "enabled" 0.0;
+         target: "disclip";
+         target: "blocker";
+      }
+      program { name: "enable";
+         signal: "elm,state,enabled";
+         source: "elm";
+         action: STATE_SET "default" 0.0;
+         target: "disclip";
+         target: "blocker";
+      }
+      program { name: "item_click2";
+         signal: "mouse,down,1";
+         source: "over2";
+         script {
+            set_state(PART:"elm.text", "clicked", 0.0);
+            set_state(PART:"bg", "clicked", 0.0);
+         }
+      }
+      program { name: "item_unclick2";
+         signal: "mouse,up,1";
+         source: "over2";
+         script {
+            set_state(PART:"elm.text", "default", 0.0);
+            set_state(PART:"bg", "default", 0.0);
+         }
+      }
+   }
+}
index 9f8520e6870be0efd076aefcbf6287751b7fb958..449c1b7f48ba663259fe2835170f380464880fc7 100644 (file)
@@ -361,6 +361,30 @@ tsbf_change(void *data       __UNUSED__,
    elm_scroll_thumbscroll_border_friction_all_set(val);
 }
 
+static void
+tssf_round(void *data       __UNUSED__,
+           Evas_Object     *obj,
+           void *event_info __UNUSED__)
+{
+   double val = elm_slider_value_get(obj);
+   double v;
+
+   v = ((double)((int)(val * 20.0))) / 20.0;
+   if (v != val) elm_slider_value_set(obj, v);
+}
+
+static void
+tssf_change(void *data       __UNUSED__,
+            Evas_Object     *obj,
+            void *event_info __UNUSED__)
+{
+   double tssf = elm_scroll_thumbscroll_sensitivity_friction_get();
+   double val = elm_slider_value_get(obj);
+
+   if (tssf == val) return;
+   elm_scroll_thumbscroll_sensitivity_friction_all_set(val);
+}
+
 static void
 cf_enable(void *data,
           Evas_Object     *obj,
@@ -864,7 +888,7 @@ _profile_change_do(Evas_Object *win,
 {
    int flush_interval, font_c, image_c, edje_file_c, edje_col_c, ts_threshould;
    double scale, s_bounce_friction, ts_momentum_threshold, ts_friction,
-          ts_border_friction, page_friction, bring_in_friction, zoom_friction;
+          ts_border_friction, ts_sensitivity_friction, page_friction, bring_in_friction, zoom_friction;
    const char *curr_theme, *curr_engine;
    const Eina_List *l_items, *l;
    Eina_Bool s_bounce, ts;
@@ -889,6 +913,7 @@ _profile_change_do(Evas_Object *win,
    ts_momentum_threshold = elm_scroll_thumbscroll_momentum_threshold_get();
    ts_friction = elm_scroll_thumbscroll_friction_get();
    ts_border_friction = elm_scroll_thumbscroll_border_friction_get();
+   ts_sensitivity_friction = elm_scroll_thumbscroll_sensitivity_friction_get();
    page_friction = elm_scroll_page_scroll_friction_get();
    bring_in_friction = elm_scroll_bring_in_scroll_friction_get();
    zoom_friction = elm_scroll_zoom_friction_get();
@@ -940,6 +965,9 @@ _profile_change_do(Evas_Object *win,
    elm_scroll_thumbscroll_border_friction_all_set(ts_border_friction);
    elm_slider_value_set(evas_object_data_get(win, "ts_border_friction_slider"),
                         ts_border_friction);
+   elm_scroll_thumbscroll_sensitivity_friction_all_set(ts_sensitivity_friction);
+   elm_slider_value_set(evas_object_data_get(win, "ts_sensitivity_friction_slider"),
+                        ts_sensitivity_friction);
    elm_scroll_page_scroll_friction_all_set(page_friction);
    elm_slider_value_set(evas_object_data_get(win,
                                              "page_scroll_friction_slider"),
@@ -2518,6 +2546,26 @@ _status_config_scrolling(Evas_Object *win,
    evas_object_smart_callback_add(sl, "changed", tsbf_round, NULL);
    evas_object_smart_callback_add(sl, "delay,changed", tsbf_change, NULL);
 
+   LABEL_FRAME_ADD("<hilight>Thumb scroll sensitivity friction</>");
+
+   sl = elm_slider_add(win);
+   elm_object_tooltip_text_set(sl, "This is the sensitivity amount which<br>"
+                                   "is be multiplied by the length of mouse<br>"
+                                   "dragging.");
+   evas_object_data_set(win, "ts_sensitivity_friction_slider", sl);
+   evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
+   elm_slider_span_size_set(sl, 120);
+   elm_slider_unit_format_set(sl, "%1.2f");
+   elm_slider_indicator_format_set(sl, "%1.2f");
+   elm_slider_min_max_set(sl, 0.1, 1.0);
+   elm_slider_value_set(sl, elm_scroll_thumbscroll_sensitivity_friction_get());
+   elm_box_pack_end(bx, sl);
+   evas_object_show(sl);
+
+   evas_object_smart_callback_add(sl, "changed", tssf_round, NULL);
+   evas_object_smart_callback_add(sl, "delay,changed", tssf_change, NULL);
+
    sp = elm_separator_add(win);
    elm_separator_horizontal_set(sp, EINA_TRUE);
    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
index b8f2a8ae175cc54c48afe653e65c0ee42170a652..39a87196ee974aede186973372117b374c40b537 100644 (file)
@@ -2830,6 +2830,46 @@ extern "C" {
     */
    EAPI void             elm_scroll_thumbscroll_border_friction_all_set(double friction);
 
+   /**
+    * Get the sensitivity amount which is be multiplied by the length of
+    * mouse dragging.
+    *
+    * @return the thumb scroll sensitivity friction
+    *
+    * @ingroup Scrolling
+    */
+   EAPI double           elm_scroll_thumbscroll_sensitivity_friction_get(void);
+
+   /**
+    * Set the sensitivity amount which is be multiplied by the length of
+    * mouse dragging.
+    *
+    * @param friction the thumb scroll sensitivity friction. @c 0.1 for
+    *        minimun sensitivity, @c 1.0 for maximum sensitivity. 0.25
+    *        is proper.
+    *
+    * @see elm_thumbscroll_sensitivity_friction_get()
+    * @note parameter value will get bound to 0.1 - 1.0 interval, always
+    *
+    * @ingroup Scrolling
+    */
+   EAPI void             elm_scroll_thumbscroll_sensitivity_friction_set(double friction);
+
+   /**
+    * Set the sensitivity amount which is be multiplied by the length of
+    * mouse dragging, for all Elementary application windows.
+    *
+    * @param friction the thumb scroll sensitivity friction. @c 0.1 for
+    *        minimun sensitivity, @c 1.0 for maximum sensitivity. 0.25
+    *        is proper.
+    *
+    * @see elm_thumbscroll_sensitivity_friction_get()
+    * @note parameter value will get bound to 0.1 - 1.0 interval, always
+    *
+    * @ingroup Scrolling
+    */
+   EAPI void             elm_scroll_thumbscroll_sensitivity_friction_all_set(double friction);
+
    /**
     * @}
     */
index 59aec78a8e7ca5da65c7d7949a1778b360f23061..345909f83d3b4cf7a95623b0413d27e472360123 100644 (file)
@@ -76,7 +76,7 @@ static size_t _elm_user_dir_snprintf(char       *dst,
 #ifdef HAVE_ELEMENTARY_X
 static Ecore_Event_Handler *_prop_change_handler = NULL;
 static Ecore_X_Window _root_1st = 0;
-#define ATOM_COUNT 22
+#define ATOM_COUNT 23
 static Ecore_X_Atom _atom[ATOM_COUNT];
 static Ecore_X_Atom _atom_config = 0;
 static const char *_atom_names[ATOM_COUNT] =
@@ -99,6 +99,7 @@ static const char *_atom_names[ATOM_COUNT] =
    "ENLIGHTENMENT_THUMBSCROLL_MOMENTUM_THRESHOLD",
    "ENLIGHTENMENT_THUMBSCROLL_FRICTION",
    "ENLIGHTENMENT_THUMBSCROLL_BORDER_FRICTION",
+   "ENLIGHTENMENT_THUMBSCROLL_SENSITIVITY_FRICTION",
    "ENLIGHTENMENT_THUMBSCROLL_PAGE_SCROLL_FRICTION",
    "ENLIGHTENMENT_THUMBSCROLL_BRING_IN_SCROLL_FRICTION",
    "ENLIGHTENMENT_THUMBSCROLL_ZOOM_FRICTION",
@@ -122,10 +123,11 @@ static const char *_atom_names[ATOM_COUNT] =
 #define ATOM_E_THUMBSCROLL_MOMENTUM_THRESHOLD       15
 #define ATOM_E_THUMBSCROLL_FRICTION                 16
 #define ATOM_E_THUMBSCROLL_BORDER_FRICTION          17
-#define ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION     18
-#define ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION 19
-#define ATOM_E_THUMBSCROLL_ZOOM_FRICTION            20
-#define ATOM_E_CONFIG                               21
+#define ATOM_E_THUMBSCROLL_SENSITIVITY_FRICTION     18
+#define ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION     19
+#define ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION 20
+#define ATOM_E_THUMBSCROLL_ZOOM_FRICTION            21
+#define ATOM_E_CONFIG                               22
 
 static Eina_Bool _prop_config_get(void);
 static Eina_Bool _prop_change(void *data  __UNUSED__,
@@ -465,6 +467,18 @@ _prop_change(void *data  __UNUSED__,
                   _elm_config->thumbscroll_border_friction =
                      (double)val / 1000.0;
                }
+          }
+               else if (event->atom == _atom[ATOM_E_THUMBSCROLL_SENSITIVITY_FRICTION])
+          {
+             unsigned int val = 1000;
+
+             if (ecore_x_window_prop_card32_get(event->win,
+                                                event->atom,
+                                                &val, 1) > 0)
+               {
+                  _elm_config->thumbscroll_sensitivity_friction =
+                     (double)val / 1000.0;
+               }
           }
         else if (event->atom == _atom[ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION])
           {
@@ -566,6 +580,7 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, thumbscroll_border_friction, T_DOUBLE);
+   ELM_CONFIG_VAL(D, T, thumbscroll_sensitivity_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, page_scroll_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, bring_in_scroll_friction, T_DOUBLE);
    ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
@@ -1138,6 +1153,7 @@ _config_load(void)
    _elm_config->bring_in_scroll_friction = 0.5;
    _elm_config->zoom_friction = 0.5;
    _elm_config->thumbscroll_border_friction = 0.5;
+   _elm_config->thumbscroll_sensitivity_friction = 0.25; // magic number! just trial and error shows this makes it behave "nicer" and not run off at high speed all the time
    _elm_config->scroll_smooth_amount = 1.0;
    _elm_config->scroll_smooth_history_weight = 0.3;
    _elm_config->scroll_smooth_future_time = 0.0;
@@ -1508,6 +1524,18 @@ _env_get(void)
 
         _elm_config->thumbscroll_border_friction = friction;
      }
+   s = getenv("ELM_THUMBSCROLL_SENSITIVITY_FRICTION");
+   if (s)
+     {
+        friction = atof(s);
+        if (friction < 0.1)
+          friction = 0.1;
+
+        if (friction > 1.0)
+          friction = 1.0;
+
+        _elm_config->thumbscroll_sensitivity_friction = friction;
+     }
    s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
    if (s) _elm_config->scroll_smooth_amount = atof(s);
    s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT");
index 76a0988e74135d9fa1436da46a4baaaf859a0033..b16d9eeb8ec218f377f4e56dee65274a5f4bfe12 100644 (file)
@@ -1887,6 +1887,44 @@ elm_scroll_thumbscroll_border_friction_all_set(double friction)
 #endif
 }
 
+EAPI double
+elm_scroll_thumbscroll_sensitivity_friction_get(void)
+{
+   return _elm_config->thumbscroll_sensitivity_friction;
+}
+
+EAPI void
+elm_scroll_thumbscroll_sensitivity_friction_set(double friction)
+{
+   if (friction < 0.1)
+     friction = 0.1;
+
+   if (friction > 1.0)
+     friction = 1.0;
+
+   _elm_config->thumbscroll_friction = friction;
+}
+
+EAPI void
+elm_scroll_thumbscroll_sensitivity_friction_all_set(double friction)
+{
+   if (friction < 0.1)
+     friction = 0.1;
+
+   if (friction > 1.0)
+     friction = 1.0;
+
+#ifdef HAVE_ELEMENTARY_X
+   static Ecore_X_Atom atom = 0;
+   unsigned int sensitivity_friction_i = (unsigned int)(friction * 1000.0);
+
+   if (!atom)
+     atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_SENSITIVITY_FRICTION");
+   ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
+                                  atom, &sensitivity_friction_i, 1);
+#endif
+}
+
 EAPI void
 elm_object_scroll_hold_push(Evas_Object *obj)
 {
index 1b17e4edcdefd8b83e3b1204a9404b87cd1a907a..e720af1fb6fa3b76709dd708b8e10db76b8dfc00 100644 (file)
@@ -97,6 +97,7 @@ struct _Elm_Config
    double         zoom_friction;
    unsigned char  thumbscroll_bounce_enable;
    double         thumbscroll_border_friction;
+   double         thumbscroll_sensitivity_friction;
    double         scroll_smooth_amount;
    double         scroll_smooth_history_weight;
    double         scroll_smooth_future_time;
index eed8d203e5af7062507f5880be3a424963475328..935371f6a52c445d99c4e0816d84335d0cd76658 100644 (file)
@@ -1969,7 +1969,7 @@ _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *ev
                        ax /= (i + 1);
                        ay /= (i + 1);
                        at /= (i + 1);
-                       at *= 4.0; // magic number! just trial and error shows this makes it behave "nicer" and not run off at high speed all the time
+                       at /= _elm_config->thumbscroll_sensitivity_friction;
                        dx = ev->canvas.x - ax;
                        dy = ev->canvas.y - ay;
                        if (at > 0)