forked from enlightenment/efl
label: Fix size calculation for wrapped label
Summary: Label size is incorrectly calculated (text does not wrap) if elm_label_line_wrap_set() is called before elm_label_wrap_width_set(). @fix Test Plan: The label3 test case is added to show the bug case. In label3 test case, if we switch the calling sequence of elm_label_line_wrap_set() and elm_label_wrap_width_set(), the result is different. Reviewers: raster, seoz, woohyun, Hermet Differential Revision: https://phab.enlightenment.org/D1369
This commit is contained in:
parent
cdec9a9e85
commit
8c0dcde37d
|
@ -174,6 +174,7 @@ void test_flip_to(void *data, Evas_Object *obj, void *event_info);
|
|||
void test_flip_page(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_label(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_label2(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_label3(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_conformant(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_conformant2(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_conformant_indicator(void *data, Evas_Object *obj, void *event_info);
|
||||
|
@ -764,6 +765,7 @@ add_tests:
|
|||
//------------------------------//
|
||||
ADD_TEST(NULL, "Text", "Label", test_label);
|
||||
ADD_TEST(NULL, "Text", "Label2", test_label2);
|
||||
ADD_TEST(NULL, "Text", "Label3", test_label3);
|
||||
|
||||
//------------------------------//
|
||||
ADD_TEST(NULL, "Stored Surface Buffer", "Launcher", test_launcher);
|
||||
|
|
|
@ -288,3 +288,29 @@ test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
evas_object_resize(win, 320, 320);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
||||
void
|
||||
test_label3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *bx, *lb;
|
||||
|
||||
win = elm_win_util_standard_add("label", "Label");
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
bx = elm_box_add(win);
|
||||
|
||||
lb = elm_label_add(win);
|
||||
elm_object_text_set(lb,
|
||||
"This is text for our label, that is long but "
|
||||
"not too long. The label is designed to have line-wrap."
|
||||
);
|
||||
elm_label_line_wrap_set(lb, ELM_WRAP_CHAR);
|
||||
elm_label_wrap_width_set(lb, 200);
|
||||
evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx, lb);
|
||||
evas_object_show(lb);
|
||||
|
||||
evas_object_show(bx);
|
||||
evas_object_show(win);
|
||||
elm_win_resize_object_add(win, bx);
|
||||
}
|
||||
|
|
|
@ -39,13 +39,18 @@ _recalc(void *data)
|
|||
ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
|
||||
|
||||
Evas_Coord minw = -1, minh = -1;
|
||||
Evas_Coord resw;
|
||||
Evas_Coord resw, w;
|
||||
|
||||
evas_event_freeze(evas_object_evas_get(data));
|
||||
evas_object_geometry_get(wd->resize_obj, NULL, NULL, &resw, NULL);
|
||||
if (sd->wrap_w > resw)
|
||||
resw = sd->wrap_w;
|
||||
edje_object_size_min_calc(wd->resize_obj, &minw, NULL);
|
||||
evas_object_geometry_get(wd->resize_obj, NULL, NULL, &w, NULL);
|
||||
|
||||
if (sd->wrap_w > minw)
|
||||
resw = sd->wrap_w;
|
||||
else if ((sd->wrap_w > 0) && (minw > sd->wrap_w))
|
||||
resw = minw;
|
||||
else
|
||||
resw = w;
|
||||
edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh, resw, 0);
|
||||
|
||||
/* This is a hack to workaround the way min size hints are treated.
|
||||
|
|
Loading…
Reference in New Issue