summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeeyong Um <conr2d@gmail.com>2017-06-12 15:55:25 +0900
committerJeeyong Um <conr2d@gmail.com>2017-06-12 16:21:39 +0900
commit383bf1969e1c8239bbcb4a689597761fc33264a0 (patch)
tree15851dcab3ab31faccba9a2f1806e5cbf3dc6afe
parent1270ddb3ed41ede70b49bb0034babcf1380efea3 (diff)
elm hoversel: Clean up sizing_eval function
-rw-r--r--src/lib/elementary/elc_hoversel.c91
1 files changed, 42 insertions, 49 deletions
diff --git a/src/lib/elementary/elc_hoversel.c b/src/lib/elementary/elc_hoversel.c
index e73fdac6fa..42f0448cf4 100644
--- a/src/lib/elementary/elc_hoversel.c
+++ b/src/lib/elementary/elc_hoversel.c
@@ -242,8 +242,7 @@ _sizing_eval(void *data)
242 int max_size = 0; 242 int max_size = 0;
243 char buf[128]; 243 char buf[128];
244 Evas_Coord box_w = -1, box_h = -1; 244 Evas_Coord box_w = -1, box_h = -1;
245 Evas_Coord x, y, w, h, xx, yy, ww, hh; 245 Eina_Rectangle base, adjusted, parent;
246 Evas_Coord obj_x, obj_y, obj_w;
247 246
248 ELM_HOVERSEL_DATA_GET(obj, sd); 247 ELM_HOVERSEL_DATA_GET(obj, sd);
249 248
@@ -267,96 +266,90 @@ _sizing_eval(void *data)
267 266
268 if (sd->horizontal) 267 if (sd->horizontal)
269 { 268 {
270 ww = (max_size > 0) ? MIN(box_w, max_size) : box_w ; 269 adjusted.w = (max_size > 0) ? MIN(box_w, max_size) : box_w ;
271 hh = box_h; 270 adjusted.h = box_h;
272
273 evas_object_size_hint_min_set(sd->spacer, ww, hh);
274
275 if (!sd->last_location)
276 sd->last_location = elm_hover_best_content_location_get(sd->hover, ELM_HOVER_AXIS_HORIZONTAL);
277 } 271 }
278 else 272 else
279 { 273 {
280 ww = box_w; 274 adjusted.w = box_w;
281 hh = (max_size > 0) ? MIN(box_h, max_size) : box_h ; 275 adjusted.h = (max_size > 0) ? MIN(box_h, max_size) : box_h ;
282
283 evas_object_size_hint_min_set(sd->spacer, ww, hh);
284
285 if (!sd->last_location)
286 sd->last_location = elm_hover_best_content_location_get(sd->hover, ELM_HOVER_AXIS_VERTICAL);
287 } 276 }
288 277
289 evas_object_geometry_get(sd->hover_parent, &x, &y, &w, &h); 278 evas_object_size_hint_min_set(sd->spacer, adjusted.w, adjusted.h);
279 if (!sd->last_location)
280 sd->last_location = elm_hover_best_content_location_get(sd->hover, !sd->horizontal + 1);
281
282 evas_object_geometry_get(sd->hover_parent, &parent.x, &parent.y, &parent.w, &parent.h);
290 if (efl_isa(sd->hover_parent, EFL_UI_WIN_CLASS)) 283 if (efl_isa(sd->hover_parent, EFL_UI_WIN_CLASS))
291 { 284 {
292 x = 0; 285 parent.x = 0;
293 y = 0; 286 parent.y = 0;
294 } 287 }
295 288
296 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", sd->last_location); 289 snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", sd->last_location);
297 edje_object_part_geometry_get(elm_layout_edje_get(sd->hover), buf, &xx, &yy, NULL, NULL); 290 edje_object_part_geometry_get(elm_layout_edje_get(sd->hover), buf, &adjusted.x, &adjusted.y, NULL, NULL);
298 xx += x; 291 adjusted.x += parent.x;
299 yy += y; 292 adjusted.y += parent.y;
300 293
301 evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, NULL); 294 evas_object_geometry_get(obj, &base.x, &base.y, &base.w, NULL);
302 295
303 if (sd->horizontal) 296 if (sd->horizontal)
304 { 297 {
305 if (!strcmp(sd->last_location, "left")) 298 if (!strcmp(sd->last_location, "left"))
306 { 299 {
307 xx = x; 300 adjusted.x = parent.x;
308 if ((xx + ww) > obj_x) 301 if ((adjusted.x + adjusted.w) > base.x)
309 ww = obj_x - xx; 302 adjusted.w = base.x - adjusted.x;
310 } 303 }
311 else 304 else
312 { 305 {
313 if ((xx + ww) > (x + w)) 306 if ((adjusted.x + adjusted.w) > (parent.x + parent.w))
314 ww = (x + w) - xx; 307 adjusted.w = (parent.x + parent.w) - adjusted.x;
315 } 308 }
316 309
317 if (yy < 0) yy = y; 310 if (adjusted.y < 0) adjusted.y = parent.y;
318 if ((yy + hh) > (y + h)) 311 if ((adjusted.y + adjusted.h) > (parent.y + parent.h))
319 hh = (y + h) - yy; 312 adjusted.h = (parent.y + parent.h) - adjusted.y;
320 } 313 }
321 else 314 else
322 { 315 {
323 if (!strcmp(sd->last_location, "top")) 316 if (!strcmp(sd->last_location, "top"))
324 { 317 {
325 yy = y; 318 adjusted.y = parent.y;
326 if ((yy + hh) > obj_y) 319 if ((adjusted.y + adjusted.h) > base.y)
327 hh = obj_y - yy; 320 adjusted.h = base.y - adjusted.y;
328 } 321 }
329 else 322 else
330 { 323 {
331 if ((yy + hh) > (y + h)) 324 if ((adjusted.y + adjusted.h) > (parent.y + parent.h))
332 hh = (y + h) - yy; 325 adjusted.h = (parent.y + parent.h) - adjusted.y;
333 } 326 }
334 327
335 if (xx < 0) xx = x; 328 if (adjusted.x < 0) adjusted.x = parent.x;
336 if ((xx + ww) > (x + w)) 329 if ((adjusted.x + adjusted.w) > (parent.x + parent.w))
337 { 330 {
338 if ((obj_x + obj_w - x) > ((x + w) - obj_x)) 331 if ((base.x + base.w - parent.x) > ((parent.x + parent.w) - base.x))
339 { 332 {
340 if (elm_obj_widget_mirrored_get(obj)) 333 if (elm_widget_mirrored_get(obj))
341 elm_obj_layout_signal_emit(sd->hover, "elm,state,align,right", "elm"); 334 elm_object_signal_emit(sd->hover, "elm,state,align,right", "elm");
342 else 335 else
343 elm_obj_layout_signal_emit(sd->hover, "elm,state,align,default", "elm"); 336 elm_object_signal_emit(sd->hover, "elm,state,align,default", "elm");
344 337
345 if ((obj_x + obj_w - ww) < x) 338 if ((base.x + base.w - adjusted.w) < parent.x)
346 ww = obj_x + obj_w - x; 339 adjusted.w = base.x + base.w - parent.x;
347 } 340 }
348 else 341 else
349 { 342 {
350 if (elm_obj_widget_mirrored_get(obj)) 343 if (elm_widget_mirrored_get(obj))
351 elm_obj_layout_signal_emit(sd->hover, "elm,state,align,default", "elm"); 344 elm_object_signal_emit(sd->hover, "elm,state,align,default", "elm");
352 else 345 else
353 elm_obj_layout_signal_emit(sd->hover, "elm,state,align,right", "elm"); 346 elm_object_signal_emit(sd->hover, "elm,state,align,right", "elm");
354 347
355 ww = (x + w) - xx; 348 adjusted.w = (parent.x + parent.w) - adjusted.x;
356 } 349 }
357 } 350 }
358 } 351 }
359 evas_object_size_hint_min_set(sd->spacer, ww, hh); 352 evas_object_size_hint_min_set(sd->spacer, adjusted.w, adjusted.h);
360} 353}
361 354
362static void 355static void