[Scroller] changed acceleration constant values

This commit is contained in:
Hosang Kim 2013-04-17 21:46:21 +09:00 committed by Jaehwan Kim
parent 31afa29838
commit 6883e2a2b1
8 changed files with 274 additions and 8 deletions

View File

@ -9,6 +9,9 @@ group "Elm_Config" struct {
value "thumbscroll_friction" double: 1.0;
value "thumbscroll_bounce_friction" double: 0.5;
value "thumbscroll_bounce_enable" uchar: 1;
value "thumbscroll_acceleration_threshold" double: 500.0;
value "thumbscroll_acceleration_time_limit" double: 0.7;
value "thumbscroll_acceleration_weight" double: 1.5;
value "page_scroll_friction" double: 0.5;
value "bring_in_scroll_friction" double: 0.5;
value "zoom_friction" double: 0.5;

View File

@ -9,6 +9,9 @@ group "Elm_Config" struct {
value "thumbscroll_friction" double: 1.0;
value "thumbscroll_bounce_friction" double: 0.5;
value "thumbscroll_bounce_enable" uchar: 1;
value "thumbscroll_acceleration_threshold" double: 2000.0;
value "thumbscroll_acceleration_time_limit" double: 0.5;
value "thumbscroll_acceleration_weight" double: 1.5;
value "page_scroll_friction" double: 0.5;
value "bring_in_scroll_friction" double: 0.5;
value "zoom_friction" double: 0.5;

View File

@ -9,6 +9,9 @@ group "Elm_Config" struct {
value "thumbscroll_friction" double: 1.0;
value "thumbscroll_bounce_friction" double: 0.5;
value "thumbscroll_bounce_enable" uchar: 0;
value "thumbscroll_acceleration_threshold" double: 500.0;
value "thumbscroll_acceleration_time_limit" double: 0.7;
value "thumbscroll_acceleration_weight" double: 1.5;
value "page_scroll_friction" double: 0.5;
value "bring_in_scroll_friction" double: 0.5;
value "zoom_friction" double: 0.5;

View File

@ -421,6 +421,81 @@ tssf_change(void *data __UNUSED__,
elm_config_all_flush();
}
static void
tsat_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
tsat_change(void *data __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
double tsat = elm_config_scroll_thumbscroll_acceleration_threshold_get();
double val = elm_slider_value_get(obj);
if (tsat == val) return;
elm_config_scroll_thumbscroll_acceleration_threshold_set(val);
elm_config_all_flush();
}
static void
tsatl_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
tsatl_change(void *data __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
double tsatl = elm_config_scroll_thumbscroll_acceleration_time_limit_get();
double val = elm_slider_value_get(obj);
if (tsatl == val) return;
elm_config_scroll_thumbscroll_acceleration_time_limit_set(val);
elm_config_all_flush();
}
static void
tsaw_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
tsaw_change(void *data __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
double tsaw = elm_config_scroll_thumbscroll_acceleration_weight_get();
double val = elm_slider_value_get(obj);
if (tsaw == val) return;
elm_config_scroll_thumbscroll_acceleration_weight_set(val);
elm_config_all_flush();
}
static void
cf_enable(void *data,
Evas_Object *obj,
@ -974,8 +1049,9 @@ static void
_config_display_update(Evas_Object *win)
{
int flush_interval, font_c, image_c, edje_file_c, edje_col_c, ts_threshould, ts_hold_threshold;
double scale, s_bounce_friction, ts_momentum_threshold, ts_friction,
ts_border_friction, ts_sensitivity_friction, page_friction, bring_in_friction, zoom_friction;
double scale, s_bounce_friction, ts_momentum_threshold, ts_friction, ts_border_friction,
ts_sensitivity_friction, ts_acceleration_threshold, ts_acceleration_time_limit,
ts_acceleration_weight, page_friction, bring_in_friction, zoom_friction;
const char *curr_theme, *curr_engine;
const Eina_List *l_items, *l;
Eina_Bool s_bounce, ts;
@ -1000,6 +1076,9 @@ _config_display_update(Evas_Object *win)
ts_friction = elm_config_scroll_thumbscroll_friction_get();
ts_border_friction = elm_config_scroll_thumbscroll_border_friction_get();
ts_sensitivity_friction = elm_config_scroll_thumbscroll_sensitivity_friction_get();
ts_acceleration_threshold = elm_config_scroll_thumbscroll_acceleration_threshold_get();
ts_acceleration_time_limit = elm_config_scroll_thumbscroll_acceleration_time_limit_get();
ts_acceleration_weight = elm_config_scroll_thumbscroll_acceleration_weight_get();
page_friction = elm_config_scroll_page_scroll_friction_get();
bring_in_friction = elm_config_scroll_bring_in_scroll_friction_get();
zoom_friction = elm_config_scroll_zoom_friction_get();
@ -1042,6 +1121,12 @@ _config_display_update(Evas_Object *win)
ts_border_friction);
elm_slider_value_set(evas_object_data_get(win, "ts_sensitivity_friction_slider"),
ts_sensitivity_friction);
elm_slider_value_set(evas_object_data_get(win, "ts_acceleration_threshold_slider"),
ts_acceleration_threshold);
elm_slider_value_set(evas_object_data_get(win, "ts_acceleration_time_limit_slider"),
ts_acceleration_time_limit);
elm_slider_value_set(evas_object_data_get(win, "ts_acceleration_weight_slider"),
ts_acceleration_weight);
elm_slider_value_set(evas_object_data_get(win,
"page_scroll_friction_slider"),
page_friction);
@ -2751,6 +2836,64 @@ _status_config_scrolling(Evas_Object *win,
evas_object_smart_callback_add(sl, "changed", tssf_round, NULL);
evas_object_smart_callback_add(sl, "delay,changed", tssf_change, NULL);
LABEL_FRAME_ADD("<hilight>Thumb scroll acceleration threshold</>");
sl = elm_slider_add(win);
elm_object_tooltip_text_set(sl, "This is the minimum speed of mouse <br/>"
"cursor movement which will accelerate<br/>"
"scrolling velocity after a<br/>"
"mouse up event (pixels/second)");
evas_object_data_set(win, "ts_acceleration_threshold_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/s");
elm_slider_indicator_format_set(sl, "%1.0f");
elm_slider_min_max_set(sl, 10.0, 5000.0);
elm_slider_value_set(sl, elm_config_scroll_thumbscroll_acceleration_threshold_get());
elm_box_pack_end(bx, sl);
evas_object_show(sl);
evas_object_smart_callback_add(sl, "changed", tsat_round, NULL);
evas_object_smart_callback_add(sl, "delay,changed", tsat_change, NULL);
LABEL_FRAME_ADD("<hilight>Thumb scroll acceleration time limit</>");
sl = elm_slider_add(win);
elm_object_tooltip_text_set(sl, "This is the time limit for<br/>"
"accelerating velocity<br/>");
evas_object_data_set(win, "ts_acceleration_time_limit_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.1f");
elm_slider_indicator_format_set(sl, "%1.1f");
elm_slider_min_max_set(sl, 0.0, 15.0);
elm_slider_value_set(sl, elm_config_scroll_thumbscroll_acceleration_time_limit_get());
elm_box_pack_end(bx, sl);
evas_object_show(sl);
evas_object_smart_callback_add(sl, "changed", tsatl_round, NULL);
evas_object_smart_callback_add(sl, "delay,changed", tsatl_change, NULL);
LABEL_FRAME_ADD("<hilight>Thumb scroll acceleration weight</>");
sl = elm_slider_add(win);
elm_object_tooltip_text_set(sl, "This is the weight for acceleration");
evas_object_data_set(win, "ts_acceleration_weight_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.1f");
elm_slider_indicator_format_set(sl, "%1.1f");
elm_slider_min_max_set(sl, 0.0, 10.0);
elm_slider_value_set(sl, elm_config_scroll_thumbscroll_acceleration_weight_get());
elm_box_pack_end(bx, sl);
evas_object_show(sl);
evas_object_smart_callback_add(sl, "changed", tsaw_round, NULL);
evas_object_smart_callback_add(sl, "delay,changed", tsaw_change, NULL);
sp = elm_separator_add(win);
elm_separator_horizontal_set(sp, EINA_TRUE);
evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);

View File

@ -357,6 +357,9 @@ _desc_init(void)
ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE);
ELM_CONFIG_VAL(D, T, thumbscroll_border_friction, T_DOUBLE);
ELM_CONFIG_VAL(D, T, thumbscroll_sensitivity_friction, T_DOUBLE);
ELM_CONFIG_VAL(D, T, thumbscroll_acceleration_threshold, T_DOUBLE);
ELM_CONFIG_VAL(D, T, thumbscroll_acceleration_time_limit, T_DOUBLE);
ELM_CONFIG_VAL(D, T, thumbscroll_acceleration_weight, T_DOUBLE);
ELM_CONFIG_VAL(D, T, page_scroll_friction, T_DOUBLE);
ELM_CONFIG_VAL(D, T, bring_in_scroll_friction, T_DOUBLE);
ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
@ -1062,6 +1065,9 @@ _config_load(void)
_elm_config->thumbscroll_friction = 1.0;
_elm_config->thumbscroll_bounce_friction = 0.5;
_elm_config->thumbscroll_bounce_enable = EINA_TRUE;
_elm_config->thumbscroll_acceleration_threshold = 500.0;
_elm_config->thumbscroll_acceleration_time_limit = 0.7;
_elm_config->thumbscroll_acceleration_weight = 1.5;
_elm_config->page_scroll_friction = 0.5;
_elm_config->bring_in_scroll_friction = 0.5;
_elm_config->zoom_friction = 0.5;
@ -1479,6 +1485,12 @@ _env_get(void)
if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s);
s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION");
if (s) _elm_config->thumbscroll_bounce_friction = _elm_atof(s);
s = getenv("ELM_THUMBSCROLL_ACCELERATION_THRESHOLD");
if (s) _elm_config->thumbscroll_acceleration_threshold = _elm_atof(s);
s = getenv("ELM_THUMBSCROLL_ACCELERATION_TIME_LIMIT");
if (s) _elm_config->thumbscroll_acceleration_time_limit = _elm_atof(s);
s = getenv("ELM_THUMBSCROLL_ACCELERATION_WEIGHT");
if (s) _elm_config->thumbscroll_acceleration_weight = _elm_atof(s);
s = getenv("ELM_PAGE_SCROLL_FRICTION");
if (s) _elm_config->page_scroll_friction = _elm_atof(s);
s = getenv("ELM_BRING_IN_SCROLL_FRICTION");
@ -2169,6 +2181,42 @@ elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction)
_elm_config->thumbscroll_sensitivity_friction = friction;
}
EAPI double
elm_config_scroll_thumbscroll_acceleration_threshold_get(void)
{
return _elm_config->thumbscroll_acceleration_threshold;
}
EAPI void
elm_config_scroll_thumbscroll_acceleration_threshold_set(double threshold)
{
_elm_config->thumbscroll_acceleration_threshold = threshold;
}
EAPI double
elm_config_scroll_thumbscroll_acceleration_time_limit_get(void)
{
return _elm_config->thumbscroll_acceleration_time_limit;
}
EAPI void
elm_config_scroll_thumbscroll_acceleration_time_limit_set(double time_limit)
{
_elm_config->thumbscroll_acceleration_time_limit = time_limit;
}
EAPI double
elm_config_scroll_thumbscroll_acceleration_weight_get(void)
{
return _elm_config->thumbscroll_acceleration_weight;
}
EAPI void
elm_config_scroll_thumbscroll_acceleration_weight_set(double weight)
{
_elm_config->thumbscroll_acceleration_weight = weight;
}
EAPI void
elm_config_longpress_timeout_set(double longpress_timeout)
{

View File

@ -422,6 +422,67 @@ EAPI double elm_config_scroll_thumbscroll_sensitivity_friction_get(void);
*/
EAPI void elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction);
/**
* Get the minimum speed of mouse cursor movement which will accelerate
* scrolling velocity after a mouse up event
* (pixels/second).
*
* @return the thumb scroll acceleration threshold
*
* @ingroup Scrolling
*/
EAPI double elm_config_scroll_thumbscroll_acceleration_threshold_get(void);
/**
* Set the minimum speed of mouse cursor movement which will accelerate
* scrolling velocity after a mouse up event
* (pixels/second).
*
* @param threshold the thumb scroll acceleration threshold
*
* @see elm_config_thumbscroll_acceleration_threshold_get()
* @ingroup Scrolling
*/
EAPI void elm_config_scroll_thumbscroll_acceleration_threshold_set(double threshold);
/**
* Get the time limit for accelerating velocity.
*
* @return the thumb scroll acceleration time limit
*
* @ingroup Scrolling
*/
EAPI double elm_config_scroll_thumbscroll_acceleration_time_limit_get(void);
/**
* Set the time limit for accelerating velocity.
*
* @param threshold the thumb scroll acceleration time limit
*
* @see elm_config_thumbscroll_acceleration_time_limit_get()
* @ingroup Scrolling
*/
EAPI void elm_config_scroll_thumbscroll_acceleration_time_limit_set(double time_limit);
/**
* Get the weight for the acceleration.
*
* @return the thumb scroll acceleration weight
*
* @ingroup Scrolling
*/
EAPI double elm_config_scroll_thumbscroll_acceleration_weight_get(void);
/**
* Set the weight for the acceleration.
*
* @param threshold the thumb scroll acceleration weight
*
* @see elm_config_thumbscroll_acceleration_weight_get()
* @ingroup Scrolling
*/
EAPI void elm_config_scroll_thumbscroll_acceleration_weight_set(double weight);
/**
* @}
*/

View File

@ -2390,18 +2390,20 @@ _elm_scroll_mouse_up_event_cb(void *data,
else
sid->down.extra_time = 0.0;
if (abs(sid->down.dx) > 500 && (dtt < 0.7) &&
if (abs(sid->down.dx) > _elm_config->thumbscroll_acceleration_threshold &&
(dtt < _elm_config->thumbscroll_acceleration_time_limit) &&
(((sid->down.dx > 0) && (sid->down.pdx > 0)) ||
((sid->down.dx < 0) && (sid->down.pdx < 0))))
if (px > minx && px < mx)
sid->down.dx += (double)sid->down.pdx * 1.5;
// FIXME: > 500, < 0.7, * 1.5 - probably should be config
if (abs(sid->down.dy) > 500 && (dtt < 0.7) &&
sid->down.dx += (double)sid->down.pdx * _elm_config->thumbscroll_acceleration_weight;
if (abs(sid->down.dy) > _elm_config->thumbscroll_acceleration_threshold &&
(dtt < _elm_config->thumbscroll_acceleration_time_limit) &&
(((sid->down.dy > 0) && (sid->down.pdy > 0)) ||
((sid->down.dy < 0) && (sid->down.pdy < 0))))
if (py > miny && py < my)
sid->down.dy += (double)sid->down.pdy * 1.5;
// FIXME: > 500, < 0.7, * 1.5 - probably should be config
{
sid->down.dy += (double)sid->down.pdy * _elm_config->thumbscroll_acceleration_weight;
}
sid->down.pdx = sid->down.dx;
sid->down.pdy = sid->down.dy;
ox = -sid->down.dx;

View File

@ -163,6 +163,9 @@ struct _Elm_Config
double thumbscroll_momentum_threshold;
double thumbscroll_friction;
double thumbscroll_bounce_friction;
double thumbscroll_acceleration_threshold;
double thumbscroll_acceleration_time_limit;
double thumbscroll_acceleration_weight;
double page_scroll_friction;
double bring_in_scroll_friction;
double zoom_friction;