From c36769a9ae0cb2adba00f54626470bad191cd456 Mon Sep 17 00:00:00 2001 From: Jaehwan Kim Date: Thu, 7 Mar 2013 18:13:15 +0900 Subject: [PATCH] Add the config ELM_THUMBSCROLL_HOLD_THRESHOLD. This is the number of pixels the range which can be scrolled, while the scroller is holed. In case of mobile, this config is useful since the out of scroller area is too small. --- legacy/elementary/ChangeLog | 4 ++ 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/bin/config.c | 51 ++++++++++++++++++- legacy/elementary/src/lib/elm_config.c | 16 ++++++ legacy/elementary/src/lib/elm_config.h | 21 ++++++++ .../src/lib/elm_interface_scrollable.c | 36 ++++++------- legacy/elementary/src/lib/elm_priv.h | 1 + 10 files changed, 114 insertions(+), 19 deletions(-) diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog index 8da1b21a5f..84f2df8aca 100644 --- a/legacy/elementary/ChangeLog +++ b/legacy/elementary/ChangeLog @@ -1114,3 +1114,7 @@ * Add elm_object_item_signal_callback_add(), elm_object_item_signal_callback_del(). +2013-03-07 Jaehwan Kim + + * Add the config ELM_THUMBSCROLL_HOLD_THRESHOLD. + This is the number of pixels the range which can be scrolled, while the scroller is holed. diff --git a/legacy/elementary/NEWS b/legacy/elementary/NEWS index 29c21543bc..b515fb97c7 100644 --- a/legacy/elementary/NEWS +++ b/legacy/elementary/NEWS @@ -46,6 +46,7 @@ Additions: * Add elm_transit_smooth_set(), elm_transit_smooth_get() * Add edje_object_message_signal_process before edje_object_size_min_restricted_calc. * Add elm_object_item_signal_callback_add(), elm_object_item_signal_callback_del(). + * Add the config ELM_THUMBSCROLL_HOLD_THRESHOLD. Improvements: diff --git a/legacy/elementary/config/default/base.src b/legacy/elementary/config/default/base.src index 61591e4499..c928779c6c 100644 --- a/legacy/elementary/config/default/base.src +++ b/legacy/elementary/config/default/base.src @@ -4,6 +4,7 @@ group "Elm_Config" struct { value "vsync" uchar: 0; value "thumbscroll_enable" uchar: 1; value "thumbscroll_threshold" int: 24; + value "thumbscroll_hold_threshold" int: 24; value "thumbscroll_momentum_threshold" double: 100.0; value "thumbscroll_friction" double: 1.0; value "thumbscroll_bounce_friction" double: 0.5; diff --git a/legacy/elementary/config/mobile/base.src b/legacy/elementary/config/mobile/base.src index d112cf7dc0..604154e62d 100644 --- a/legacy/elementary/config/mobile/base.src +++ b/legacy/elementary/config/mobile/base.src @@ -4,6 +4,7 @@ group "Elm_Config" struct { value "vsync" uchar: 0; value "thumbscroll_enable" uchar: 1; value "thumbscroll_threshold" int: 24; + value "thumbscroll_hold_threshold" int: 100; value "thumbscroll_momentum_threshold" double: 100.0; value "thumbscroll_friction" double: 1.0; value "thumbscroll_bounce_friction" double: 0.5; diff --git a/legacy/elementary/config/standard/base.src b/legacy/elementary/config/standard/base.src index e1aa88cecb..4870f3907a 100644 --- a/legacy/elementary/config/standard/base.src +++ b/legacy/elementary/config/standard/base.src @@ -4,6 +4,7 @@ group "Elm_Config" struct { value "vsync" uchar: 0; value "thumbscroll_enable" uchar: 0; value "thumbscroll_threshold" int: 4; + value "thumbscroll_hold_threshold" int: 4; value "thumbscroll_momentum_threshold" double: 100.0; value "thumbscroll_friction" double: 1.0; value "thumbscroll_bounce_friction" double: 0.5; diff --git a/legacy/elementary/src/bin/config.c b/legacy/elementary/src/bin/config.c index 33866065b6..3d4b960b0e 100644 --- a/legacy/elementary/src/bin/config.c +++ b/legacy/elementary/src/bin/config.c @@ -296,6 +296,31 @@ tst_change(void *data __UNUSED__, elm_config_all_flush(); } +static void +tsht_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 +tsht_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + double tst = elm_config_scroll_thumbscroll_hold_threshold_get(); + double val = elm_slider_value_get(obj); + + if (tst == val) return; + elm_config_scroll_thumbscroll_hold_threshold_set(val); + elm_config_all_flush(); +} + static void tsmt_round(void *data __UNUSED__, Evas_Object *obj, @@ -948,7 +973,7 @@ _font_overlay_change(void *data __UNUSED__, static void _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; double scale, s_bounce_friction, ts_momentum_threshold, ts_friction, ts_border_friction, ts_sensitivity_friction, page_friction, bring_in_friction, zoom_friction; const char *curr_theme, *curr_engine; @@ -970,6 +995,7 @@ _config_display_update(Evas_Object *win) s_bounce_friction = elm_config_scroll_bounce_friction_get(); ts = elm_config_scroll_thumbscroll_enabled_get(); ts_threshould = elm_config_scroll_thumbscroll_threshold_get(); + ts_hold_threshold = elm_config_scroll_thumbscroll_hold_threshold_get(); ts_momentum_threshold = elm_config_scroll_thumbscroll_momentum_threshold_get(); ts_friction = elm_config_scroll_thumbscroll_friction_get(); ts_border_friction = elm_config_scroll_thumbscroll_border_friction_get(); @@ -1003,6 +1029,9 @@ _config_display_update(Evas_Object *win) elm_slider_value_set(evas_object_data_get(win, "thumbscroll_threshold_slider"), ts_threshould); + elm_slider_value_set(evas_object_data_get(win, + "ts_hold_threshold_slider"), + ts_hold_threshold); elm_slider_value_set(evas_object_data_get(win, "ts_momentum_threshold_slider"), ts_momentum_threshold); @@ -2618,6 +2647,26 @@ _status_config_scrolling(Evas_Object *win, evas_object_smart_callback_add(sl, "changed", tst_round, NULL); evas_object_smart_callback_add(sl, "delay,changed", tst_change, NULL); + LABEL_FRAME_ADD("Thumb scroll hold threshold"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the number of pixels the range
" + "which can be scrolled, while the scroller
" + "is holed"); + evas_object_data_set(win, "thumbscroll_hold_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"); + elm_slider_indicator_format_set(sl, "%1.0f"); + elm_slider_min_max_set(sl, 4.0, 500.0); + elm_slider_value_set(sl, elm_config_scroll_thumbscroll_threshold_get()); + elm_box_pack_end(bx, sl); + evas_object_show(sl); + + evas_object_smart_callback_add(sl, "changed", tsht_round, NULL); + evas_object_smart_callback_add(sl, "delay,changed", tsht_change, NULL); + LABEL_FRAME_ADD("Thumb scroll momentum threshold"); sl = elm_slider_add(win); diff --git a/legacy/elementary/src/lib/elm_config.c b/legacy/elementary/src/lib/elm_config.c index 48f1c53fe9..f5ff09738e 100644 --- a/legacy/elementary/src/lib/elm_config.c +++ b/legacy/elementary/src/lib/elm_config.c @@ -350,6 +350,7 @@ _desc_init(void) ELM_CONFIG_VAL(D, T, vsync, T_UCHAR); ELM_CONFIG_VAL(D, T, thumbscroll_enable, T_UCHAR); 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_momentum_threshold, T_DOUBLE); ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE); ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE); @@ -1055,6 +1056,7 @@ _config_load(void) _elm_config->vsync = 0; _elm_config->thumbscroll_enable = EINA_TRUE; _elm_config->thumbscroll_threshold = 24; + _elm_config->thumbscroll_hold_threshold = 24; _elm_config->thumbscroll_momentum_threshold = 100.0; _elm_config->thumbscroll_friction = 1.0; _elm_config->thumbscroll_bounce_friction = 0.5; @@ -1465,6 +1467,8 @@ _env_get(void) if (s) _elm_config->thumbscroll_enable = !!atoi(s); s = getenv("ELM_THUMBSCROLL_THRESHOLD"); if (s) _elm_config->thumbscroll_threshold = atoi(s); + s = getenv("ELM_THUMBSCROLL_HOLD_THRESHOLD"); + if (s) _elm_config->thumbscroll_hold_threshold = atoi(s); // FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0 s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD"); if (s) _elm_config->thumbscroll_momentum_threshold = _elm_atof(s); @@ -2100,6 +2104,18 @@ elm_config_scroll_thumbscroll_threshold_set(unsigned int threshold) _elm_config->thumbscroll_threshold = threshold; } +EAPI unsigned int +elm_config_scroll_thumbscroll_hold_threshold_get(void) +{ + return _elm_config->thumbscroll_hold_threshold; +} + +EAPI void +elm_config_scroll_thumbscroll_hold_threshold_set(unsigned int threshold) +{ + _elm_config->thumbscroll_hold_threshold = threshold; +} + EAPI double elm_config_scroll_thumbscroll_momentum_threshold_get(void) { diff --git a/legacy/elementary/src/lib/elm_config.h b/legacy/elementary/src/lib/elm_config.h index c8a0f266da..ebd34fc7e4 100644 --- a/legacy/elementary/src/lib/elm_config.h +++ b/legacy/elementary/src/lib/elm_config.h @@ -305,6 +305,27 @@ EAPI unsigned int elm_config_scroll_thumbscroll_threshold_get(void); */ EAPI void elm_config_scroll_thumbscroll_threshold_set(unsigned int threshold); +/** + * Get the number of pixels the range which can be scrolled, + * while the scroller is holded. + * + * @return the thumb scroll hold threshold + * + * @ingroup Scrolling + */ +EAPI unsigned int elm_config_scroll_thumbscroll_hold_threshold_get(void); + +/** + * Set the number of pixels the range which can be scrolled, + * while the scroller is holded. + * + * @param threshold the thumb scroll hold threshold + * + * @see elm_config_thumbscroll_hold_threshold_get() + * @ingroup Scrolling + */ +EAPI void elm_config_scroll_thumbscroll_hold_threshold_set(unsigned int threshold); + /** * Get the minimum speed of mouse cursor movement which will trigger * list self scrolling animation after a mouse up event diff --git a/legacy/elementary/src/lib/elm_interface_scrollable.c b/legacy/elementary/src/lib/elm_interface_scrollable.c index b4d5e84a81..1d0da0de78 100644 --- a/legacy/elementary/src/lib/elm_interface_scrollable.c +++ b/legacy/elementary/src/lib/elm_interface_scrollable.c @@ -2804,9 +2804,9 @@ _elm_scroll_on_hold_animator(void *data) { td = t - sid->down.onhold_tlast; vx = sid->down.onhold_vx * td * - (double)_elm_config->thumbscroll_threshold * 2.0; + (double)_elm_config->thumbscroll_hold_threshold * 2.0; vy = sid->down.onhold_vy * td * - (double)_elm_config->thumbscroll_threshold * 2.0; + (double)_elm_config->thumbscroll_hold_threshold * 2.0; eo_do(sid->obj, elm_scrollable_interface_content_pos_get(&ox, &oy)); x = ox; y = oy; @@ -3045,37 +3045,37 @@ _elm_scroll_mouse_move_event_cb(void *data, x = ev->cur.canvas.x - sid->x; y = ev->cur.canvas.y - sid->y; - if (x < _elm_config->thumbscroll_threshold) + if (x < _elm_config->thumbscroll_hold_threshold) { - if (_elm_config->thumbscroll_threshold > 0.0) - vx = -(double)(_elm_config->thumbscroll_threshold - x) - / _elm_config->thumbscroll_threshold; + if (_elm_config->thumbscroll_hold_threshold > 0.0) + vx = -(double)(_elm_config->thumbscroll_hold_threshold - x) + / _elm_config->thumbscroll_hold_threshold; else vx = -1.0; } - else if (x > (sid->w - _elm_config->thumbscroll_threshold)) + else if (x > (sid->w - _elm_config->thumbscroll_hold_threshold)) { - if (_elm_config->thumbscroll_threshold > 0.0) - vx = (double)(_elm_config->thumbscroll_threshold - + if (_elm_config->thumbscroll_hold_threshold > 0.0) + vx = (double)(_elm_config->thumbscroll_hold_threshold - (sid->w - x)) / - _elm_config->thumbscroll_threshold; + _elm_config->thumbscroll_hold_threshold; else vx = 1.0; } - if (y < _elm_config->thumbscroll_threshold) + if (y < _elm_config->thumbscroll_hold_threshold) { - if (_elm_config->thumbscroll_threshold > 0.0) - vy = -(double)(_elm_config->thumbscroll_threshold - y) - / _elm_config->thumbscroll_threshold; + if (_elm_config->thumbscroll_hold_threshold > 0.0) + vy = -(double)(_elm_config->thumbscroll_hold_threshold - y) + / _elm_config->thumbscroll_hold_threshold; else vy = -1.0; } - else if (y > (sid->h - _elm_config->thumbscroll_threshold)) + else if (y > (sid->h - _elm_config->thumbscroll_hold_threshold)) { - if (_elm_config->thumbscroll_threshold > 0.0) - vy = (double)(_elm_config->thumbscroll_threshold - + if (_elm_config->thumbscroll_hold_threshold > 0.0) + vy = (double)(_elm_config->thumbscroll_hold_threshold - (sid->h - y)) / - _elm_config->thumbscroll_threshold; + _elm_config->thumbscroll_hold_threshold; else vy = 1.0; } diff --git a/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h index 3d12ebbdfb..73d9ca00cf 100644 --- a/legacy/elementary/src/lib/elm_priv.h +++ b/legacy/elementary/src/lib/elm_priv.h @@ -159,6 +159,7 @@ struct _Elm_Config unsigned char vsync; unsigned char thumbscroll_enable; int thumbscroll_threshold; + int thumbscroll_hold_threshold; double thumbscroll_momentum_threshold; double thumbscroll_friction; double thumbscroll_bounce_friction;