discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=920bb29baa80e7c82b54838798514e6f26be6683

commit 920bb29baa80e7c82b54838798514e6f26be6683
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Thu Feb 18 12:22:00 2016 -0500

    scrolling: add option to disable scroll animations
    
    when I scroll on a computer, I want my app to respond immediately. I don't
    want to wait for it to finish scrolling and I don't want to have to guess
    where the scroll will end.
    
    ref 2ac2628612060114cf6e5205e5331044221178c6
    
    @feature
---
 src/bin/config.c                   | 30 ++++++++++++++++++++++++++++++
 src/lib/elm_config.c               | 16 ++++++++++++++++
 src/lib/elm_config.h               | 27 +++++++++++++++++++++++++++
 src/lib/elm_interface_scrollable.c |  9 +++++++--
 src/lib/elm_priv.h                 |  1 +
 5 files changed, 81 insertions(+), 2 deletions(-)

diff --git a/src/bin/config.c b/src/bin/config.c
index 246a39b..e107c2a 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -151,6 +151,17 @@ config_exit(void *data       EINA_UNUSED,
 }
 
 static void
+scroll_animation_disable_change(void *data EINA_UNUSED, Evas_Object *obj, void 
*event_info EINA_UNUSED)
+{
+   Eina_Bool val = elm_check_state_get(obj);
+   Eina_Bool sb = elm_config_scroll_animation_disable_get();
+
+   if (val == sb) return;
+   elm_config_scroll_animation_disable_set(val);
+   elm_config_all_flush();
+}
+
+static void
 sb_change(void *data       EINA_UNUSED,
           Evas_Object     *obj,
           void *event_info EINA_UNUSED)
@@ -3432,6 +3443,25 @@ _status_config_scrolling(Evas_Object *win,
    evas_object_show(sc);
    elm_object_content_set(sc, box);
 
+   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);
+
+   bx = elm_box_add(fr);
+   elm_object_content_set(fr, bx);
+   evas_object_show(bx);
+
+   /* Disable Scroll Animation */
+   CHECK_ADD("Disable scroll animation",
+             "Set whether scrollers should scroll<br/>"
+             "immediately instead of animating",
+             scroll_animation_disable_change, NULL);
+   evas_object_data_set(win, "scroll_animation_disable", ck);
+   elm_check_state_set(ck, elm_config_scroll_animation_disable_get());
+
    /* Bounce */
    _status_config_scrolling_bounce(win, box);
 
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index 7239248..414c8a9 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -401,6 +401,7 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
    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_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
@@ -1724,6 +1725,7 @@ _config_load(void)
    _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_start_enable = EINA_TRUE;
+   _elm_config->scroll_smooth_start_enable = EINA_FALSE;
 //   _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
@@ -2291,6 +2293,8 @@ _env_get(void)
      }
    s = getenv("ELM_SCROLL_SMOOTH_START_ENABLE");
    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_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");
@@ -3314,6 +3318,18 @@ elm_config_scroll_thumbscroll_smooth_start_set(Eina_Bool 
enable)
    _elm_config->scroll_smooth_start_enable = enable;
 }
 
+EAPI Eina_Bool
+elm_config_scroll_animation_disable_get(void)
+{
+   return _elm_config->scroll_animation_disable;
+}
+
+EAPI void
+elm_config_scroll_animation_disable_set(Eina_Bool disable)
+{
+   _elm_config->scroll_animation_disable = !!disable;
+}
+
 EAPI void
 elm_config_scroll_thumbscroll_smooth_amount_set(double amount)
 {
diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h
index 8f72415..d122293 100644
--- a/src/lib/elm_config.h
+++ b/src/lib/elm_config.h
@@ -620,6 +620,33 @@ EAPI Eina_Bool    
elm_config_scroll_thumbscroll_smooth_start_get(void);
 EAPI void         elm_config_scroll_thumbscroll_smooth_start_set(Eina_Bool 
enable);
 
 /**
+ * Get the value of this option
+ *
+ * @return State of this option
+ * 
+ * @see elm_config_scroll_animation_disable_set()
+ *
+ * @since 1.18
+ * @ingroup Scrolling
+ */
+EAPI Eina_Bool    elm_config_scroll_animation_disable_get(void);
+
+/**
+ * Set the value for this option
+ *
+ * This option disables timed animations during scrolling and forces scroll 
actions
+ * to be performed immediately.
+ * 
+ * @param disable The state of this option
+ * 
+ * @see elm_config_scroll_animation_disable_get()
+ *
+ * @since 1.18
+ * @ingroup Scrolling
+ */
+EAPI void         elm_config_scroll_animation_disable_set(Eina_Bool enable);
+
+/**
  * 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 37451bc..0b87794 100644
--- a/src/lib/elm_interface_scrollable.c
+++ b/src/lib/elm_interface_scrollable.c
@@ -1964,8 +1964,13 @@ _scroll_wheel_post_event_cb(void *data, Evas *e 
EINA_UNUSED)
         if ((!sid->hold) && (!sid->freeze))
           {
              _elm_scroll_wanted_coordinates_update(sid, x, y);
-             _elm_scroll_scroll_to_x(sid, 
_elm_config->bring_in_scroll_friction, x);
-             _elm_scroll_scroll_to_y(sid, 
_elm_config->bring_in_scroll_friction, y);
+             if (_elm_config->scroll_animation_disable)
+               eo_do(sid->obj, elm_interface_scrollable_content_pos_set(x, y, 
EINA_TRUE));
+             else
+               {
+                  _elm_scroll_scroll_to_x(sid, 
_elm_config->bring_in_scroll_friction, x);
+                  _elm_scroll_scroll_to_y(sid, 
_elm_config->bring_in_scroll_friction, y);
+               }
           }
      }
    else
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index a1dcb50..47b2463 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -211,6 +211,7 @@ struct _Elm_Config
    double        page_scroll_friction;
    double        bring_in_scroll_friction;
    double        zoom_friction;
+   Eina_Bool     scroll_animation_disable;
    unsigned char thumbscroll_bounce_enable;
    double        thumbscroll_border_friction;
    double        thumbscroll_sensitivity_friction;

-- 


Reply via email to