summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-09-11 23:24:51 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-09-11 23:24:51 +0900
commit939d8ef4c3c48120046560814db63858175a2d12 (patch)
treed90277e62000a090515529662bad9826a4518a9e
parent933dfca5bcda4943ecdd81ab09dc34989234f7f3 (diff)
elm - thumbscroll finger scrolling - make it far smoother
smooth out scrolling and simplifyconfig as well as expose config apis to configure it all and elm config ui sliders and checkboxes for related config values etc. etc. - with this it is much smoother if you use the default values, though latency is a bit worse. it looks nicer though. @feature
-rw-r--r--config/default/base.src.in9
-rw-r--r--config/mobile/base.src.in5
-rw-r--r--config/standard/base.src.in9
-rw-r--r--src/bin/config.c131
-rw-r--r--src/lib/elm_config.c68
-rw-r--r--src/lib/elm_config.h84
-rw-r--r--src/lib/elm_interface_scrollable.c84
-rw-r--r--src/lib/elm_priv.h6
8 files changed, 313 insertions, 83 deletions
diff --git a/config/default/base.src.in b/config/default/base.src.in
index 83cff053f..5b01b5e87 100644
--- a/config/default/base.src.in
+++ b/config/default/base.src.in
@@ -20,12 +20,9 @@ group "Elm_Config" struct {
20 value "zoom_friction" double: 0.5; 20 value "zoom_friction" double: 0.5;
21 value "thumbscroll_border_friction" double: 0.5; 21 value "thumbscroll_border_friction" double: 0.5;
22 value "thumbscroll_sensitivity_friction" double: 0.25; 22 value "thumbscroll_sensitivity_friction" double: 0.25;
23 value "scroll_smooth_start_enable" uchar: 0; 23 value "scroll_smooth_start_enable" uchar: 1;
24 value "scroll_smooth_time_interval" double: 0.0; 24 value "scroll_smooth_amount" double: 1.0;
25 value "scroll_smooth_amount" double: 0.0; 25 value "scroll_smooth_time_window" double: 0.15;
26 value "scroll_smooth_history_weight" double: 0.1;
27 value "scroll_smooth_future_time" double: 0.0;
28 value "scroll_smooth_time_window" double: 0.01;
29 value "focus_autoscroll_mode" uchar: 0; 26 value "focus_autoscroll_mode" uchar: 0;
30 value "slider_indicator_visible_mode" int: 0; 27 value "slider_indicator_visible_mode" int: 0;
31 value "scale" double: 1.0; 28 value "scale" double: 1.0;
diff --git a/config/mobile/base.src.in b/config/mobile/base.src.in
index 8be5652e8..6219c1120 100644
--- a/config/mobile/base.src.in
+++ b/config/mobile/base.src.in
@@ -21,11 +21,8 @@ group "Elm_Config" struct {
21 value "thumbscroll_border_friction" double: 0.5; 21 value "thumbscroll_border_friction" double: 0.5;
22 value "thumbscroll_sensitivity_friction" double: 0.7; 22 value "thumbscroll_sensitivity_friction" double: 0.7;
23 value "scroll_smooth_start_enable" uchar: 1; 23 value "scroll_smooth_start_enable" uchar: 1;
24 value "scroll_smooth_time_interval" double: 0;
25 value "scroll_smooth_amount" double: 1.0; 24 value "scroll_smooth_amount" double: 1.0;
26 value "scroll_smooth_history_weight" double: 0.1; 25 value "scroll_smooth_time_window" double: 0.15;
27 value "scroll_smooth_future_time" double: 0.0;
28 value "scroll_smooth_time_window" double: 0.01;
29 value "focus_autoscroll_mode" uchar: 0; 26 value "focus_autoscroll_mode" uchar: 0;
30 value "slider_indicator_visible_mode" int: 0; 27 value "slider_indicator_visible_mode" int: 0;
31 value "scale" double: 1.0; 28 value "scale" double: 1.0;
diff --git a/config/standard/base.src.in b/config/standard/base.src.in
index 1b1cb849f..b5f1b7a78 100644
--- a/config/standard/base.src.in
+++ b/config/standard/base.src.in
@@ -20,12 +20,9 @@ group "Elm_Config" struct {
20 value "zoom_friction" double: 0.5; 20 value "zoom_friction" double: 0.5;
21 value "thumbscroll_border_friction" double: 0.5; 21 value "thumbscroll_border_friction" double: 0.5;
22 value "thumbscroll_sensitivity_friction" double: 0.25; 22 value "thumbscroll_sensitivity_friction" double: 0.25;
23 value "scroll_smooth_start_enable" uchar: 0; 23 value "scroll_smooth_start_enable" uchar: 1;
24 value "scroll_smooth_time_interval" double: 0.0; 24 value "scroll_smooth_amount" double: 1.0;
25 value "scroll_smooth_amount" double: 0.0; 25 value "scroll_smooth_time_window" double: 0.15;
26 value "scroll_smooth_history_weight" double: 0.1;
27 value "scroll_smooth_future_time" double: 0.0;
28 value "scroll_smooth_time_window" double: 0.01;
29 value "focus_autoscroll_mode" uchar: 0; 26 value "focus_autoscroll_mode" uchar: 0;
30 value "slider_indicator_visible_mode" int: 0; 27 value "slider_indicator_visible_mode" int: 0;
31 value "scale" double: 1.0; 28 value "scale" double: 1.0;
diff --git a/src/bin/config.c b/src/bin/config.c
index d1740248d..37a7e9623 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -166,6 +166,19 @@ sb_change(void *data EINA_UNUSED,
166} 166}
167 167
168static void 168static void
169ss_change(void *data EINA_UNUSED,
170 Evas_Object *obj,
171 void *event_info EINA_UNUSED)
172{
173 Eina_Bool val = elm_check_state_get(obj);
174 Eina_Bool ss = elm_config_scroll_thumbscroll_smooth_start_get();
175
176 if (val == ss) return;
177 elm_config_scroll_thumbscroll_smooth_start_set(val);
178 elm_config_all_flush();
179}
180
181static void
169bf_round(void *data EINA_UNUSED, 182bf_round(void *data EINA_UNUSED,
170 Evas_Object *obj, 183 Evas_Object *obj,
171 void *event_info EINA_UNUSED) 184 void *event_info EINA_UNUSED)
@@ -266,6 +279,56 @@ zf_change(void *data EINA_UNUSED,
266} 279}
267 280
268static void 281static void
282smooth_round(void *data EINA_UNUSED,
283 Evas_Object *obj,
284 void *event_info EINA_UNUSED)
285{
286 double val = elm_slider_value_get(obj);
287 double v;
288
289 v = ((double)((int)(val * 100.0))) / 100.0;
290 if (v != val) elm_slider_value_set(obj, v);
291}
292
293static void
294smooth_change(void *data EINA_UNUSED,
295 Evas_Object *obj,
296 void *event_info EINA_UNUSED)
297{
298 double zf = elm_config_scroll_thumbscroll_smooth_amount_get();
299 double val = elm_slider_value_get(obj);
300
301 if (zf == val) return;
302 elm_config_scroll_thumbscroll_smooth_amount_set(val);
303 elm_config_all_flush();
304}
305
306static void
307smooth_win_round(void *data EINA_UNUSED,
308 Evas_Object *obj,
309 void *event_info EINA_UNUSED)
310{
311 double val = elm_slider_value_get(obj);
312 double v;
313
314 v = ((double)((int)(val * 100.0))) / 100.0;
315 if (v != val) elm_slider_value_set(obj, v);
316}
317
318static void
319smooth_win_change(void *data EINA_UNUSED,
320 Evas_Object *obj,
321 void *event_info EINA_UNUSED)
322{
323 double zf = elm_config_scroll_thumbscroll_smooth_time_window_get();
324 double val = elm_slider_value_get(obj);
325
326 if (zf == val) return;
327 elm_config_scroll_thumbscroll_smooth_time_window_set(val);
328 elm_config_all_flush();
329}
330
331static void
269ts_change(void *data EINA_UNUSED, 332ts_change(void *data EINA_UNUSED,
270 Evas_Object *obj, 333 Evas_Object *obj,
271 void *event_info EINA_UNUSED) 334 void *event_info EINA_UNUSED)
@@ -1191,9 +1254,10 @@ _config_display_update(Evas_Object *win)
1191 ts_min_friction, ts_friction_standard, ts_border_friction, 1254 ts_min_friction, ts_friction_standard, ts_border_friction,
1192 ts_sensitivity_friction, ts_acceleration_threshold, 1255 ts_sensitivity_friction, ts_acceleration_threshold,
1193 ts_acceleration_time_limit, ts_acceleration_weight, page_friction, 1256 ts_acceleration_time_limit, ts_acceleration_weight, page_friction,
1194 bring_in_friction, zoom_friction, transition_duration; 1257 bring_in_friction, zoom_friction, transition_duration,
1258 smooth_amount, smooth_time_window;
1195 const char *curr_theme; 1259 const char *curr_theme;
1196 Eina_Bool s_bounce, ts; 1260 Eina_Bool s_bounce, ts, smooth_start;
1197 Elm_Theme *th; 1261 Elm_Theme *th;
1198 int fs; 1262 int fs;
1199 1263
@@ -1224,6 +1288,9 @@ _config_display_update(Evas_Object *win)
1224 page_friction = elm_config_scroll_page_scroll_friction_get(); 1288 page_friction = elm_config_scroll_page_scroll_friction_get();
1225 bring_in_friction = elm_config_scroll_bring_in_scroll_friction_get(); 1289 bring_in_friction = elm_config_scroll_bring_in_scroll_friction_get();
1226 zoom_friction = elm_config_scroll_zoom_friction_get(); 1290 zoom_friction = elm_config_scroll_zoom_friction_get();
1291 smooth_start = elm_config_scroll_thumbscroll_smooth_start_get();
1292 smooth_amount = elm_config_scroll_thumbscroll_smooth_amount_get();
1293 smooth_time_window = elm_config_scroll_thumbscroll_smooth_time_window_get();
1227 1294
1228 /* gotta update root windows' atoms */ 1295 /* gotta update root windows' atoms */
1229 elm_slider_value_set(evas_object_data_get(win, "scale_slider"), scale); 1296 elm_slider_value_set(evas_object_data_get(win, "scale_slider"), scale);
@@ -1288,6 +1355,15 @@ _config_display_update(Evas_Object *win)
1288 "zoom_scroll_friction_slider"), 1355 "zoom_scroll_friction_slider"),
1289 zoom_friction); 1356 zoom_friction);
1290 1357
1358 elm_check_state_set(evas_object_data_get(win, "scroll_smooth_start"),
1359 smooth_start);
1360 elm_slider_value_set(evas_object_data_get(win,
1361 "scroll_smooth_amount"),
1362 smooth_amount);
1363 elm_slider_value_set(evas_object_data_get(win,
1364 "scroll_smooth_time_window"),
1365 smooth_time_window);
1366
1291 curr_theme = _elm_theme_current_get(elm_theme_get(NULL)); 1367 curr_theme = _elm_theme_current_get(elm_theme_get(NULL));
1292 1368
1293 th = elm_theme_new(); 1369 th = elm_theme_new();
@@ -3355,7 +3431,7 @@ static void
3355_status_config_scrolling(Evas_Object *win, 3431_status_config_scrolling(Evas_Object *win,
3356 Evas_Object *naviframe) 3432 Evas_Object *naviframe)
3357{ 3433{
3358 Evas_Object *lb, *pd, *bx, *sl, *sc; 3434 Evas_Object *lb, *pd, *bx, *sl, *sc, *ck;
3359 3435
3360 bx = elm_box_add(win); 3436 bx = elm_box_add(win);
3361 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0); 3437 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
@@ -3440,6 +3516,55 @@ _status_config_scrolling(Evas_Object *win,
3440 evas_object_smart_callback_add(sl, "changed", zf_round, NULL); 3516 evas_object_smart_callback_add(sl, "changed", zf_round, NULL);
3441 evas_object_smart_callback_add(sl, "delay,changed", zf_change, NULL); 3517 evas_object_smart_callback_add(sl, "delay,changed", zf_change, NULL);
3442 3518
3519 /* Enable Scroll Bounce */
3520 CHECK_ADD("Enable smooth start",
3521 "Set whether scrollers start smoothly on thumb<br/>"
3522 "scroll",
3523 ss_change, NULL);
3524 evas_object_data_set(win, "scroll_smooth_start", ck);
3525 elm_check_state_set(ck, elm_config_scroll_thumbscroll_smooth_start_get());
3526
3527 /* Scroll Smooth Amount */
3528 LABEL_FRAME_ADD("<hilight>Scroll Smooth Amount</>");
3529
3530 sl = elm_slider_add(win);
3531 elm_object_tooltip_text_set(sl, "This is the amount smoothing to apply<br/>"
3532 "to thumbscroll to avoid jerky input");
3533 evas_object_data_set(win, "scroll_smooth_amount", sl);
3534 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
3535 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
3536 elm_slider_span_size_set(sl, 120);
3537 elm_slider_unit_format_set(sl, "%1.2f");
3538 elm_slider_indicator_format_set(sl, "%1.2f");
3539 elm_slider_min_max_set(sl, 0.0, 1.0);
3540 elm_slider_value_set(sl, elm_config_scroll_thumbscroll_smooth_amount_get());
3541 elm_box_pack_end(bx, sl);
3542 evas_object_show(sl);
3543
3544 evas_object_smart_callback_add(sl, "changed", smooth_round, NULL);
3545 evas_object_smart_callback_add(sl, "delay,changed", smooth_change, NULL);
3546
3547 /* Scroll Smooth Time Window */
3548 LABEL_FRAME_ADD("<hilight>Scroll Smooth Amount</>");
3549
3550 sl = elm_slider_add(win);
3551 elm_object_tooltip_text_set(sl, "This is the amount smoothing to apply<br/>"
3552 "to thumbscroll to avoid jerky input");
3553 evas_object_data_set(win, "scroll_smooth_time_window", sl);
3554 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
3555 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
3556 elm_slider_span_size_set(sl, 120);
3557 elm_slider_unit_format_set(sl, "%1.2f");
3558 elm_slider_indicator_format_set(sl, "%1.2f");
3559 elm_slider_min_max_set(sl, 0.0, 1.0);
3560 elm_slider_value_set(sl, elm_config_scroll_thumbscroll_smooth_time_window_get());
3561 elm_box_pack_end(bx, sl);
3562 evas_object_show(sl);
3563
3564 evas_object_smart_callback_add(sl, "changed", smooth_win_round, NULL);
3565 evas_object_smart_callback_add(sl, "delay,changed", smooth_win_change, NULL);
3566
3567
3443 evas_object_data_set(win, "scrolling", sc); 3568 evas_object_data_set(win, "scrolling", sc);
3444 3569
3445 elm_naviframe_item_simple_push(naviframe, sc); 3570 elm_naviframe_item_simple_push(naviframe, sc);
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index d65c7ab56..afb569d6d 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -343,10 +343,10 @@ _desc_init(void)
343 ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE); 343 ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
344 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_enable, T_UCHAR); 344 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_enable, T_UCHAR);
345 ELM_CONFIG_VAL(D, T, scroll_smooth_start_enable, T_UCHAR); 345 ELM_CONFIG_VAL(D, T, scroll_smooth_start_enable, T_UCHAR);
346 ELM_CONFIG_VAL(D, T, scroll_smooth_time_interval, T_DOUBLE); 346// ELM_CONFIG_VAL(D, T, scroll_smooth_time_interval, T_DOUBLE); // not used anymore
347 ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE); 347 ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE);
348 ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE); 348// ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE); // not used anymore
349 ELM_CONFIG_VAL(D, T, scroll_smooth_future_time, T_DOUBLE); 349// ELM_CONFIG_VAL(D, T, scroll_smooth_future_time, T_DOUBLE); // not used anymore
350 ELM_CONFIG_VAL(D, T, scroll_smooth_time_window, T_DOUBLE); 350 ELM_CONFIG_VAL(D, T, scroll_smooth_time_window, T_DOUBLE);
351 ELM_CONFIG_VAL(D, T, scale, T_DOUBLE); 351 ELM_CONFIG_VAL(D, T, scale, T_DOUBLE);
352 ELM_CONFIG_VAL(D, T, bgpixmap, T_INT); 352 ELM_CONFIG_VAL(D, T, bgpixmap, T_INT);
@@ -1373,12 +1373,12 @@ _config_load(void)
1373 _elm_config->zoom_friction = 0.5; 1373 _elm_config->zoom_friction = 0.5;
1374 _elm_config->thumbscroll_border_friction = 0.5; 1374 _elm_config->thumbscroll_border_friction = 0.5;
1375 _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 1375 _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
1376 _elm_config->scroll_smooth_start_enable = EINA_FALSE; 1376 _elm_config->scroll_smooth_start_enable = EINA_TRUE;
1377 _elm_config->scroll_smooth_time_interval = 0.008; 1377// _elm_config->scroll_smooth_time_interval = 0.008; // not used anymore
1378 _elm_config->scroll_smooth_amount = 1.0; 1378 _elm_config->scroll_smooth_amount = 1.0;
1379 _elm_config->scroll_smooth_history_weight = 0.3; 1379// _elm_config->scroll_smooth_history_weight = 0.3; // not used anymore
1380 _elm_config->scroll_smooth_future_time = 0.0; 1380// _elm_config->scroll_smooth_future_time = 0.0; // not used anymore
1381 _elm_config->scroll_smooth_time_window = 0.2; 1381 _elm_config->scroll_smooth_time_window = 0.15;
1382 _elm_config->scale = 1.0; 1382 _elm_config->scale = 1.0;
1383 _elm_config->bgpixmap = 0; 1383 _elm_config->bgpixmap = 0;
1384 _elm_config->compositing = 1; 1384 _elm_config->compositing = 1;
@@ -1930,14 +1930,14 @@ _env_get(void)
1930 } 1930 }
1931 s = getenv("ELM_SCROLL_SMOOTH_START_ENABLE"); 1931 s = getenv("ELM_SCROLL_SMOOTH_START_ENABLE");
1932 if (s) _elm_config->scroll_smooth_start_enable = !!atoi(s); 1932 if (s) _elm_config->scroll_smooth_start_enable = !!atoi(s);
1933 s = getenv("ELM_SCROLL_SMOOTH_TIME_INTERVAL"); 1933// s = getenv("ELM_SCROLL_SMOOTH_TIME_INTERVAL"); // not used anymore
1934 if (s) _elm_config->scroll_smooth_time_interval = atof(s); 1934// if (s) _elm_config->scroll_smooth_time_interval = atof(s); // not used anymore
1935 s = getenv("ELM_SCROLL_SMOOTH_AMOUNT"); 1935 s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
1936 if (s) _elm_config->scroll_smooth_amount = _elm_atof(s); 1936 if (s) _elm_config->scroll_smooth_amount = _elm_atof(s);
1937 s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT"); 1937// s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT"); // not used anymore
1938 if (s) _elm_config->scroll_smooth_history_weight = _elm_atof(s); 1938// if (s) _elm_config->scroll_smooth_history_weight = _elm_atof(s); // not used anymore
1939 s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME"); 1939// s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME"); // not used anymore
1940 if (s) _elm_config->scroll_smooth_future_time = _elm_atof(s); 1940// if (s) _elm_config->scroll_smooth_future_time = _elm_atof(s); // not used anymore
1941 s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW"); 1941 s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW");
1942 if (s) _elm_config->scroll_smooth_time_window = _elm_atof(s); 1942 if (s) _elm_config->scroll_smooth_time_window = _elm_atof(s);
1943 s = getenv("ELM_FOCUS_AUTOSCROLL_MODE"); 1943 s = getenv("ELM_FOCUS_AUTOSCROLL_MODE");
@@ -2886,6 +2886,46 @@ elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction)
2886 _elm_config->thumbscroll_sensitivity_friction = friction; 2886 _elm_config->thumbscroll_sensitivity_friction = friction;
2887} 2887}
2888 2888
2889EAPI Eina_Bool
2890elm_config_scroll_thumbscroll_smooth_start_get(void)
2891{
2892 return _elm_config->scroll_smooth_start_enable;
2893}
2894
2895EAPI void
2896elm_config_scroll_thumbscroll_smooth_start_set(Eina_Bool enable)
2897{
2898 _elm_config->scroll_smooth_start_enable = enable;
2899}
2900
2901EAPI void
2902elm_config_scroll_thumbscroll_smooth_amount_set(double amount)
2903{
2904 if (amount < 0.0) amount = 0.0;
2905 if (amount > 1.0) amount = 1.0;
2906 _elm_config->scroll_smooth_amount = amount;
2907}
2908
2909EAPI double
2910elm_config_scroll_thumbscroll_smooth_amount_get(void)
2911{
2912 return _elm_config->scroll_smooth_amount;
2913}
2914
2915EAPI void
2916elm_config_scroll_thumbscroll_smooth_time_window_set(double amount)
2917{
2918 if (amount < 0.0) amount = 0.0;
2919 if (amount > 1.0) amount = 1.0;
2920 _elm_config->scroll_smooth_time_window = amount;
2921}
2922
2923EAPI double
2924elm_config_scroll_thumbscroll_smooth_time_window_get(void)
2925{
2926 return _elm_config->scroll_smooth_time_window;
2927}
2928
2889EAPI double 2929EAPI double
2890elm_config_scroll_thumbscroll_acceleration_threshold_get(void) 2930elm_config_scroll_thumbscroll_acceleration_threshold_get(void)
2891{ 2931{
diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h
index 9aa11198c..8719d6549 100644
--- a/src/lib/elm_config.h
+++ b/src/lib/elm_config.h
@@ -490,6 +490,90 @@ EAPI double elm_config_scroll_thumbscroll_sensitivity_friction_get(void);
490EAPI void elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction); 490EAPI void elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction);
491 491
492/** 492/**
493 * Get the smooth start mode for scrolling with your finger
494 *
495 * @return smooth scroll flag
496 *
497 * @see elm_config_scroll_thumbscroll_smooth_start_set()
498 *
499 * @since 1.16
500 * @ingroup Scrolling
501 */
502EAPI Eina_Bool elm_config_scroll_thumbscroll_smooth_start_get(void);
503
504/**
505 * Set the smooth start mode for scrolling with your finger
506 *
507 * This enabled finger scrolling to scroll from the currunt point rather than
508 * jumping and playing catch-up to make start of scrolling look smoother once
509 * the finger or mouse goes past the threshold.
510 *
511 * @param enable The enabled state of the smooth scroller
512 *
513 * @see elm_config_scroll_thumbscroll_smooth_start_get()
514 *
515 * @since 1.16
516 * @ingroup Scrolling
517 */
518EAPI void elm_config_scroll_thumbscroll_smooth_start_set(Eina_Bool enable);
519
520/**
521 * Get the amount of smoothing to apply to scrolling
522 *
523 * @return the amount of smoothing to apply from 0.0 to 1.0
524 *
525 * @see elm_config_scroll_thumbscroll_smooth_amount_set()
526 *
527 * @since 1.16
528 * @ingroup Scrolling
529 */
530EAPI double elm_config_scroll_thumbscroll_smooth_amount_get(void);
531
532/**
533 * Set the amount of smoothing to apply to scrolling
534 *
535 * Scrolling with your finger can be smoothed out and the amount to smooth
536 * is determined by this parameter. 0.0 means to not smooth at all and
537 * 1.0 is to smoth as much as possible.
538 *
539 * @param the amount to smooth from 0.0 to 1.0 with 0.0 being none
540 *
541 * @see elm_config_thumbscroll_acceleration_threshold_set()
542 *
543 * @since 1.16
544 * @ingroup Scrolling
545 */
546EAPI void elm_config_scroll_thumbscroll_smooth_amount_set(double amount);
547
548/**
549 * Get the time window to look back at for events for smoothing
550 *
551 * @return the time window in seconds (between 0.0 and 1.0)
552 *
553 * @see elm_config_scroll_thumbscroll_smooth_time_window_set()
554 *
555 * @since 1.16
556 * @ingroup Scrolling
557 */
558EAPI double elm_config_scroll_thumbscroll_smooth_time_window_get(void);
559
560/**
561 * Set the time window to look back at for events for smoothing
562 *
563 * Scrolling with your finger can be smoothed out and the window of time
564 * to look at is determined by this config. The value is in seconds and
565 * is from 0.0 to 1.0
566 *
567 * @param the time window in seconds (between 0.0 and 1.0)
568 *
569 * @see elm_config_scroll_thumbscroll_smooth_time_window_get()
570 *
571 * @since 1.16
572 * @ingroup Scrolling
573 */
574EAPI void elm_config_scroll_thumbscroll_smooth_time_window_set(double amount);
575
576/**
493 * Get the minimum speed of mouse cursor movement which will accelerate 577 * Get the minimum speed of mouse cursor movement which will accelerate
494 * scrolling velocity after a mouse up event 578 * scrolling velocity after a mouse up event
495 * (pixels/second). 579 * (pixels/second).
diff --git a/src/lib/elm_interface_scrollable.c b/src/lib/elm_interface_scrollable.c
index 77763ab1f..fa24d67ea 100644
--- a/src/lib/elm_interface_scrollable.c
+++ b/src/lib/elm_interface_scrollable.c
@@ -2964,12 +2964,17 @@ _elm_scroll_hold_enterer(void *data)
2964 2964
2965 fx = sid->down.hold_x; 2965 fx = sid->down.hold_x;
2966 fy = sid->down.hold_y; 2966 fy = sid->down.hold_y;
2967// printf("%1.5f %i ",
2968// ecore_loop_time_get() - sid->down.dragged_began_timestamp,
2969// fy);
2967 2970
2968 if (_elm_config->scroll_smooth_amount > 0.0) 2971 if ((_elm_config->scroll_smooth_amount > 0.0) &&
2972 (_elm_config->scroll_smooth_time_window > 0.0))
2969 { 2973 {
2970 int i, count = 0; 2974 int i, count = 0;
2971 Evas_Coord basex = 0, basey = 0, x, y; 2975 Evas_Coord basex = 0, basey = 0, x, y;
2972 double dt, t, tdiff, tnow, twin; 2976 double dt, t, tdiff, tnow, twin;
2977 double xx, yy, tot;
2973 struct 2978 struct
2974 { 2979 {
2975 Evas_Coord x, y, dx, dy; 2980 Evas_Coord x, y, dx, dy;
@@ -2977,76 +2982,61 @@ _elm_scroll_hold_enterer(void *data)
2977 } pos[60]; 2982 } pos[60];
2978 2983
2979 tdiff = sid->down.hist.est_timestamp_diff; 2984 tdiff = sid->down.hist.est_timestamp_diff;
2980 tnow = ecore_time_get() - tdiff; 2985 tnow = ecore_loop_time_get();
2981 t = tnow; 2986 t = tnow;
2982 twin = _elm_config->scroll_smooth_time_window; 2987 twin = _elm_config->scroll_smooth_time_window;
2983 for (i = 0; i < 60; i++) 2988 for (i = 0; i < 60; i++)
2984 { 2989 {
2985 if (sid->down.history[i].timestamp > 2990 if ((sid->down.history[i].timestamp - tdiff) > tnow)
2986 sid->down.dragged_began_timestamp) 2991 {
2992 continue;
2993 }
2994 if ((sid->down.history[i].timestamp >
2995 sid->down.dragged_began_timestamp) || (count == 0))
2987 { 2996 {
2988 // oldest point is sd->down.history[i]
2989 // newset is sd->down.history[0]
2990 dt = t - sid->down.history[i].timestamp;
2991 if (dt > twin)
2992 {
2993 i--;
2994 count--;
2995 break;
2996 }
2997 x = sid->down.history[i].x; 2997 x = sid->down.history[i].x;
2998 y = sid->down.history[i].y; 2998 y = sid->down.history[i].y;
2999 _elm_scroll_down_coord_eval(sid, &x, &y);
3000 if (i == 0) 2999 if (i == 0)
3001 { 3000 {
3002 basex = x; 3001 basex = x;
3003 basey = y; 3002 basey = y;
3004 } 3003 }
3004 dt = t - sid->down.history[i].timestamp;
3005 if ((dt > twin) && (count > 0)) break;
3006 _elm_scroll_down_coord_eval(sid, &x, &y);
3005 pos[i].x = x - basex; 3007 pos[i].x = x - basex;
3006 pos[i].y = y - basey; 3008 pos[i].y = y - basey;
3007 pos[i].t = sid->down.history[i].timestamp - sid->down.history[0].timestamp; 3009 pos[i].t = sid->down.history[0].timestamp - sid->down.history[i].timestamp;
3008 count++; 3010 count++;
3009 } 3011 }
3010 } 3012 }
3011 if (count >= 2) 3013 if (count > 0)
3012 { 3014 {
3013 double dtsum = 0.0, tadd, maxdt; 3015 xx = 0.0;
3014 double dxsum = 0.0, dysum = 0.0, xsum = 0.0, ysum = 0.0; 3016 yy = 0.0;
3015 for (i = 0; i < (count - 1); i++) 3017 tot = 0.0;
3018 for (i = 0; i < count; i++)
3016 { 3019 {
3017 pos[i].dx = pos[i].x - pos[i + 1].x; 3020 double wt = (twin - pos[i].t) / twin;
3018 pos[i].dy = pos[i].y - pos[i + 1].y; 3021
3019 pos[i].dt = pos[i].t - pos[i + 1].t; 3022 xx += ((double)(pos[i].x)) * wt;
3020 dxsum += pos[i].dx; 3023 yy += ((double)(pos[i].y)) * wt;
3021 dysum += pos[i].dy; 3024 tot += wt;
3022 dtsum += pos[i].dt;
3023 xsum += pos[i].x;
3024 ysum += pos[i].y;
3025 } 3025 }
3026 maxdt = pos[i].t; 3026 if (tot > 0.0)
3027 dxsum /= (double)i;
3028 dysum /= (double)i;
3029 dtsum /= (double)i;
3030 if (dtsum > 0)
3031 { 3027 {
3032 xsum /= (double)i; 3028 xx = basex + (xx / tot);
3033 ysum /= (double)i; 3029 yy = basey + (yy / tot);
3034 tadd = tnow - sid->down.history[0].timestamp + _elm_config->scroll_smooth_future_time; 3030 fx =
3035 tadd = tadd - (maxdt / 2); 3031 (_elm_config->scroll_smooth_amount * xx) +
3036#define WEIGHT(n, o, v) n = (((double)o * (1.0 - v)) + ((double)n * v)) 3032 ((1.0 - _elm_config->scroll_smooth_amount) * fx);
3037 WEIGHT(tadd, sid->down.hist.tadd, _elm_config->scroll_smooth_history_weight); 3033 fy =
3038 WEIGHT(dxsum, sid->down.hist.dxsum, _elm_config->scroll_smooth_history_weight); 3034 (_elm_config->scroll_smooth_amount * yy) +
3039 WEIGHT(dysum, sid->down.hist.dysum, _elm_config->scroll_smooth_history_weight); 3035 ((1.0 - _elm_config->scroll_smooth_amount) * fy);
3040 fx = basex + xsum + ((dxsum * tadd) / dtsum);
3041 fy = basey + ysum + ((dysum * tadd) / dtsum);
3042 sid->down.hist.tadd = tadd;
3043 sid->down.hist.dxsum = dxsum;
3044 sid->down.hist.dysum = dysum;
3045 WEIGHT(fx, sid->down.hold_x, _elm_config->scroll_smooth_amount);
3046 WEIGHT(fy, sid->down.hold_y, _elm_config->scroll_smooth_amount);
3047 } 3036 }
3048 } 3037 }
3049 } 3038 }
3039// printf("%i\n", fy);
3050 3040
3051 eo_do(sid->obj, elm_interface_scrollable_content_pos_get(&ox, &oy)); 3041 eo_do(sid->obj, elm_interface_scrollable_content_pos_get(&ox, &oy));
3052 if (sid->down.dir_x) 3042 if (sid->down.dir_x)
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index 0b03d54ab..48f2267b7 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -204,10 +204,10 @@ struct _Elm_Config
204 double thumbscroll_border_friction; 204 double thumbscroll_border_friction;
205 double thumbscroll_sensitivity_friction; 205 double thumbscroll_sensitivity_friction;
206 unsigned char scroll_smooth_start_enable; 206 unsigned char scroll_smooth_start_enable;
207 double scroll_smooth_time_interval; 207// double scroll_smooth_time_interval;; // not used anymore
208 double scroll_smooth_amount; 208 double scroll_smooth_amount;
209 double scroll_smooth_history_weight; 209// double scroll_smooth_history_weight;; // not used anymore
210 double scroll_smooth_future_time; 210// double scroll_smooth_future_time;; // not used anymore
211 double scroll_smooth_time_window; 211 double scroll_smooth_time_window;
212 double scale; 212 double scale;
213 int bgpixmap; 213 int bgpixmap;