summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/elementary/themes/edc/elm/label.edc19
-rw-r--r--src/lib/edje/edje_calc.c305
-rw-r--r--src/lib/edje/edje_util.c69
-rw-r--r--src/lib/elementary/elm_label.c38
4 files changed, 329 insertions, 102 deletions
diff --git a/data/elementary/themes/edc/elm/label.edc b/data/elementary/themes/edc/elm/label.edc
index b1e273bc09..99227d8067 100644
--- a/data/elementary/themes/edc/elm/label.edc
+++ b/data/elementary/themes/edc/elm/label.edc
@@ -25,9 +25,26 @@ group { name: "elm/label/base/default";
25 rel2.relative: 1.0 1.0; 25 rel2.relative: 1.0 1.0;
26 text { 26 text {
27 style: "label_style"; 27 style: "label_style";
28 min: 0 1; 28 min: 1 1;
29 } 29 }
30 } 30 }
31 description { state: "horizontal_fixed" 0.0;
32 inherit: "default" 0.0;
33 fixed: 1 0;
34 text.min: 0 1;
35 }
36 }
37 }
38 programs {
39 program { name: "horizontal_expandable";
40 signal: "elm,state,horizontal,expandable"; source: "elm";
41 action: STATE_SET "default" 0.0;
42 target: "elm.text";
43 }
44 program { name: "horizontal_fixed";
45 signal: "elm,state,horizontal,fixed"; source: "elm";
46 action: STATE_SET "horizontal_fixed" 0.0;
47 target: "elm.text";
31 } 48 }
32 } 49 }
33} 50}
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index 320fbffc89..d52069d85c 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -1445,9 +1445,17 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
1445 int *minw, int *minh, 1445 int *minw, int *minh,
1446 int *maxw, int *maxh) 1446 int *maxw, int *maxh)
1447{ 1447{
1448 int min_calc_w = 0, min_calc_h = 0;
1449
1448 if ((ep->type != EDJE_RP_TYPE_TEXT) || 1450 if ((ep->type != EDJE_RP_TYPE_TEXT) ||
1449 (!ep->typedata.text)) 1451 (!ep->typedata.text))
1450 return; 1452 return;
1453
1454 /* min_calc_* values need to save calculated minumum size
1455 * for maximum size calculation */
1456 if (minw) min_calc_w = *minw;
1457 if (minh) min_calc_h = *minh;
1458
1451 if (chosen_desc) 1459 if (chosen_desc)
1452 { 1460 {
1453 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b; 1461 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
@@ -1592,56 +1600,277 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
1592 } 1600 }
1593 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) 1601 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
1594 { 1602 {
1595 int mw = 0, mh = 0; 1603 evas_object_textblock_style_insets_get(ep->object, &ins_l,
1604 &ins_r, &ins_t, &ins_b);
1596 1605
1597 tw = th = 0; 1606 tw = th = 0;
1598 if (!chosen_desc->text.min_x) 1607 if (!chosen_desc->text.min_x)
1599 { 1608 {
1600 efl_gfx_size_set(ep->object, TO_INT(params->eval.w), TO_INT(params->eval.h)); 1609 /* text.min: 0 1
1601 efl_canvas_text_size_formatted_get(ep->object, &tw, &th); 1610 * text.max: X X */
1611 int temp_h = TO_INT(params->eval.h);
1612 int temp_w = TO_INT(params->eval.w);
1613
1614 if (min_calc_w > temp_w)
1615 temp_w = min_calc_w;
1616 if ((!chosen_desc->text.max_x) &&
1617 maxw && (*maxw > -1) && (*maxw < temp_w))
1618 temp_w = *maxw;
1619
1620 if (chosen_desc->text.max_y)
1621 {
1622 /* text.min: 0 1
1623 * text.max: X 1 */
1624 temp_h = INT_MAX / 10000;
1625 }
1626 else if (maxh && (*maxh > TO_INT(params->eval.h)))
1627 {
1628 /* text.min: 0 1
1629 * text.max: X 0
1630 * And there is a limit for height. */
1631 temp_h = *maxh;
1632 }
1633
1634 /* If base width for calculation is 0,
1635 * don't get meaningless height for multiline */
1636 if (temp_w > 0)
1637 {
1638 efl_gfx_size_set(ep->object, temp_w, temp_h);
1639 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1640
1641 tw += ins_l + ins_r;
1642 th += ins_t + ins_b;
1643 }
1644 else
1645 {
1646 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1647
1648 th += ins_t + ins_b;
1649 }
1602 } 1650 }
1603 else 1651 else
1604 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1605 evas_object_textblock_style_insets_get(ep->object, &ins_l,
1606 &ins_r, &ins_t, &ins_b);
1607 mw = ins_l + tw + ins_r;
1608 mh = ins_t + th + ins_b;
1609 if (minw && chosen_desc->text.min_x)
1610 { 1652 {
1611 if (mw > *minw) *minw = mw; 1653 /* text.min: 1 X
1654 * text.max: X X */
1655 if (chosen_desc->text.min_y && (!chosen_desc->text.max_x) &&
1656 maxw && (*maxw > -1))
1657 {
1658 /* text.min: 1 1
1659 * text.max: 0 X */
1660 int temp_w, temp_h;
1661
1662 temp_w = *maxw;
1663 temp_h = INT_MAX / 10000;
1664
1665 if (min_calc_w > temp_w)
1666 temp_w = min_calc_w;
1667
1668 if ((!chosen_desc->text.max_y) && maxh && (*maxh > -1))
1669 {
1670 /* text.min: 1 1
1671 * text.max: 0 0
1672 * There is limit for height. */
1673 temp_h = *maxh;
1674 }
1675
1676 efl_gfx_size_set(ep->object, temp_w, temp_h);
1677 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1678
1679 tw += ins_l + ins_r;
1680 th += ins_t + ins_b;
1681
1682 /* If base width for calculation is 0,
1683 * don't get meaningless height for multiline */
1684 if (temp_w <= 0)
1685 {
1686 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1687
1688 th += ins_t + ins_b;
1689 }
1690 }
1691 else
1692 {
1693 /* text.min: 1 X
1694 * text.max: 1 X
1695 * Or,
1696 * text.min: 1 X
1697 * text.max: 0 X without max width.
1698 * It is a singleline Textblock. */
1699 efl_canvas_text_size_native_get(ep->object, &tw, &th);
1700
1701 tw += ins_l + ins_r;
1702 th += ins_t + ins_b;
1703
1704 if (!chosen_desc->text.max_x &&
1705 (maxw && (*maxw > -1) && (*maxw < tw)))
1706 {
1707 /* text.min: 1 0
1708 * text.max: 0 X */
1709 tw = *maxw;
1710 }
1711 }
1612 } 1712 }
1613 if (minh && chosen_desc->text.min_y) 1713
1714 if (tw > min_calc_w) min_calc_w = tw;
1715 if (th > min_calc_h) min_calc_h = th;
1716 if (chosen_desc->text.min_x && minw) *minw = min_calc_w;
1717 if (chosen_desc->text.min_y && minh) *minh = min_calc_h;
1718 }
1719
1720 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
1721 {
1722 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
1723 &ins_t, &ins_b);
1724
1725 tw = th = 0;
1726 if (!chosen_desc->text.max_x)
1614 { 1727 {
1615 if (mh > *minh) *minh = mh; 1728 /* text.min: X X
1729 * text.max: 0 1 */
1730 int temp_w, temp_h;
1731
1732 if (chosen_desc->text.min_y)
1733 {
1734 /* text.min: X 1
1735 * text.max: 0 1
1736 * Already calculated in text for height. */
1737 tw = TO_INT(params->eval.w);
1738 if (min_calc_w > tw)
1739 tw = min_calc_w;
1740
1741 th = min_calc_h;
1742 }
1743 else
1744 {
1745 /* text.min: X 0
1746 * text.max: 0 1 */
1747 temp_w = TO_INT(params->eval.w);
1748 temp_h = TO_INT(params->eval.h);
1749
1750 if (min_calc_w > temp_w)
1751 temp_w = min_calc_w;
1752 if (maxw && (*maxw > -1) && (*maxw < temp_w))
1753 temp_w = *maxw;
1754 if (min_calc_h > temp_h)
1755 temp_h = min_calc_h;
1756
1757 /* If base width for calculation is 0,
1758 * don't get meaningless height for multiline */
1759 if (temp_w > 0)
1760 {
1761 efl_gfx_size_set(ep->object, temp_w, temp_h);
1762 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1763
1764 tw += ins_l + ins_r;
1765 th += ins_t + ins_b;
1766 }
1767 else
1768 {
1769 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1770
1771 th += ins_t + ins_b;
1772 }
1773 }
1616 } 1774 }
1617 } 1775 else
1618 } 1776 {
1777 /* text.max: 1 X */
1778 if (chosen_desc->text.min_x)
1779 {
1780 /* text.min: 1 X
1781 * text.max: 1 X
1782 * Singleline. */
1783 efl_canvas_text_size_native_get(ep->object, &tw, &th);
1619 1784
1620 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y)) 1785 tw += ins_l + ins_r;
1621 { 1786 th += ins_t + ins_b;
1622 int mw = 0, mh = 0; 1787 }
1788 else
1789 {
1790 /* text.min: 0 X
1791 * text.max: 1 X */
1792 if (chosen_desc->text.max_y)
1793 {
1794 /* text.min: 0 X
1795 * text.max: 1 1 */
1796 int temp_w, temp_h;
1797
1798 temp_w = TO_INT(params->eval.w);
1799 temp_h = TO_INT(params->eval.h);
1800
1801 if (min_calc_w > temp_w)
1802 temp_w = min_calc_w;
1803 if (min_calc_h > temp_h)
1804 temp_h = min_calc_h;
1805
1806 if (chosen_desc->text.min_y)
1807 {
1808 /* text.min: 0 1
1809 * text.max: 1 1
1810 * There is no need to calculate it again. */
1811 tw = min_calc_w;
1812 th = min_calc_h;
1813 }
1814 else
1815 {
1816 /* text.min: 0 0
1817 * text.max: 1 1 */
1818
1819 efl_gfx_size_set(ep->object, temp_w, temp_h);
1820 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1821
1822 tw += ins_l + ins_r;
1823 th += ins_t + ins_b;
1824
1825 /* If base width for calculation is 0,
1826 * don't get meaningless height for multiline */
1827 if (temp_w <= 0)
1828 {
1829 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1830
1831 th += ins_t + ins_b;
1832 }
1833 }
1834 }
1835 else
1836 {
1837 /* text.min: 0 X
1838 * text.max: 1 0 */
1839 int temp_w, temp_h;
1623 1840
1624 tw = th = 0; 1841 temp_w = TO_INT(params->eval.w);
1625 if (!chosen_desc->text.max_x) 1842 if (min_calc_w > temp_w)
1626 { 1843 temp_w = min_calc_w;
1627 efl_gfx_size_set(ep->object, TO_INT(params->eval.w), TO_INT(params->eval.h)); 1844
1628 efl_canvas_text_size_formatted_get(ep->object, &tw, &th); 1845 efl_gfx_size_get(ep->object, NULL, &temp_h);
1629 } 1846 efl_gfx_size_set(ep->object, temp_w, temp_h);
1630 else 1847 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1631 evas_object_textblock_size_native_get(ep->object, &tw, &th); 1848
1632 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, 1849 tw += ins_l + ins_r;
1633 &ins_t, &ins_b); 1850 th += ins_t + ins_b;
1634 mw = ins_l + tw + ins_r; 1851
1635 mh = ins_t + th + ins_b; 1852 /* If base width for calculation is 0,
1636 if (maxw && chosen_desc->text.max_x) 1853 * don't get meaningless height for multiline */
1637 { 1854 if (temp_w <= 0)
1638 if (mw > *maxw) *maxw = mw; 1855 {
1639 if (minw && (*maxw < *minw)) *maxw = *minw; 1856 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1640 } 1857
1641 if (maxh && chosen_desc->text.max_y) 1858 th += ins_t + ins_b;
1642 { 1859 }
1643 if (mh > *maxh) *maxh = mh; 1860 }
1644 if (minh && (*maxh < *minh)) *maxh = *minh; 1861 }
1862 }
1863
1864 if (maxw && chosen_desc->text.max_x)
1865 {
1866 if (tw > *maxw) *maxw = tw;
1867 if (minw && (*maxw < *minw)) *maxw = *minw;
1868 }
1869 if (maxh && chosen_desc->text.max_y)
1870 {
1871 if (th > *maxh) *maxh = th;
1872 if (minh && (*maxh < *minh)) *maxh = *minh;
1873 }
1645 } 1874 }
1646 } 1875 }
1647 1876
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index d8a29fe369..158259eaf0 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -3872,7 +3872,6 @@ _edje_object_size_min_restricted_calc(Eo *obj EINA_UNUSED, Edje *ed, Evas_Coord
3872 Eina_Bool repeat_w, repeat_h; 3872 Eina_Bool repeat_w, repeat_h;
3873 Eina_Bool reset_max = EINA_TRUE; 3873 Eina_Bool reset_max = EINA_TRUE;
3874 Edje_Real_Part *pep = NULL; 3874 Edje_Real_Part *pep = NULL;
3875 Eina_Bool has_fixed_tb;
3876 3875
3877 if ((!ed) || (!ed->collection)) 3876 if ((!ed) || (!ed->collection))
3878 { 3877 {
@@ -3916,13 +3915,11 @@ again:
3916 } 3915 }
3917 3916
3918 pep = NULL; 3917 pep = NULL;
3919 has_fixed_tb = EINA_TRUE;
3920 3918
3921 //for parts 3919 //for parts
3922 for (i = 0; i < ed->table_parts_size; i++) 3920 for (i = 0; i < ed->table_parts_size; i++)
3923 { 3921 {
3924 Edje_Real_Part *ep = ed->table_parts[i]; 3922 Edje_Real_Part *ep = ed->table_parts[i];
3925 Evas_Coord ins_l, ins_r;
3926 3923
3927 if (!ep->chosen_description) continue; 3924 if (!ep->chosen_description) continue;
3928 3925
@@ -3930,49 +3927,21 @@ again:
3930 int over_w = (ep->w - ep->req.w); 3927 int over_w = (ep->w - ep->req.w);
3931 int over_h = (ep->h - ep->req.h); 3928 int over_h = (ep->h - ep->req.h);
3932 3929
3933 Eina_Bool skip_h = EINA_FALSE;
3934
3935 //width 3930 //width
3936 if (!ep->chosen_description->fixed.w) 3931 if ((!ep->chosen_description->fixed.w) &&
3932 (over_w > max_over_w))
3937 { 3933 {
3938 //We care textblock width size specially. 3934 max_over_w = over_w;
3939 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) 3935 repeat_w = EINA_TRUE;
3940 { 3936 pep = ep;
3941 Evas_Coord tb_mw;
3942 evas_object_textblock_size_formatted_get(ep->object,
3943 &tb_mw, NULL);
3944 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, NULL, NULL);
3945 tb_mw = ins_l + tb_mw + ins_r;
3946 tb_mw -= ep->req.w;
3947 if (tb_mw > over_w) over_w = tb_mw;
3948 has_fixed_tb = EINA_FALSE;
3949 }
3950
3951 if (over_w > max_over_w)
3952 {
3953 max_over_w = over_w;
3954 repeat_w = EINA_TRUE;
3955 pep = ep;
3956 skip_h = EINA_TRUE;
3957 }
3958 } 3937 }
3959 //height 3938 //height
3960 if (!ep->chosen_description->fixed.h) 3939 if ((!ep->chosen_description->fixed.h) &&
3940 (over_h > max_over_h))
3961 { 3941 {
3962 if ((ep->part->type != EDJE_PART_TYPE_TEXTBLOCK) || 3942 max_over_h = over_h;
3963 ((Edje_Part_Description_Text *)ep->chosen_description)->text.min_x || 3943 repeat_h = EINA_TRUE;
3964 !skip_h) 3944 pep = ep;
3965 {
3966 if (over_h > max_over_h)
3967 {
3968 max_over_h = over_h;
3969 repeat_h = EINA_TRUE;
3970 pep = ep;
3971 }
3972 }
3973
3974 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
3975 has_fixed_tb = EINA_FALSE;
3976 } 3945 }
3977 } 3946 }
3978 if (repeat_w) 3947 if (repeat_w)
@@ -3992,18 +3961,14 @@ again:
3992 3961
3993 if (reset_max && (calc_count > CALC_COUNT_LIMIT)) 3962 if (reset_max && (calc_count > CALC_COUNT_LIMIT))
3994 { 3963 {
3995 /* Only print it if we have a non-fixed textblock. 3964 /* We should possibly avoid all of this if in this case, but in
3996 * We should possibly avoid all of this if in this case, but in
3997 * the meanwhile, just doing this. */ 3965 * the meanwhile, just doing this. */
3998 if (!has_fixed_tb) 3966 if (pep)
3999 { 3967 ERR("file %s, group %s has a non-fixed part '%s'. Adding 'fixed: 1 1;' to source EDC may help. Continuing discarding faulty part.",
4000 if (pep) 3968 ed->path, ed->group, pep->part->name);
4001 ERR("file %s, group %s has a non-fixed part '%s'. Adding 'fixed: 1 1;' to source EDC may help. Continuing discarding faulty part.", 3969 else
4002 ed->path, ed->group, pep->part->name); 3970 ERR("file %s, group %s runs infinite minimum calculation loops.Continuing discarding faulty parts.",
4003 else 3971 ed->path, ed->group);
4004 ERR("file %s, group %s runs infinite minimum calculation loops.Continuing discarding faulty parts.",
4005 ed->path, ed->group);
4006 }
4007 3972
4008 reset_max = EINA_FALSE; 3973 reset_max = EINA_FALSE;
4009 goto again; 3974 goto again;
diff --git a/src/lib/elementary/elm_label.c b/src/lib/elementary/elm_label.c
index 7af1237278..76cb63c22c 100644
--- a/src/lib/elementary/elm_label.c
+++ b/src/lib/elementary/elm_label.c
@@ -52,18 +52,13 @@ _recalc(void *data)
52 resw = w; 52 resw = w;
53 edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh, resw, 0); 53 edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh, resw, 0);
54 54
55 /* This is a hack to workaround the way min size hints are treated. 55 /* If wrap_w is not set, label's width has to be controlled
56 * If the minimum width is smaller than the restricted width, it means 56 by outside of label. So, we don't need to set minimum width. */
57 * the minimum doesn't matter. */ 57 if (sd->wrap_w == -1)
58 if ((minw <= resw) && (minw != sd->wrap_w)) 58 evas_object_size_hint_min_set(data, 0, minh);
59 { 59 else
60 Evas_Coord ominw = -1; 60 evas_object_size_hint_min_set(data, minw, minh);
61
62 efl_gfx_size_hint_combined_min_get(data, &ominw, NULL);
63 minw = ominw;
64 }
65 61
66 evas_object_size_hint_min_set(data, minw, minh);
67 evas_event_thaw(evas_object_evas_get(data)); 62 evas_event_thaw(evas_object_evas_get(data));
68 evas_event_thaw_eval(evas_object_evas_get(data)); 63 evas_event_thaw_eval(evas_object_evas_get(data));
69} 64}
@@ -178,6 +173,18 @@ _label_slide_change(Evas_Object *obj)
178 } 173 }
179} 174}
180 175
176static void
177_elm_label_horizontal_size_policy_update(Eo *obj, Elm_Label_Data *sd)
178{
179 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
180
181 if (!sd->ellipsis && (sd->linewrap == ELM_WRAP_NONE))
182 edje_object_signal_emit(wd->resize_obj, "elm,state,horizontal,expandable", "elm");
183 else
184 edje_object_signal_emit(wd->resize_obj, "elm,state,horizontal,fixed", "elm");
185 edje_object_message_signal_process(wd->resize_obj);
186}
187
181EOLIAN static Elm_Theme_Apply 188EOLIAN static Elm_Theme_Apply
182_elm_label_elm_widget_theme_apply(Eo *obj, Elm_Label_Data *sd) 189_elm_label_elm_widget_theme_apply(Eo *obj, Elm_Label_Data *sd)
183{ 190{
@@ -190,6 +197,8 @@ _elm_label_elm_widget_theme_apply(Eo *obj, Elm_Label_Data *sd)
190 int_ret = elm_obj_widget_theme_apply(efl_super(obj, MY_CLASS)); 197 int_ret = elm_obj_widget_theme_apply(efl_super(obj, MY_CLASS));
191 if (!int_ret) return ELM_THEME_APPLY_FAILED; 198 if (!int_ret) return ELM_THEME_APPLY_FAILED;
192 199
200 _elm_label_horizontal_size_policy_update(obj, sd);
201
193 _label_format_set(wd->resize_obj, sd->format); 202 _label_format_set(wd->resize_obj, sd->format);
194 _label_slide_change(obj); 203 _label_slide_change(obj);
195 204
@@ -437,6 +446,10 @@ _elm_label_line_wrap_set(Eo *obj, Elm_Label_Data *sd, Elm_Wrap_Type wrap)
437 if (sd->linewrap == wrap) return; 446 if (sd->linewrap == wrap) return;
438 447
439 sd->linewrap = wrap; 448 sd->linewrap = wrap;
449 sd->lastw = -1;
450
451 _elm_label_horizontal_size_policy_update(obj, sd);
452
440 text = elm_layout_text_get(obj, NULL); 453 text = elm_layout_text_get(obj, NULL);
441 if (!text) return; 454 if (!text) return;
442 455
@@ -510,6 +523,9 @@ _elm_label_ellipsis_set(Eo *obj, Elm_Label_Data *sd, Eina_Bool ellipsis)
510 523
511 if (sd->ellipsis == ellipsis) return; 524 if (sd->ellipsis == ellipsis) return;
512 sd->ellipsis = ellipsis; 525 sd->ellipsis = ellipsis;
526 sd->lastw = -1;
527
528 _elm_label_horizontal_size_policy_update(obj, sd);
513 529
514 text = elm_layout_text_get(obj, NULL); 530 text = elm_layout_text_get(obj, NULL);
515 if (!text) return; 531 if (!text) return;