From 0bde066596a87aa2db1fbb2d2ccf3e117929b941 Mon Sep 17 00:00:00 2001 From: Jaehwan Kim Date: Tue, 30 Apr 2013 16:46:59 +0900 Subject: [PATCH] Add the config elm_scroll_smooth_start_enable. There's no tick when scroller starts scroll if it's set. --- legacy/elementary/ChangeLog | 5 ++ legacy/elementary/NEWS | 1 + legacy/elementary/config/default/base.src | 1 + legacy/elementary/config/mobile/base.src | 1 + legacy/elementary/config/standard/base.src | 1 + legacy/elementary/src/lib/elm_config.c | 4 ++ .../src/lib/elm_interface_scrollable.c | 56 ++++++++++++------- .../src/lib/elm_interface_scrollable.h | 1 + legacy/elementary/src/lib/elm_priv.h | 1 + 9 files changed, 51 insertions(+), 20 deletions(-) diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog index ef59b77065..fab69bdb62 100644 --- a/legacy/elementary/ChangeLog +++ b/legacy/elementary/ChangeLog @@ -1302,3 +1302,8 @@ 2013-04-29 ChunEon Park (Hermet) * Fix toolbar item clipped problem on reordering toolbar item. + +2013-04-30 Jaehwan Kim + + * Add the config elm_scroll_smooth_start_enable. + There's no tick when scroller starts scroll if it's set. diff --git a/legacy/elementary/NEWS b/legacy/elementary/NEWS index 76880ec2d4..6a1c4b63a5 100644 --- a/legacy/elementary/NEWS +++ b/legacy/elementary/NEWS @@ -64,6 +64,7 @@ Additions: * Add elm_access_action(), elm_access_action_cb_set() * Add elm_object_domain_part_text_translatable_set(), elm_object_item_domain_part_text_translatable_set(). * Support language,changed callback (Fileselector_Button, Fileselector Entry, Spinner. + * Add the config elm_scroll_smooth_start_enable. Improvements: diff --git a/legacy/elementary/config/default/base.src b/legacy/elementary/config/default/base.src index 8177b3c1bb..3b396b67cb 100644 --- a/legacy/elementary/config/default/base.src +++ b/legacy/elementary/config/default/base.src @@ -17,6 +17,7 @@ group "Elm_Config" struct { value "zoom_friction" double: 0.5; value "thumbscroll_border_friction" double: 0.5; value "thumbscroll_sensitivity_friction" double: 0.25; + value "scroll_smooth_start_enable" uchar: 0; value "scroll_smooth_time_interval" double: 0.0; value "scroll_smooth_amount" double: 0.0; value "scroll_smooth_history_weight" double: 0.1; diff --git a/legacy/elementary/config/mobile/base.src b/legacy/elementary/config/mobile/base.src index 9037022cab..ea10161fc5 100644 --- a/legacy/elementary/config/mobile/base.src +++ b/legacy/elementary/config/mobile/base.src @@ -17,6 +17,7 @@ group "Elm_Config" struct { value "zoom_friction" double: 0.5; value "thumbscroll_border_friction" double: 0.5; value "thumbscroll_sensitivity_friction" double: 0.25; + value "scroll_smooth_start_enable" uchar: 1; value "scroll_smooth_time_interval" double: 0; value "scroll_smooth_amount" double: 1.0; value "scroll_smooth_history_weight" double: 0.1; diff --git a/legacy/elementary/config/standard/base.src b/legacy/elementary/config/standard/base.src index 8bd1a18276..65ea0801d7 100644 --- a/legacy/elementary/config/standard/base.src +++ b/legacy/elementary/config/standard/base.src @@ -17,6 +17,7 @@ group "Elm_Config" struct { value "zoom_friction" double: 0.5; value "thumbscroll_border_friction" double: 0.5; value "thumbscroll_sensitivity_friction" double: 0.25; + value "scroll_smooth_start_enable" uchar: 0; value "scroll_smooth_time_interval" double: 0.0; value "scroll_smooth_amount" double: 0.0; value "scroll_smooth_history_weight" double: 0.1; diff --git a/legacy/elementary/src/lib/elm_config.c b/legacy/elementary/src/lib/elm_config.c index 51ea0ee710..53eea72b17 100644 --- a/legacy/elementary/src/lib/elm_config.c +++ b/legacy/elementary/src/lib/elm_config.c @@ -364,6 +364,7 @@ _desc_init(void) ELM_CONFIG_VAL(D, T, bring_in_scroll_friction, T_DOUBLE); 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_smooth_time_interval, T_DOUBLE); ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE); ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE); @@ -1073,6 +1074,7 @@ _config_load(void) _elm_config->zoom_friction = 0.5; _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_FALSE; _elm_config->scroll_smooth_time_interval = 0.008; _elm_config->scroll_smooth_amount = 1.0; _elm_config->scroll_smooth_history_weight = 0.3; @@ -1521,6 +1523,8 @@ _env_get(void) _elm_config->thumbscroll_sensitivity_friction = friction; } + s = getenv("ELM_SCROLL_SMOOTH_START_ENABLE"); + if (s) _elm_config->scroll_smooth_start_enable = !!atoi(s); s = getenv("ELM_SCROLL_SMOOTH_TIME_INTERVAL"); if (s) _elm_config->scroll_smooth_time_interval = atof(s); s = getenv("ELM_SCROLL_SMOOTH_AMOUNT"); diff --git a/legacy/elementary/src/lib/elm_interface_scrollable.c b/legacy/elementary/src/lib/elm_interface_scrollable.c index 7883027f49..e283f97fc2 100644 --- a/legacy/elementary/src/lib/elm_interface_scrollable.c +++ b/legacy/elementary/src/lib/elm_interface_scrollable.c @@ -2638,6 +2638,7 @@ _elm_scroll_mouse_down_event_cb(void *data, #else sid->down.history[0].timestamp = ecore_loop_time_get(); #endif + sid->down.dragged_began_timestamp = sid->down.history[0].timestamp; sid->down.history[0].x = ev->canvas.x; sid->down.history[0].y = ev->canvas.y; } @@ -2817,27 +2818,31 @@ _elm_scroll_hold_animator(void *data) twin = _elm_config->scroll_smooth_time_window; for (i = 0; i < 60; i++) { - // oldest point is sd->down.history[i] - // newset is sd->down.history[0] - dt = t - sid->down.history[i].timestamp; - if (dt > twin) + if (sid->down.history[i].timestamp > + sid->down.dragged_began_timestamp) { - i--; - break; + // oldest point is sd->down.history[i] + // newset is sd->down.history[0] + dt = t - sid->down.history[i].timestamp; + if (dt > twin) + { + i--; + break; + } + x = sid->down.history[i].x; + y = sid->down.history[i].y; + _elm_scroll_down_coord_eval(sid, &x, &y); + if (i == 0) + { + basex = x; + basey = y; + } + pos[i].x = x - basex; + pos[i].y = y - basey; + pos[i].t = sid->down.history[i].timestamp - sid->down.history[0].timestamp; + count++; } - x = sid->down.history[i].x; - y = sid->down.history[i].y; - _elm_scroll_down_coord_eval(sid, &x, &y); - if (i == 0) - { - basex = x; - basey = y; - } - pos[i].x = x - basex; - pos[i].y = y - basey; - pos[i].t = sid->down.history[i].timestamp - sid->down.history[0].timestamp; - count++; - } + } count = i; if (count >= 2) { @@ -3081,8 +3086,19 @@ _elm_scroll_mouse_move_event_cb(void *data, if ((sid->down.dragged) || (((x * x) + (y * y)) > (_elm_config->thumbscroll_threshold * - _elm_config->thumbscroll_threshold))) + _elm_config->thumbscroll_threshold))) { + if (!sid->down.dragged_began && + _elm_config->scroll_smooth_start_enable) + { + sid->down.x = ev->cur.canvas.x; + sid->down.y = ev->cur.canvas.y; +#ifdef EVTIME + sid->down.dragged_began_timestamp = ev->timestamp / 1000.0; +#else + sid->down.dragged_began_timestamp = ecore_loop_time_get(); +#endif + } sid->down.dragged_began = EINA_TRUE; if (!sid->down.dragged) { diff --git a/legacy/elementary/src/lib/elm_interface_scrollable.h b/legacy/elementary/src/lib/elm_interface_scrollable.h index 48d987137a..bee2229d70 100644 --- a/legacy/elementary/src/lib/elm_interface_scrollable.h +++ b/legacy/elementary/src/lib/elm_interface_scrollable.h @@ -1001,6 +1001,7 @@ struct _Elm_Scrollable_Smart_Interface_Data double est_timestamp_diff; } hist; + double dragged_began_timestamp; double anim_start; double anim_start2; double anim_start3; diff --git a/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h index dd4481add9..6f5d279514 100644 --- a/legacy/elementary/src/lib/elm_priv.h +++ b/legacy/elementary/src/lib/elm_priv.h @@ -172,6 +172,7 @@ struct _Elm_Config unsigned char thumbscroll_bounce_enable; double thumbscroll_border_friction; double thumbscroll_sensitivity_friction; + unsigned char scroll_smooth_start_enable; double scroll_smooth_time_interval; double scroll_smooth_amount; double scroll_smooth_history_weight;