[*][Scroller] merge from upstream revision 64051, but didn't accept data/theme/widget...
authorJaehwan Kim <jae.hwan.kim@samsung.com>
Mon, 17 Oct 2011 02:28:51 +0000 (11:28 +0900)
committerJaehwan Kim <jae.hwan.kim@samsung.com>
Mon, 17 Oct 2011 04:13:48 +0000 (13:13 +0900)
From: Jaehwan Kim <jae.hwan.kim@samsung.com>
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.

git-svn-id: https://svn.enlightenment.org/svn/e/trunk/elementary@64051 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

Conflicts:

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

Change-Id: I00033eb58f1d73a7b0b260919885b1556dd71994

config/default/base.src
config/illume/base.src
config/standard/base.src
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 eb99ae3..8aa95fa 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 4c44144..767f597 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_time_interval" double: 0.008;
   value "scroll_smooth_amount" double: 1.0;
   value "scroll_smooth_history_weight" double: 0.3;
index f0e8565..47f729d 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 5a500df..a88cc64 100644 (file)
@@ -362,6 +362,30 @@ tsbf_change(void *data       __UNUSED__,
 }
 
 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,
           void *event_info __UNUSED__)
@@ -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"),
@@ -2502,6 +2530,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 c3321cf..2f72662 100644 (file)
@@ -1393,6 +1393,50 @@ extern "C" {
    EAPI void             elm_scroll_thumbscroll_border_friction_set(double friction);
    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);
+
+   /**
+    * @}
+    */
+
    EAPI void             elm_object_scroll_hold_push(Evas_Object *obj) EINA_ARG_NONNULL(1);
    EAPI void             elm_object_scroll_hold_pop(Evas_Object *obj) EINA_ARG_NONNULL(1);
    EAPI void             elm_object_scroll_freeze_push(Evas_Object *obj) EINA_ARG_NONNULL(1);
index a9fb6a1..033c30e 100644 (file)
@@ -74,7 +74,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] =
@@ -97,6 +97,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",
@@ -120,10 +121,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__,
@@ -464,6 +466,18 @@ _prop_change(void *data  __UNUSED__,
                      (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])
           {
              unsigned int val = 1000;
@@ -564,6 +578,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);
@@ -1126,6 +1141,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_time_interval = 0.008;
    _elm_config->scroll_smooth_amount = 1.0;
    _elm_config->scroll_smooth_history_weight = 0.3;
@@ -1483,6 +1499,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_TIME_INTERVAL");
    if (s) _elm_config->scroll_smooth_time_interval = atof(s);
    s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
index e309668..f973501 100644 (file)
@@ -3127,6 +3127,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
+}
+
 /**
  * @defgroup Scrollhints Scrollhints
  * @ingroup Main
@@ -3556,4 +3594,4 @@ EAPI void
 elm_object_item_signal_emit(Elm_Object_Item *it, const char *emission, const char *source)
 {
    elm_widget_item_signal_emit(it, emission, source);
-}
\ No newline at end of file
+}
index 7ff273f..e68ce22 100644 (file)
@@ -182,6 +182,7 @@ struct _Elm_Config
    double         zoom_friction;
    unsigned char  thumbscroll_bounce_enable;
    double         thumbscroll_border_friction;
+   double         thumbscroll_sensitivity_friction;
    double         scroll_smooth_time_interval;
    double         scroll_smooth_amount;
    double         scroll_smooth_history_weight;
index 58f9185..484efdb 100644 (file)
@@ -1900,7 +1900,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)