summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaeun Choi <jaeun12.choi@samsung.com>2017-06-14 23:44:05 +0900
committerJaeun Choi <jaeun12.choi@samsung.com>2017-06-15 16:02:38 +0900
commit72a8fd60ca0aa2415db0db301cb90a849f9492e9 (patch)
treeb716edc418995583aa5e1a4ee377e189d1de2f87
parent7a66fdc7847395c23b13195d19b35f49fb9b2634 (diff)
efl_ui_scroll_manager: take the first step to breaking the inheritance of elm_interface_scrollabledevs/eunue/scrollable
the final goal is to implement efl_ui_scroll_manager without using elm_interface_scrollable API. to complete this job, i first broke the features down into several parts: basic scroll, scroll bar, scroll blocking, edge effect, key input handling, etc. this commit implements basic scroll feature at a low level.
-rw-r--r--src/lib/elementary/efl_ui_scroll_manager.c221
-rw-r--r--src/lib/elementary/efl_ui_widget_scroll_manager.h22
2 files changed, 229 insertions, 14 deletions
diff --git a/src/lib/elementary/efl_ui_scroll_manager.c b/src/lib/elementary/efl_ui_scroll_manager.c
index c237ef6f8b..25ae1fdaa5 100644
--- a/src/lib/elementary/efl_ui_scroll_manager.c
+++ b/src/lib/elementary/efl_ui_scroll_manager.c
@@ -9,6 +9,10 @@
9#define MY_CLASS EFL_UI_SCROLL_MANAGER_CLASS 9#define MY_CLASS EFL_UI_SCROLL_MANAGER_CLASS
10#define MY_CLASS_NAME "Efl_Ui_Scroll_Manager" 10#define MY_CLASS_NAME "Efl_Ui_Scroll_Manager"
11 11
12#define MY_SCROLLABLE_INTERFACE ELM_INTERFACE_SCROLLABLE_MIXIN
13#define MY_PAN_CLASS ELM_PAN_CLASS
14#define LEGACY 0
15
12 16
13EOLIAN static void 17EOLIAN static void
14_efl_ui_scroll_manager_scrollbar_mode_set(Eo *obj, 18_efl_ui_scroll_manager_scrollbar_mode_set(Eo *obj,
@@ -16,7 +20,10 @@ _efl_ui_scroll_manager_scrollbar_mode_set(Eo *obj,
16 Efl_Ui_Scrollbar_Mode hmode, 20 Efl_Ui_Scrollbar_Mode hmode,
17 Efl_Ui_Scrollbar_Mode vmode) 21 Efl_Ui_Scrollbar_Mode vmode)
18{ 22{
23#if LEGACY
19 elm_interface_scrollable_policy_set(obj, hmode, vmode); 24 elm_interface_scrollable_policy_set(obj, hmode, vmode);
25#else
26#endif
20} 27}
21 28
22EOLIAN static Efl_Ui_Focus_Manager* 29EOLIAN static Efl_Ui_Focus_Manager*
@@ -39,7 +46,7 @@ _efl_ui_scroll_manager_efl_gfx_size_set(Eo *obj EINA_UNUSED,
39 Evas_Coord w, 46 Evas_Coord w,
40 Evas_Coord h) 47 Evas_Coord h)
41{ 48{
42 efl_gfx_size_set(sd->hit_rect, w, h); 49 efl_gfx_size_set(sd->event_obj, w, h);
43} 50}
44 51
45EOLIAN static void 52EOLIAN static void
@@ -48,19 +55,168 @@ _efl_ui_scroll_manager_efl_gfx_position_set(Eo *obj EINA_UNUSED,
48 Evas_Coord x, 55 Evas_Coord x,
49 Evas_Coord y) 56 Evas_Coord y)
50{ 57{
51 efl_gfx_position_set(sd->hit_rect, x, y); 58 efl_gfx_position_set(sd->event_obj, x, y);
52} 59}
53 60
61#if LEGACY
54static void 62static void
55_resize_cb(Evas_Object *obj, Evas_Coord w EINA_UNUSED, Evas_Coord h EINA_UNUSED) 63_viewport_resize_cb(Evas_Object *obj, Evas_Coord w EINA_UNUSED, Evas_Coord h EINA_UNUSED)
56{ 64{
57 Evas_Coord minw, minh; 65 Evas_Coord minw, minh;
58 Efl_Ui_Scroll_Manager_Data *sd = efl_data_scope_get(obj, EFL_UI_SCROLL_MANAGER_CLASS); 66 Efl_Ui_Scroll_Manager_Data *sd = efl_data_scope_get(obj, EFL_UI_SCROLL_MANAGER_CLASS);
59 67
60 efl_gfx_size_hint_combined_min_get(sd->content, &minw, &minh); 68 efl_gfx_size_hint_combined_min_get(sd->content.obj, &minw, &minh);
61 efl_gfx_size_set(sd->content, minw, minh); 69 efl_gfx_size_set(sd->content.obj, minw, minh);
70}
71#else
72static void
73_edje_object_resize_cb(void *data,
74 Evas *e EINA_UNUSED,
75 Evas_Object *obj,
76 void *event_info EINA_UNUSED)
77{
78 Efl_Ui_Scroll_Manager_Data *sd = data;
79 Evas_Coord w, h;
80 efl_gfx_size_get(obj, &w, &h);
81
82 sd->edje_obj.w = w;
83 sd->edje_obj.h = h;
84}
85
86static void
87_edje_object_move_cb(void *data,
88 Evas *e EINA_UNUSED,
89 Evas_Object *obj,
90 void *event_info EINA_UNUSED)
91{
92 Efl_Ui_Scroll_Manager_Data *sd = data;
93 Evas_Coord x, y;
94 efl_gfx_position_get(obj, &x, &y);
95
96 sd->edje_obj.x = x;
97 sd->edje_obj.y = y;
98}
99
100static void
101_mouse_down_cb(void *data,
102 Evas *e,
103 Evas_Object *obj,
104 void *event_info)
105{
106 Efl_Ui_Scroll_Manager_Data *sd = data;
107 Evas_Event_Mouse_Down *ev = event_info;
108
109 sd->down.on = EINA_TRUE;
110 sd->down.x = ev->canvas.x;
111 sd->down.y = ev->canvas.y;
112
113 sd->prev_x = sd->down.x;
114 sd->prev_y = sd->down.y;
115}
116
117static void
118_mouse_move_cb(void *data,
119 Evas *e,
120 Evas_Object *obj,
121 void *event_info)
122{
123 Efl_Ui_Scroll_Manager_Data *sd = data;
124 Evas_Event_Mouse_Move *ev = event_info;
125 Evas_Coord cur_x, cur_y, dx, dy, x, y;
126
127 if (!sd->down.on) return;
128
129 cur_x = ev->cur.canvas.x;
130 cur_y = ev->cur.canvas.y;
131 dx = cur_x - sd->prev_x;
132 dy = cur_y - sd->prev_y;
133
134 elm_obj_pan_pos_get(sd->pan_obj, &x, &y);
135 elm_obj_pan_pos_set(sd->pan_obj, (x - dx), (y - dy));
136
137 sd->prev_x = cur_x;
138 sd->prev_y = cur_y;
139}
140
141static void
142_mouse_up_cb(void *data,
143 Evas *e,
144 Evas_Object *obj,
145 void *event_info)
146{
147 Efl_Ui_Scroll_Manager_Data *sd = data;
148 Evas_Event_Mouse_Up *ev = event_info;
149
150 sd->down.on = EINA_FALSE;
151}
152
153static void
154_edje_object_cb_add(Efl_Ui_Scroll_Manager_Data *sd)
155{
156 evas_object_event_callback_add
157 (sd->edje_obj.obj, EVAS_CALLBACK_RESIZE, _edje_object_resize_cb, sd);
158 evas_object_event_callback_add
159 (sd->edje_obj.obj, EVAS_CALLBACK_MOVE, _edje_object_move_cb, sd);
160}
161
162static void
163_edje_object_cb_del(Efl_Ui_Scroll_Manager_Data *sd)
164{
165 evas_object_event_callback_del_full
166 (sd->edje_obj.obj, EVAS_CALLBACK_RESIZE, _edje_object_resize_cb, sd);
167 evas_object_event_callback_del_full
168 (sd->edje_obj.obj, EVAS_CALLBACK_MOVE, _edje_object_move_cb, sd);
169}
170
171static void
172_event_object_cb_add(Efl_Ui_Scroll_Manager_Data *sd)
173{
174 evas_object_event_callback_add
175 (sd->event_obj, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, sd);
176 evas_object_event_callback_add
177 (sd->event_obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, sd);
178 evas_object_event_callback_add
179 (sd->event_obj, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, sd);
62} 180}
63 181
182static void
183_event_object_cb_del(Efl_Ui_Scroll_Manager_Data *sd)
184{
185 evas_object_event_callback_del_full
186 (sd->event_obj, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, sd);
187 evas_object_event_callback_del_full
188 (sd->event_obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, sd);
189 evas_object_event_callback_del_full
190 (sd->event_obj, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, sd);
191}
192
193static void
194_pan_object_change_cb(void *data, const Efl_Event *event EINA_UNUSED)
195{
196 Efl_Ui_Scroll_Manager_Data *sd = data;
197 Evas_Coord w, h;
198
199 elm_obj_pan_content_size_get(sd->pan_obj, &w, &h);
200 sd->content.w = w;
201 sd->content.h = h;
202 evas_object_size_hint_min_set(sd->edje_obj.obj, sd->content.w, sd->content.h);
203}
204
205static void
206_pan_object_resize_cb(void *data,
207 Evas *e EINA_UNUSED,
208 Evas_Object *obj EINA_UNUSED,
209 void *event_info EINA_UNUSED)
210{
211 Efl_Ui_Scroll_Manager_Data *sd = data;
212 Evas_Coord minw, minh;
213
214 edje_object_calc_force(sd->edje_obj.obj);
215 efl_gfx_size_hint_combined_min_get(sd->content.obj, &minw, &minh);
216 efl_gfx_size_set(sd->content.obj, minw, minh);
217}
218#endif
219
64EOLIAN static void 220EOLIAN static void
65_efl_ui_scroll_manager_efl_canvas_group_group_add(Eo *obj, 221_efl_ui_scroll_manager_efl_canvas_group_group_add(Eo *obj,
66 Efl_Ui_Scroll_Manager_Data *sd) 222 Efl_Ui_Scroll_Manager_Data *sd)
@@ -68,15 +224,38 @@ _efl_ui_scroll_manager_efl_canvas_group_group_add(Eo *obj,
68 sd->parent = efl_parent_get(obj); 224 sd->parent = efl_parent_get(obj);
69 ELM_WIDGET_DATA_GET_OR_RETURN(sd->parent, wd); 225 ELM_WIDGET_DATA_GET_OR_RETURN(sd->parent, wd);
70 226
227#if LEGACY
71 efl_canvas_group_add(efl_super(obj, MY_CLASS)); 228 efl_canvas_group_add(efl_super(obj, MY_CLASS));
72 229
73 sd->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj)); 230 sd->event_obj = evas_object_rectangle_add(evas_object_evas_get(obj));
74 efl_gfx_color_set(sd->hit_rect, 0, 0, 0, 0); 231 efl_gfx_color_set(sd->event_obj, 0, 0, 0, 0);
75 efl_gfx_visible_set(sd->hit_rect, EINA_TRUE); 232 efl_gfx_visible_set(sd->event_obj, EINA_TRUE);
76 233
77 elm_interface_scrollable_objects_set(obj, wd->resize_obj, sd->hit_rect); 234 elm_interface_scrollable_objects_set(obj, wd->resize_obj, sd->event_obj);
78 235
79 elm_interface_scrollable_content_viewport_resize_cb_set(obj, _resize_cb); 236 elm_interface_scrollable_content_viewport_resize_cb_set(obj, _viewport_resize_cb);
237#else
238 efl_canvas_group_add(efl_super(obj, MY_SCROLLABLE_INTERFACE));
239
240 sd->edje_obj.x = 0;
241 sd->edje_obj.y = 0;
242 sd->edje_obj.w = 0;
243 sd->edje_obj.h = 0;
244
245 if (sd->edje_obj.obj) _edje_object_cb_del(sd);
246 sd->edje_obj.obj = wd->resize_obj;
247
248 _edje_object_cb_add(sd);
249
250 if (sd->event_obj) _event_object_cb_del(sd);
251
252 sd->event_obj = evas_object_rectangle_add(evas_object_evas_get(obj));
253 efl_gfx_color_set(sd->event_obj, 0, 0, 0, 0);
254 efl_gfx_visible_set(sd->event_obj, EINA_TRUE);
255 efl_canvas_object_repeat_events_set(sd->event_obj, EINA_TRUE);
256
257 _event_object_cb_add(sd);
258#endif
80} 259}
81 260
82EOLIAN static void 261EOLIAN static void
@@ -84,11 +263,29 @@ _efl_ui_scroll_manager_content_set(Eo *obj,
84 Efl_Ui_Scroll_Manager_Data *sd, 263 Efl_Ui_Scroll_Manager_Data *sd,
85 Evas_Object *content) 264 Evas_Object *content)
86{ 265{
87 if (sd->content == content) return; 266 Evas_Coord w, h;
267 if (sd->content.obj == content) return;
88 268
89 sd->content = content; 269 sd->content.obj = content;
90 efl_canvas_group_member_add(obj, content); 270 efl_canvas_group_member_add(obj, content);
271#if LEGACY
91 elm_interface_scrollable_content_set(obj, content); 272 elm_interface_scrollable_content_set(obj, content);
273#else
274 if (!sd->pan_obj)
275 {
276 sd->pan_obj = efl_add(MY_PAN_CLASS, evas_object_evas_get(obj));
277 efl_event_callback_add(sd->pan_obj, ELM_PAN_EVENT_CHANGED,
278 _pan_object_change_cb, sd);
279 evas_object_event_callback_add(sd->pan_obj, EVAS_CALLBACK_RESIZE,
280 _pan_object_resize_cb, sd);
281 edje_object_part_swallow(sd->edje_obj.obj, "elm.swallow.content",
282 sd->pan_obj);
283 }
284 elm_obj_pan_content_set(sd->pan_obj, content);
285 elm_obj_pan_content_size_get(sd->pan_obj, &w, &h);
286 sd->content.w = w;
287 sd->content.h = h;
288#endif
92} 289}
93 290
94EOLIAN static Eo * 291EOLIAN static Eo *
diff --git a/src/lib/elementary/efl_ui_widget_scroll_manager.h b/src/lib/elementary/efl_ui_widget_scroll_manager.h
index 231ba05744..070cb5e75d 100644
--- a/src/lib/elementary/efl_ui_widget_scroll_manager.h
+++ b/src/lib/elementary/efl_ui_widget_scroll_manager.h
@@ -5,10 +5,28 @@
5 5
6typedef struct _Efl_Ui_Scroll_Manager_Data 6typedef struct _Efl_Ui_Scroll_Manager_Data
7{ 7{
8 Evas_Coord prev_x, prev_y;
9
10 struct {
11 Evas_Object *obj;
12 Evas_Coord x, y, w, h;
13 } edje_obj;
14
15 struct {
16 Evas_Object *obj;
17 Evas_Coord w, h;
18 } content;
19
20 struct {
21 Evas_Coord x, y; //mouse cursor
22 Evas_Coord cx, cy; //content position
23 Eina_Bool on : 1;
24 } down;
25
8 Eo *parent; 26 Eo *parent;
9 27
10 Evas_Object *hit_rect; 28 Evas_Object *event_obj;
11 Evas_Object *content; 29 Evas_Object *pan_obj;
12 30
13} Efl_Ui_Scroll_Manager_Data; 31} Efl_Ui_Scroll_Manager_Data;
14 32