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
This commit is contained in:
Mike Blumenkrantz 2016-02-18 12:22:00 -05:00
parent fd6f12de5d
commit 0116e07288
5 changed files with 81 additions and 2 deletions

View File

@ -150,6 +150,17 @@ config_exit(void *data EINA_UNUSED,
elm_exit(); /* exit the program's main loop that runs in elm_run() */
}
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,
@ -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);

View File

@ -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)
{

View File

@ -619,6 +619,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
*

View File

@ -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

View File

@ -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;