summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorJinYong Park <j4939.park@samsung.com>2017-12-15 13:56:25 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-12-15 13:56:25 +0900
commitccfa9ae2201a6b567859f8d16d2674c3be7b81f6 (patch)
tree707725c8286175f052ed752012aca444bda09123 /src/lib
parentfe8c5f8269b06165a7c7b1da9a956ef0839bad52 (diff)
Efl.Ui.Popup.Anchor: apply group calculate with size problem fix
Summary: Size and align calculation in Efl.Ui.Popup was advanced using group calculate, so Efl.Ui.Popup.Anchor apply it also. Test Plan: elementary_test -to efl.ui.popup.anchor Reviewers: Jaehyun_Cho, herb, jpeg, woohyun, cedric Reviewed By: Jaehyun_Cho Differential Revision: https://phab.enlightenment.org/D5655
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elementary/efl_ui_popup.c12
-rw-r--r--src/lib/elementary/efl_ui_popup_anchor.c104
-rw-r--r--src/lib/elementary/efl_ui_popup_anchor.eo2
-rw-r--r--src/lib/elementary/efl_ui_popup_anchor_private.h1
4 files changed, 58 insertions, 61 deletions
diff --git a/src/lib/elementary/efl_ui_popup.c b/src/lib/elementary/efl_ui_popup.c
index f8134d285b..c5cf4f54dd 100644
--- a/src/lib/elementary/efl_ui_popup.c
+++ b/src/lib/elementary/efl_ui_popup.c
@@ -40,9 +40,6 @@ _calc_align(Eo *obj)
40 40
41 Eina_Rect p_geom = efl_gfx_geometry_get(pd->win_parent); 41 Eina_Rect p_geom = efl_gfx_geometry_get(pd->win_parent);
42 42
43 efl_gfx_position_set(pd->backwall, EINA_POSITION2D(0, 0));
44 efl_gfx_size_set(pd->backwall, EINA_SIZE2D(p_geom.w, p_geom.h));
45
46 Eina_Rect o_geom = efl_gfx_geometry_get(obj); 43 Eina_Rect o_geom = efl_gfx_geometry_get(obj);
47 44
48 Evas_Coord pw, ph; 45 Evas_Coord pw, ph;
@@ -80,10 +77,7 @@ _efl_ui_popup_efl_gfx_size_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Eina_
80{ 77{
81 efl_gfx_size_set(efl_super(obj, MY_CLASS), size); 78 efl_gfx_size_set(efl_super(obj, MY_CLASS), size);
82 79
83 //Add align calc only
84 Eina_Bool needs_size_calc = pd->needs_size_calc;
85 elm_layout_sizing_eval(obj); 80 elm_layout_sizing_eval(obj);
86 pd->needs_size_calc = needs_size_calc;
87} 81}
88 82
89static void 83static void
@@ -312,6 +306,12 @@ _efl_ui_popup_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Popup_Data *pd)
312 _calc_align(obj); 306 _calc_align(obj);
313 pd->needs_align_calc = EINA_FALSE; 307 pd->needs_align_calc = EINA_FALSE;
314 } 308 }
309
310 Eina_Rect p_geom = efl_gfx_geometry_get(pd->win_parent);
311
312 efl_gfx_position_set(pd->backwall, EINA_POSITION2D(0, 0));
313 efl_gfx_size_set(pd->backwall, EINA_SIZE2D(p_geom.w, p_geom.h));
314
315 pd->needs_group_calc = EINA_FALSE; 315 pd->needs_group_calc = EINA_FALSE;
316 } 316 }
317} 317}
diff --git a/src/lib/elementary/efl_ui_popup_anchor.c b/src/lib/elementary/efl_ui_popup_anchor.c
index b94bf7edd3..c1bf965b8b 100644
--- a/src/lib/elementary/efl_ui_popup_anchor.c
+++ b/src/lib/elementary/efl_ui_popup_anchor.c
@@ -8,6 +8,7 @@
8#include <Elementary.h> 8#include <Elementary.h>
9 9
10#include "elm_priv.h" 10#include "elm_priv.h"
11#include "efl_ui_popup_private.h"
11#include "efl_ui_popup_anchor_private.h" 12#include "efl_ui_popup_anchor_private.h"
12 13
13#define MY_CLASS EFL_UI_POPUP_ANCHOR_CLASS 14#define MY_CLASS EFL_UI_POPUP_ANCHOR_CLASS
@@ -17,7 +18,8 @@ static void
17_anchor_calc(Eo *obj) 18_anchor_calc(Eo *obj)
18{ 19{
19 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 20 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
20 EFL_UI_POPUP_ANCHOR_DATA_GET(obj, sd); 21 EFL_UI_POPUP_DATA_GET_OR_RETURN(obj, ppd);
22 EFL_UI_POPUP_ANCHOR_DATA_GET(obj, pd);
21 23
22 Eina_Position2D pos = {0, 0}; 24 Eina_Position2D pos = {0, 0};
23 25
@@ -28,11 +30,11 @@ _anchor_calc(Eo *obj)
28 return; 30 return;
29 } 31 }
30 32
31 Eina_Rect a_geom = efl_gfx_geometry_get(sd->anchor); 33 Eina_Rect a_geom = efl_gfx_geometry_get(pd->anchor);
32 Eina_Rect o_geom = efl_gfx_geometry_get(obj); 34 Eina_Rect o_geom = efl_gfx_geometry_get(obj);
33 Eina_Rect p_geom = efl_gfx_geometry_get(parent); 35 Eina_Rect p_geom = efl_gfx_geometry_get(parent);
34 36
35 sd->used_align = EFL_UI_POPUP_ALIGN_NONE; 37 pd->used_align = EFL_UI_POPUP_ALIGN_NONE;
36 38
37 /* 1. Find align which display popup. 39 /* 1. Find align which display popup.
38 It enables to shifting popup from exact position. 40 It enables to shifting popup from exact position.
@@ -46,9 +48,9 @@ _anchor_calc(Eo *obj)
46 Efl_Ui_Popup_Align cur_align; 48 Efl_Ui_Popup_Align cur_align;
47 49
48 if (idx == 0) 50 if (idx == 0)
49 cur_align = sd->align; 51 cur_align = ppd->align;
50 else 52 else
51 cur_align = sd->priority[idx - 1]; 53 cur_align = pd->priority[idx - 1];
52 54
53 if (cur_align == EFL_UI_POPUP_ALIGN_NONE) 55 if (cur_align == EFL_UI_POPUP_ALIGN_NONE)
54 continue; 56 continue;
@@ -135,7 +137,7 @@ _anchor_calc(Eo *obj)
135 continue; 137 continue;
136 } 138 }
137 139
138 sd->used_align = cur_align; 140 pd->used_align = cur_align;
139 goto end; 141 goto end;
140 } 142 }
141 143
@@ -146,9 +148,9 @@ _anchor_calc(Eo *obj)
146 Efl_Ui_Popup_Align cur_align; 148 Efl_Ui_Popup_Align cur_align;
147 149
148 if (idx == 0) 150 if (idx == 0)
149 cur_align = sd->align; 151 cur_align = ppd->align;
150 else 152 else
151 cur_align = sd->priority[idx - 1]; 153 cur_align = pd->priority[idx - 1];
152 154
153 if (cur_align == EFL_UI_POPUP_ALIGN_NONE) 155 if (cur_align == EFL_UI_POPUP_ALIGN_NONE)
154 continue; 156 continue;
@@ -158,35 +160,35 @@ _anchor_calc(Eo *obj)
158 case EFL_UI_POPUP_ALIGN_TOP: 160 case EFL_UI_POPUP_ALIGN_TOP:
159 pos.x = a_geom.x + ((a_geom.w - o_geom.w) / 2); 161 pos.x = a_geom.x + ((a_geom.w - o_geom.w) / 2);
160 pos.y = (a_geom.y - o_geom.h); 162 pos.y = (a_geom.y - o_geom.h);
161 sd->used_align = cur_align; 163 pd->used_align = cur_align;
162 goto end; 164 goto end;
163 break; 165 break;
164 166
165 case EFL_UI_POPUP_ALIGN_LEFT: 167 case EFL_UI_POPUP_ALIGN_LEFT:
166 pos.x = (a_geom.x - o_geom.w); 168 pos.x = (a_geom.x - o_geom.w);
167 pos.y = a_geom.y + ((a_geom.h - o_geom.h) / 2); 169 pos.y = a_geom.y + ((a_geom.h - o_geom.h) / 2);
168 sd->used_align = cur_align; 170 pd->used_align = cur_align;
169 goto end; 171 goto end;
170 break; 172 break;
171 173
172 case EFL_UI_POPUP_ALIGN_RIGHT: 174 case EFL_UI_POPUP_ALIGN_RIGHT:
173 pos.x = (a_geom.x + a_geom.w); 175 pos.x = (a_geom.x + a_geom.w);
174 pos.y = a_geom.y + ((a_geom.h - o_geom.h) / 2); 176 pos.y = a_geom.y + ((a_geom.h - o_geom.h) / 2);
175 sd->used_align = cur_align; 177 pd->used_align = cur_align;
176 goto end; 178 goto end;
177 break; 179 break;
178 180
179 case EFL_UI_POPUP_ALIGN_BOTTOM: 181 case EFL_UI_POPUP_ALIGN_BOTTOM:
180 pos.x = a_geom.x + ((a_geom.w - o_geom.w) / 2); 182 pos.x = a_geom.x + ((a_geom.w - o_geom.w) / 2);
181 pos.y = (a_geom.y + a_geom.h); 183 pos.y = (a_geom.y + a_geom.h);
182 sd->used_align = cur_align; 184 pd->used_align = cur_align;
183 goto end; 185 goto end;
184 break; 186 break;
185 187
186 case EFL_UI_POPUP_ALIGN_CENTER: 188 case EFL_UI_POPUP_ALIGN_CENTER:
187 pos.x = a_geom.x + ((a_geom.w - o_geom.w) / 2); 189 pos.x = a_geom.x + ((a_geom.w - o_geom.w) / 2);
188 pos.y = a_geom.y + ((a_geom.h - o_geom.h) / 2); 190 pos.y = a_geom.y + ((a_geom.h - o_geom.h) / 2);
189 sd->used_align = cur_align; 191 pd->used_align = cur_align;
190 goto end; 192 goto end;
191 break; 193 break;
192 194
@@ -196,7 +198,7 @@ _anchor_calc(Eo *obj)
196 } 198 }
197 199
198end: 200end:
199 if (sd->used_align != EFL_UI_POPUP_ALIGN_NONE) 201 if (pd->used_align != EFL_UI_POPUP_ALIGN_NONE)
200 efl_gfx_position_set(efl_super(obj, EFL_UI_POPUP_CLASS), pos); 202 efl_gfx_position_set(efl_super(obj, EFL_UI_POPUP_CLASS), pos);
201} 203}
202 204
@@ -209,7 +211,8 @@ _anchor_geom_cb(void *data, const Efl_Event *ev EINA_UNUSED)
209static void 211static void
210_anchor_del_cb(void *data, const Efl_Event *ev EINA_UNUSED) 212_anchor_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
211{ 213{
212 EFL_UI_POPUP_ANCHOR_DATA_GET(data, sd); 214 EFL_UI_POPUP_DATA_GET_OR_RETURN(data, ppd);
215 EFL_UI_POPUP_ANCHOR_DATA_GET(data, pd);
213 216
214 Eo *parent = efl_provider_find(data, EFL_UI_WIN_CLASS); 217 Eo *parent = efl_provider_find(data, EFL_UI_WIN_CLASS);
215 if (!parent) 218 if (!parent)
@@ -220,16 +223,19 @@ _anchor_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
220 223
221 efl_event_callback_del(parent, EFL_GFX_EVENT_RESIZE, _anchor_geom_cb, data); 224 efl_event_callback_del(parent, EFL_GFX_EVENT_RESIZE, _anchor_geom_cb, data);
222 225
223 sd->anchor = NULL; 226 pd->anchor = NULL;
224 efl_ui_popup_align_set(efl_super(data, MY_CLASS), sd->align); 227 //Add align calc only
228 Eina_Bool needs_size_calc = ppd->needs_size_calc;
229 elm_layout_sizing_eval(data);
230 ppd->needs_size_calc = needs_size_calc;
225} 231}
226 232
227static void 233static void
228_anchor_detach(Eo *obj) 234_anchor_detach(Eo *obj)
229{ 235{
230 EFL_UI_POPUP_ANCHOR_DATA_GET(obj, sd); 236 EFL_UI_POPUP_ANCHOR_DATA_GET(obj, pd);
231 237
232 if (sd->anchor == NULL) return; 238 if (!pd->anchor) return;
233 239
234 Eo *parent = efl_provider_find(obj, EFL_UI_WIN_CLASS); 240 Eo *parent = efl_provider_find(obj, EFL_UI_WIN_CLASS);
235 if (!parent) 241 if (!parent)
@@ -239,25 +245,21 @@ _anchor_detach(Eo *obj)
239 } 245 }
240 246
241 efl_event_callback_del(parent, EFL_GFX_EVENT_RESIZE, _anchor_geom_cb, obj); 247 efl_event_callback_del(parent, EFL_GFX_EVENT_RESIZE, _anchor_geom_cb, obj);
242 efl_event_callback_del(sd->anchor, EFL_GFX_EVENT_RESIZE, _anchor_geom_cb, obj); 248 efl_event_callback_del(pd->anchor, EFL_GFX_EVENT_RESIZE, _anchor_geom_cb, obj);
243 efl_event_callback_del(sd->anchor, EFL_GFX_EVENT_MOVE, _anchor_geom_cb, obj); 249 efl_event_callback_del(pd->anchor, EFL_GFX_EVENT_MOVE, _anchor_geom_cb, obj);
244 efl_event_callback_del(sd->anchor, EFL_EVENT_DEL, _anchor_del_cb, obj); 250 efl_event_callback_del(pd->anchor, EFL_EVENT_DEL, _anchor_del_cb, obj);
245} 251}
246 252
247EOLIAN static void 253EOLIAN static void
248_efl_ui_popup_anchor_anchor_set(Eo *obj, Efl_Ui_Popup_Anchor_Data *pd, Eo *anchor) 254_efl_ui_popup_anchor_anchor_set(Eo *obj, Efl_Ui_Popup_Anchor_Data *pd, Eo *anchor)
249{ 255{
256 EFL_UI_POPUP_DATA_GET_OR_RETURN(obj, ppd);
257
250 _anchor_detach(obj); 258 _anchor_detach(obj);
251 pd->anchor = anchor; 259 pd->anchor = anchor;
252 260
253 if (anchor == NULL) 261 if (anchor)
254 efl_ui_popup_align_set(efl_super(obj, MY_CLASS), pd->align);
255 else
256 { 262 {
257 efl_ui_popup_align_set(efl_super(obj, MY_CLASS), EFL_UI_POPUP_ALIGN_NONE);
258
259 _anchor_calc(obj);
260
261 Eo *parent = efl_provider_find(obj, EFL_UI_WIN_CLASS); 263 Eo *parent = efl_provider_find(obj, EFL_UI_WIN_CLASS);
262 if (!parent) 264 if (!parent)
263 { 265 {
@@ -270,6 +272,11 @@ _efl_ui_popup_anchor_anchor_set(Eo *obj, Efl_Ui_Popup_Anchor_Data *pd, Eo *ancho
270 efl_event_callback_add(anchor, EFL_GFX_EVENT_MOVE, _anchor_geom_cb, obj); 272 efl_event_callback_add(anchor, EFL_GFX_EVENT_MOVE, _anchor_geom_cb, obj);
271 efl_event_callback_add(anchor, EFL_EVENT_DEL, _anchor_del_cb, obj); 273 efl_event_callback_add(anchor, EFL_EVENT_DEL, _anchor_del_cb, obj);
272 } 274 }
275
276 //Add align/anchor calc only
277 Eina_Bool needs_size_calc = ppd->needs_size_calc;
278 elm_layout_sizing_eval(obj);
279 ppd->needs_size_calc = needs_size_calc;
273} 280}
274 281
275EOLIAN static Efl_Object * 282EOLIAN static Efl_Object *
@@ -311,39 +318,33 @@ _efl_ui_popup_anchor_align_priority_get(Eo *obj EINA_UNUSED,
311} 318}
312 319
313EOLIAN static void 320EOLIAN static void
314_efl_ui_popup_anchor_efl_gfx_position_set(Eo *obj, Efl_Ui_Popup_Anchor_Data *pd EINA_UNUSED, Eina_Position2D pos) 321_efl_ui_popup_anchor_efl_gfx_position_set(Eo *obj, Efl_Ui_Popup_Anchor_Data *pd, Eina_Position2D pos)
315{ 322{
316 _anchor_detach(obj); 323 _anchor_detach(obj);
317 324
318 pd->anchor = NULL; 325 pd->anchor = NULL;
319 pd->align = EFL_UI_POPUP_ALIGN_NONE;
320 326
321 efl_gfx_position_set(efl_super(obj, MY_CLASS), pos); 327 efl_gfx_position_set(efl_super(obj, MY_CLASS), pos);
322} 328}
323 329
324EOLIAN static void 330EOLIAN static void
325_efl_ui_popup_anchor_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Anchor_Data *pd EINA_UNUSED) 331_efl_ui_popup_anchor_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Popup_Anchor_Data *pd)
326{ 332{
327 elm_layout_sizing_eval(efl_super(obj, MY_CLASS)); 333 EFL_UI_POPUP_DATA_GET_OR_RETURN(obj, ppd);
328 334 /* When elm_layout_sizing_eval() is called, just flag is set instead of size
329 if (pd->anchor != NULL) 335 * calculation.
330 _anchor_calc(obj); 336 * The actual size calculation is done here when the object is rendered to
331} 337 * avoid duplicate size calculations. */
338 if (ppd->needs_group_calc)
339 {
340 if (pd->anchor)
341 ppd->needs_align_calc = EINA_FALSE;
332 342
333EOLIAN static void 343 efl_canvas_group_calculate(efl_super(obj, MY_CLASS));
334_efl_ui_popup_anchor_efl_ui_popup_align_set(Eo *obj, Efl_Ui_Popup_Anchor_Data *pd, Efl_Ui_Popup_Align type)
335{
336 pd->align = type;
337 if (pd->anchor == NULL)
338 efl_ui_popup_align_set(efl_super(obj, MY_CLASS), type);
339 else
340 _anchor_calc(obj);
341}
342 344
343EOLIAN static Efl_Ui_Popup_Align 345 if (pd->anchor)
344_efl_ui_popup_anchor_efl_ui_popup_align_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Anchor_Data *pd) 346 _anchor_calc(obj);
345{ 347 }
346 return pd->align;
347} 348}
348 349
349EOLIAN static Eo * 350EOLIAN static Eo *
@@ -368,7 +369,4 @@ _efl_ui_popup_anchor_efl_object_constructor(Eo *obj,
368 return obj; 369 return obj;
369} 370}
370 371
371#define EFL_UI_POPUP_ANCHOR_EXTRA_OPS \
372 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup_anchor)
373
374#include "efl_ui_popup_anchor.eo.c" 372#include "efl_ui_popup_anchor.eo.c"
diff --git a/src/lib/elementary/efl_ui_popup_anchor.eo b/src/lib/elementary/efl_ui_popup_anchor.eo
index 8819efaffd..1bdd8684e6 100644
--- a/src/lib/elementary/efl_ui_popup_anchor.eo
+++ b/src/lib/elementary/efl_ui_popup_anchor.eo
@@ -35,7 +35,7 @@ class Efl.Ui.Popup_Anchor(Efl.Ui.Popup)
35 } 35 }
36 implements { 36 implements {
37 Efl.Object.constructor; 37 Efl.Object.constructor;
38 Efl.Canvas.Group.group_calculate;
38 Efl.Gfx.position { set; } 39 Efl.Gfx.position { set; }
39 Efl.Ui.Popup.align { set; get; }
40 } 40 }
41} 41}
diff --git a/src/lib/elementary/efl_ui_popup_anchor_private.h b/src/lib/elementary/efl_ui_popup_anchor_private.h
index 81e0c60364..87e3f696ef 100644
--- a/src/lib/elementary/efl_ui_popup_anchor_private.h
+++ b/src/lib/elementary/efl_ui_popup_anchor_private.h
@@ -7,7 +7,6 @@ typedef struct _Efl_Ui_Popup_Anchor_Data Efl_Ui_Popup_Anchor_Data;
7struct _Efl_Ui_Popup_Anchor_Data 7struct _Efl_Ui_Popup_Anchor_Data
8{ 8{
9 Eo *anchor; 9 Eo *anchor;
10 Efl_Ui_Popup_Align align;
11 Efl_Ui_Popup_Align priority[5]; 10 Efl_Ui_Popup_Align priority[5];
12 Efl_Ui_Popup_Align used_align; 11 Efl_Ui_Popup_Align used_align;
13}; 12};