summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_calc.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-06-09 20:20:47 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-06-09 20:20:47 -0400
commit84c79f6c496b766b32ac0df6edfb284ff8e7e5f3 (patch)
tree4aa5dba3272b49e16ed26c189611803f930c9bf3 /src/lib/edje/edje_calc.c
parent2ba847f4c2b258f78d56d658d117c834df1df2c8 (diff)
Revert "Revert "Edje calc: Fix textblock size calculation logic""
This reverts commit 0392cd3c489ee1c69dc768b2c3e8ac01ba1854c1. oops this was supposed to just be local
Diffstat (limited to 'src/lib/edje/edje_calc.c')
-rw-r--r--src/lib/edje/edje_calc.c305
1 files changed, 267 insertions, 38 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index 7a2e6a8d60..47e918cdcc 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -1476,9 +1476,17 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
1476 int *minw, int *minh, 1476 int *minw, int *minh,
1477 int *maxw, int *maxh) 1477 int *maxw, int *maxh)
1478{ 1478{
1479 int min_calc_w = 0, min_calc_h = 0;
1480
1479 if ((ep->type != EDJE_RP_TYPE_TEXT) || 1481 if ((ep->type != EDJE_RP_TYPE_TEXT) ||
1480 (!ep->typedata.text)) 1482 (!ep->typedata.text))
1481 return; 1483 return;
1484
1485 /* min_calc_* values need to save calculated minumum size
1486 * for maximum size calculation */
1487 if (minw) min_calc_w = *minw;
1488 if (minh) min_calc_h = *minh;
1489
1482 if (chosen_desc) 1490 if (chosen_desc)
1483 { 1491 {
1484 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b; 1492 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
@@ -1623,56 +1631,277 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
1623 } 1631 }
1624 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) 1632 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
1625 { 1633 {
1626 int mw = 0, mh = 0; 1634 evas_object_textblock_style_insets_get(ep->object, &ins_l,
1635 &ins_r, &ins_t, &ins_b);
1627 1636
1628 tw = th = 0; 1637 tw = th = 0;
1629 if (!chosen_desc->text.min_x) 1638 if (!chosen_desc->text.min_x)
1630 { 1639 {
1631 efl_gfx_size_set(ep->object, TO_INT(params->eval.w), TO_INT(params->eval.h)); 1640 /* text.min: 0 1
1632 efl_canvas_text_size_formatted_get(ep->object, &tw, &th); 1641 * text.max: X X */
1642 int temp_h = TO_INT(params->eval.h);
1643 int temp_w = TO_INT(params->eval.w);
1644
1645 if (min_calc_w > temp_w)
1646 temp_w = min_calc_w;
1647 if ((!chosen_desc->text.max_x) &&
1648 maxw && (*maxw > -1) && (*maxw < temp_w))
1649 temp_w = *maxw;
1650
1651 if (chosen_desc->text.max_y)
1652 {
1653 /* text.min: 0 1
1654 * text.max: X 1 */
1655 temp_h = INT_MAX / 10000;
1656 }
1657 else if (maxh && (*maxh > TO_INT(params->eval.h)))
1658 {
1659 /* text.min: 0 1
1660 * text.max: X 0
1661 * And there is a limit for height. */
1662 temp_h = *maxh;
1663 }
1664
1665 /* If base width for calculation is 0,
1666 * don't get meaningless height for multiline */
1667 if (temp_w > 0)
1668 {
1669 efl_gfx_size_set(ep->object, temp_w, temp_h);
1670 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1671
1672 tw += ins_l + ins_r;
1673 th += ins_t + ins_b;
1674 }
1675 else
1676 {
1677 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1678
1679 th += ins_t + ins_b;
1680 }
1633 } 1681 }
1634 else 1682 else
1635 evas_object_textblock_size_native_get(ep->object, &tw, &th);
1636 evas_object_textblock_style_insets_get(ep->object, &ins_l,
1637 &ins_r, &ins_t, &ins_b);
1638 mw = ins_l + tw + ins_r;
1639 mh = ins_t + th + ins_b;
1640 if (minw && chosen_desc->text.min_x)
1641 { 1683 {
1642 if (mw > *minw) *minw = mw; 1684 /* text.min: 1 X
1685 * text.max: X X */
1686 if (chosen_desc->text.min_y && (!chosen_desc->text.max_x) &&
1687 maxw && (*maxw > -1))
1688 {
1689 /* text.min: 1 1
1690 * text.max: 0 X */
1691 int temp_w, temp_h;
1692
1693 temp_w = *maxw;
1694 temp_h = INT_MAX / 10000;
1695
1696 if (min_calc_w > temp_w)
1697 temp_w = min_calc_w;
1698
1699 if ((!chosen_desc->text.max_y) && maxh && (*maxh > -1))
1700 {
1701 /* text.min: 1 1
1702 * text.max: 0 0
1703 * There is limit for height. */
1704 temp_h = *maxh;
1705 }
1706
1707 efl_gfx_size_set(ep->object, temp_w, temp_h);
1708 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1709
1710 tw += ins_l + ins_r;
1711 th += ins_t + ins_b;
1712
1713 /* If base width for calculation is 0,
1714 * don't get meaningless height for multiline */
1715 if (temp_w <= 0)
1716 {
1717 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1718
1719 th += ins_t + ins_b;
1720 }
1721 }
1722 else
1723 {
1724 /* text.min: 1 X
1725 * text.max: 1 X
1726 * Or,
1727 * text.min: 1 X
1728 * text.max: 0 X without max width.
1729 * It is a singleline Textblock. */
1730 efl_canvas_text_size_native_get(ep->object, &tw, &th);
1731
1732 tw += ins_l + ins_r;
1733 th += ins_t + ins_b;
1734
1735 if (!chosen_desc->text.max_x &&
1736 (maxw && (*maxw > -1) && (*maxw < tw)))
1737 {
1738 /* text.min: 1 0
1739 * text.max: 0 X */
1740 tw = *maxw;
1741 }
1742 }
1643 } 1743 }
1644 if (minh && chosen_desc->text.min_y) 1744
1745 if (tw > min_calc_w) min_calc_w = tw;
1746 if (th > min_calc_h) min_calc_h = th;
1747 if (chosen_desc->text.min_x && minw) *minw = min_calc_w;
1748 if (chosen_desc->text.min_y && minh) *minh = min_calc_h;
1749 }
1750
1751 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
1752 {
1753 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
1754 &ins_t, &ins_b);
1755
1756 tw = th = 0;
1757 if (!chosen_desc->text.max_x)
1645 { 1758 {
1646 if (mh > *minh) *minh = mh; 1759 /* text.min: X X
1760 * text.max: 0 1 */
1761 int temp_w, temp_h;
1762
1763 if (chosen_desc->text.min_y)
1764 {
1765 /* text.min: X 1
1766 * text.max: 0 1
1767 * Already calculated in text for height. */
1768 tw = TO_INT(params->eval.w);
1769 if (min_calc_w > tw)
1770 tw = min_calc_w;
1771
1772 th = min_calc_h;
1773 }
1774 else
1775 {
1776 /* text.min: X 0
1777 * text.max: 0 1 */
1778 temp_w = TO_INT(params->eval.w);
1779 temp_h = TO_INT(params->eval.h);
1780
1781 if (min_calc_w > temp_w)
1782 temp_w = min_calc_w;
1783 if (maxw && (*maxw > -1) && (*maxw < temp_w))
1784 temp_w = *maxw;
1785 if (min_calc_h > temp_h)
1786 temp_h = min_calc_h;
1787
1788 /* If base width for calculation is 0,
1789 * don't get meaningless height for multiline */
1790 if (temp_w > 0)
1791 {
1792 efl_gfx_size_set(ep->object, temp_w, temp_h);
1793 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1794
1795 tw += ins_l + ins_r;
1796 th += ins_t + ins_b;
1797 }
1798 else
1799 {
1800 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1801
1802 th += ins_t + ins_b;
1803 }
1804 }
1647 } 1805 }
1648 } 1806 else
1649 } 1807 {
1808 /* text.max: 1 X */
1809 if (chosen_desc->text.min_x)
1810 {
1811 /* text.min: 1 X
1812 * text.max: 1 X
1813 * Singleline. */
1814 efl_canvas_text_size_native_get(ep->object, &tw, &th);
1650 1815
1651 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y)) 1816 tw += ins_l + ins_r;
1652 { 1817 th += ins_t + ins_b;
1653 int mw = 0, mh = 0; 1818 }
1819 else
1820 {
1821 /* text.min: 0 X
1822 * text.max: 1 X */
1823 if (chosen_desc->text.max_y)
1824 {
1825 /* text.min: 0 X
1826 * text.max: 1 1 */
1827 int temp_w, temp_h;
1828
1829 temp_w = TO_INT(params->eval.w);
1830 temp_h = TO_INT(params->eval.h);
1831
1832 if (min_calc_w > temp_w)
1833 temp_w = min_calc_w;
1834 if (min_calc_h > temp_h)
1835 temp_h = min_calc_h;
1836
1837 if (chosen_desc->text.min_y)
1838 {
1839 /* text.min: 0 1
1840 * text.max: 1 1
1841 * There is no need to calculate it again. */
1842 tw = min_calc_w;
1843 th = min_calc_h;
1844 }
1845 else
1846 {
1847 /* text.min: 0 0
1848 * text.max: 1 1 */
1849
1850 efl_gfx_size_set(ep->object, temp_w, temp_h);
1851 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1852
1853 tw += ins_l + ins_r;
1854 th += ins_t + ins_b;
1855
1856 /* If base width for calculation is 0,
1857 * don't get meaningless height for multiline */
1858 if (temp_w <= 0)
1859 {
1860 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1861
1862 th += ins_t + ins_b;
1863 }
1864 }
1865 }
1866 else
1867 {
1868 /* text.min: 0 X
1869 * text.max: 1 0 */
1870 int temp_w, temp_h;
1654 1871
1655 tw = th = 0; 1872 temp_w = TO_INT(params->eval.w);
1656 if (!chosen_desc->text.max_x) 1873 if (min_calc_w > temp_w)
1657 { 1874 temp_w = min_calc_w;
1658 efl_gfx_size_set(ep->object, TO_INT(params->eval.w), TO_INT(params->eval.h)); 1875
1659 efl_canvas_text_size_formatted_get(ep->object, &tw, &th); 1876 efl_gfx_size_get(ep->object, NULL, &temp_h);
1660 } 1877 efl_gfx_size_set(ep->object, temp_w, temp_h);
1661 else 1878 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
1662 evas_object_textblock_size_native_get(ep->object, &tw, &th); 1879
1663 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, 1880 tw += ins_l + ins_r;
1664 &ins_t, &ins_b); 1881 th += ins_t + ins_b;
1665 mw = ins_l + tw + ins_r; 1882
1666 mh = ins_t + th + ins_b; 1883 /* If base width for calculation is 0,
1667 if (maxw && chosen_desc->text.max_x) 1884 * don't get meaningless height for multiline */
1668 { 1885 if (temp_w <= 0)
1669 if (mw > *maxw) *maxw = mw; 1886 {
1670 if (minw && (*maxw < *minw)) *maxw = *minw; 1887 efl_canvas_text_size_native_get(ep->object, NULL, &th);
1671 } 1888
1672 if (maxh && chosen_desc->text.max_y) 1889 th += ins_t + ins_b;
1673 { 1890 }
1674 if (mh > *maxh) *maxh = mh; 1891 }
1675 if (minh && (*maxh < *minh)) *maxh = *minh; 1892 }
1893 }
1894
1895 if (maxw && chosen_desc->text.max_x)
1896 {
1897 if (tw > *maxw) *maxw = tw;
1898 if (minw && (*maxw < *minw)) *maxw = *minw;
1899 }
1900 if (maxh && chosen_desc->text.max_y)
1901 {
1902 if (th > *maxh) *maxh = th;
1903 if (minh && (*maxh < *minh)) *maxh = *minh;
1904 }
1676 } 1905 }
1677 } 1906 }
1678 1907