summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-07-24 03:52:14 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-07-24 03:52:14 +0000
commit29452cf797b15373f0509929e40836e046612d9a (patch)
tree5e3a714f48e93fa9544c887fe71eadb6e5762bc9
parent5410726016478b3a90035ca4c04108ff9e1e3bbd (diff)
fix entry shift selection extend with mouse.
SVN revision: 74338
-rw-r--r--legacy/edje/ChangeLog6
-rw-r--r--legacy/edje/src/lib/edje_entry.c160
2 files changed, 107 insertions, 59 deletions
diff --git a/legacy/edje/ChangeLog b/legacy/edje/ChangeLog
index 563cc37f57..78fee46d4d 100644
--- a/legacy/edje/ChangeLog
+++ b/legacy/edje/ChangeLog
@@ -531,3 +531,9 @@
5312012-07-14 Cedric Bail 5312012-07-14 Cedric Bail
532 532
533 * Fix Edje_Multisense shutdown. 533 * Fix Edje_Multisense shutdown.
534
5352012-07-24 Carsten Haitzler (The Rasterman)
536
537 * Fix edje entry to extend selection to char pos/word or line
538 when holding shift + mouse click.
539
diff --git a/legacy/edje/src/lib/edje_entry.c b/legacy/edje/src/lib/edje_entry.c
index a4323553e9..fba869423d 100644
--- a/legacy/edje/src/lib/edje_entry.c
+++ b/legacy/edje/src/lib/edje_entry.c
@@ -1651,8 +1651,9 @@ _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS
1651 Entry *en; 1651 Entry *en;
1652 Evas_Coord x, y, w, h; 1652 Evas_Coord x, y, w, h;
1653 // Eina_Bool multiline; 1653 // Eina_Bool multiline;
1654 Evas_Textblock_Cursor *tc; 1654 Evas_Textblock_Cursor *tc = NULL;
1655 Eina_Bool dosel = EINA_FALSE; 1655 Eina_Bool dosel = EINA_FALSE;
1656 Eina_Bool shift;
1656 if (!rp) return; 1657 if (!rp) return;
1657 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; 1658 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1658 en = rp->entry_data; 1659 en = rp->entry_data;
@@ -1673,6 +1674,7 @@ _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS
1673 } 1674 }
1674#endif 1675#endif
1675 1676
1677 shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
1676 en->select_mod_start = EINA_FALSE; 1678 en->select_mod_start = EINA_FALSE;
1677 en->select_mod_end = EINA_FALSE; 1679 en->select_mod_end = EINA_FALSE;
1678 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT) 1680 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
@@ -1684,33 +1686,63 @@ _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS
1684 if (ev->button == 2) dosel = EINA_FALSE; 1686 if (ev->button == 2) dosel = EINA_FALSE;
1685 if (dosel) 1687 if (dosel)
1686 { 1688 {
1689 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
1690 cx = ev->canvas.x - x;
1691 cy = ev->canvas.y - y;
1687 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) 1692 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
1688 { 1693 {
1689 en->have_selection = EINA_FALSE; 1694 if (shift)
1690 en->selecting = EINA_FALSE; 1695 {
1691 _sel_clear(en->cursor, rp->object, en); 1696 tc = evas_object_textblock_cursor_new(rp->object);
1692 tc = evas_object_textblock_cursor_new(rp->object); 1697 evas_textblock_cursor_copy(en->cursor, tc);
1693 evas_textblock_cursor_copy(en->cursor, tc); 1698 if (evas_textblock_cursor_compare(en->cursor, en->sel_start) < 0)
1694 evas_textblock_cursor_line_char_first(en->cursor); 1699 evas_textblock_cursor_line_char_first(en->cursor);
1695 _sel_start(en->cursor, rp->object, en); 1700 else
1696 evas_textblock_cursor_line_char_last(en->cursor); 1701 evas_textblock_cursor_line_char_last(en->cursor);
1697 _sel_extend(en->cursor, rp->object, en); 1702 _sel_extend(en->cursor, rp->object, en);
1698 1703 }
1704 else
1705 {
1706 en->have_selection = EINA_FALSE;
1707 en->selecting = EINA_FALSE;
1708 _sel_clear(en->cursor, rp->object, en);
1709 tc = evas_object_textblock_cursor_new(rp->object);
1710 evas_textblock_cursor_copy(en->cursor, tc);
1711 evas_textblock_cursor_line_char_first(en->cursor);
1712 _sel_start(en->cursor, rp->object, en);
1713 evas_textblock_cursor_line_char_last(en->cursor);
1714 _sel_extend(en->cursor, rp->object, en);
1715 }
1699 goto end; 1716 goto end;
1700 } 1717 }
1701 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) 1718 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1702 { 1719 {
1703 en->have_selection = EINA_FALSE; 1720 if (shift)
1704 en->selecting = EINA_FALSE; 1721 {
1705 _sel_clear(en->cursor, rp->object, en); 1722 tc = evas_object_textblock_cursor_new(rp->object);
1706 tc = evas_object_textblock_cursor_new(rp->object); 1723 evas_textblock_cursor_copy(en->cursor, tc);
1707 evas_textblock_cursor_copy(en->cursor, tc); 1724 if (evas_textblock_cursor_compare(en->cursor, en->sel_start) < 0)
1708 evas_textblock_cursor_word_start(en->cursor); 1725 evas_textblock_cursor_word_start(en->cursor);
1709 _sel_start(en->cursor, rp->object, en); 1726 else
1710 evas_textblock_cursor_word_end(en->cursor); 1727 {
1711 evas_textblock_cursor_char_next(en->cursor); 1728 evas_textblock_cursor_word_end(en->cursor);
1712 _sel_extend(en->cursor, rp->object, en); 1729 evas_textblock_cursor_char_next(en->cursor);
1713 1730 }
1731 _sel_extend(en->cursor, rp->object, en);
1732 }
1733 else
1734 {
1735 en->have_selection = EINA_FALSE;
1736 en->selecting = EINA_FALSE;
1737 _sel_clear(en->cursor, rp->object, en);
1738 tc = evas_object_textblock_cursor_new(rp->object);
1739 evas_textblock_cursor_copy(en->cursor, tc);
1740 evas_textblock_cursor_word_start(en->cursor);
1741 _sel_start(en->cursor, rp->object, en);
1742 evas_textblock_cursor_word_end(en->cursor);
1743 evas_textblock_cursor_char_next(en->cursor);
1744 _sel_extend(en->cursor, rp->object, en);
1745 }
1714 goto end; 1746 goto end;
1715 } 1747 }
1716 } 1748 }
@@ -1761,55 +1793,65 @@ _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS
1761 if ((en->have_selection) && 1793 if ((en->have_selection) &&
1762 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)) 1794 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
1763 { 1795 {
1764 Eina_List *first, *last; 1796 if (shift)
1765 FLOAT_T sc; 1797 _sel_extend(en->cursor, rp->object, en);
1766 1798 else
1767 first = en->sel;
1768 last = eina_list_last(en->sel);
1769 if (first && last)
1770 { 1799 {
1771 Evas_Textblock_Rectangle *r1, *r2; 1800 Eina_List *first, *last;
1772 Evas_Coord d, d1, d2; 1801 FLOAT_T sc;
1773 1802
1774 r1 = first->data; 1803 first = en->sel;
1775 r2 = last->data; 1804 last = eina_list_last(en->sel);
1776 d = r1->x - cx; 1805 if (first && last)
1777 d1 = d * d;
1778 d = (r1->y + (r1->h / 2)) - cy;
1779 d1 += d * d;
1780 d = r2->x + r2->w - 1 - cx;
1781 d2 = d * d;
1782 d = (r2->y + (r2->h / 2)) - cy;
1783 d2 += d * d;
1784 sc = rp->edje->scale;
1785 if (sc == ZERO) sc = _edje_scale;
1786 d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
1787 d = d * d;
1788 if (d1 < d2)
1789 { 1806 {
1790 if (d1 <= d) 1807 Evas_Textblock_Rectangle *r1, *r2;
1808 Evas_Coord d, d1, d2;
1809
1810 r1 = first->data;
1811 r2 = last->data;
1812 d = r1->x - cx;
1813 d1 = d * d;
1814 d = (r1->y + (r1->h / 2)) - cy;
1815 d1 += d * d;
1816 d = r2->x + r2->w - 1 - cx;
1817 d2 = d * d;
1818 d = (r2->y + (r2->h / 2)) - cy;
1819 d2 += d * d;
1820 sc = rp->edje->scale;
1821 if (sc == ZERO) sc = _edje_scale;
1822 d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
1823 d = d * d;
1824 if (d1 < d2)
1791 { 1825 {
1792 en->select_mod_start = EINA_TRUE; 1826 if (d1 <= d)
1793 en->selecting = EINA_TRUE; 1827 {
1828 en->select_mod_start = EINA_TRUE;
1829 en->selecting = EINA_TRUE;
1830 }
1794 } 1831 }
1795 } 1832 else
1796 else
1797 {
1798 if (d2 <= d)
1799 { 1833 {
1800 en->select_mod_end = EINA_TRUE; 1834 if (d2 <= d)
1801 en->selecting = EINA_TRUE; 1835 {
1836 en->select_mod_end = EINA_TRUE;
1837 en->selecting = EINA_TRUE;
1838 }
1802 } 1839 }
1803 } 1840 }
1804 } 1841 }
1805 } 1842 }
1806 else 1843 else
1807 { 1844 {
1808 en->selecting = EINA_TRUE; 1845 if ((en->have_selection) && (shift))
1809 _sel_clear(en->cursor, rp->object, en); 1846 _sel_extend(en->cursor, rp->object, en);
1810 if (en->select_allow) 1847 else
1811 { 1848 {
1812 _sel_start(en->cursor, rp->object, en); 1849 en->selecting = EINA_TRUE;
1850 _sel_clear(en->cursor, rp->object, en);
1851 if (en->select_allow)
1852 {
1853 _sel_start(en->cursor, rp->object, en);
1854 }
1813 } 1855 }
1814 } 1856 }
1815 } 1857 }