diff --git a/legacy/elementary/src/bin/config.c b/legacy/elementary/src/bin/config.c index e107c2ab15..7b8d30413a 100644 --- a/legacy/elementary/src/bin/config.c +++ b/legacy/elementary/src/bin/config.c @@ -161,6 +161,17 @@ scroll_animation_disable_change(void *data EINA_UNUSED, Evas_Object *obj, void * elm_config_all_flush(); } +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, @@ -3443,6 +3454,37 @@ _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, "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("Wheel acceleration factor"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the factor by which scrolling
" + "increments will be multiplied when scrolling
" + "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); diff --git a/legacy/elementary/src/lib/elm_config.c b/legacy/elementary/src/lib/elm_config.c index 414c8a9690..f958730b37 100644 --- a/legacy/elementary/src/lib/elm_config.c +++ b/legacy/elementary/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"); @@ -3330,6 +3338,20 @@ elm_config_scroll_animation_disable_set(Eina_Bool disable) _elm_config->scroll_animation_disable = !!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) { diff --git a/legacy/elementary/src/lib/elm_config.h b/legacy/elementary/src/lib/elm_config.h index d122293d42..27043f79a5 100644 --- a/legacy/elementary/src/lib/elm_config.h +++ b/legacy/elementary/src/lib/elm_config.h @@ -646,6 +646,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 * diff --git a/legacy/elementary/src/lib/elm_interface_scrollable.c b/legacy/elementary/src/lib/elm_interface_scrollable.c index 0b8779462e..ba2f681295 100644 --- a/legacy/elementary/src/lib/elm_interface_scrollable.c +++ b/legacy/elementary/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/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h index 47b24636e5..9b7fce8969 100644 --- a/legacy/elementary/src/lib/elm_priv.h +++ b/legacy/elementary/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;