Change the method to calculate a distance which be scrolled from linear to sine curve.

And add the configuration thumbscroll_flick_distance_tolerance. It's the max flick distance.
This commit is contained in:
Jaehwan Kim 2013-07-03 18:43:19 +09:00
parent 3b9e0357a6
commit 504f59f174
10 changed files with 118 additions and 3 deletions

View File

@ -1482,3 +1482,8 @@
* added callback call "scroll", "scroll,anim,start", "scroll,anim,stop", "scroll,drag,start", "scroll,drag,stop" * added callback call "scroll", "scroll,anim,start", "scroll,anim,stop", "scroll,drag,start", "scroll,drag,stop"
in toolar widget. in toolar widget.
2013-07-03 Jaehwan Kim
* Change the method to calculate a distance which be scrolled from linear to sine curve.
And add the configuration thumbscroll_flick_distance_tolerance. It's the max flick distance.

View File

@ -78,6 +78,7 @@ Additions:
* Add elm_fileselector_mime_type_filter_append and elm_fileselector_filters_clear to support mime type filter. * Add elm_fileselector_mime_type_filter_append and elm_fileselector_filters_clear to support mime type filter.
* Add the elm_scrollable_interface_content_viewport_resize_cb_set. * Add the elm_scrollable_interface_content_viewport_resize_cb_set.
* added callback call "scroll", "scroll,anim,start", "scroll,anim,stop", "scroll,drag,start", "scroll,drag,stop" in toolar widget. * added callback call "scroll", "scroll,anim,start", "scroll,anim,stop", "scroll,drag,start", "scroll,drag,stop" in toolar widget.
* Add the configuration thumbscroll_flick_distance_tolerance.
Improvements: Improvements:
@ -119,6 +120,7 @@ Improvements:
* Support language change for widget items (Ctxpopup, Hoversel, Naviframe, Diskselector, List, Menu, Segment_Control, Toolbar, Popup, MultibuttonEntry) * Support language change for widget items (Ctxpopup, Hoversel, Naviframe, Diskselector, List, Menu, Segment_Control, Toolbar, Popup, MultibuttonEntry)
* Move cursor when mouse moves with longpress. * Move cursor when mouse moves with longpress.
* Show magnifier when selection handlers are pressed or moved. * Show magnifier when selection handlers are pressed or moved.
* Change the method to calculate a distance which be scrolled from linear to sine curve.
Fixes: Fixes:
* Now elm_datetime_field_limit_set() can set year limits wihtout problems. * Now elm_datetime_field_limit_set() can set year limits wihtout problems.

View File

@ -6,6 +6,7 @@ group "Elm_Config" struct {
value "thumbscroll_threshold" int: 24; value "thumbscroll_threshold" int: 24;
value "thumbscroll_hold_threshold" int: 24; value "thumbscroll_hold_threshold" int: 24;
value "thumbscroll_momentum_threshold" double: 100.0; value "thumbscroll_momentum_threshold" double: 100.0;
value "thumbscroll_flick_distance_tolerance" int: 1000;
value "thumbscroll_friction" double: 1.0; value "thumbscroll_friction" double: 1.0;
value "thumbscroll_min_friction" double: 1.0; value "thumbscroll_min_friction" double: 1.0;
value "thumbscroll_friction_standard" double: 2000.0; value "thumbscroll_friction_standard" double: 2000.0;

View File

@ -6,6 +6,7 @@ group "Elm_Config" struct {
value "thumbscroll_threshold" int: 24; value "thumbscroll_threshold" int: 24;
value "thumbscroll_hold_threshold" int: 100; value "thumbscroll_hold_threshold" int: 100;
value "thumbscroll_momentum_threshold" double: 100.0; value "thumbscroll_momentum_threshold" double: 100.0;
value "thumbscroll_flick_distance_tolerance" int: 1000;
value "thumbscroll_friction" double: 1.0; value "thumbscroll_friction" double: 1.0;
value "thumbscroll_min_friction" double: 0.3; value "thumbscroll_min_friction" double: 0.3;
value "thumbscroll_friction_standard" double: 3000.0; value "thumbscroll_friction_standard" double: 3000.0;

View File

@ -6,6 +6,7 @@ group "Elm_Config" struct {
value "thumbscroll_threshold" int: 4; value "thumbscroll_threshold" int: 4;
value "thumbscroll_hold_threshold" int: 4; value "thumbscroll_hold_threshold" int: 4;
value "thumbscroll_momentum_threshold" double: 100.0; value "thumbscroll_momentum_threshold" double: 100.0;
value "thumbscroll_flick_distance_tolerance" int: 1000;
value "thumbscroll_friction" double: 1.0; value "thumbscroll_friction" double: 1.0;
value "thumbscroll_min_friction" double: 1.0; value "thumbscroll_min_friction" double: 1.0;
value "thumbscroll_friction_standard" double: 2000.0; value "thumbscroll_friction_standard" double: 2000.0;

View File

@ -346,6 +346,31 @@ tsmt_change(void *data __UNUSED__,
elm_config_all_flush(); elm_config_all_flush();
} }
static void
tsfdt_round(void *data __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
double val = elm_slider_value_get(obj);
double v;
v = ((double)((int)(val * 10.0))) / 10.0;
if (v != val) elm_slider_value_set(obj, v);
}
static void
tsfdt_change(void *data __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
double tsfdt = elm_config_scroll_thumbscroll_flick_distance_tolerance_get();
double val = elm_slider_value_get(obj);
if (tsfdt == val) return;
elm_config_scroll_thumbscroll_flick_distance_tolerance_set(val);
elm_config_all_flush();
}
static void static void
tsf_round(void *data __UNUSED__, tsf_round(void *data __UNUSED__,
Evas_Object *obj, Evas_Object *obj,
@ -1122,7 +1147,8 @@ _config_display_update(Evas_Object *win)
{ {
int flush_interval, font_c, image_c, edje_file_c, edje_col_c, ts_threshould, int flush_interval, font_c, image_c, edje_file_c, edje_col_c, ts_threshould,
ts_hold_threshold; ts_hold_threshold;
double scale, s_bounce_friction, ts_momentum_threshold, ts_friction, double scale, s_bounce_friction, ts_momentum_threshold,
ts_flick_distance_tolerance, ts_friction,
ts_min_friction, ts_friction_standard, ts_border_friction, ts_min_friction, ts_friction_standard, ts_border_friction,
ts_sensitivity_friction, ts_acceleration_threshold, ts_sensitivity_friction, ts_acceleration_threshold,
ts_acceleration_time_limit, ts_acceleration_weight, page_friction, ts_acceleration_time_limit, ts_acceleration_weight, page_friction,
@ -1148,6 +1174,7 @@ _config_display_update(Evas_Object *win)
ts_threshould = elm_config_scroll_thumbscroll_threshold_get(); ts_threshould = elm_config_scroll_thumbscroll_threshold_get();
ts_hold_threshold = elm_config_scroll_thumbscroll_hold_threshold_get(); ts_hold_threshold = elm_config_scroll_thumbscroll_hold_threshold_get();
ts_momentum_threshold = elm_config_scroll_thumbscroll_momentum_threshold_get(); ts_momentum_threshold = elm_config_scroll_thumbscroll_momentum_threshold_get();
ts_flick_distance_tolerance = elm_config_scroll_thumbscroll_flick_distance_tolerance_get();
ts_friction = elm_config_scroll_thumbscroll_friction_get(); ts_friction = elm_config_scroll_thumbscroll_friction_get();
ts_min_friction = elm_config_scroll_thumbscroll_min_friction_get(); ts_min_friction = elm_config_scroll_thumbscroll_min_friction_get();
ts_friction_standard = elm_config_scroll_thumbscroll_friction_standard_get(); ts_friction_standard = elm_config_scroll_thumbscroll_friction_standard_get();
@ -1191,6 +1218,9 @@ _config_display_update(Evas_Object *win)
elm_slider_value_set(evas_object_data_get(win, elm_slider_value_set(evas_object_data_get(win,
"ts_momentum_threshold_slider"), "ts_momentum_threshold_slider"),
ts_momentum_threshold); ts_momentum_threshold);
elm_slider_value_set(evas_object_data_get(win,
"ts_flick_distance_tolerance_slider"),
ts_flick_distance_tolerance);
elm_slider_value_set(evas_object_data_get(win, elm_slider_value_set(evas_object_data_get(win,
"ts_friction_slider"), "ts_friction_slider"),
ts_friction); ts_friction);
@ -2888,6 +2918,27 @@ _status_config_scrolling(Evas_Object *win,
evas_object_smart_callback_add(sl, "delay,changed", tsmt_change, evas_object_smart_callback_add(sl, "delay,changed", tsmt_change,
NULL); NULL);
LABEL_FRAME_ADD("<hilight>Thumb scroll flick distance tolerance</>");
sl = elm_slider_add(win);
elm_object_tooltip_text_set(sl, "This is the number of pixels the maximum<br/>"
"distance which can be flicked. If it is<br/>"
"flicked more than this, the flick distance<br/>"
"is same with maximum distance");
evas_object_data_set(win, "ts_flick_distance_tolerance_slider", 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.0f pixels");
elm_slider_indicator_format_set(sl, "%1.0f");
elm_slider_min_max_set(sl, 100.0, 3000.0);
elm_slider_value_set(sl, elm_config_scroll_thumbscroll_flick_distance_tolerance_get());
elm_box_pack_end(bx, sl);
evas_object_show(sl);
evas_object_smart_callback_add(sl, "changed", tsfdt_round, NULL);
evas_object_smart_callback_add(sl, "delay,changed", tsfdt_change, NULL);
LABEL_FRAME_ADD("<hilight>Thumb scroll friction</>"); LABEL_FRAME_ADD("<hilight>Thumb scroll friction</>");
sl = elm_slider_add(win); sl = elm_slider_add(win);

View File

@ -342,6 +342,7 @@ _desc_init(void)
ELM_CONFIG_VAL(D, T, thumbscroll_threshold, T_INT); ELM_CONFIG_VAL(D, T, thumbscroll_threshold, T_INT);
ELM_CONFIG_VAL(D, T, thumbscroll_hold_threshold, T_INT); ELM_CONFIG_VAL(D, T, thumbscroll_hold_threshold, T_INT);
ELM_CONFIG_VAL(D, T, thumbscroll_momentum_threshold, T_DOUBLE); ELM_CONFIG_VAL(D, T, thumbscroll_momentum_threshold, T_DOUBLE);
ELM_CONFIG_VAL(D, T, thumbscroll_flick_distance_tolerance, T_INT);
ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE); ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE);
ELM_CONFIG_VAL(D, T, thumbscroll_min_friction, T_DOUBLE); ELM_CONFIG_VAL(D, T, thumbscroll_min_friction, T_DOUBLE);
ELM_CONFIG_VAL(D, T, thumbscroll_friction_standard, T_DOUBLE); ELM_CONFIG_VAL(D, T, thumbscroll_friction_standard, T_DOUBLE);
@ -1085,6 +1086,7 @@ _config_load(void)
_elm_config->thumbscroll_threshold = 24; _elm_config->thumbscroll_threshold = 24;
_elm_config->thumbscroll_hold_threshold = 24; _elm_config->thumbscroll_hold_threshold = 24;
_elm_config->thumbscroll_momentum_threshold = 100.0; _elm_config->thumbscroll_momentum_threshold = 100.0;
_elm_config->thumbscroll_flick_distance_tolerance = 1000;
_elm_config->thumbscroll_friction = 1.0; _elm_config->thumbscroll_friction = 1.0;
_elm_config->thumbscroll_min_friction = 0.5; _elm_config->thumbscroll_min_friction = 0.5;
_elm_config->thumbscroll_friction_standard = 1000.0; _elm_config->thumbscroll_friction_standard = 1000.0;
@ -1507,6 +1509,8 @@ _env_get(void)
// FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0 // FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0
s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD"); s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD");
if (s) _elm_config->thumbscroll_momentum_threshold = _elm_atof(s); if (s) _elm_config->thumbscroll_momentum_threshold = _elm_atof(s);
s = getenv("ELM_THUMBSCROLL_FLICK_DISTANCE_TOLERANCE");
if (s) _elm_config->thumbscroll_flick_distance_tolerance = atoi(s);
s = getenv("ELM_THUMBSCROLL_FRICTION"); s = getenv("ELM_THUMBSCROLL_FRICTION");
if (s) _elm_config->thumbscroll_friction = _elm_atof(s); if (s) _elm_config->thumbscroll_friction = _elm_atof(s);
s = getenv("ELM_THUMBSCROLL_MIN_FRICTION"); s = getenv("ELM_THUMBSCROLL_MIN_FRICTION");
@ -2182,6 +2186,18 @@ elm_config_scroll_thumbscroll_momentum_threshold_set(double threshold)
_elm_config->thumbscroll_momentum_threshold = threshold; _elm_config->thumbscroll_momentum_threshold = threshold;
} }
EAPI unsigned int
elm_config_scroll_thumbscroll_flick_distance_tolerance_get(void)
{
return _elm_config->thumbscroll_flick_distance_tolerance;
}
EAPI void
elm_config_scroll_thumbscroll_flick_distance_tolerance_set(unsigned int distance)
{
_elm_config->thumbscroll_flick_distance_tolerance = distance;
}
EAPI double EAPI double
elm_config_scroll_thumbscroll_friction_get(void) elm_config_scroll_thumbscroll_friction_get(void)
{ {

View File

@ -349,6 +349,29 @@ EAPI double elm_config_scroll_thumbscroll_momentum_threshold_get(void);
*/ */
EAPI void elm_config_scroll_thumbscroll_momentum_threshold_set(double threshold); EAPI void elm_config_scroll_thumbscroll_momentum_threshold_set(double threshold);
/**
* Get the number of pixels the maximum distance which can be flicked.
* If it is flicked more than this,
* the flick distance is same with maximum distance.
*
* @return the thumb scroll maximum flick distance
*
* @ingroup Scrolling
*/
EAPI unsigned int elm_config_scroll_thumbscroll_flick_distance_tolerance_get(void);
/**
* Set the number of pixels the maximum distance which can be flicked.
* If it is flicked more than this,
* the flick distance is same with maximum distance.
*
* @param distance the thumb scroll maximum flick distance
*
* @see elm_config_thumbscroll_flick_distance_tolerance_get()
* @ingroup Scrolling
*/
EAPI void elm_config_scroll_thumbscroll_flick_distance_tolerance_set(unsigned int distance);
/** /**
* Get the amount of inertia a scroller will impose at self scrolling * Get the amount of inertia a scroller will impose at self scrolling
* animations. * animations.

View File

@ -2400,6 +2400,7 @@ _elm_scroll_mouse_up_event_cb(void *data,
if ((_elm_config->thumbscroll_friction > 0.0) && if ((_elm_config->thumbscroll_friction > 0.0) &&
(vel > _elm_config->thumbscroll_momentum_threshold)) (vel > _elm_config->thumbscroll_momentum_threshold))
{ {
Evas_Coord vw, vh, max_d;
int minx, miny, mx, my, px, py; int minx, miny, mx, my, px, py;
double tt = 0.0, dtt = 0.0; double tt = 0.0, dtt = 0.0;
@ -2408,8 +2409,21 @@ _elm_scroll_mouse_up_event_cb(void *data,
eo_do(sid->pan_obj, elm_obj_pan_pos_max_get eo_do(sid->pan_obj, elm_obj_pan_pos_max_get
(&mx, &my)); (&mx, &my));
eo_do(sid->pan_obj, elm_obj_pan_pos_get(&px, &py)); eo_do(sid->pan_obj, elm_obj_pan_pos_get(&px, &py));
sid->down.dx = ((double)dx / at); eo_do(sid->obj,
sid->down.dy = ((double)dy / at); elm_scrollable_interface_content_viewport_size_get(&vw, &vh));
max_d = _elm_config->thumbscroll_flick_distance_tolerance;
if (dx > 0)
sid->down.dx = (sin((M_PI * (double)dx / max_d)
- (M_PI / 2)) + 1) * max_d / at;
else
sid->down.dx = (sin((M_PI * (double)dx / max_d)
+ (M_PI / 2)) - 1) * max_d / at;
if (dy > 0)
sid->down.dy = (sin((M_PI * (double)dy / max_d)
- (M_PI / 2)) + 1) * max_d / at;
else
sid->down.dy = (sin((M_PI * (double)dy / max_d)
+ (M_PI / 2)) - 1) * max_d / at;
if (((sid->down.dx > 0) && (sid->down.pdx > 0)) || if (((sid->down.dx > 0) && (sid->down.pdx > 0)) ||
((sid->down.dx < 0) && (sid->down.pdx < 0)) || ((sid->down.dx < 0) && (sid->down.pdx < 0)) ||
((sid->down.dy > 0) && (sid->down.pdy > 0)) || ((sid->down.dy > 0) && (sid->down.pdy > 0)) ||

View File

@ -161,6 +161,7 @@ struct _Elm_Config
int thumbscroll_threshold; int thumbscroll_threshold;
int thumbscroll_hold_threshold; int thumbscroll_hold_threshold;
double thumbscroll_momentum_threshold; double thumbscroll_momentum_threshold;
int thumbscroll_flick_distance_tolerance;
double thumbscroll_friction; double thumbscroll_friction;
double thumbscroll_min_friction; double thumbscroll_min_friction;
double thumbscroll_friction_standard; double thumbscroll_friction_standard;