diff options
author | Hosang Kim <hosang12.kim@samsung.com> | 2020-01-10 09:26:32 +0000 |
---|---|---|
committer | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2020-01-17 17:21:09 +0100 |
commit | fbb77e7d1c3116f4187370ec9406755f38cf44be (patch) | |
tree | 429f27f90728582e79b9f53248dcab66c2e4cfb2 /src | |
parent | bac185e8f3ed5a17d9c29e5daf2e2038b6734767 (diff) | |
download | efl-fbb77e7d1c3116f4187370ec9406755f38cf44be.tar.gz |
efl_ui_scrollbar: change scrollbar state when theme is reloaded.
Scrollbar visible state is not synchronized when theme is reloaded.
Differential Revision: https://phab.enlightenment.org/D10649
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/efl/interfaces/efl_ui_scrollbar.eo | 12 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_scroll_manager.c | 7 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_scroll_manager.eo | 1 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_scroll_util.c | 14 | ||||
-rw-r--r-- | src/tests/elementary/efl_ui_test_list_collection.c | 4 | ||||
-rw-r--r-- | src/tests/elementary/efl_ui_test_scroller.c | 51 |
6 files changed, 87 insertions, 2 deletions
diff --git a/src/lib/efl/interfaces/efl_ui_scrollbar.eo b/src/lib/efl/interfaces/efl_ui_scrollbar.eo index 5741df6b8f..3b4696f00b 100644 --- a/src/lib/efl/interfaces/efl_ui_scrollbar.eo +++ b/src/lib/efl/interfaces/efl_ui_scrollbar.eo @@ -60,6 +60,18 @@ interface Efl.Ui.Scrollbar and $[1.0] (the bottom side of the thumb is touching the bottom edge of the widget).]] } } + @property bar_visibility { + [[Current visibility state of the scrollbars. + This is useful in @Efl.Ui.Scrollbar_Mode.auto mode where EFL decides if the scrollbars + are shown or hidden. See also the @[.bar,show] and @[.bar,hide] events. + ]] + get { + } + values { + hbar: bool; [[Whether the horizontal scrollbar is currently visible.]] + vbar: bool; [[Whether the vertical scrollbar is currently visible.]] + } + } bar_visibility_update @protected @beta{ [[Update bar visibility. diff --git a/src/lib/elementary/efl_ui_scroll_manager.c b/src/lib/elementary/efl_ui_scroll_manager.c index 3d332e94fb..650a726bc1 100644 --- a/src/lib/elementary/efl_ui_scroll_manager.c +++ b/src/lib/elementary/efl_ui_scroll_manager.c @@ -2188,6 +2188,13 @@ _efl_ui_scrollbar_v_visibility_adjust(Eo *obj) } EOLIAN static void +_efl_ui_scroll_manager_efl_ui_scrollbar_bar_visibility_get(const Eo *obj EINA_UNUSED, Efl_Ui_Scroll_Manager_Data *sd, Eina_Bool *hbar, Eina_Bool *vbar) +{ + if (hbar) *hbar = sd->hbar_visible; + if (vbar) *vbar = sd->vbar_visible; +} + +EOLIAN static void _efl_ui_scroll_manager_efl_ui_scrollbar_bar_visibility_update(Eo *obj, Efl_Ui_Scroll_Manager_Data *sd EINA_UNUSED) { _efl_ui_scrollbar_h_visibility_adjust(obj); diff --git a/src/lib/elementary/efl_ui_scroll_manager.eo b/src/lib/elementary/efl_ui_scroll_manager.eo index 957a4f4d4d..9dcd9f8a88 100644 --- a/src/lib/elementary/efl_ui_scroll_manager.eo +++ b/src/lib/elementary/efl_ui_scroll_manager.eo @@ -39,6 +39,7 @@ class @beta Efl.Ui.Scroll.Manager extends Efl.Object implements Efl.Ui.Scrollbar.bar_mode { get; set; } Efl.Ui.Scrollbar.bar_size { get; } Efl.Ui.Scrollbar.bar_position { get; set; } + Efl.Ui.Scrollbar.bar_visibility { get; } Efl.Ui.Scrollbar.bar_visibility_update; Efl.Ui.Scrollable.scroll; } diff --git a/src/lib/elementary/efl_ui_scroll_util.c b/src/lib/elementary/efl_ui_scroll_util.c index 673cac2eae..6a7378e3b4 100644 --- a/src/lib/elementary/efl_ui_scroll_util.c +++ b/src/lib/elementary/efl_ui_scroll_util.c @@ -38,6 +38,20 @@ _scroll_connector_reload_cb(void *data, const char *source EINA_UNUSED) { Scroll_Connector_Context *ctx = data; + ELM_WIDGET_DATA_GET_OR_RETURN(ctx->obj, wd); + Eina_Bool hbar_visible = EINA_FALSE, vbar_visible = EINA_FALSE; + + efl_ui_scrollbar_bar_visibility_get(ctx->smanager, &hbar_visible, &vbar_visible); + + if (hbar_visible) + efl_layout_signal_emit(wd->resize_obj, "efl,horizontal_bar,visible,on", "efl"); + else + efl_layout_signal_emit(wd->resize_obj, "efl,horizontal_bar,visible,off", "efl"); + + if (vbar_visible) + efl_layout_signal_emit(wd->resize_obj, "efl,vertical_bar,visible,on", "efl"); + else + efl_layout_signal_emit(wd->resize_obj, "efl,vertical_bar,visible,off", "efl"); efl_ui_scrollbar_bar_visibility_update(ctx->smanager); } diff --git a/src/tests/elementary/efl_ui_test_list_collection.c b/src/tests/elementary/efl_ui_test_list_collection.c index 1d4f913901..94bafbd010 100644 --- a/src/tests/elementary/efl_ui_test_list_collection.c +++ b/src/tests/elementary/efl_ui_test_list_collection.c @@ -161,7 +161,7 @@ EFL_START_TEST(placement_test_group) r = efl_gfx_entity_geometry_get(core_item[i]); ck_assert_int_eq(r.x, 1); - ck_assert_int_eq(r.y, 21+(i - 1)*40); + ck_assert_int_eq(r.y, 22+(i - 1)*40); ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar. ck_assert_int_eq(r.h, 40); } @@ -181,7 +181,7 @@ EFL_START_TEST(placement_test_group) r = efl_gfx_entity_geometry_get(core_item[i]); ck_assert_int_eq(r.x, 1); - ck_assert_int_eq(r.y, 1+(i-2)*40); + ck_assert_int_eq(r.y, 2+(i-2)*40); ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar. ck_assert_int_eq(r.h, 40); } diff --git a/src/tests/elementary/efl_ui_test_scroller.c b/src/tests/elementary/efl_ui_test_scroller.c index e1aa4ef53b..78f8bfaf7f 100644 --- a/src/tests/elementary/efl_ui_test_scroller.c +++ b/src/tests/elementary/efl_ui_test_scroller.c @@ -144,7 +144,58 @@ EFL_START_TEST(efl_ui_test_scroller_events) } EFL_END_TEST +EFL_START_TEST(efl_ui_test_scroller_scrollbar) +{ + Eo *sc; + + Eo *win = win_add(); + Eina_Bool hbar_visible = EINA_FALSE, vbar_visible = EINA_FALSE; + efl_gfx_entity_size_set(win, EINA_SIZE2D(500, 500)); + + sc = efl_add(EFL_UI_SCROLLER_CLASS, win, + efl_ui_scrollbar_bar_mode_set(efl_added, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO), + efl_content_set(win, efl_added)); + + /*Scrollbar auto mode test.*/ + efl_loop_iterate(efl_main_loop_get()); + + efl_ui_scrollbar_bar_visibility_get(sc, &hbar_visible, &vbar_visible); + ck_assert(hbar_visible == EINA_FALSE); + ck_assert(vbar_visible == EINA_FALSE); + + /*Scrollbar auto mode test.*/ + efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(sc), + efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(5000, 5000)), + efl_content_set(sc, efl_added)); + + efl_loop_iterate(efl_main_loop_get()); + + efl_ui_scrollbar_bar_visibility_get(sc, &hbar_visible, &vbar_visible); + ck_assert(hbar_visible == EINA_TRUE); + ck_assert(vbar_visible == EINA_TRUE); + + /*Scrollbar off mode test.*/ + efl_ui_scrollbar_bar_mode_set(sc, EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF); + + efl_loop_iterate(efl_main_loop_get()); + + efl_ui_scrollbar_bar_visibility_get(sc, &hbar_visible, &vbar_visible); + ck_assert(hbar_visible == EINA_FALSE); + ck_assert(vbar_visible == EINA_FALSE); + + /*Scrollbar on mode test.*/ + efl_ui_scrollbar_bar_mode_set(sc, EFL_UI_SCROLLBAR_MODE_ON, EFL_UI_SCROLLBAR_MODE_ON); + + efl_loop_iterate(efl_main_loop_get()); + + efl_ui_scrollbar_bar_visibility_get(sc, &hbar_visible, &vbar_visible); + ck_assert(hbar_visible == EINA_TRUE); + ck_assert(vbar_visible == EINA_TRUE); +} +EFL_END_TEST + void efl_ui_test_scroller(TCase *tc) { tcase_add_test(tc, efl_ui_test_scroller_events); + tcase_add_test(tc, efl_ui_test_scroller_scrollbar); } |