summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwoochan lee <wc0917.lee@samsung.com>2015-03-04 20:38:04 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-03-04 20:38:04 +0900
commit5dfd049d43a612f11c0a2320e954be590d0337fe (patch)
treee4e1858d487d86be47f0e80ec62219b79036f19c
parent8ea5cb6c7f8b0cf5a4b978820f2dd83c2c24579a (diff)
multibuttonentry: Item width size set policy change.
Summary: Item width max size set as 130 in edc before, i thinks that value doen't have any meaning, so i changed the item max width size to follow container width size. For modification, item size calc, box resize logic changed. Test Plan: 1. Run elementary_test 2. Execute multibuttonentry sample. 3. Input some text for make item. Reviewers: Hermet, seoz, woohyun, Jaehyun Differential Revision: https://phab.enlightenment.org/D1970
-rw-r--r--data/themes/edc/elm/multibuttonentry.edc1
-rw-r--r--src/lib/elc_multibuttonentry.c267
2 files changed, 111 insertions, 157 deletions
diff --git a/data/themes/edc/elm/multibuttonentry.edc b/data/themes/edc/elm/multibuttonentry.edc
index 764296ae2..d30623182 100644
--- a/data/themes/edc/elm/multibuttonentry.edc
+++ b/data/themes/edc/elm/multibuttonentry.edc
@@ -73,7 +73,6 @@ group { name: "elm/multibuttonentry/btn/default";
73 images.image: "sym_close_dark_normal.png" COMP; 73 images.image: "sym_close_dark_normal.png" COMP;
74 images.image: "sym_close_dark_selected.png" COMP; 74 images.image: "sym_close_dark_selected.png" COMP;
75 images.image: "win_glow.png" COMP; 75 images.image: "win_glow.png" COMP;
76 data.item: "button_max_size" 130;
77 styles { 76 styles {
78 style { name: "multibuttonentry_textblock_style"; 77 style { name: "multibuttonentry_textblock_style";
79 base: "font="FN" align=0.5 font_size=10 color=#ffffffff style=shadow,bottom shadow_color=#00000080 text_class=multibuttonentry_item ellipsis=1.0"; 78 base: "font="FN" align=0.5 font_size=10 color=#ffffffff style=shadow,bottom shadow_color=#00000080 text_class=multibuttonentry_item ellipsis=1.0";
diff --git a/src/lib/elc_multibuttonentry.c b/src/lib/elc_multibuttonentry.c
index 324606606..40ba537a3 100644
--- a/src/lib/elc_multibuttonentry.c
+++ b/src/lib/elc_multibuttonentry.c
@@ -179,7 +179,7 @@ _shrink_mode_set(Evas_Object *obj,
179 179
180 EINA_LIST_FOREACH(sd->items, l, eo_item) 180 EINA_LIST_FOREACH(sd->items, l, eo_item)
181 { 181 {
182 Evas_Coord w_label_count = 0, h = 0; 182 Evas_Coord item_w, w_label_count = 0, h = 0;
183 char *buf; 183 char *buf;
184 184
185 ELM_MULTIBUTTONENTRY_ITEM_DATA_GET(eo_item, item); 185 ELM_MULTIBUTTONENTRY_ITEM_DATA_GET(eo_item, item);
@@ -187,7 +187,9 @@ _shrink_mode_set(Evas_Object *obj,
187 evas_object_show(VIEW(item)); 187 evas_object_show(VIEW(item));
188 item->visible = EINA_TRUE; 188 item->visible = EINA_TRUE;
189 189
190 w -= item->vw; 190 evas_object_size_hint_min_get(VIEW(item), &item_w, NULL);
191
192 w -= item_w;
191 w -= box_inner_item_width_padding; 193 w -= box_inner_item_width_padding;
192 count--; 194 count--;
193 195
@@ -511,38 +513,6 @@ _on_item_deleted(void *data,
511 } 513 }
512} 514}
513 515
514static void
515_item_resize(Evas_Object *obj,
516 Evas_Object *btn,
517 Evas_Coord *realw,
518 Evas_Coord *vieww)
519{
520 Evas_Coord rw, vw;
521 const char *size_str;
522 Evas_Coord w_btn = 0, h_btn = 0, button_max_width = 0;
523
524 size_str = edje_object_data_get(elm_layout_edje_get(btn), "button_max_size");
525 if (size_str) button_max_width = atoi(size_str);
526
527 button_max_width *= elm_widget_scale_get(obj) * elm_config_scale_get();
528
529 // decide the size of button
530 edje_object_size_min_calc(elm_layout_edje_get(btn), &w_btn, &h_btn);
531
532 rw = w_btn;
533
534 if (button_max_width < w_btn) vw = button_max_width;
535 else vw = w_btn;
536
537 //resize item
538 elm_coords_finger_size_adjust(1, &vw, 1, &h_btn);
539 evas_object_resize(btn, vw, h_btn);
540 evas_object_size_hint_min_set(btn, vw, h_btn);
541
542 if (realw) *realw = rw;
543 if (vieww) *vieww = vw;
544}
545
546EOLIAN static void 516EOLIAN static void
547_elm_multibuttonentry_item_elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED, 517_elm_multibuttonentry_item_elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED,
548 Elm_Multibuttonentry_Item_Data *item, 518 Elm_Multibuttonentry_Item_Data *item,
@@ -566,7 +536,6 @@ _elm_multibuttonentry_item_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED
566 dest_part = part; 536 dest_part = part;
567 537
568 edje_object_part_text_escaped_set(elm_layout_edje_get(VIEW(item)), dest_part, label); 538 edje_object_part_text_escaped_set(elm_layout_edje_get(VIEW(item)), dest_part, label);
569 _item_resize(item->base->widget, VIEW(item), &item->rw, &item->vw);
570} 539}
571 540
572EOLIAN static const char * 541EOLIAN static const char *
@@ -656,14 +625,13 @@ _item_new(Elm_Multibuttonentry_Data *sd,
656 void *data) 625 void *data)
657{ 626{
658 Eina_List *l; 627 Eina_List *l;
659 Evas_Coord rw, vw;
660 Eo *eo_item; 628 Eo *eo_item;
661 Evas_Coord width = -1, height = -1;
662 Elm_Multibuttonentry_Item_Filter *item_filter; 629 Elm_Multibuttonentry_Item_Filter *item_filter;
663 Elm_Multibuttonentry_Item_Data *reference = eo_reference? 630 Elm_Multibuttonentry_Item_Data *reference = eo_reference?
664 eo_data_scope_get(eo_reference, ELM_MULTIBUTTONENTRY_ITEM_CLASS): 631 eo_data_scope_get(eo_reference, ELM_MULTIBUTTONENTRY_ITEM_CLASS):
665 NULL; 632 NULL;
666 Evas_Object *obj; 633 Evas_Object *obj;
634 int minw, minh, boxw;
667 635
668 obj = sd->parent; 636 obj = sd->parent;
669 637
@@ -692,23 +660,25 @@ _item_new(Elm_Multibuttonentry_Data *sd,
692 //entry is cleared when text is made to button 660 //entry is cleared when text is made to button
693 elm_object_text_set(sd->entry, ""); 661 elm_object_text_set(sd->entry, "");
694 662
695 evas_object_smart_calculate(VIEW(item));
696 edje_object_part_geometry_get
697 (elm_layout_edje_get(VIEW(item)), "elm.btn.text", NULL, NULL, &width, &height);
698 evas_object_size_hint_min_set(VIEW(item), width, height);
699 edje_object_signal_callback_add 663 edje_object_signal_callback_add
700 (elm_layout_edje_get(VIEW(item)), "mouse,clicked,1", "*", _on_item_clicked, EO_OBJ(item)); 664 (elm_layout_edje_get(VIEW(item)), "mouse,clicked,1", "*", _on_item_clicked, EO_OBJ(item));
701 edje_object_signal_callback_add 665 edje_object_signal_callback_add
702 (elm_layout_edje_get(VIEW(item)), "elm,deleted", "elm", _on_item_deleted, EO_OBJ(item)); 666 (elm_layout_edje_get(VIEW(item)), "elm,deleted", "elm", _on_item_deleted, EO_OBJ(item));
703 evas_object_size_hint_weight_set(VIEW(item), 0.0, 0.0);
704 evas_object_show(VIEW(item)); 667 evas_object_show(VIEW(item));
705 668
706 _item_resize(obj, VIEW(item), &rw, &vw); 669 evas_object_smart_calculate(VIEW(item));
670 evas_object_size_hint_min_get(VIEW(item), &minw, &minh);
671 evas_object_geometry_get(sd->box, NULL, NULL, &boxw, NULL);
672
673 if (sd->w_box && minw > boxw)
674 {
675 elm_coords_finger_size_adjust(1, &boxw, 1, &minh);
676 evas_object_size_hint_min_set(VIEW(item), boxw, minh);
677 evas_object_resize(VIEW(item), boxw, minh);
678 }
707 679
708 elm_object_focus_allow_set(VIEW(item), EINA_TRUE); 680 elm_object_focus_allow_set(VIEW(item), EINA_TRUE);
709 681
710 item->rw = rw;
711 item->vw = vw;
712 item->visible = EINA_TRUE; 682 item->visible = EINA_TRUE;
713 683
714 // ACCESS 684 // ACCESS
@@ -854,24 +824,18 @@ _elm_multibuttonentry_elm_widget_event(Eo *obj EINA_UNUSED, Elm_Multibuttonentry
854} 824}
855 825
856EOLIAN static void 826EOLIAN static void
857_elm_multibuttonentry_elm_layout_sizing_eval(Eo *obj, Elm_Multibuttonentry_Data *sd) 827_elm_multibuttonentry_elm_layout_sizing_eval(Eo *obj, Elm_Multibuttonentry_Data *sd EINA_UNUSED)
858{ 828{
859 Evas_Coord minw = -1, minh = -1; 829 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
860 Evas_Coord left, right, top, bottom;
861 830
862 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 831 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
863 832
864 evas_object_size_hint_min_get(sd->box, &minw, &minh); 833 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
865 edje_object_part_geometry_get 834 edje_object_size_min_restricted_calc
866 (wd->resize_obj, "top.left.pad", NULL, NULL, &left, &top); 835 (wd->resize_obj, &minw, &minh, minw, minh);
867 edje_object_part_geometry_get 836 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
868 (wd->resize_obj, "bottom.right.pad", NULL, NULL, &right,
869 &bottom);
870
871 minw += (left + right);
872 minh += (top + bottom);
873
874 evas_object_size_hint_min_set(obj, minw, minh); 837 evas_object_size_hint_min_set(obj, minw, minh);
838 evas_object_size_hint_max_set(obj, maxw, maxh);
875} 839}
876 840
877static void 841static void
@@ -889,8 +853,11 @@ _box_resize_cb(void *data,
889 Evas_Object *obj EINA_UNUSED, 853 Evas_Object *obj EINA_UNUSED,
890 void *event EINA_UNUSED) 854 void *event EINA_UNUSED)
891{ 855{
856 Evas_Coord w, h, mnw, mnh;
857 Eina_List *l;
858 Elm_Object_Item *eo_it;
859
892 ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(data, sd); 860 ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(data, sd);
893 Evas_Coord w, h;
894 861
895 evas_object_geometry_get(sd->box, NULL, NULL, &w, &h); 862 evas_object_geometry_get(sd->box, NULL, NULL, &w, &h);
896 863
@@ -899,10 +866,36 @@ _box_resize_cb(void *data,
899 else if (sd->h_box > h) 866 else if (sd->h_box > h)
900 evas_object_smart_callback_call(sd->parent, SIG_CONTRACTED, NULL); 867 evas_object_smart_callback_call(sd->parent, SIG_CONTRACTED, NULL);
901 868
869 if (sd->w_box && sd->w_box != w)
870 {
871 if (sd->items)
872 {
873
874 EINA_LIST_FOREACH (sd->items, l, eo_it)
875 {
876 ELM_MULTIBUTTONENTRY_ITEM_DATA_GET(eo_it, it);
877
878 elm_layout_sizing_eval(VIEW(it));
879 evas_object_smart_calculate(VIEW(it));
880
881 evas_object_size_hint_min_get(VIEW(it), &mnw, &mnh);
882
883 if (mnw > w)
884 {
885 mnw = w;
886 evas_object_size_hint_min_set(VIEW(it), mnw, mnh);
887 evas_object_resize(VIEW(it), mnw, mnh);
888 }
889 }
890 }
891 }
892 if (!elm_object_focus_get(data) && !evas_object_visible_get(sd->entry))
893 {
894 _shrink_mode_set(data, EINA_TRUE);
895 }
896
902 sd->w_box = w; 897 sd->w_box = w;
903 sd->h_box = h; 898 sd->h_box = h;
904
905 _view_update(sd);
906} 899}
907 900
908static void 901static void
@@ -1158,109 +1151,66 @@ _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
1158 free(item_filter); 1151 free(item_filter);
1159} 1152}
1160 1153
1161static void 1154static Eina_Bool
1162_box_min_size_calculate(Evas_Object *box, 1155_box_min_size_calculate(Evas_Object *box,
1163 Evas_Object_Box_Data *priv) 1156 Evas_Object_Box_Data *priv,
1157 int *line_height,
1158 void *data EINA_UNUSED)
1164{ 1159{
1165 Evas_Coord minw, minh, mnw, mnh, ww; 1160 Evas_Coord mnw, mnh, w, minw, minh = 0, linew = 0, lineh = 0;
1166 Evas_Coord w, cw = 0, cmaxh = 0; 1161 int line_num;
1162 Eina_List *l, *l_next;
1167 Evas_Object_Box_Option *opt; 1163 Evas_Object_Box_Option *opt;
1168 const Eina_List *l;
1169 double wx;
1170
1171 /* FIXME: need to calc max */
1172 minw = 0;
1173 minh = 0;
1174 1164
1175 evas_object_geometry_get(box, NULL, NULL, &w, NULL); 1165 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1176 evas_object_size_hint_min_get(box, &minw, NULL); 1166 evas_object_size_hint_min_get(box, &minw, NULL);
1177 1167
1168 if (!w) return EINA_FALSE;
1169
1170 line_num = 1;
1178 EINA_LIST_FOREACH(priv->children, l, opt) 1171 EINA_LIST_FOREACH(priv->children, l, opt)
1179 { 1172 {
1180 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh); 1173 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1181 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1182 1174
1183 if (wx) 1175 linew += mnw;
1184 { 1176 if (lineh < mnh) lineh = mnh;
1185 if (mnw != -1 && (w - cw) >= mnw)
1186 ww = w - cw;
1187 else
1188 ww = w;
1189 }
1190 else
1191 ww = mnw;
1192 1177
1193 if ((cw + mnw) > w) 1178 if (linew > w)
1194 { 1179 {
1195 minh += cmaxh; 1180 linew = mnw;
1196 cw = 0; 1181 line_num++;
1182
1183 l_next = eina_list_next(l);
1184 opt = eina_list_data_get(l_next);
1185 if (l_next && opt && opt->obj &&
1186 !strcmp(elm_widget_type_get(opt->obj), "elm_entry"))
1187 {
1188 linew = 0;
1189 line_num++;
1190 }
1197 } 1191 }
1198 cw += ww;
1199 if (cmaxh < mnh) cmaxh = mnh;
1200 } 1192 }
1201 1193 minh = lineh * line_num;
1202 minh += cmaxh;
1203 1194
1204 evas_object_size_hint_min_set(box, minw, minh); 1195 evas_object_size_hint_min_set(box, minw, minh);
1205} 1196 *line_height = lineh;
1206
1207static Evas_Coord
1208_item_max_height_calculate(Evas_Object *box,
1209 Evas_Object_Box_Data *priv,
1210 int obj_index)
1211{
1212 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1213 Evas_Object_Box_Option *opt;
1214 int local_index = 0;
1215 const Eina_List *l;
1216 double wx;
1217
1218 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1219
1220 EINA_LIST_FOREACH(priv->children, l, opt)
1221 {
1222 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1223 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1224 1197
1225 if (wx) 1198 return EINA_TRUE;
1226 {
1227 if (mnw != -1 && (w - cw) >= mnw)
1228 ww = w - cw;
1229 else
1230 ww = w;
1231 }
1232 else
1233 ww = mnw;
1234
1235 if ((cw + ww) > w)
1236 {
1237 if (local_index > obj_index) return cmaxh;
1238 cw = 0;
1239 }
1240
1241 cw += ww;
1242 if (cmaxh < mnh) cmaxh = mnh;
1243
1244 local_index++;
1245 }
1246
1247 return cmaxh;
1248} 1199}
1249 1200
1250static void 1201static void
1251_box_layout_cb(Evas_Object *o, 1202_box_layout_cb(Evas_Object *o,
1252 Evas_Object_Box_Data *priv, 1203 Evas_Object_Box_Data *priv,
1253 void *data EINA_UNUSED) 1204 void *data)
1254{ 1205{
1255 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1256 Evas_Coord x, y, w, h, xx, yy; 1206 Evas_Coord x, y, w, h, xx, yy;
1207 Evas_Coord minw, minh, linew = 0, lineh = 0;
1257 Evas_Object_Box_Option *opt; 1208 Evas_Object_Box_Option *opt;
1258 Evas_Coord minw, minh;
1259 const Eina_List *l, *l_next; 1209 const Eina_List *l, *l_next;
1260 Evas_Object *obj; 1210 Evas_Object *obj;
1261 double ax, ay; 1211 double ax, ay;
1262 1212
1263 _box_min_size_calculate(o, priv); 1213 if (!_box_min_size_calculate(o, priv, &lineh, data)) return;
1264 1214
1265 evas_object_geometry_get(o, &x, &y, &w, &h); 1215 evas_object_geometry_get(o, &x, &y, &w, &h);
1266 1216
@@ -1282,7 +1232,7 @@ _box_layout_cb(Evas_Object *o,
1282 1232
1283 EINA_LIST_FOREACH_SAFE(priv->children, l, l_next, opt) 1233 EINA_LIST_FOREACH_SAFE(priv->children, l, l_next, opt)
1284 { 1234 {
1285 Evas_Coord mnw, mnh, mxw, mxh; 1235 Evas_Coord mnw, mnh;
1286 Evas_Coord ww, hh, ow, oh; 1236 Evas_Coord ww, hh, ow, oh;
1287 double wx, wy; 1237 double wx, wy;
1288 int fw, fh; 1238 int fw, fh;
@@ -1291,44 +1241,49 @@ _box_layout_cb(Evas_Object *o,
1291 evas_object_size_hint_align_get(obj, &ax, &ay); 1241 evas_object_size_hint_align_get(obj, &ax, &ay);
1292 evas_object_size_hint_weight_get(obj, &wx, &wy); 1242 evas_object_size_hint_weight_get(obj, &wx, &wy);
1293 evas_object_size_hint_min_get(obj, &mnw, &mnh); 1243 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1294 evas_object_size_hint_max_get(obj, &mxw, &mxh); 1244
1295 fw = fh = 0; 1245 fw = fh = EINA_FALSE;
1296 if (ax == -1.0) {fw = 1; ax = 0.5; } 1246 if (ax == -1.0) {fw = 1; ax = 0.5; }
1297 if (ay == -1.0) {fh = 1; ay = 0.5; } 1247 if (ay == -1.0) {fh = 1; ay = 0.5; }
1298 1248
1249 ww = mnw;
1299 if (wx) 1250 if (wx)
1300 { 1251 {
1301 if (mnw != -1 && (w - cw) >= mnw) 1252 if (ww <= w - linew) ww = w - linew;
1302 ww = w - cw; 1253 else ww = w;
1303 else
1304 ww = w;
1305 } 1254 }
1306 else 1255 hh = lineh;
1307 ww = mnw;
1308 hh = _item_max_height_calculate(o, priv, obj_index);
1309 1256
1310 ow = mnw; 1257 ow = mnw;
1311 if (fw) ow = ww; 1258 if (fw) ow = ww;
1312 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1313 oh = mnh; 1259 oh = mnh;
1314 if (fh) oh = hh; 1260 if (fh) oh = hh;
1315 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1316 1261
1317 if ((cw + ww) > w) 1262 linew += ww;
1263 if (linew > w && l != priv->children)
1318 { 1264 {
1319 ch += cmaxh; 1265 xx = x;
1320 cw = 0; 1266 yy += hh;
1267 linew = ww;
1321 } 1268 }
1322 1269
1323 evas_object_move 1270 evas_object_move(obj,
1324 (obj, xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax), 1271 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
1325 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay)); 1272 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
1326 evas_object_resize(obj, ow, oh); 1273 evas_object_resize(obj, ow, oh);
1327 1274
1328 cw += ww; 1275 xx += ww;
1329 if (cmaxh < hh) cmaxh = hh;
1330 1276
1331 obj_index++; 1277 if (linew > w)
1278 {
1279 opt = eina_list_data_get(l_next);
1280 if (opt && opt->obj && !strcmp(elm_widget_type_get(opt->obj), "elm_entry"))
1281 {
1282 xx = x;
1283 yy += hh;
1284 linew = 0;
1285 }
1286 }
1332 } 1287 }
1333} 1288}
1334 1289
@@ -1338,7 +1293,7 @@ _view_init(Evas_Object *obj, Elm_Multibuttonentry_Data *sd)
1338 sd->box = elm_box_add(obj); 1293 sd->box = elm_box_add(obj);
1339 1294
1340 if (!sd->box) return; 1295 if (!sd->box) return;
1341 elm_box_layout_set(sd->box, _box_layout_cb, NULL, NULL); 1296 elm_box_layout_set(sd->box, _box_layout_cb, obj, NULL);
1342 elm_box_homogeneous_set(sd->box, EINA_FALSE); 1297 elm_box_homogeneous_set(sd->box, EINA_FALSE);
1343 elm_layout_content_set(obj, "box.swallow", sd->box); 1298 elm_layout_content_set(obj, "box.swallow", sd->box);
1344 1299