discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=0c3dd90d2f4e33ccb7296cd418ee927bbb05fc1e

commit 0c3dd90d2f4e33ccb7296cd418ee927bbb05fc1e
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Thu Feb 18 12:44:43 2016 -0500

    config: add option to modify scroll acceleration factor
    
    when using a touchpad or frictionless mouse wheel, it becomes impossible
    to accurately use a scroller which accelerates as scrollers on mobile 
devices
    do. by setting this new option to 0, acceleration can be disabled and 
regular
    behavior can be restored
    
    ref 2ac2628612060114cf6e5205e5331044221178c6
    
    @feature
---
 src/bin/config.c                   | 42 ++++++++++++++++++++++++++++++++++++++
 src/lib/elm_config.c               | 22 ++++++++++++++++++++
 src/lib/elm_config.h               | 29 ++++++++++++++++++++++++++
 src/lib/elm_interface_scrollable.c |  2 +-
 src/lib/elm_priv.h                 |  3 ++-
 5 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/src/bin/config.c b/src/bin/config.c
index e107c2a..7b8d304 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -162,6 +162,17 @@ scroll_animation_disable_change(void *data EINA_UNUSED, 
Evas_Object *obj, void *
 }
 
 static void
+scroll_accel_factor_change(void *data EINA_UNUSED, Evas_Object *obj, void 
*event_info EINA_UNUSED)
+{
+   double bf = elm_config_scroll_accel_factor_get();
+   double val = elm_slider_value_get(obj);
+
+   if (fabs(bf - val) < DBL_EPSILON) return;
+   elm_config_scroll_accel_factor_set(val);
+   elm_config_all_flush();
+}
+
+static void
 sb_change(void *data       EINA_UNUSED,
           Evas_Object     *obj,
           void *event_info EINA_UNUSED)
@@ -3446,6 +3457,37 @@ _status_config_scrolling(Evas_Object *win,
    fr = elm_frame_add(box);
    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_object_text_set(fr, "Acceleration");
+   elm_box_pack_end(box, fr);
+   evas_object_show(fr);
+
+   bx = elm_box_add(fr);
+   elm_object_content_set(fr, bx);
+   evas_object_show(bx);
+
+   LABEL_FRAME_ADD("<hilight>Wheel acceleration factor</>");
+
+   sl = elm_slider_add(win);
+   elm_object_tooltip_text_set(sl, "This is the factor by which scrolling<br/>"
+                                   "increments will be multiplied when 
scrolling<br/>"
+                                   "quickly");
+   evas_object_data_set(win, "scroll_accel_factor", 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.1f");
+   elm_slider_indicator_format_set(sl, "%2.1f");
+   elm_slider_min_max_set(sl, 0.0, 10.0);
+   elm_slider_value_set(sl, elm_config_scroll_accel_factor_get());
+   elm_box_pack_end(bx, sl);
+   evas_object_show(sl);
+
+   evas_object_smart_callback_add(sl, "changed", bis_round, NULL);
+   evas_object_smart_callback_add(sl, "delay,changed", 
scroll_accel_factor_change, NULL);
+
+   fr = elm_frame_add(box);
+   evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
    elm_object_text_set(fr, "Animation");
    elm_box_pack_end(box, fr);
    evas_object_show(fr);
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index 414c8a9..f958730 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -402,6 +402,7 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, thumbscroll_bounce_enable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, scroll_smooth_start_enable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, scroll_animation_disable, T_UCHAR);
+   ELM_CONFIG_VAL(D, T, scroll_accel_factor, T_DOUBLE);
 //   ELM_CONFIG_VAL(D, T, scroll_smooth_time_interval, T_DOUBLE); // not used 
anymore
    ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE);
 //   ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE); // not used 
anymore
@@ -1726,6 +1727,7 @@ _config_load(void)
    _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_start_enable = EINA_TRUE;
    _elm_config->scroll_smooth_start_enable = EINA_FALSE;
+   _elm_config->scroll_smooth_amount = 7.0;
 //   _elm_config->scroll_smooth_time_interval = 0.008; // not used anymore
    _elm_config->scroll_smooth_amount = 1.0;
 //   _elm_config->scroll_smooth_history_weight = 0.3; // not used anymore
@@ -2149,6 +2151,10 @@ _config_update(void)
    _elm_config->popup_horizontal_align = 0.5;
    _elm_config->popup_vertical_align = 0.5;
    IFCFGEND
+
+   IFCFG(0x0009)
+   _elm_config->scroll_accel_factor = 7.0;
+   IFCFGEND
    /**
     * Fix user config for current ELM_CONFIG_EPOCH here.
     **/
@@ -2295,6 +2301,8 @@ _env_get(void)
    if (s) _elm_config->scroll_smooth_start_enable = !!atoi(s);
    s = getenv("ELM_SCROLL_ANIMATION_DISABLE");
    if (s) _elm_config->scroll_animation_disable = !!atoi(s);
+   s = getenv("ELM_SCROLL_ACCEL_FACTOR");
+   if (s) _elm_config->scroll_accel_factor = atof(s);
 //   s = getenv("ELM_SCROLL_SMOOTH_TIME_INTERVAL"); // not used anymore
 //   if (s) _elm_config->scroll_smooth_time_interval = atof(s); // not used 
anymore
    s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
@@ -3331,6 +3339,20 @@ elm_config_scroll_animation_disable_set(Eina_Bool 
disable)
 }
 
 EAPI void
+elm_config_scroll_accel_factor_set(double factor)
+{
+   if (factor < 0.0) factor = 0.0;
+   if (factor > 10.0) factor = 10.0;
+   _elm_config->scroll_accel_factor = factor;
+}
+
+EAPI double
+elm_config_scroll_accel_factor_get(void)
+{
+   return _elm_config->scroll_accel_factor;
+}
+
+EAPI void
 elm_config_scroll_thumbscroll_smooth_amount_set(double amount)
 {
    if (amount < 0.0) amount = 0.0;
diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h
index d122293..27043f7 100644
--- a/src/lib/elm_config.h
+++ b/src/lib/elm_config.h
@@ -647,6 +647,35 @@ EAPI Eina_Bool    
elm_config_scroll_animation_disable_get(void);
 EAPI void         elm_config_scroll_animation_disable_set(Eina_Bool enable);
 
 /**
+ * Get the value of this option
+ *
+ * @return State of this option
+ * 
+ * @see elm_config_scroll_accel_factor_set()
+ *
+ * @since 1.18
+ * @ingroup Scrolling
+ */
+EAPI double       elm_config_scroll_accel_factor_get(void);
+
+/**
+ * Set the value for this option
+ *
+ * Using a mouse wheel or touchpad to scroll will result in events
+ * being processed. If events occur quickly, the scroll amount will
+ * be multiplied by this value to accelerate the scrolling.
+ * 
+ * @param factor The value of this option from 0.0 to 10.0
+ *
+ * @see elm_config_scroll_accel_factor_get()
+ * @note Set 0.0 to disable acceleration
+ * 
+ * @since 1.18
+ * @ingroup Scrolling
+ */
+EAPI void         elm_config_scroll_accel_factor_set(double factor);
+
+/**
  * Get the amount of smoothing to apply to scrolling
  *
  * @return the amount of smoothing to apply from 0.0 to 1.0
diff --git a/src/lib/elm_interface_scrollable.c 
b/src/lib/elm_interface_scrollable.c
index 0b87794..ba2f681 100644
--- a/src/lib/elm_interface_scrollable.c
+++ b/src/lib/elm_interface_scrollable.c
@@ -1947,7 +1947,7 @@ _scroll_wheel_post_event_cb(void *data, Evas *e 
EINA_UNUSED)
         double delta_t = (double)(ev->timestamp - sid->last_wheel) / 1000.0;
         double mul;
 
-        mul = 1.0 + (7.0 * ((0.2 - delta_t) / 0.2));
+        mul = 1.0 + (_elm_config->scroll_accel_factor * ((0.2 - delta_t) / 
0.2));
         if (delta_t < 0.2) d *= mul;
         sid->last_wheel = ev->timestamp;
         if (!direction)
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index 47b2463..9b7fce8 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -134,7 +134,7 @@ struct _Elm_Theme
  * the users config doesn't need to be wiped - simply new values need
  * to be put in
  */
-#define ELM_CONFIG_FILE_GENERATION 0x0008
+#define ELM_CONFIG_FILE_GENERATION 0x0009
 #define ELM_CONFIG_VERSION_EPOCH_OFFSET 16
 #define ELM_CONFIG_VERSION         ((ELM_CONFIG_EPOCH << 
ELM_CONFIG_VERSION_EPOCH_OFFSET) | \
                                     ELM_CONFIG_FILE_GENERATION)
@@ -212,6 +212,7 @@ struct _Elm_Config
    double        bring_in_scroll_friction;
    double        zoom_friction;
    Eina_Bool     scroll_animation_disable;
+   double        scroll_accel_factor;
    unsigned char thumbscroll_bounce_enable;
    double        thumbscroll_border_friction;
    double        thumbscroll_sensitivity_friction;

-- 


Reply via email to