summaryrefslogtreecommitdiff
path: root/src/lib/elm_toolbar.c
diff options
context:
space:
mode:
authorSubodh Kumar <s7158.kumar@samsung.com>2015-03-19 18:46:59 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-03-19 18:46:59 +0900
commitf3a066305bdfa7585df8532c1eb404c13c449cb4 (patch)
treeea2bf8a6aebdb5de00db20ad113b700b893a1433 /src/lib/elm_toolbar.c
parent695a0e59cb525350e9d295e6d93c325dddc9e8a1 (diff)
Elm_toolbar: Sizing evaluation improvement.
Summary: Issue: Flickering when toolbar was set/unset Solution: Unnecessary resizes and show caused the flicker, removed unnecessary resizes. Reviewers: seoz, raster, shilpasingh Reviewed By: shilpasingh Subscribers: poornima.srinivasan, rajeshps, govi Differential Revision: https://phab.enlightenment.org/D2070
Diffstat (limited to 'src/lib/elm_toolbar.c')
-rw-r--r--src/lib/elm_toolbar.c244
1 files changed, 75 insertions, 169 deletions
diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c
index c418ced7c..cb4278b59 100644
--- a/src/lib/elm_toolbar.c
+++ b/src/lib/elm_toolbar.c
@@ -54,6 +54,7 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
54 54
55static Eina_Bool _key_action_select(Evas_Object *obj, const char *params); 55static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
56static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); 56static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
57static void _sizing_eval(Evas_Object *obj);
57 58
58static const Elm_Action key_actions[] = { 59static const Elm_Action key_actions[] = {
59 {"select", _key_action_select}, 60 {"select", _key_action_select},
@@ -547,10 +548,8 @@ _resize_job(void *data)
547 EINA_INLIST_FOREACH(sd->items, it) 548 EINA_INLIST_FOREACH(sd->items, it)
548 { 549 {
549 if (it->selected) 550 if (it->selected)
550 { 551 _item_show(it);
551 _item_show(it); 552 evas_object_show(VIEW(it));
552 break;
553 }
554 } 553 }
555 } 554 }
556 555
@@ -948,20 +947,44 @@ _elm_toolbar_elm_widget_event(Eo *obj, Elm_Toolbar_Data *sd, Evas_Object *src, E
948} 947}
949 948
950static void 949static void
951_resize_cb(void *data, 950_resizing_eval(Evas_Object *obj)
952 Evas *e EINA_UNUSED,
953 Evas_Object *obj EINA_UNUSED,
954 void *event_info EINA_UNUSED)
955{ 951{
956 Evas_Coord x, y, h; 952 Evas_Coord x, y, h;
953 Evas_Coord mw = -1, mh = -1;
954 ELM_TOOLBAR_DATA_GET(obj, sd);
957 955
958 ELM_TOOLBAR_DATA_GET(data, sd); 956 evas_object_geometry_get(obj, &x, &y, NULL, &h);
957 evas_object_move(sd->more, x, y + h);
958 if (sd->resize_job) ecore_job_del(sd->resize_job);
959 // fit and fix the visibility
960 sd->resize_job = ecore_job_add(_resize_job, obj);
961}
959 962
960 evas_object_geometry_get(data, &x, &y, NULL, &h); 963static void
964_resizing_eval_item(Elm_Toolbar_Item_Data *it)
965{
966 Evas_Coord x, y, h;
967 Evas_Coord mw = -1, mh = -1;
968 Evas_Object *obj = WIDGET(it);
969 ELM_TOOLBAR_DATA_GET(obj, sd);
970
971 evas_object_geometry_get(obj, &x, &y, NULL, &h);
961 evas_object_move(sd->more, x, y + h); 972 evas_object_move(sd->more, x, y + h);
973 //calculate the size of item
974 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
975 if (!it->separator && !it->object)
976 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
977 evas_object_size_hint_min_set(VIEW(it), mw, mh);
978 evas_object_size_hint_max_set(VIEW(it), -1, -1);
979}
962 980
963 ecore_job_del(sd->resize_job); 981static void
964 sd->resize_job = ecore_job_add(_resize_job, data); 982_resize_cb(void *data,
983 Evas *e EINA_UNUSED,
984 Evas_Object *obj EINA_UNUSED,
985 void *event_info EINA_UNUSED)
986{
987 _resizing_eval(data);
965} 988}
966 989
967EOLIAN static void 990EOLIAN static void
@@ -1219,10 +1242,6 @@ _item_theme_hook(Evas_Object *obj,
1219 edje_object_part_text_escaped_set(view, "elm.text", it->label); 1242 edje_object_part_text_escaped_set(view, "elm.text", it->label);
1220 edje_object_signal_emit(view, "elm,state,text,visible", "elm"); 1243 edje_object_signal_emit(view, "elm,state,text,visible", "elm");
1221 } 1244 }
1222 if (sd->vertical)
1223 edje_object_signal_emit(view, "elm,orient,vertical", "elm");
1224 else
1225 edje_object_signal_emit(view, "elm,orient,horizontal", "elm");
1226 } 1245 }
1227 else 1246 else
1228 { 1247 {
@@ -1230,43 +1249,47 @@ _item_theme_hook(Evas_Object *obj,
1230 { 1249 {
1231 elm_widget_theme_object_set 1250 elm_widget_theme_object_set
1232 (obj, view, "toolbar", "separator", style); 1251 (obj, view, "toolbar", "separator", style);
1233 if (sd->vertical)
1234 {
1235 edje_object_signal_emit(view, "elm,orient,vertical", "elm");
1236 evas_object_size_hint_weight_set
1237 (view, EVAS_HINT_EXPAND, 0.0);
1238 evas_object_size_hint_align_set
1239 (view, EVAS_HINT_FILL, EVAS_HINT_FILL);
1240 }
1241 else
1242 {
1243 edje_object_signal_emit(view, "elm,orient,horizontal", "elm");
1244 evas_object_size_hint_weight_set
1245 (view, 0.0, EVAS_HINT_EXPAND);
1246 evas_object_size_hint_align_set
1247 (view, EVAS_HINT_FILL, EVAS_HINT_FILL);
1248 }
1249 } 1252 }
1250 else 1253 else
1251 { 1254 {
1252 elm_widget_theme_object_set 1255 elm_widget_theme_object_set
1253 (obj, view, "toolbar", "object", style); 1256 (obj, view, "toolbar", "object", style);
1254 edje_object_part_swallow(view, "elm.swallow.object", it->object); 1257 edje_object_part_swallow(view, "elm.swallow.object", it->object);
1255 if (sd->vertical)
1256 edje_object_signal_emit(view, "elm,orient,vertical", "elm");
1257 else
1258 edje_object_signal_emit(view, "elm,orient,horizontal", "elm");
1259 } 1258 }
1260 } 1259 }
1261 1260
1262 // If the min size is changed by edje signal in edc, 1261 if (sd->vertical)
1263 //the below function should be called before the calculation. 1262 edje_object_signal_emit(view, "elm,orient,vertical", "elm");
1264 edje_object_message_signal_process(view); 1263 else
1265 1264 edje_object_signal_emit(view, "elm,orient,horizontal", "elm");
1266 if (!it->separator && !it->object) 1265
1267 elm_coords_finger_size_adjust(1, &mw, 1, &mh); 1266 edje_object_message_signal_process(view);
1268 edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh); 1267 if (!it->separator && !it->object)
1269 evas_object_size_hint_min_set(view, mw, mh); 1268 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1269 if (sd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1270 {
1271 if (sd->vertical)
1272 {
1273 evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, -1.0);
1274 evas_object_size_hint_align_set
1275 (view, EVAS_HINT_FILL, EVAS_HINT_FILL);
1276 }
1277 else
1278 {
1279 evas_object_size_hint_weight_set(VIEW(it), -1.0, EVAS_HINT_EXPAND);
1280 evas_object_size_hint_align_set
1281 (view, EVAS_HINT_FILL, EVAS_HINT_FILL);
1282 }
1283 }
1284 else
1285 {
1286 evas_object_size_hint_weight_set
1287 (VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1288 evas_object_size_hint_align_set
1289 (VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1290 }
1291 _resizing_eval_item(it);
1292 _sizing_eval(obj);
1270} 1293}
1271 1294
1272static void 1295static void
@@ -1435,53 +1458,11 @@ _elm_toolbar_elm_widget_theme_apply(Eo *obj, Elm_Toolbar_Data *sd)
1435static void 1458static void
1436_elm_toolbar_item_label_update(Elm_Toolbar_Item_Data *item) 1459_elm_toolbar_item_label_update(Elm_Toolbar_Item_Data *item)
1437{ 1460{
1438 Evas_Coord mw = -1, mh = -1, minw = -1, minh = -1;
1439
1440 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
1441
1442 edje_object_part_text_escaped_set(VIEW(item), "elm.text", item->label); 1461 edje_object_part_text_escaped_set(VIEW(item), "elm.text", item->label);
1443 if (item->label) 1462 if (item->label)
1444 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm"); 1463 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
1445 else 1464 else
1446 edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm"); 1465 edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
1447
1448 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1449 // If the min size is changed by edje signal in edc,
1450 //the below function should be called before the calculation.
1451 edje_object_message_signal_process(VIEW(item));
1452 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1453 if (sd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1454 {
1455 if (sd->vertical)
1456 {
1457 evas_object_size_hint_weight_set
1458 (VIEW(item), EVAS_HINT_EXPAND, -1.0);
1459 evas_object_size_hint_align_set
1460 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1461 }
1462 else
1463 {
1464 evas_object_size_hint_weight_set
1465 (VIEW(item), -1.0, EVAS_HINT_EXPAND);
1466 evas_object_size_hint_align_set
1467 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1468 }
1469 }
1470 else
1471 {
1472 evas_object_size_hint_weight_set
1473 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1474 evas_object_size_hint_align_set
1475 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1476 }
1477
1478 evas_object_size_hint_min_get(VIEW(item), &minw, &minh);
1479 if ((minw < mw) && (minh < mh))
1480 evas_object_size_hint_min_set(VIEW(item), mw, mh);
1481 else if ((minw < mw) && (minh > mh))
1482 evas_object_size_hint_min_set(VIEW(item), mw, minh);
1483 else if ((minw > mw) && (minh < mh))
1484 evas_object_size_hint_min_set(VIEW(item), minw, mh);
1485} 1466}
1486 1467
1487static void 1468static void
@@ -1521,7 +1502,7 @@ _item_label_set(Elm_Toolbar_Item_Data *item,
1521 else 1502 else
1522 _elm_toolbar_item_label_update(item); 1503 _elm_toolbar_item_label_update(item);
1523 1504
1524 _resize_cb(WIDGET(item), NULL, NULL, NULL); 1505 _resizing_eval_item(item);
1525} 1506}
1526 1507
1527EOLIAN static void 1508EOLIAN static void
@@ -1639,7 +1620,8 @@ _item_resize(void *data,
1639 void *event_info EINA_UNUSED) 1620 void *event_info EINA_UNUSED)
1640{ 1621{
1641 _sizing_eval(data); 1622 _sizing_eval(data);
1642 _resize_cb(data, NULL, NULL, NULL); 1623 _resizing_eval(data);
1624
1643} 1625}
1644 1626
1645static void 1627static void
@@ -1772,7 +1754,7 @@ _items_change(Elm_Toolbar_Item_Data *reorder_from, Elm_Toolbar_Item_Data *reorde
1772 _item_move_cb, reorder_to); 1754 _item_move_cb, reorder_to);
1773 } 1755 }
1774 1756
1775 _resize_cb(WIDGET(reorder_from), NULL, NULL, NULL); 1757 _resizing_eval(WIDGET(reorder_from));
1776} 1758}
1777 1759
1778static void 1760static void
@@ -2313,7 +2295,6 @@ _item_new(Evas_Object *obj,
2313 const void *data) 2295 const void *data)
2314{ 2296{
2315 Evas_Object *icon_obj; 2297 Evas_Object *icon_obj;
2316 Evas_Coord mw, mh;
2317 2298
2318 ELM_TOOLBAR_DATA_GET(obj, sd); 2299 ELM_TOOLBAR_DATA_GET(obj, sd);
2319 2300
@@ -2390,41 +2371,9 @@ _item_new(Evas_Object *obj,
2390 edje_object_signal_emit(VIEW(it), "elm,state,text,visible", "elm"); 2371 edje_object_signal_emit(VIEW(it), "elm,state,text,visible", "elm");
2391 } 2372 }
2392 2373
2393 mw = mh = -1;
2394 if (!it->separator && !it->object)
2395 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2396 // If the min size is changed by edje signal in edc,
2397 //the below function should be called before the calculation.
2398 edje_object_message_signal_process(VIEW(it));
2399 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
2400 if (sd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
2401 {
2402 if (sd->vertical)
2403 {
2404 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, -1.0);
2405 evas_object_size_hint_align_set
2406 (VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
2407 }
2408 else
2409 {
2410 evas_object_size_hint_weight_set(VIEW(it), -1.0, EVAS_HINT_EXPAND);
2411 evas_object_size_hint_align_set
2412 (VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
2413 }
2414 }
2415 else
2416 {
2417 evas_object_size_hint_weight_set
2418 (VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2419 evas_object_size_hint_align_set
2420 (VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
2421 }
2422
2423 evas_object_size_hint_min_set(VIEW(it), mw, mh);
2424 evas_object_size_hint_max_set(VIEW(it), -1, -1);
2425 evas_object_event_callback_add 2374 evas_object_event_callback_add
2426 (VIEW(it), EVAS_CALLBACK_RESIZE, _item_resize, obj); 2375 (VIEW(it), EVAS_CALLBACK_RESIZE, _item_resize, obj);
2427 2376 _resizing_eval_item(it);
2428 if ((!sd->items) && (sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS)) 2377 if ((!sd->items) && (sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
2429 _item_select(it); 2378 _item_select(it);
2430 return it; 2379 return it;
@@ -2433,14 +2382,11 @@ _item_new(Evas_Object *obj,
2433static void 2382static void
2434_elm_toolbar_item_icon_update(Elm_Toolbar_Item_Data *item) 2383_elm_toolbar_item_icon_update(Elm_Toolbar_Item_Data *item)
2435{ 2384{
2436 Evas_Coord mw = -1, mh = -1, minw = -1, minh = -1;
2437 Elm_Toolbar_Item_State *it_state; 2385 Elm_Toolbar_Item_State *it_state;
2438 Evas_Object *old_icon = 2386 Evas_Object *old_icon =
2439 edje_object_part_swallow_get(VIEW(item), "elm.swallow.icon"); 2387 edje_object_part_swallow_get(VIEW(item), "elm.swallow.icon");
2440 Eina_List *l; 2388 Eina_List *l;
2441 2389
2442 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
2443
2444 elm_widget_sub_object_del(WIDGET(item), old_icon); 2390 elm_widget_sub_object_del(WIDGET(item), old_icon);
2445 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon); 2391 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
2446 if (item->icon) 2392 if (item->icon)
@@ -2448,43 +2394,6 @@ _elm_toolbar_item_icon_update(Elm_Toolbar_Item_Data *item)
2448 else 2394 else
2449 edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm"); 2395 edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
2450 evas_object_hide(old_icon); 2396 evas_object_hide(old_icon);
2451 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2452 // If the min size is changed by edje signal in edc,
2453 //the below function should be called before the calculation.
2454 edje_object_message_signal_process(VIEW(item));
2455 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
2456 if (sd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
2457 {
2458 if (sd->vertical)
2459 {
2460 evas_object_size_hint_weight_set
2461 (VIEW(item), EVAS_HINT_EXPAND, -1.0);
2462 evas_object_size_hint_align_set
2463 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
2464 }
2465 else
2466 {
2467 evas_object_size_hint_weight_set
2468 (VIEW(item), -1.0, EVAS_HINT_EXPAND);
2469 evas_object_size_hint_align_set
2470 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
2471 }
2472 }
2473 else
2474 {
2475 evas_object_size_hint_weight_set
2476 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2477 evas_object_size_hint_align_set
2478 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
2479 }
2480
2481 evas_object_size_hint_min_get(VIEW(item), &minw, &minh);
2482 if ((minw < mw) && (minh < mh))
2483 evas_object_size_hint_min_set(VIEW(item), mw, mh);
2484 else if ((minw < mw) && (minh > mh))
2485 evas_object_size_hint_min_set(VIEW(item), mw, minh);
2486 else if ((minw > mw) && (minh < mh))
2487 evas_object_size_hint_min_set(VIEW(item), minw, mh);
2488 2397
2489 EINA_LIST_FOREACH(item->states, l, it_state) 2398 EINA_LIST_FOREACH(item->states, l, it_state)
2490 { 2399 {
@@ -2555,8 +2464,7 @@ _elm_toolbar_item_icon_obj_set(Evas_Object *obj,
2555 } 2464 }
2556 else 2465 else
2557 _elm_toolbar_item_icon_update(item); 2466 _elm_toolbar_item_icon_update(item);
2558 2467 _resizing_eval_item(item);
2559 _resize_cb(obj, NULL, NULL, NULL);
2560} 2468}
2561 2469
2562static void 2470static void
@@ -3075,7 +2983,6 @@ _elm_toolbar_item_insert_before(Eo *obj, Elm_Toolbar_Data *sd, Elm_Object_Item *
3075 sd->items = eina_inlist_prepend_relative 2983 sd->items = eina_inlist_prepend_relative
3076 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_before)); 2984 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_before));
3077 evas_object_box_insert_before(sd->bx, VIEW(it), VIEW(_before)); 2985 evas_object_box_insert_before(sd->bx, VIEW(it), VIEW(_before));
3078 evas_object_show(VIEW(it));
3079 _item_theme_hook(obj, it, scale, sd->icon_size); 2986 _item_theme_hook(obj, it, scale, sd->icon_size);
3080 _sizing_eval(obj); 2987 _sizing_eval(obj);
3081 sd->item_count++; 2988 sd->item_count++;
@@ -3099,7 +3006,6 @@ _elm_toolbar_item_insert_after(Eo *obj, Elm_Toolbar_Data *sd, Elm_Object_Item *e
3099 sd->items = eina_inlist_append_relative 3006 sd->items = eina_inlist_append_relative
3100 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_after)); 3007 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_after));
3101 evas_object_box_insert_after(sd->bx, VIEW(it), VIEW(_after)); 3008 evas_object_box_insert_after(sd->bx, VIEW(it), VIEW(_after));
3102 evas_object_show(VIEW(it));
3103 _item_theme_hook(obj, it, scale, sd->icon_size); 3009 _item_theme_hook(obj, it, scale, sd->icon_size);
3104 _sizing_eval(obj); 3010 _sizing_eval(obj);
3105 sd->item_count++; 3011 sd->item_count++;
@@ -3153,7 +3059,7 @@ _elm_toolbar_item_priority_set(Eo *eo_item EINA_UNUSED, Elm_Toolbar_Item_Data *i
3153{ 3059{
3154 if (item->prio.priority == priority) return; 3060 if (item->prio.priority == priority) return;
3155 item->prio.priority = priority; 3061 item->prio.priority = priority;
3156 _resize_cb(WIDGET(item), NULL, NULL, NULL); 3062 _resizing_eval(WIDGET(item));
3157} 3063}
3158 3064
3159EOLIAN static int 3065EOLIAN static int
@@ -3741,7 +3647,7 @@ _elm_toolbar_standard_priority_set(Eo *obj, Elm_Toolbar_Data *sd, int priority)
3741{ 3647{
3742 if (sd->standard_priority == priority) return; 3648 if (sd->standard_priority == priority) return;
3743 sd->standard_priority = priority; 3649 sd->standard_priority = priority;
3744 _resize_cb(obj, NULL, NULL, NULL); 3650 _resizing_eval(obj);
3745} 3651}
3746 3652
3747EOLIAN static int 3653EOLIAN static int