summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHosang Kim <hosang12.kim@samsung.com>2020-01-10 09:26:32 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-17 17:21:09 +0100
commitfbb77e7d1c3116f4187370ec9406755f38cf44be (patch)
tree429f27f90728582e79b9f53248dcab66c2e4cfb2
parentbac185e8f3ed5a17d9c29e5daf2e2038b6734767 (diff)
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
-rw-r--r--src/lib/efl/interfaces/efl_ui_scrollbar.eo12
-rw-r--r--src/lib/elementary/efl_ui_scroll_manager.c7
-rw-r--r--src/lib/elementary/efl_ui_scroll_manager.eo1
-rw-r--r--src/lib/elementary/efl_ui_scroll_util.c14
-rw-r--r--src/tests/elementary/efl_ui_test_list_collection.c4
-rw-r--r--src/tests/elementary/efl_ui_test_scroller.c51
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
60 and $[1.0] (the bottom side of the thumb is touching the bottom edge of the widget).]] 60 and $[1.0] (the bottom side of the thumb is touching the bottom edge of the widget).]]
61 } 61 }
62 } 62 }
63 @property bar_visibility {
64 [[Current visibility state of the scrollbars.
65 This is useful in @Efl.Ui.Scrollbar_Mode.auto mode where EFL decides if the scrollbars
66 are shown or hidden. See also the @[.bar,show] and @[.bar,hide] events.
67 ]]
68 get {
69 }
70 values {
71 hbar: bool; [[Whether the horizontal scrollbar is currently visible.]]
72 vbar: bool; [[Whether the vertical scrollbar is currently visible.]]
73 }
74 }
63 bar_visibility_update @protected @beta{ 75 bar_visibility_update @protected @beta{
64 [[Update bar visibility. 76 [[Update bar visibility.
65 77
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)
2188} 2188}
2189 2189
2190EOLIAN static void 2190EOLIAN static void
2191_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)
2192{
2193 if (hbar) *hbar = sd->hbar_visible;
2194 if (vbar) *vbar = sd->vbar_visible;
2195}
2196
2197EOLIAN static void
2191_efl_ui_scroll_manager_efl_ui_scrollbar_bar_visibility_update(Eo *obj, Efl_Ui_Scroll_Manager_Data *sd EINA_UNUSED) 2198_efl_ui_scroll_manager_efl_ui_scrollbar_bar_visibility_update(Eo *obj, Efl_Ui_Scroll_Manager_Data *sd EINA_UNUSED)
2192{ 2199{
2193 _efl_ui_scrollbar_h_visibility_adjust(obj); 2200 _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
39 Efl.Ui.Scrollbar.bar_mode { get; set; } 39 Efl.Ui.Scrollbar.bar_mode { get; set; }
40 Efl.Ui.Scrollbar.bar_size { get; } 40 Efl.Ui.Scrollbar.bar_size { get; }
41 Efl.Ui.Scrollbar.bar_position { get; set; } 41 Efl.Ui.Scrollbar.bar_position { get; set; }
42 Efl.Ui.Scrollbar.bar_visibility { get; }
42 Efl.Ui.Scrollbar.bar_visibility_update; 43 Efl.Ui.Scrollbar.bar_visibility_update;
43 Efl.Ui.Scrollable.scroll; 44 Efl.Ui.Scrollable.scroll;
44 } 45 }
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,
38 const char *source EINA_UNUSED) 38 const char *source EINA_UNUSED)
39{ 39{
40 Scroll_Connector_Context *ctx = data; 40 Scroll_Connector_Context *ctx = data;
41 ELM_WIDGET_DATA_GET_OR_RETURN(ctx->obj, wd);
42 Eina_Bool hbar_visible = EINA_FALSE, vbar_visible = EINA_FALSE;
43
44 efl_ui_scrollbar_bar_visibility_get(ctx->smanager, &hbar_visible, &vbar_visible);
45
46 if (hbar_visible)
47 efl_layout_signal_emit(wd->resize_obj, "efl,horizontal_bar,visible,on", "efl");
48 else
49 efl_layout_signal_emit(wd->resize_obj, "efl,horizontal_bar,visible,off", "efl");
50
51 if (vbar_visible)
52 efl_layout_signal_emit(wd->resize_obj, "efl,vertical_bar,visible,on", "efl");
53 else
54 efl_layout_signal_emit(wd->resize_obj, "efl,vertical_bar,visible,off", "efl");
41 55
42 efl_ui_scrollbar_bar_visibility_update(ctx->smanager); 56 efl_ui_scrollbar_bar_visibility_update(ctx->smanager);
43} 57}
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)
161 r = efl_gfx_entity_geometry_get(core_item[i]); 161 r = efl_gfx_entity_geometry_get(core_item[i]);
162 162
163 ck_assert_int_eq(r.x, 1); 163 ck_assert_int_eq(r.x, 1);
164 ck_assert_int_eq(r.y, 21+(i - 1)*40); 164 ck_assert_int_eq(r.y, 22+(i - 1)*40);
165 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar. 165 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
166 ck_assert_int_eq(r.h, 40); 166 ck_assert_int_eq(r.h, 40);
167 } 167 }
@@ -181,7 +181,7 @@ EFL_START_TEST(placement_test_group)
181 r = efl_gfx_entity_geometry_get(core_item[i]); 181 r = efl_gfx_entity_geometry_get(core_item[i]);
182 182
183 ck_assert_int_eq(r.x, 1); 183 ck_assert_int_eq(r.x, 1);
184 ck_assert_int_eq(r.y, 1+(i-2)*40); 184 ck_assert_int_eq(r.y, 2+(i-2)*40);
185 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar. 185 ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
186 ck_assert_int_eq(r.h, 40); 186 ck_assert_int_eq(r.h, 40);
187 } 187 }
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)
144} 144}
145EFL_END_TEST 145EFL_END_TEST
146 146
147EFL_START_TEST(efl_ui_test_scroller_scrollbar)
148{
149 Eo *sc;
150
151 Eo *win = win_add();
152 Eina_Bool hbar_visible = EINA_FALSE, vbar_visible = EINA_FALSE;
153 efl_gfx_entity_size_set(win, EINA_SIZE2D(500, 500));
154
155 sc = efl_add(EFL_UI_SCROLLER_CLASS, win,
156 efl_ui_scrollbar_bar_mode_set(efl_added, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO),
157 efl_content_set(win, efl_added));
158
159 /*Scrollbar auto mode test.*/
160 efl_loop_iterate(efl_main_loop_get());
161
162 efl_ui_scrollbar_bar_visibility_get(sc, &hbar_visible, &vbar_visible);
163 ck_assert(hbar_visible == EINA_FALSE);
164 ck_assert(vbar_visible == EINA_FALSE);
165
166 /*Scrollbar auto mode test.*/
167 efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(sc),
168 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(5000, 5000)),
169 efl_content_set(sc, efl_added));
170
171 efl_loop_iterate(efl_main_loop_get());
172
173 efl_ui_scrollbar_bar_visibility_get(sc, &hbar_visible, &vbar_visible);
174 ck_assert(hbar_visible == EINA_TRUE);
175 ck_assert(vbar_visible == EINA_TRUE);
176
177 /*Scrollbar off mode test.*/
178 efl_ui_scrollbar_bar_mode_set(sc, EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
179
180 efl_loop_iterate(efl_main_loop_get());
181
182 efl_ui_scrollbar_bar_visibility_get(sc, &hbar_visible, &vbar_visible);
183 ck_assert(hbar_visible == EINA_FALSE);
184 ck_assert(vbar_visible == EINA_FALSE);
185
186 /*Scrollbar on mode test.*/
187 efl_ui_scrollbar_bar_mode_set(sc, EFL_UI_SCROLLBAR_MODE_ON, EFL_UI_SCROLLBAR_MODE_ON);
188
189 efl_loop_iterate(efl_main_loop_get());
190
191 efl_ui_scrollbar_bar_visibility_get(sc, &hbar_visible, &vbar_visible);
192 ck_assert(hbar_visible == EINA_TRUE);
193 ck_assert(vbar_visible == EINA_TRUE);
194}
195EFL_END_TEST
196
147void efl_ui_test_scroller(TCase *tc) 197void efl_ui_test_scroller(TCase *tc)
148{ 198{
149 tcase_add_test(tc, efl_ui_test_scroller_events); 199 tcase_add_test(tc, efl_ui_test_scroller_events);
200 tcase_add_test(tc, efl_ui_test_scroller_scrollbar);
150} 201}