From 9e8a68da509e097839a75ec6f7314d9b4a3c56fb Mon Sep 17 00:00:00 2001 From: Gustavo Lima Chaves Date: Mon, 6 Dec 2010 12:46:10 +0000 Subject: [PATCH] New Elementary Config. App. options tab: Scrolling. Also introducing config. API to set/query those values. SVN revision: 55328 --- src/bin/config.c | 693 ++++++++++++++++++++++++++++++---------- src/lib/Elementary.h.in | 95 ++++-- src/lib/elm_config.c | 177 +++++++++- src/lib/elm_main.c | 564 +++++++++++++++++++++++++++++++- 4 files changed, 1324 insertions(+), 205 deletions(-) diff --git a/src/bin/config.c b/src/bin/config.c index a51f3c965..c6826adb7 100644 --- a/src/bin/config.c +++ b/src/bin/config.c @@ -67,6 +67,25 @@ struct _Fonts_Data } \ while (0) +#define LABEL_FRAME_ADD(label) \ + do \ + { \ + pd = elm_frame_add(win); \ + evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); \ + evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); \ + elm_object_style_set(pd, "pad_medium"); \ + elm_box_pack_end(bx, pd); \ + evas_object_show(pd); \ + \ + lb = elm_label_add(win); \ + evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); \ + evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); \ + elm_label_label_set(lb, label); \ + elm_frame_content_set(pd, lb); \ + evas_object_show(lb); \ + } \ + while (0) + static int quiet = 0; static int interactive = 1; @@ -118,6 +137,226 @@ config_exit(void *data __UNUSED__, elm_exit(); /* exit the program's main loop that runs in elm_run() */ } +static void +sb_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + Eina_Bool val = elm_check_state_get(obj); + Eina_Bool sb = elm_scroll_bounce_enabled_get(); + + if (val == sb) return; + elm_scroll_bounce_enabled_all_set(val); + + /*TODO: enable/disable subordinate sliders (make 'em support it 1st)*/ +} + +static void +bf_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 +bf_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + double bf = elm_scroll_bounce_friction_get(); + double val = elm_slider_value_get(obj); + + if (bf == val) return; + elm_scroll_bounce_friction_all_set(val); +} + +static void +ps_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 +ps_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + double ps = elm_scroll_page_scroll_friction_get(); + double val = elm_slider_value_get(obj); + + if (ps == val) return; + elm_scroll_page_scroll_friction_all_set(val); +} + +static void +bis_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 +bis_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + double bis = elm_scroll_bring_in_scroll_friction_get(); + double val = elm_slider_value_get(obj); + + if (bis == val) return; + elm_scroll_bring_in_scroll_friction_all_set(val); +} + +static void +zf_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 +zf_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + double zf = elm_scroll_zoom_friction_get(); + double val = elm_slider_value_get(obj); + + if (zf == val) return; + elm_scroll_zoom_friction_all_set(val); +} + +static void +ts_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + Eina_Bool val = elm_check_state_get(obj); + Eina_Bool sb = elm_scroll_bounce_enabled_get(); + + if (val == sb) return; + elm_scroll_thumbscroll_enabled_all_set(val); + + /*TODO: enable/disable subordinate sliders (make 'em support it 1st)*/ +} + +static void +tst_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 +tst_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + double tst = elm_scroll_thumbscroll_threshold_get(); + double val = elm_slider_value_get(obj); + + if (tst == val) return; + elm_scroll_thumbscroll_threshold_all_set(val); +} + +static void +tsmt_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 +tsmt_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + double tsmt = elm_scroll_thumbscroll_momentum_threshold_get(); + double val = elm_slider_value_get(obj); + + if (tsmt == val) return; + elm_scroll_thumbscroll_momentum_threshold_all_set(val); +} + +static void +tsf_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 +tsf_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + double tsf = elm_scroll_thumbscroll_friction_get(); + double val = elm_slider_value_get(obj); + + if (tsf == val) return; + elm_scroll_thumbscroll_friction_all_set(val); +} + +static void +tsbf_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 +tsbf_change(void *data __UNUSED__, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + double tsbf = elm_scroll_thumbscroll_border_friction_get(); + double val = elm_slider_value_get(obj); + + if (tsbf == val) return; + elm_scroll_thumbscroll_border_friction_all_set(val); +} + static void cf_round(void *data __UNUSED__, Evas_Object *obj, @@ -310,42 +549,30 @@ static void _status_config(Evas_Object *win, Evas_Object *bx0) { - Evas_Object *lb, *pd, *bx2, *fr, *sl, *sp; + Evas_Object *lb, *pd, *bx, *fr, *sl, *sp; fr = elm_frame_add(win); - evas_object_size_hint_weight_set(fr, 1.0, 1.0); + evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_frame_label_set(fr, "Sizing"); elm_box_pack_end(bx0, fr); evas_object_show(fr); - bx2 = elm_box_add(win); - evas_object_size_hint_weight_set(bx2, 1.0, 0.0); - evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, 0.5); + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5); - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, 1.0, 0.0); - evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx2, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, 1.0, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); - elm_label_label_set(lb, "Scale"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); + LABEL_FRAME_ADD("Scale"); sl = elm_slider_add(win); - evas_object_size_hint_weight_set(sl, 1.0, 0.0); + 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.2f"); elm_slider_indicator_format_set(sl, "%1.2f"); elm_slider_min_max_set(sl, 0.25, 5.0); elm_slider_value_set(sl, elm_scale_get()); - elm_box_pack_end(bx2, sl); + elm_box_pack_end(bx, sl); evas_object_show(sl); evas_object_smart_callback_add(sl, "changed", sc_round, NULL); @@ -353,34 +580,22 @@ _status_config(Evas_Object *win, sp = elm_separator_add(win); elm_separator_horizontal_set(sp, 1); - evas_object_size_hint_weight_set(sp, 1.0, 0.0); + evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5); - elm_box_pack_end(bx2, sp); + elm_box_pack_end(bx, sp); evas_object_show(sp); - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, 1.0, 0.0); - evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx2, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, 1.0, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); - elm_label_label_set(lb, "Finger Size
"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); + LABEL_FRAME_ADD("Finger Size
"); sl = elm_slider_add(win); - evas_object_size_hint_weight_set(sl, 1.0, 0.0); + 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"); elm_slider_indicator_format_set(sl, "%1.0f"); elm_slider_min_max_set(sl, 5, 200); elm_slider_value_set(sl, elm_finger_size_get()); - elm_box_pack_end(bx2, sl); + elm_box_pack_end(bx, sl); evas_object_show(sl); evas_object_smart_callback_add(sl, "changed", fs_round, NULL); @@ -389,8 +604,8 @@ _status_config(Evas_Object *win, // FIXME: add theme selector (basic mode and advanced for fallbacks) // FIXME: save config // FIXME: profile selector / creator etc. - elm_frame_content_set(fr, bx2); - evas_object_show(bx2); + elm_frame_content_set(fr, bx); + evas_object_show(bx); } static void @@ -630,12 +845,14 @@ static void _profile_change_do(Evas_Object *win, const char *profile) { - int flush_interval, font_c, image_c, edje_file_c, edje_col_c; + int flush_interval, font_c, image_c, edje_file_c, edje_col_c, ts_threshould; + double scale, s_bounce_friction, ts_momentum_threshold, ts_friction, + ts_border_friction, page_friction, bring_in_friction, zoom_friction; const char *curr_theme, *curr_engine; const Eina_List *l_items, *l; + Eina_Bool s_bounce, ts; Elm_List_Item *it; Elm_Theme *th; - double scale; int fs; elm_profile_all_set(profile); @@ -648,6 +865,17 @@ _profile_change_do(Evas_Object *win, edje_file_c = elm_edje_file_cache_get(); edje_col_c = elm_edje_collection_cache_get(); + s_bounce = elm_scroll_bounce_enabled_get(); + s_bounce_friction = elm_scroll_bounce_friction_get(); + ts = elm_scroll_thumbscroll_enabled_get(); + ts_threshould = elm_scroll_thumbscroll_threshold_get(); + ts_momentum_threshold = elm_scroll_thumbscroll_momentum_threshold_get(); + ts_friction = elm_scroll_thumbscroll_friction_get(); + ts_border_friction = elm_scroll_thumbscroll_border_friction_get(); + page_friction = elm_scroll_page_scroll_friction_get(); + bring_in_friction = elm_scroll_bring_in_scroll_friction_get(); + zoom_friction = elm_scroll_zoom_friction_get(); + /* gotta update root windows' atoms */ elm_scale_all_set(scale); elm_slider_value_set(evas_object_data_get(win, "scale_slider"), scale); @@ -672,6 +900,42 @@ _profile_change_do(Evas_Object *win, "edje_collection_cache_slider"), edje_col_c); + elm_scroll_bounce_enabled_all_set(s_bounce); + elm_check_state_set(evas_object_data_get(win, "scroll_bounce_check"), + s_bounce); + elm_scroll_bounce_friction_all_set(s_bounce_friction); + elm_slider_value_set(evas_object_data_get(win, "bounce_friction_slider"), + s_bounce_friction); + elm_scroll_thumbscroll_enabled_all_set(ts); + elm_check_state_set(evas_object_data_get(win, "thumbscroll_check"), ts); + elm_scroll_thumbscroll_threshold_all_set(ts_threshould); + elm_slider_value_set(evas_object_data_get(win, + "thumbscroll_threshold_slider"), + ts_threshould); + elm_scroll_thumbscroll_momentum_threshold_all_set(ts_momentum_threshold); + elm_slider_value_set(evas_object_data_get(win, + "ts_momentum_threshold_slider"), + ts_momentum_threshold); + elm_scroll_thumbscroll_friction_all_set(ts_friction); + elm_slider_value_set(evas_object_data_get(win, + "thumbscroll_friction_slider"), + ts_friction); + elm_scroll_thumbscroll_border_friction_all_set(ts_border_friction); + elm_slider_value_set(evas_object_data_get(win, "ts_border_friction_slider"), + ts_border_friction); + elm_scroll_page_scroll_friction_all_set(page_friction); + elm_slider_value_set(evas_object_data_get(win, + "page_scroll_friction_slider"), + page_friction); + elm_scroll_bring_in_scroll_friction_all_set(bring_in_friction); + elm_slider_value_set(evas_object_data_get(win, + "bring_in_scroll_friction_slider"), + bring_in_friction); + elm_scroll_zoom_friction_all_set(zoom_friction); + elm_slider_value_set(evas_object_data_get(win, + "zoom_scroll_friction_slider"), + zoom_friction); + curr_theme = _elm_theme_current_get(elm_theme_get(NULL)); elm_theme_all_set(curr_theme); @@ -858,19 +1122,7 @@ _status_config_sizing(Evas_Object *win, evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5); - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); - elm_label_label_set(lb, "Scale"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); + LABEL_FRAME_ADD("Scale"); sl = elm_slider_add(win); evas_object_data_set(win, "scale_slider", sl); @@ -894,19 +1146,7 @@ _status_config_sizing(Evas_Object *win, elm_box_pack_end(bx, sp); evas_object_show(sp); - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); - elm_label_label_set(lb, "Finger Size
"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); + LABEL_FRAME_ADD("Finger Size
"); sl = elm_slider_add(win); evas_object_data_set(win, "fs_slider", sl); @@ -1159,35 +1399,6 @@ _status_config_themes(Evas_Object *win, elm_pager_content_push(pager, tb); } -static void -_unimplemented(Evas_Object *win, - Evas_Object *pager, - const char *name) -{ - Evas_Object *lb, *pd, *bx2; - - bx2 = elm_box_add(win); - evas_object_size_hint_weight_set(bx2, 1.0, 0.0); - evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, 0.5); - - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, 0.0, 0.0); - evas_object_size_hint_align_set(pd, 0.5, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx2, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, 0.0, 0.0); - evas_object_size_hint_align_set(lb, 0.5, 0.5); - elm_label_label_set(lb, "Not implemented yet"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); - - evas_object_data_set(win, name, bx2); - elm_pager_content_push(pager, bx2); -} - static void _font_preview_update(Evas_Object *win) { @@ -2114,7 +2325,225 @@ static void _status_config_scrolling(Evas_Object *win, Evas_Object *pager) { - _unimplemented(win, pager, "scrolling"); + Evas_Object *lb, *pd, *bx, *sl, *sp, *ck, *sc; + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5); + + sc = elm_scroller_add(win); + evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE); + evas_object_show(sc); + elm_scroller_content_set(sc, bx); + + ck = elm_check_add(win); + elm_object_tooltip_text_set(ck, "Set whether scrollers should bounce
" + "when they reach their viewport's edge
" + "during a scroll"); + elm_check_label_set(ck, "Enable scroll bounce"); + evas_object_data_set(win, "scroll_bounce_check", ck); + evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5); + elm_check_state_set(ck, elm_scroll_bounce_enabled_get()); + elm_box_pack_end(bx, ck); + evas_object_show(ck); + + evas_object_smart_callback_add(ck, "changed", sb_change, NULL); + + LABEL_FRAME_ADD("Scroll bounce friction"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the amount of inertia a
" + "scroller will impose at bounce animations"); + evas_object_data_set(win, "bounce_friction_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.2f"); + elm_slider_indicator_format_set(sl, "%1.2f"); + elm_slider_min_max_set(sl, 0.0, 4.0); + elm_slider_value_set(sl, elm_scroll_bounce_friction_get()); + elm_box_pack_end(bx, sl); + evas_object_show(sl); + + evas_object_smart_callback_add(sl, "changed", bf_round, NULL); + evas_object_smart_callback_add(sl, "delay,changed", bf_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); + evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, sp); + evas_object_show(sp); + + ck = elm_check_add(win); + elm_object_tooltip_text_set(ck, "Set whether scrollers should be
" + "draggable from any point in their views"); + elm_check_label_set(ck, "Enable thumb scroll"); + evas_object_data_set(win, "thumbscroll_check", ck); + evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5); + elm_check_state_set(ck, elm_scroll_thumbscroll_enabled_get()); + elm_box_pack_end(bx, ck); + evas_object_show(ck); + + evas_object_smart_callback_add(ck, "changed", ts_change, NULL); + + LABEL_FRAME_ADD("Thumb scroll threshold"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the number of pixels one should
" + "travel while dragging a scroller's view to
" + "actually trigger scrolling"); + evas_object_data_set(win, "thumbscroll_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, 8.0, 50.0); + elm_slider_value_set(sl, elm_scroll_thumbscroll_threshold_get()); + elm_box_pack_end(bx, sl); + evas_object_show(sl); + + 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 momentum threshold"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the minimum speed of mouse
" + "cursor movement which will trigger
" + "list self scrolling animation after a
" + "mouse up event (pixels/second)"); + evas_object_data_set(win, "ts_momentum_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, 200.0); + elm_slider_value_set(sl, elm_scroll_thumbscroll_momentum_threshold_get()); + elm_box_pack_end(bx, sl); + evas_object_show(sl); + + evas_object_smart_callback_add(sl, "changed", tsmt_round, NULL); + evas_object_smart_callback_add(sl, "delay,changed", tsmt_change, + NULL); + + LABEL_FRAME_ADD("Thumb scroll friction"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the amount of inertia a
" + "scroller will impose at self scrolling
" + "animations"); + evas_object_data_set(win, "thumbscroll_friction_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_scroll_thumbscroll_friction_get()); + elm_box_pack_end(bx, sl); + evas_object_show(sl); + + evas_object_smart_callback_add(sl, "changed", tsf_round, NULL); + evas_object_smart_callback_add(sl, "delay,changed", tsf_change, NULL); + + LABEL_FRAME_ADD("Thumb scroll border friction"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the amount of lag between your
" + "actual mouse cursor dragging movement and
" + "a scroller's view movement itself, while
" + "pushing it into bounce state manually"); + evas_object_data_set(win, "ts_border_friction_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.2f"); + elm_slider_indicator_format_set(sl, "%1.2f"); + elm_slider_min_max_set(sl, 0.0, 1.0); + elm_slider_value_set(sl, elm_scroll_thumbscroll_border_friction_get()); + elm_box_pack_end(bx, sl); + evas_object_show(sl); + + evas_object_smart_callback_add(sl, "changed", tsbf_round, NULL); + evas_object_smart_callback_add(sl, "delay,changed", tsbf_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); + evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, sp); + evas_object_show(sp); + + LABEL_FRAME_ADD("Page scroll friction"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the amount of inertia a
" + "paged scroller will impose at
" + "page fitting animations"); + evas_object_data_set(win, "page_scroll_friction_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, 5.0); + elm_slider_value_set(sl, elm_scroll_page_scroll_friction_get()); + elm_box_pack_end(bx, sl); + evas_object_show(sl); + + evas_object_smart_callback_add(sl, "changed", ps_round, NULL); + evas_object_smart_callback_add(sl, "delay,changed", ps_change, NULL); + + LABEL_FRAME_ADD("Bring in scroll friction"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the amount of inertia a
" + "scroller will impose at region bring
" + "animations"); + evas_object_data_set(win, "bring_in_scroll_friction_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, 5.0); + elm_slider_value_set(sl, elm_scroll_bring_in_scroll_friction_get()); + elm_box_pack_end(bx, sl); + evas_object_show(sl); + + evas_object_smart_callback_add(sl, "changed", bis_round, NULL); + evas_object_smart_callback_add(sl, "delay,changed", bis_change, NULL); + + LABEL_FRAME_ADD("Zoom scroll friction"); + + sl = elm_slider_add(win); + elm_object_tooltip_text_set(sl, "This is the amount of inertia inertia
" + "scrollers will impose at animations
" + "triggered by Elementary widgets' zooming API"); + evas_object_data_set(win, "zoom_scroll_friction_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, 5.0); + elm_slider_value_set(sl, elm_scroll_zoom_friction_get()); + elm_box_pack_end(bx, sl); + evas_object_show(sl); + + evas_object_smart_callback_add(sl, "changed", zf_round, NULL); + evas_object_smart_callback_add(sl, "delay,changed", zf_change, NULL); + + evas_object_data_set(win, "scrolling", sc); + + elm_pager_content_push(pager, sc); } static char * @@ -2270,19 +2699,7 @@ _status_config_caches(Evas_Object *win, evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5); - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); - elm_label_label_set(lb, "Cache Flush Interval"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); + LABEL_FRAME_ADD("Cache Flush Interval"); sl = elm_slider_add(win); evas_object_data_set(win, "cache_flush_interval_slider", sl); @@ -2306,19 +2723,7 @@ _status_config_caches(Evas_Object *win, elm_box_pack_end(bx, sp); evas_object_show(sp); - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); - elm_label_label_set(lb, "Font Cache Size"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); + LABEL_FRAME_ADD("Font Cache Size"); sl = elm_slider_add(win); evas_object_data_set(win, "font_cache_slider", sl); @@ -2342,19 +2747,7 @@ _status_config_caches(Evas_Object *win, elm_box_pack_end(bx, sp); evas_object_show(sp); - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); - elm_label_label_set(lb, "Image Cache Size
"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); + LABEL_FRAME_ADD("Image Cache Size"); sl = elm_slider_add(win); evas_object_data_set(win, "image_cache_slider", sl); @@ -2378,19 +2771,7 @@ _status_config_caches(Evas_Object *win, elm_box_pack_end(bx, sp); evas_object_show(sp); - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); - elm_label_label_set(lb, "Number of Edje Files to Cache"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); + LABEL_FRAME_ADD("Number of Edje Files to Cache"); sl = elm_slider_add(win); evas_object_data_set(win, "edje_file_cache_slider", sl); @@ -2414,19 +2795,7 @@ _status_config_caches(Evas_Object *win, elm_box_pack_end(bx, sp); evas_object_show(sp); - pd = elm_frame_add(win); - evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5); - elm_object_style_set(pd, "pad_medium"); - elm_box_pack_end(bx, pd); - evas_object_show(pd); - - lb = elm_label_add(win); - evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5); - elm_label_label_set(lb, "Number of Edje Collections to Cache"); - elm_frame_content_set(pd, lb); - evas_object_show(lb); + LABEL_FRAME_ADD("Number of Edje Collections to Cache"); sl = elm_slider_add(win); evas_object_data_set(win, "edje_collection_cache_slider", sl); diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 809d5387d..30b1ea65b 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -356,6 +356,37 @@ extern "C" { EAPI void elm_object_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir) EINA_ARG_NONNULL(1); EAPI void elm_object_focus_direction_go(Evas_Object *obj, int x, int y) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_scroll_bounce_enabled_get(void); + EAPI void elm_scroll_bounce_enabled_set(Eina_Bool enabled); + EAPI void elm_scroll_bounce_enabled_all_set(Eina_Bool enabled); + EAPI double elm_scroll_bounce_friction_get(void); + EAPI void elm_scroll_bounce_friction_set(double friction); + EAPI void elm_scroll_bounce_friction_all_set(double friction); + EAPI double elm_scroll_page_scroll_friction_get(void); + EAPI void elm_scroll_page_scroll_friction_set(double friction); + EAPI void elm_scroll_page_scroll_friction_all_set(double friction); + EAPI double elm_scroll_bring_in_scroll_friction_get(void); + EAPI void elm_scroll_bring_in_scroll_friction_set(double friction); + EAPI void elm_scroll_bring_in_scroll_friction_all_set(double friction); + EAPI double elm_scroll_zoom_friction_get(void); + EAPI void elm_scroll_zoom_friction_set(double friction); + EAPI void elm_scroll_zoom_friction_all_set(double friction); + EAPI Eina_Bool elm_scroll_thumbscroll_enabled_get(void); + EAPI void elm_scroll_thumbscroll_enabled_set(Eina_Bool enabled); + EAPI void elm_scroll_thumbscroll_enabled_all_set(Eina_Bool enabled); + EAPI unsigned int elm_scroll_thumbscroll_threshold_get(void); + EAPI void elm_scroll_thumbscroll_threshold_set(unsigned int threshold); + EAPI void elm_scroll_thumbscroll_threshold_all_set(unsigned int threshold); + EAPI double elm_scroll_thumbscroll_momentum_threshold_get(void); + EAPI void elm_scroll_thumbscroll_momentum_threshold_set(double threshold); + EAPI void elm_scroll_thumbscroll_momentum_threshold_all_set(double threshold); + EAPI double elm_scroll_thumbscroll_friction_get(void); + EAPI void elm_scroll_thumbscroll_friction_set(double friction); + EAPI void elm_scroll_thumbscroll_friction_all_set(double friction); + EAPI double elm_scroll_thumbscroll_border_friction_get(void); + EAPI void elm_scroll_thumbscroll_border_friction_set(double friction); + EAPI void elm_scroll_thumbscroll_border_friction_all_set(double friction); + EAPI void elm_object_scroll_hold_push(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_object_scroll_hold_pop(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_object_scroll_freeze_push(Evas_Object *obj) EINA_ARG_NONNULL(1); @@ -530,7 +561,7 @@ extern "C" { * "focus,out" - window lost focus * "moved" - window that holds the canvas was moved */ - + /* bg */ typedef enum _Elm_Bg_Option { @@ -539,7 +570,7 @@ extern "C" { ELM_BG_OPTION_STRETCH, /**< stretch the background to fill */ ELM_BG_OPTION_TILE /**< tile background at its original size */ } Elm_Bg_Option; - + EAPI Evas_Object *elm_bg_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_bg_file_set(Evas_Object *obj, const char *file, const char *group) EINA_ARG_NONNULL(1); EAPI void elm_bg_file_get(const Evas_Object *obj, const char **file, const char **group) EINA_ARG_NONNULL(1); @@ -1132,7 +1163,7 @@ extern "C" { ELM_ICON_STANDARD } Elm_Icon_Type; typedef struct _Elm_Hoversel_Item Elm_Hoversel_Item; /**< Item of Elm_Hoversel. Sub-type of Elm_Widget_Item */ - + EAPI Evas_Object *elm_entry_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_entry_single_line_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); @@ -1343,7 +1374,7 @@ extern "C" { * "generate,error" - the thumbnail generation failed * "load,error" - the thumbnail image loading failed */ - + /* hoversel */ EAPI Evas_Object *elm_hoversel_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_hoversel_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) EINA_ARG_NONNULL(1); @@ -1384,7 +1415,7 @@ extern "C" { typedef struct _Elm_Toolbar_Item Elm_Toolbar_Item; /**< Item of Elm_Toolbar. Sub-type of Elm_Widget_Item */ typedef struct _Elm_Toolbar_Item_State Elm_Toolbar_Item_State; /** State of a Elm_Toolbar_Item */ - + EAPI Evas_Object *elm_toolbar_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size) EINA_ARG_NONNULL(1); EAPI int elm_toolbar_icon_size_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); @@ -1455,7 +1486,7 @@ extern "C" { * default * transparent (no background or shadow, just show the provided content) */ - + /* tooltip */ EAPI double elm_tooltip_delay_get(void); EAPI Eina_Bool elm_tooltip_delay_set(double delay); @@ -1900,7 +1931,7 @@ extern "C" { /* index */ typedef struct _Elm_Index_Item Elm_Index_Item; /**< Item of Elm_Index. Sub-type of Elm_Widget_Item */ - + EAPI Evas_Object *elm_index_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_index_active_set(Evas_Object *obj, Eina_Bool active) EINA_ARG_NONNULL(1); EAPI void elm_index_item_level_set(Evas_Object *obj, int level) EINA_ARG_NONNULL(1); @@ -1935,7 +1966,7 @@ extern "C" { ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL, ELM_PHOTOCAM_ZOOM_MODE_LAST } Elm_Photocam_Zoom_Mode; - + EAPI Evas_Object *elm_photocam_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI Evas_Load_Error elm_photocam_file_set(Evas_Object *obj, const char *file) EINA_ARG_NONNULL(1); EAPI const char *elm_photocam_file_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); @@ -2004,7 +2035,7 @@ extern "C" { typedef Evas_Object *(*ElmMapMarkerIconGetFunc) (Evas_Object *obj, Elm_Map_Marker *marker, void *data); typedef Evas_Object *(*ElmMapGroupIconGetFunc) (Evas_Object *obj, void *data); typedef char *(*ElmMapSourceURLFunc) (int x, int y, int zoom); - + EAPI Evas_Object *elm_map_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_map_zoom_set(Evas_Object *obj, int zoom) EINA_ARG_NONNULL(1); EAPI double elm_map_zoom_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); @@ -2071,7 +2102,7 @@ extern "C" { ELM_PANEL_ORIENT_LEFT, ELM_PANEL_ORIENT_RIGHT, } Elm_Panel_Orient; - + EAPI Evas_Object *elm_panel_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient) EINA_ARG_NONNULL(1); EAPI Elm_Panel_Orient elm_panel_orient_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); @@ -2127,7 +2158,7 @@ extern "C" { /* smart callbacks called: * "animate,done" - when a flip animation is finished */ - + /* scrolledentry */ EAPI Evas_Object *elm_scrolled_entry_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_scrolled_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line) EINA_ARG_NONNULL(1); @@ -2238,7 +2269,7 @@ extern "C" { */ /* animator */ - typedef enum + typedef enum { ELM_ANIMATOR_CURVE_LINEAR, ELM_ANIMATOR_CURVE_IN_OUT, @@ -2277,12 +2308,12 @@ extern "C" { EAPI void elm_animator_resume(Elm_Animator *animator) EINA_ARG_NONNULL(1); /* calendar */ - typedef enum + typedef enum { - ELM_CALENDAR_UNIQUE, + ELM_CALENDAR_UNIQUE, ELM_CALENDAR_DAILY, ELM_CALENDAR_WEEKLY, - ELM_CALENDAR_MONTHLY, + ELM_CALENDAR_MONTHLY, ELM_CALENDAR_ANNUALLY } Elm_Calendar_Mark_Repeat; typedef struct _Elm_Calendar_Mark Elm_Calendar_Mark; @@ -2307,7 +2338,7 @@ extern "C" { EAPI void elm_calendar_text_saturday_color_set(Evas_Object *obj, int pos) EINA_ARG_NONNULL(1); EAPI void elm_calendar_text_sunday_color_set(Evas_Object *obj, int pos) EINA_ARG_NONNULL(1); EAPI void elm_calendar_text_weekday_color_set(Evas_Object *obj, int pos) EINA_ARG_NONNULL(1); - + /* smart callbacks called: * changed - emitted when the user select a day or change the displayed * month. @@ -2368,7 +2399,7 @@ extern "C" { /* ctxpopup */ typedef struct _Elm_Ctxpopup_Item Elm_Ctxpopup_Item; - + EAPI Evas_Object *elm_ctxpopup_add(Evas_Object* parent) EINA_ARG_NONNULL(1); EAPI void elm_ctxpopup_hover_end(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI Evas_Object *elm_ctxpopup_item_icon_get(const Elm_Ctxpopup_Item *item) EINA_ARG_NONNULL(1); @@ -2413,7 +2444,7 @@ extern "C" { ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE, ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW } Elm_Fx_Wipe_Type; - + typedef struct _Elm_Transit Elm_Transit; EAPI Elm_Transit *elm_transit_add(double duration); @@ -2493,7 +2524,7 @@ extern "C" { typedef void (*Elm_Store_Item_Fetch_Cb) (void *data, Elm_Store_Item *sti); typedef void (*Elm_Store_Item_Unfetch_Cb) (void *data, Elm_Store_Item *sti); typedef void *(*Elm_Store_Item_Mapping_Cb) (void *data, Elm_Store_Item *sti, const char *part); - + typedef enum { ELM_STORE_ITEM_MAPPING_NONE = 0, @@ -2505,7 +2536,7 @@ extern "C" { // can add more here as needed by common apps ELM_STORE_ITEM_MAPPING_LAST } Elm_Store_Item_Mapping_Type; - + struct _Elm_Store_Item_Mapping_Icon { // FIXME: allow edje file icons @@ -2517,22 +2548,22 @@ extern "C" { Eina_Bool scale_up : 1; Eina_Bool scale_down : 1; }; - + struct _Elm_Store_Item_Mapping_Empty { Eina_Bool dummy; }; - + struct _Elm_Store_Item_Mapping_Photo { int size; }; - + struct _Elm_Store_Item_Mapping_Custom { Elm_Store_Item_Mapping_Cb func; }; - + struct _Elm_Store_Item_Mapping { Elm_Store_Item_Mapping_Type type; @@ -2546,7 +2577,7 @@ extern "C" { // add more types here } details; }; - + struct _Elm_Store_Item_Info { Elm_Genlist_Item_Class *item_class; @@ -2560,26 +2591,26 @@ extern "C" { Elm_Store_Item_Info base; char *path; }; - + #define ELM_STORE_ITEM_MAPPING_END { ELM_STORE_ITEM_MAPPING_NONE, NULL, 0, { .empty = { EINA_TRUE } } } #define ELM_STORE_ITEM_MAPPING_OFFSET(st, it) offsetof(st, it) - + EAPI void elm_store_free(Elm_Store *st); - + EAPI Elm_Store *elm_store_filesystem_new(void); EAPI void elm_store_filesystem_directory_set(Elm_Store *st, const char *dir) EINA_ARG_NONNULL(1); EAPI const char *elm_store_filesystem_directory_get(const Elm_Store *st) EINA_ARG_NONNULL(1); EAPI const char *elm_store_item_filesystem_path_get(const Elm_Store_Item *sti) EINA_ARG_NONNULL(1); - + EAPI void elm_store_target_genlist_set(Elm_Store *st, Evas_Object *obj) EINA_ARG_NONNULL(1); - + EAPI void elm_store_cache_set(Elm_Store *st, int max) EINA_ARG_NONNULL(1); EAPI int elm_store_cache_get(const Elm_Store *st) EINA_ARG_NONNULL(1); EAPI void elm_store_list_func_set(Elm_Store *st, Elm_Store_Item_List_Cb func, const void *data) EINA_ARG_NONNULL(1, 2); EAPI void elm_store_fetch_func_set(Elm_Store *st, Elm_Store_Item_Fetch_Cb func, const void *data) EINA_ARG_NONNULL(1, 2); EAPI void elm_store_fetch_thread_set(Elm_Store *st, Eina_Bool use_thread) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_store_fetch_thread_get(const Elm_Store *st) EINA_ARG_NONNULL(1); - + EAPI void elm_store_unfetch_func_set(Elm_Store *st, Elm_Store_Item_Unfetch_Cb func, const void *data) EINA_ARG_NONNULL(1, 2); EAPI void elm_store_sorted_set(Elm_Store *st, Eina_Bool sorted) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_store_sorted_get(const Elm_Store *st) EINA_ARG_NONNULL(1); @@ -2587,7 +2618,7 @@ extern "C" { EAPI void *elm_store_item_data_get(Elm_Store_Item *sti) EINA_ARG_NONNULL(1); EAPI const Elm_Store *elm_store_item_store_get(const Elm_Store_Item *sti) EINA_ARG_NONNULL(1); EAPI const Elm_Genlist_Item *elm_store_item_genlist_item_get(const Elm_Store_Item *sti) EINA_ARG_NONNULL(1); - + #ifdef __cplusplus } #endif diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c index 0a5ea6960..2cc188bd3 100644 --- a/src/lib/elm_config.c +++ b/src/lib/elm_config.c @@ -67,7 +67,7 @@ static size_t _elm_user_dir_snprintf(char *dst, size_t size, const char *fmt, .. #ifdef HAVE_ELEMENTARY_X static Ecore_Event_Handler *_prop_change_handler = NULL; static Ecore_X_Window _root_1st = 0; -#define ATOM_COUNT 11 +#define ATOM_COUNT 21 static Ecore_X_Atom _atom[ATOM_COUNT]; static Ecore_X_Atom _atom_config = 0; static const char *_atom_names[ATOM_COUNT] = @@ -82,6 +82,16 @@ static const char *_atom_names[ATOM_COUNT] = "ENLIGHTENMENT_IMAGE_CACHE", "ENLIGHTENMENT_EDJE_FILE_CACHE", "ENLIGHTENMENT_EDJE_COLLECTION_CACHE", + "ENLIGHTENMENT_THUMBSCROLL_BOUNCE_ENABLE", + "ENLIGHTENMENT_THUMBSCROLL_BOUNCE_FRICTION", + "ENLIGHTENMENT_THUMBSCROLL_ENABLE", + "ENLIGHTENMENT_THUMBSCROLL_THRESHOLD", + "ENLIGHTENMENT_THUMBSCROLL_MOMENTUM_THRESHOLD", + "ENLIGHTENMENT_THUMBSCROLL_FRICTION", + "ENLIGHTENMENT_THUMBSCROLL_BORDER_FRICTION", + "ENLIGHTENMENT_THUMBSCROLL_PAGE_SCROLL_FRICTION", + "ENLIGHTENMENT_THUMBSCROLL_BRING_IN_SCROLL_FRICTION", + "ENLIGHTENMENT_THUMBSCROLL_ZOOM_FRICTION", "ENLIGHTENMENT_CONFIG" }; #define ATOM_E_SCALE 0 @@ -94,7 +104,17 @@ static const char *_atom_names[ATOM_COUNT] = #define ATOM_E_IMAGE_CACHE 7 #define ATOM_E_EDJE_FILE_CACHE 8 #define ATOM_E_EDJE_COLLECTION_CACHE 9 -#define ATOM_E_CONFIG 10 +#define ATOM_E_THUMBSCROLL_BOUNCE_ENABLE 10 +#define ATOM_E_THUMBSCROLL_BOUNCE_FRICTION 11 +#define ATOM_E_THUMBSCROLL_ENABLE 12 +#define ATOM_E_THUMBSCROLL_THRESHOLD 13 +#define ATOM_E_THUMBSCROLL_MOMENTUM_THRESHOLD 14 +#define ATOM_E_THUMBSCROLL_FRICTION 15 +#define ATOM_E_THUMBSCROLL_BORDER_FRICTION 16 +#define ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION 17 +#define ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION 18 +#define ATOM_E_THUMBSCROLL_ZOOM_FRICTION 19 +#define ATOM_E_CONFIG 20 static Eina_Bool _prop_config_get(void); static Eina_Bool _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev); @@ -256,7 +276,7 @@ _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) _elm_rescale(); } } - if (event->atom == _atom[ATOM_E_CACHE_FLUSH_INTERVAL]) + else if (event->atom == _atom[ATOM_E_CACHE_FLUSH_INTERVAL]) { unsigned int val = 1000; @@ -273,7 +293,7 @@ _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) _elm_recache(); } } - if (event->atom == _atom[ATOM_E_FONT_CACHE]) + else if (event->atom == _atom[ATOM_E_FONT_CACHE]) { unsigned int val = 1000; @@ -289,7 +309,7 @@ _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) _elm_recache(); } } - if (event->atom == _atom[ATOM_E_IMAGE_CACHE]) + else if (event->atom == _atom[ATOM_E_IMAGE_CACHE]) { unsigned int val = 1000; @@ -305,7 +325,7 @@ _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) _elm_recache(); } } - if (event->atom == _atom[ATOM_E_EDJE_FILE_CACHE]) + else if (event->atom == _atom[ATOM_E_EDJE_FILE_CACHE]) { unsigned int val = 1000; @@ -321,7 +341,7 @@ _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) _elm_recache(); } } - if (event->atom == _atom[ATOM_E_EDJE_COLLECTION_CACHE]) + else if (event->atom == _atom[ATOM_E_EDJE_COLLECTION_CACHE]) { unsigned int val = 1000; @@ -338,6 +358,130 @@ _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) _elm_recache(); } } + else if (event->atom == _atom[ATOM_E_THUMBSCROLL_BOUNCE_ENABLE]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + _elm_config->thumbscroll_bounce_enable = !!val; + } + } + else if (event->atom == _atom[ATOM_E_THUMBSCROLL_BOUNCE_FRICTION]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + if (val > 0) + _elm_config->thumbscroll_bounce_friction = + (double)val / 1000.0; + } + } + else if (event->atom == _atom[ATOM_E_THUMBSCROLL_ENABLE]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + _elm_config->thumbscroll_enable = !!val; + } + } + else if (event->atom == _atom[ATOM_E_THUMBSCROLL_THRESHOLD]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + if (val > 0) _elm_config->thumbscroll_threshold = val; + } + } + else if (event->atom == _atom[ATOM_E_THUMBSCROLL_MOMENTUM_THRESHOLD]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + if (val > 0) + _elm_config->thumbscroll_momentum_threshold = + (double)val / 1000.0; + } + } + else if (event->atom == _atom[ATOM_E_THUMBSCROLL_FRICTION]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + if (val > 0) + _elm_config->thumbscroll_friction = (double)val / 1000.0; + } + } + else if (event->atom == _atom[ATOM_E_THUMBSCROLL_BORDER_FRICTION]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + if (val > 0) + _elm_config->thumbscroll_border_friction = + (double)val / 1000.0; + } + } + else if (event->atom == _atom[ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + if (val > 0) + _elm_config->page_scroll_friction = + (double)val / 1000.0; + } + } + else if (event->atom == + _atom[ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + if (val > 0) + _elm_config->bring_in_scroll_friction = + (double)val / 1000.0; + } + } + else if (event->atom == + _atom[ATOM_E_THUMBSCROLL_ZOOM_FRICTION]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + if (val > 0) + _elm_config->zoom_friction = (double)val / 1000.0; + } + } else if (((_atom_config > 0) && (event->atom == _atom_config)) || (event->atom == _atom[ATOM_E_CONFIG])) { @@ -1176,6 +1320,7 @@ static void _env_get(void) { char *s; + double friction; s = getenv("ELM_ENGINE"); if (s) @@ -1244,6 +1389,10 @@ _env_get(void) if (s) _elm_config->thumbscroll_momentum_threshold = atof(s); s = getenv("ELM_THUMBSCROLL_FRICTION"); if (s) _elm_config->thumbscroll_friction = atof(s); + s = getenv("ELM_THUMBSCROLL_BOUNCE_ENABLE"); + if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s); + s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION"); + if (s) _elm_config->thumbscroll_bounce_friction = atof(s); s = getenv("ELM_PAGE_SCROLL_FRICTION"); if (s) _elm_config->page_scroll_friction = atof(s); s = getenv("ELM_BRING_IN_SCROLL_FRICTION"); @@ -1251,8 +1400,17 @@ _env_get(void) s = getenv("ELM_ZOOM_FRICTION"); if (s) _elm_config->zoom_friction = atof(s); s = getenv("ELM_THUMBSCROLL_BORDER_FRICTION"); - if (s) _elm_config->thumbscroll_border_friction = atof(s); + if (s) + { + friction = atof(s); + if (friction < 0.0) + friction = 0.0; + + if (friction > 1.0) + friction = 1.0; + _elm_config->thumbscroll_border_friction = friction; + } s = getenv("ELM_THEME"); if (s) eina_stringshare_replace(&_elm_config->theme, s); @@ -1354,7 +1512,8 @@ _env_get(void) s = getenv("ELM_LONGPRESS_TIMEOUT"); if (s) _elm_config->longpress_timeout = atof(s); - if (_elm_config->longpress_timeout < 0.0) _elm_config->longpress_timeout = 0.0; + if (_elm_config->longpress_timeout < 0.0) + _elm_config->longpress_timeout = 0.0; } void diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index 9ac3afb19..50d3dc07d 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -1400,8 +1400,7 @@ elm_profile_all_set(const char *profile) #ifdef HAVE_ELEMENTARY_X static Ecore_X_Atom atom = 0; - if (!atom) - atom = ecore_x_atom_get("ENLIGHTENMENT_PROFILE"); + if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_PROFILE"); ecore_x_window_prop_string_set(ecore_x_window_root_first_get(), atom, profile); #endif @@ -2400,6 +2399,567 @@ elm_focus_highlight_animate_set(Eina_Bool animate) _elm_config->focus_highlight_animate = !!animate; } +/** + * @defgroup Scrolling Scrolling + * + * These are functions setting how scrollable views in Elementary + * widgets should behave on user interaction. + */ + +/** + * Get whether scrollers should bounce when they reach their + * viewport's edge during a scroll. + * + * @return the thumb scroll bouncing state + * + * This is the default behavior for touch screens, in general. + * @ingroup Scrolling + */ +EAPI Eina_Bool +elm_scroll_bounce_enabled_get(void) +{ + return _elm_config->thumbscroll_bounce_enable; +} + +/** + * Set whether scrollers should bounce when they reach their + * viewport's edge during a scroll. + * + * @param enabled the thumb scroll bouncing state + * + * @see elm_thumbscroll_bounce_enabled_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_bounce_enabled_set(Eina_Bool enabled) +{ + _elm_config->thumbscroll_bounce_enable = enabled; +} + +/** + * Set whether scrollers should bounce when they reach their + * viewport's edge during a scroll, for all Elementary application + * windows. + * + * @param enabled the thumb scroll bouncing state + * + * @see elm_thumbscroll_bounce_enabled_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_bounce_enabled_all_set(Eina_Bool enabled) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int bounce_enable_i = (unsigned int)enabled; + + if (!atom) + atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_BOUNCE_ENABLE"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &bounce_enable_i, 1); +#endif +} + +/** + * Get the amount of inertia a scroller will impose at bounce + * animations. + * + * @return the thumb scroll bounce friction + * + * @ingroup Scrolling + */ +EAPI double +elm_scroll_bounce_friction_get(void) +{ + return _elm_config->thumbscroll_bounce_friction; +} + +/** + * Set the amount of inertia a scroller will impose at bounce + * animations. + * + * @param friction the thumb scroll bounce friction + * + * @see elm_thumbscroll_bounce_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_bounce_friction_set(double friction) +{ + _elm_config->thumbscroll_bounce_friction = friction; +} + +/** + * Set the amount of inertia a scroller will impose at bounce + * animations, for all Elementary application windows. + * + * @param friction the thumb scroll bounce friction + * + * @see elm_thumbscroll_bounce_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_bounce_friction_all_set(double friction) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int bounce_friction_i = (unsigned int)(friction * 1000.0); + + if (!atom) + atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_BOUNCE_FRICTION"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &bounce_friction_i, 1); +#endif +} + +/** + * Get the amount of inertia a paged scroller will impose at + * page fitting animations. + * + * @return the page scroll friction + * + * @ingroup Scrolling + */ +EAPI double +elm_scroll_page_scroll_friction_get(void) +{ + return _elm_config->page_scroll_friction; +} + +/** + * Set the amount of inertia a paged scroller will impose at + * page fitting animations. + * + * @param friction the page scroll friction + * + * @see elm_thumbscroll_page_scroll_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_page_scroll_friction_set(double friction) +{ + _elm_config->page_scroll_friction = friction; +} + +/** + * Set the amount of inertia a paged scroller will impose at + * page fitting animations, for all Elementary application windows. + * + * @param friction the page scroll friction + * + * @see elm_thumbscroll_page_scroll_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_page_scroll_friction_all_set(double friction) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int page_scroll_friction_i = (unsigned int)(friction * 1000.0); + + if (!atom) + atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_PAGE_SCROLL_FRICTION"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &page_scroll_friction_i, 1); +#endif +} + +/** + * Get the amount of inertia a scroller will impose at region bring + * animations. + * + * @return the bring in scroll friction + * + * @ingroup Scrolling + */ +EAPI double +elm_scroll_bring_in_scroll_friction_get(void) +{ + return _elm_config->bring_in_scroll_friction; +} + +/** + * Set the amount of inertia a scroller will impose at region bring + * animations. + * + * @param friction the bring in scroll friction + * + * @see elm_thumbscroll_bring_in_scroll_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_bring_in_scroll_friction_set(double friction) +{ + _elm_config->bring_in_scroll_friction = friction; +} + +/** + * Set the amount of inertia a scroller will impose at region bring + * animations, for all Elementary application windows. + * + * @param friction the bring in scroll friction + * + * @see elm_thumbscroll_bring_in_scroll_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_bring_in_scroll_friction_all_set(double friction) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int bring_in_scroll_friction_i = (unsigned int)(friction * 1000.0); + + if (!atom) + atom = + ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_BRING_IN_SCROLL_FRICTION"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &bring_in_scroll_friction_i, 1); +#endif +} + +/** + * Get the amount of inertia scrollers will impose at animations + * triggered by Elementary widgets' zooming API. + * + * @return the zoom friction + * + * @ingroup Scrolling + */ +EAPI double +elm_scroll_zoom_friction_get(void) +{ + return _elm_config->zoom_friction; +} + +/** + * Set the amount of inertia scrollers will impose at animations + * triggered by Elementary widgets' zooming API. + * + * @param friction the zoom friction + * + * @see elm_thumbscroll_zoom_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_zoom_friction_set(double friction) +{ + _elm_config->zoom_friction = friction; +} + +/** + * Set the amount of inertia scrollers will impose at animations + * triggered by Elementary widgets' zooming API, for all Elementary + * application windows. + * + * @param friction the zoom friction + * + * @see elm_thumbscroll_zoom_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_zoom_friction_all_set(double friction) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int zoom_friction_i = (unsigned int)(friction * 1000.0); + + if (!atom) + atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_ZOOM_FRICTION"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &zoom_friction_i, 1); +#endif +} + +/** + * Get whether scrollers should be draggable from any point in their + * views. + * + * @return the thumb scroll state + * + * @note This is the default behavior for touch screens, in general. + * @note All other functions namespaced with "thumbscroll" will only + * have effect if this mode is enabled. + * + * @ingroup Scrolling + */ +EAPI Eina_Bool +elm_scroll_thumbscroll_enabled_get(void) +{ + return _elm_config->thumbscroll_enable; +} + +/** + * Set whether scrollers should be draggable from any point in their + * views. + * + * @param enabled the thumb scroll state + * + * @see elm_thumbscroll_enabled_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_enabled_set(Eina_Bool enabled) +{ + _elm_config->thumbscroll_enable = enabled; +} + +/** + * Set whether scrollers should be draggable from any point in their + * views, for all Elementary application windows. + * + * @param enabled the thumb scroll state + * + * @see elm_thumbscroll_enabled_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_enabled_all_set(Eina_Bool enabled) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int ts_enable_i = (unsigned int)enabled; + + if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_ENABLE"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &ts_enable_i, 1); +#endif +} + +/** + * Get the number of pixels one should travel while dragging a + * scroller's view to actually trigger scrolling. + * + * @return the thumb scroll threshould + * + * One would use higher values for touch screens, in general, because + * of their inherent imprecision. + * @ingroup Scrolling + */ +EAPI unsigned int +elm_scroll_thumbscroll_threshold_get(void) +{ + return _elm_config->thumbscroll_threshold; +} + +/** + * Set the number of pixels one should travel while dragging a + * scroller's view to actually trigger scrolling. + * + * @param threshold the thumb scroll threshould + * + * @see elm_thumbscroll_threshould_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_threshold_set(unsigned int threshold) +{ + _elm_config->thumbscroll_threshold = threshold; +} + +/** + * Set the number of pixels one should travel while dragging a + * scroller's view to actually trigger scrolling, for all Elementary + * application windows. + * + * @param threshold the thumb scroll threshould + * + * @see elm_thumbscroll_threshould_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_threshold_all_set(unsigned int threshold) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int ts_threshold_i = (unsigned int)threshold; + + if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_THRESHOLD"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &ts_threshold_i, 1); +#endif +} + +/** + * Get the minimum speed of mouse cursor movement which will trigger + * list self scrolling animation after a mouse up event + * (pixels/second). + * + * @return the thumb scroll momentum threshould + * + * @ingroup Scrolling + */ +EAPI double +elm_scroll_thumbscroll_momentum_threshold_get(void) +{ + return _elm_config->thumbscroll_momentum_threshold; +} + +/** + * Set the minimum speed of mouse cursor movement which will trigger + * list self scrolling animation after a mouse up event + * (pixels/second). + * + * @param threshold the thumb scroll momentum threshould + * + * @see elm_thumbscroll_momentum_threshould_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_momentum_threshold_set(double threshold) +{ + _elm_config->thumbscroll_momentum_threshold = threshold; +} + +/** + * Set the minimum speed of mouse cursor movement which will trigger + * list self scrolling animation after a mouse up event + * (pixels/second), for all Elementary application windows. + * + * @param threshold the thumb scroll momentum threshould + * + * @see elm_thumbscroll_momentum_threshould_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_momentum_threshold_all_set(double threshold) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int ts_momentum_threshold_i = (unsigned int)(threshold * 1000.0); + + if (!atom) + atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_MOMENTUM_THRESHOLD"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &ts_momentum_threshold_i, 1); +#endif +} + +/** + * Get the amount of inertia a scroller will impose at self scrolling + * animations. + * + * @return the thumb scroll friction + * + * @ingroup Scrolling + */ +EAPI double +elm_scroll_thumbscroll_friction_get(void) +{ + return _elm_config->thumbscroll_friction; +} + +/** + * Set the amount of inertia a scroller will impose at self scrolling + * animations. + * + * @param friction the thumb scroll friction + * + * @see elm_thumbscroll_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_friction_set(double friction) +{ + _elm_config->thumbscroll_friction = friction; +} + +/** + * Set the amount of inertia a scroller will impose at self scrolling + * animations, for all Elementary application windows. + * + * @param friction the thumb scroll friction + * + * @see elm_thumbscroll_friction_get() + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_friction_all_set(double friction) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int ts_friction_i = (unsigned int)(friction * 1000.0); + + if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_FRICTION"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &ts_friction_i, 1); +#endif +} + +/** + * Get the amount of lag between your actual mouse cursor dragging + * movement and a scroller's view movement itself, while pushing it + * into bounce state manually. + * + * @return the thumb scroll border friction + * + * @ingroup Scrolling + */ +EAPI double +elm_scroll_thumbscroll_border_friction_get(void) +{ + return _elm_config->thumbscroll_border_friction; +} + +/** + * Set the amount of lag between your actual mouse cursor dragging + * movement and a scroller's view movement itself, while pushing it + * into bounce state manually. + * + * @param friction the thumb scroll border friction. @c 0.0 for + * perfect synchrony between two movements, @c 1.0 for maximum + * lag. + * + * @see elm_thumbscroll_border_friction_get() + * @note parameter value will get bound to 0.0 - 1.0 interval, always + * + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_border_friction_set(double friction) +{ + if (friction < 0.0) + friction = 0.0; + + if (friction > 1.0) + friction = 1.0; + + _elm_config->thumbscroll_friction = friction; +} + +/** + * Set the amount of lag between your actual mouse cursor dragging + * movement and a scroller's view movement itself, while pushing it + * into bounce state manually, for all Elementary application windows. + * + * @param friction the thumb scroll border friction. @c 0.0 for + * perfect synchrony between two movements, @c 1.0 for maximum + * lag. + * + * @see elm_thumbscroll_border_friction_get() + * @note parameter value will get bound to 0.0 - 1.0 interval, always + * + * @ingroup Scrolling + */ +EAPI void +elm_scroll_thumbscroll_border_friction_all_set(double friction) +{ + if (friction < 0.0) + friction = 0.0; + + if (friction > 1.0) + friction = 1.0; + +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int border_friction_i = (unsigned int)(friction * 1000.0); + + if (!atom) + atom = ecore_x_atom_get("ENLIGHTENMENT_THUMBSCROLL_BORDER_FRICTION"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &border_friction_i, 1); +#endif +} + /** * @defgroup Scrollhints Scrollhints * -- 2.34.1