summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2018-09-07 12:38:35 +0300
committerDaniel Hirt <hirt.danny@gmail.com>2018-09-07 14:28:56 +0300
commit7a9ab13d518e7dd80fa05af4f507112d4ee1adcf (patch)
tree2936462b577ee1d208429b7eedb7ef2f2d413c8d
parent40e3b9bb3bacb08aaf4da9a256073596952dbd96 (diff)
Ui text: fix lifecycle and replace scroll logicdevs/herdsman/text/efl_ui_text
The following changes were squashed as there was no point to fix the lifecycle for the old scroller implementation. - Moved some of the construction code to 'finalize' - Removed explicit deletion of objects owned by the Ui.Text object - Fixed lifecycle Efl.Canvas.Text_Factory objects and simplified logic - Implemented scroll logic by using a "text scroller" class (inherits Ui.Scroller)
-rw-r--r--data/elementary/themes/edc/efl/text.edc17
-rw-r--r--src/bin/elementary/test.c4
-rw-r--r--src/bin/elementary/test_efl_ui_text.c361
-rw-r--r--src/lib/elementary/efl_ui_text.c2335
-rw-r--r--src/lib/elementary/efl_ui_text.eo19
-rw-r--r--src/lib/elementary/efl_ui_text_factory_emoticons.c11
-rw-r--r--src/lib/elementary/efl_ui_text_factory_fallback.c2
7 files changed, 639 insertions, 2110 deletions
diff --git a/data/elementary/themes/edc/efl/text.edc b/data/elementary/themes/edc/efl/text.edc
index 61986b82f5..c09dfb4fcc 100644
--- a/data/elementary/themes/edc/efl/text.edc
+++ b/data/elementary/themes/edc/efl/text.edc
@@ -548,21 +548,6 @@ group { "efl/text";
548 rel2.offset: -2 -2; 548 rel2.offset: -2 -2;
549 } 549 }
550 } 550 }
551 part { name: "efl.guide"; type: TEXTBLOCK; mouse_events: 0;
552 scale: 1;
553 description { state: "default" 0.0;
554 rel1.to: "efl.text";
555 rel2.to: "efl.text";
556 text { style: "efl_ui_text_guide_style";
557 min: 0 1;
558 align: 0.0 0.0;
559 }
560 }
561 description { state: "hidden" 0.0;
562 inherit: "default" 0.0;
563 visible: 0;
564 }
565 }
566 part { name: "efl.text"; type: SWALLOW; 551 part { name: "efl.text"; type: SWALLOW;
567 scale: 1; 552 scale: 1;
568 description { state: "default" 0.0; 553 description { state: "default" 0.0;
@@ -914,4 +899,4 @@ group { "efl/text/emoticon/worried"; images.image:
914group { "efl/text/emoticon/wtf"; images.image: 899group { "efl/text/emoticon/wtf"; images.image:
915 "emo-wtf.png" COMP; parts { part { "icon"; nomouse; desc { "default"; max: 64 64; image.normal: 900 "emo-wtf.png" COMP; parts { part { "icon"; nomouse; desc { "default"; max: 64 64; image.normal:
916 "emo-wtf.png"; } } } } 901 "emo-wtf.png"; } } } }
917//------------------------------------------------------------ \ No newline at end of file 902//------------------------------------------------------------
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 9a97840270..0038e3285b 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -339,8 +339,8 @@ void test_code_diff(void *data, Evas_Object *obj, void *event_info);
339void test_code_diff_inline(void *data, Evas_Object *obj, void *event_info); 339void test_code_diff_inline(void *data, Evas_Object *obj, void *event_info);
340 340
341void test_efl_ui_text(void *data, Evas_Object *obj, void *event_info); 341void test_efl_ui_text(void *data, Evas_Object *obj, void *event_info);
342void test_efl_ui_text_inputfield(void *data, Evas_Object *obj, void *event_info);
342void test_efl_ui_text_label(void *data, Evas_Object *obj, void *event_info); 343void test_efl_ui_text_label(void *data, Evas_Object *obj, void *event_info);
343void test_efl_ui_text_async(void *data, Evas_Object *obj, void *event_info);
344void test_ui_text_item_factory(void *data, Evas_Object *obj, void *event_info); 344void test_ui_text_item_factory(void *data, Evas_Object *obj, void *event_info);
345void test_evas_mask(void *data, Edje_Object *obj, void *event_info); 345void test_evas_mask(void *data, Edje_Object *obj, void *event_info);
346void test_gfx_filters(void *data, Evas_Object *obj, void *event_info); 346void test_gfx_filters(void *data, Evas_Object *obj, void *event_info);
@@ -860,8 +860,8 @@ add_tests:
860 ADD_TEST(NULL, "Entries", "Entry Emoticon", test_entry_emoticon); 860 ADD_TEST(NULL, "Entries", "Entry Emoticon", test_entry_emoticon);
861 ADD_TEST(NULL, "Entries", "Entry Password", test_entry_password); 861 ADD_TEST(NULL, "Entries", "Entry Password", test_entry_password);
862 ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Text", test_efl_ui_text); 862 ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Text", test_efl_ui_text);
863 ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Text Input Field", test_efl_ui_text_inputfield);
863 ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Text Label", test_efl_ui_text_label); 864 ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Text Label", test_efl_ui_text_label);
864 ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Text.Async", test_efl_ui_text_async);
865 ADD_TEST_EO(NULL, "Entries", "Ui.Text Item Factory", test_ui_text_item_factory); 865 ADD_TEST_EO(NULL, "Entries", "Ui.Text Item Factory", test_ui_text_item_factory);
866 ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Tags", test_ui_tags); 866 ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Tags", test_ui_tags);
867 867
diff --git a/src/bin/elementary/test_efl_ui_text.c b/src/bin/elementary/test_efl_ui_text.c
index 9ad0e9a50a..da894da78f 100644
--- a/src/bin/elementary/test_efl_ui_text.c
+++ b/src/bin/elementary/test_efl_ui_text.c
@@ -4,8 +4,6 @@
4#define EO_BETA_API 4#define EO_BETA_API
5#include <Elementary.h> 5#include <Elementary.h>
6 6
7// 1. Label-equivalent setup
8
9static void 7static void
10_apply_style(Eo *obj, size_t start_pos, size_t end_pos, const char *style) 8_apply_style(Eo *obj, size_t start_pos, size_t end_pos, const char *style)
11{ 9{
@@ -30,10 +28,11 @@ _create_label(Eo *win, Eo *bx)
30 en = efl_add(EFL_UI_TEXT_CLASS, win); 28 en = efl_add(EFL_UI_TEXT_CLASS, win);
31 printf("Added Efl.Ui.Text object\n"); 29 printf("Added Efl.Ui.Text object\n");
32 efl_text_interactive_editable_set(en, EINA_FALSE); 30 efl_text_interactive_editable_set(en, EINA_FALSE);
33 elm_box_pack_end(bx, en); 31 efl_pack(bx, en);
34 return en; 32 return en;
35} 33}
36 34
35
37void 36void
38test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 37test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
39{ 38{
@@ -41,57 +40,35 @@ test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
41 Eo *en; 40 Eo *en;
42 char *markup; 41 char *markup;
43 42
44 win = elm_win_util_standard_add("label", "Label"); 43 win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
45 elm_win_autodel_set(win, EINA_TRUE); 44 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
45 efl_text_set(efl_added, "Efl Canvas_Layout"),
46 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
46 47
47 bx = elm_box_add(win); 48 bx = efl_add(EFL_UI_BOX_CLASS, win);
48 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 49 efl_content_set(win, bx);
49 elm_win_resize_object_add(win, bx);
50 evas_object_show(bx);
51 50
52 en = _create_label(win, bx); 51 en = _create_label(win, bx);
53 efl_text_set(en, "This is a\t small label"); 52 efl_text_set(en, "This is a\t small label");
54 // 012345678901234567890 53 // 012345678901234567890
55 _apply_style(en, 0, 21, "font_size=12 font_weight=bold"); 54 _apply_style(en, 0, 21, "font_size=12 font_weight=bold");
56 efl_text_halign_set(en, 0.5);
57 efl_text_font_weight_set(en, EFL_TEXT_FONT_WEIGHT_BOLD); 55 efl_text_font_weight_set(en, EFL_TEXT_FONT_WEIGHT_BOLD);
58 56
59 en = _create_label(win, bx); 57 en = _create_label(win, bx);
60 efl_text_halign_set(en, 0.5); 58 efl_text_set(en, "This is a text. It is longer but its size is taken as the"
61 efl_text_set(en, "This is a text. Is also has\n" 59 " min size so that it shows in whole");
62 "newlines. There are several styles applied.");
63 _apply_style(en, 40, 45, "font_weight=bold color=#ff0"); 60 _apply_style(en, 40, 45, "font_weight=bold color=#ff0");
64 _apply_style(en, 52, 58, "font_weight=italic color=#f00"); 61 _apply_style(en, 52, 58, "font_weight=italic color=#f00");
65 efl_text_multiline_set(en, EINA_TRUE);
66 62
67 en = _create_label(win, bx); 63 en = _create_label(win, bx);
68 efl_text_halign_set(en, 0.5);
69 efl_text_set(en, "By default 'multiline' is disabled.\n" 64 efl_text_set(en, "By default 'multiline' is disabled.\n"
70 "So, \\n would only work if you enable it."); 65 "So, \\n would only work if you enable it.");
71 66
72 en = _create_label(win, bx); 67 en = _create_label(win, bx);
73 efl_text_set(en, "You can input text here.");
74 efl_text_font_set(en, "Sans", 14);
75 efl_text_interactive_editable_set(en, EINA_TRUE);
76 efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
77 efl_ui_text_scrollable_set(en, EINA_TRUE);
78 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.5);
79
80 en = _create_label(win, bx);
81 efl_text_set(en, "Input multiline here.");
82 efl_text_font_set(en, "Sans", 14);
83 efl_text_interactive_editable_set(en, EINA_TRUE);
84 efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
85 efl_text_multiline_set(en, EINA_TRUE);
86 efl_ui_text_scrollable_set(en, EINA_TRUE);
87 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.5);
88
89 en = _create_label(win, bx);
90 efl_text_markup_set(en, "You can also <b>ENTER</b> markup!"); 68 efl_text_markup_set(en, "You can also <b>ENTER</b> markup!");
91 efl_text_font_set(en, "Sans", 14); 69 efl_text_font_set(en, "Sans", 14);
92 efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD); 70 efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
93 efl_text_multiline_set(en, EINA_TRUE); 71 efl_text_multiline_set(en, EINA_TRUE);
94 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.5);
95 72
96 en = _create_label(win, bx); 73 en = _create_label(win, bx);
97 markup = efl_text_markup_util_text_to_markup(EFL_TEXT_MARKUP_UTIL_CLASS, 74 markup = efl_text_markup_util_text_to_markup(EFL_TEXT_MARKUP_UTIL_CLASS,
@@ -101,7 +78,6 @@ test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
101 efl_text_font_set(en, "Sans", 14); 78 efl_text_font_set(en, "Sans", 14);
102 efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD); 79 efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
103 efl_text_multiline_set(en, EINA_TRUE); 80 efl_text_multiline_set(en, EINA_TRUE);
104 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.5);
105 81
106 en = _create_label(win, bx); 82 en = _create_label(win, bx);
107 markup = efl_text_markup_util_markup_to_text(EFL_TEXT_MARKUP_UTIL_CLASS, 83 markup = efl_text_markup_util_markup_to_text(EFL_TEXT_MARKUP_UTIL_CLASS,
@@ -111,14 +87,8 @@ test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
111 efl_text_font_set(en, "Sans", 14); 87 efl_text_font_set(en, "Sans", 14);
112 efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD); 88 efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
113 efl_text_multiline_set(en, EINA_TRUE); 89 efl_text_multiline_set(en, EINA_TRUE);
114 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.5);
115
116 evas_object_resize(win, 480, 480);
117 evas_object_show(win);
118} 90}
119 91
120// 2. Entry-equivalent setup
121
122typedef struct 92typedef struct
123{ 93{
124 const char *wrap_mode[4]; 94 const char *wrap_mode[4];
@@ -126,30 +96,23 @@ typedef struct
126} Test_Data; 96} Test_Data;
127 97
128static void 98static void
129my_efl_ui_text_bt_3(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 99_on_bt3_clicked(void *data, const Efl_Event *event EINA_UNUSED)
130{ 100{
131 Efl_Text_Cursor_Cursor *sel_start, *sel_end; 101 Efl_Text_Cursor_Cursor *sel_start, *sel_end;
102 Eo *en = data;
132 103
133 efl_text_interactive_selection_cursors_get(data, &sel_start, &sel_end); 104 efl_text_interactive_selection_cursors_get(data, &sel_start, &sel_end);
134 const char *s = efl_canvas_text_range_text_get(data, sel_start, sel_end); 105 const char *s = efl_canvas_text_range_text_get(data, sel_start, sel_end);
135 106
136 printf("SELECTION REGION: %d - %d\n", 107 printf("SELECTION REGION: %d - %d\n",
137 efl_text_cursor_position_get(obj, sel_start), 108 efl_text_cursor_position_get(en, sel_start),
138 efl_text_cursor_position_get(obj, sel_end)); 109 efl_text_cursor_position_get(en, sel_end));
139 printf("SELECTION:\n"); 110 printf("SELECTION:\n");
140 if (s) printf("%s\n", s); 111 if (s) printf("%s\n", s);
141} 112}
142 113
143static void 114static void
144my_efl_ui_text_bt_4(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 115_on_bt6_clicked(void *data, const Efl_Event *event EINA_UNUSED)
145{
146 Evas_Object *en = data;
147 efl_text_cursor_item_insert(en, efl_text_cursor_get(en, EFL_TEXT_CURSOR_GET_MAIN),
148 "emoticon/evil-laugh", "size=32x32");
149}
150
151static void
152my_efl_ui_text_bt_6(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
153{ 116{
154 Eo *text_obj = data; 117 Eo *text_obj = data;
155 118
@@ -175,164 +138,105 @@ my_efl_ui_text_bt_6(void *data, Evas_Object *obj EINA_UNUSED, void *event_info E
175 efl_text_wrap_set(text_obj, wrap); 138 efl_text_wrap_set(text_obj, wrap);
176} 139}
177 140
178static void
179my_efl_ui_text_bt_5(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
180{
181 Evas_Object *en = data;
182 efl_ui_text_scrollable_set(en, !efl_ui_text_scrollable_get(en));
183}
184
185void 141void
186test_efl_ui_text(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 142test_efl_ui_text(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
187{ 143{
188 Evas_Object *win, *bx, *bx2, *bx3, *bt, *en; 144 Eo *win, *bx, *bx2, *en;
189 Efl_Text_Cursor_Cursor *main_cur, *cur; 145 Eo *bt;
190 char buf[128];
191 146
192 win = elm_win_util_standard_add("entry", "Entry"); 147 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
193 elm_win_autodel_set(win, EINA_TRUE); 148 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
149 efl_text_set(efl_added, "Efl Ui Text"),
150 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
194 151
195 bx = elm_box_add(win); 152 bx = efl_add(EFL_UI_BOX_CLASS, win);
196 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 153 efl_gfx_size_hint_weight_set(bx, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND);
197 elm_win_resize_object_add(win, bx); 154 efl_content_set(win, bx);
198 evas_object_show(bx);
199 155
200 en = efl_add(EFL_UI_TEXT_CLASS, win, 156 en = efl_add(EFL_UI_TEXT_CLASS, bx,
201 efl_text_multiline_set(efl_added, EINA_TRUE)); 157 efl_text_multiline_set(efl_added, EINA_TRUE));
202 158
203 printf("Added Efl.Ui.Text object\n");
204 efl_key_data_set(en, "wrap_idx", 0);
205 efl_text_set(en, "Hello world! Goodbye world! This is a test text for the"
206 " new UI Text widget.\xE2\x80\xA9This is the next paragraph.\nThis"
207 " is the next line.\nThis is Yet another line! Line and paragraph"
208 " separators are actually different!");
209 efl_text_font_set(en, "Sans", 14);
210 efl_text_font_weight_set(en, EFL_TEXT_FONT_WEIGHT_BOLD);
211 efl_text_font_slant_set(en, EFL_TEXT_FONT_SLANT_ITALIC);
212 efl_text_font_width_set(en, EFL_TEXT_FONT_WIDTH_ULTRACONDENSED);
213 efl_text_normal_color_set(en, 255, 255, 255, 255);
214
215 main_cur = efl_text_cursor_get(en, EFL_TEXT_CURSOR_GET_MAIN);
216 cur = efl_text_cursor_new(en);
217
218 efl_text_cursor_position_set(en, cur, 2);
219 efl_text_cursor_item_insert(en, cur, "emoticon/happy", "size=32x32");
220 efl_text_cursor_position_set(en, cur, 50);
221 sprintf(buf, "file://%s/images/sky_01.jpg", elm_app_data_dir_get());
222 efl_text_cursor_item_insert(en, cur, buf, "size=32x32");
223
224 efl_text_cursor_position_set(en, main_cur, 5);
225 efl_text_cursor_position_set(en, cur, 20);
226
227 efl_text_annotation_insert(en, main_cur, cur, "a href=#hello");
228
229 efl_text_interactive_editable_set(en, EINA_TRUE); 159 efl_text_interactive_editable_set(en, EINA_TRUE);
230 efl_ui_text_scrollable_set(en, EINA_TRUE); 160 efl_ui_text_scrollable_set(en, EINA_TRUE);
231 elm_box_pack_end(bx, en);
232 elm_object_focus_set(en, EINA_TRUE);
233 161
234 bx2 = elm_box_add(win); 162 efl_text_font_set(en, "Sans", 12);
235 elm_box_horizontal_set(bx2, EINA_TRUE); 163 efl_text_font_width_set(en, EFL_TEXT_FONT_WIDTH_ULTRACONDENSED);
236 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0); 164 efl_text_normal_color_set(en, 255, 255, 255, 255);
237 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
238
239 bt = elm_button_add(win);
240 elm_object_text_set(bt, "Sel");
241 evas_object_smart_callback_add(bt, "clicked", my_efl_ui_text_bt_3, en);
242 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
243 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
244 elm_box_pack_end(bx2, bt);
245 elm_object_focus_allow_set(bt, EINA_FALSE);
246 evas_object_show(bt);
247
248 bt = elm_button_add(win);
249 elm_object_text_set(bt, "Ins");
250 evas_object_smart_callback_add(bt, "clicked", my_efl_ui_text_bt_4, en);
251 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
252 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
253 elm_box_pack_end(bx2, bt);
254 elm_object_focus_allow_set(bt, EINA_FALSE);
255 evas_object_show(bt);
256
257 bt = elm_button_add(win);
258 elm_object_text_set(bt, "Scrl");
259 evas_object_smart_callback_add(bt, "clicked", my_efl_ui_text_bt_5, en);
260 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
261 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
262 elm_box_pack_end(bx2, bt);
263 elm_object_focus_allow_set(bt, EINA_FALSE);
264 evas_object_show(bt);
265
266 bt = elm_button_add(win);
267 elm_object_text_set(bt, "Wr");
268 evas_object_smart_callback_add(bt, "clicked", my_efl_ui_text_bt_6, en);
269 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
270 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
271 elm_box_pack_end(bx2, bt);
272 elm_object_focus_allow_set(bt, EINA_FALSE);
273 evas_object_show(bt);
274 165
275 bx3 = elm_box_add(win); 166 efl_text_set(en,
276 elm_box_horizontal_set(bx3, EINA_TRUE); 167 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n"
277 evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0); 168 "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\n"
278 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL); 169 "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\n"
170 "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate\n"
171 "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint\n"
172 "occaecat cupidatat non proident, sunt in culpa qui officia deserunt\n"
173 "mollit anim id est laborum");
174
175 efl_gfx_size_hint_min_set(en, EINA_SIZE2D(300, 100));
176 efl_pack(bx, en);
177
178 bx2 = efl_add(EFL_UI_BOX_CLASS, bx);
179 efl_gfx_size_hint_weight_set(bx2, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND);
180 efl_ui_direction_set(bx2, EFL_UI_DIR_HORIZONTAL);
181
182 bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
183 efl_text_set(bt, "Sel");
184 efl_event_callback_add(bt, EFL_UI_EVENT_CLICKED, _on_bt3_clicked, en);
185 efl_gfx_size_hint_weight_set(bt, EFL_GFX_SIZE_HINT_EXPAND, 0.0);
186 efl_pack(bx2, bt);
187 elm_object_focus_allow_set(bt, EINA_FALSE);
279 188
280 elm_box_pack_end(bx, bx3); 189 bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
281 elm_box_pack_end(bx, bx2); 190 efl_text_set(bt, "Wr");
282 evas_object_show(bx3); 191 efl_event_callback_add(bt, EFL_UI_EVENT_CLICKED, _on_bt6_clicked, en);
283 evas_object_show(bx2); 192 efl_gfx_size_hint_weight_set(bt, EFL_GFX_SIZE_HINT_EXPAND, 0.0);
193 efl_pack(bx2, bt);
194 elm_object_focus_allow_set(bt, EINA_FALSE);
284 195
285 evas_object_resize(win, 480, 320); 196 efl_pack(bx, bx2);
286 evas_object_show(win);
287} 197}
288 198
289void 199void
290test_efl_ui_text_async(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 200test_efl_ui_text_inputfield(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
291{ 201{
292 Evas_Object *win, *bx, *bx2, *bx3, *en; 202 Eo *win, *bx, *en;
293 203
294 win = elm_win_util_standard_add("entry", "Entry"); 204 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
295 elm_win_autodel_set(win, EINA_TRUE); 205 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
206 efl_text_set(efl_added, "Efl Ui Text Input Field"),
207 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
296 208
297 bx = elm_box_add(win); 209 bx = efl_add(EFL_UI_BOX_CLASS, win);
298 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 210 efl_gfx_size_hint_weight_set(bx, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND);
299 elm_win_resize_object_add(win, bx); 211 efl_content_set(win, bx);
300 evas_object_show(bx);
301 212
302 en = efl_add(EFL_UI_TEXT_CLASS, win, 213 en = efl_add(EFL_UI_TEXT_CLASS, bx,
303 efl_text_wrap_set(efl_added, EFL_TEXT_FORMAT_WRAP_WORD), 214 efl_text_multiline_set(efl_added, EINA_FALSE));
304 efl_text_multiline_set(efl_added, EINA_TRUE) 215
305 ); 216 efl_text_interactive_editable_set(en, EINA_TRUE);
217 efl_ui_text_scrollable_set(en, EINA_TRUE);
306 218
307 printf("Added Efl.Ui.Text object\n"); 219 printf("Added Efl.Ui.Text object\n");
308 efl_key_data_set(en, "wrap_idx", 0); 220 efl_text_set(en, "Sample input text");
309 efl_text_set(en, "Hello world! Goodbye world! This is a test text for the" 221 efl_text_font_set(en, "Sans", 14);
310 " new UI Text widget.\xE2\x80\xA9This is the next paragraph.\nThis" 222 efl_text_font_width_set(en, EFL_TEXT_FONT_WIDTH_ULTRACONDENSED);
311 " is the next line.\nThis is Yet another line! Line and paragraph"
312 " separators are actually different!");
313 efl_text_font_set(en, "Sans", 10);
314 efl_text_normal_color_set(en, 255, 255, 255, 255); 223 efl_text_normal_color_set(en, 255, 255, 255, 255);
315 224
316 elm_box_pack_end(bx, en); 225 efl_pack(bx, en);
317 elm_object_focus_set(en, EINA_TRUE);
318 226
319 bx2 = elm_box_add(win); 227 en = _create_label(win, bx);
320 elm_box_horizontal_set(bx2, EINA_TRUE); 228 efl_text_set(en, "This is a multiline input.\n"
321 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0); 229 "Enter multiline here");
322 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL); 230 efl_text_font_set(en, "Sans", 14);
323 231 efl_text_interactive_editable_set(en, EINA_TRUE);
324 bx3 = elm_box_add(win); 232 efl_text_wrap_set(en, EFL_TEXT_FORMAT_WRAP_WORD);
325 elm_box_horizontal_set(bx3, EINA_TRUE); 233 efl_text_multiline_set(en, EINA_TRUE);
326 evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0); 234 efl_ui_text_scrollable_set(en, EINA_TRUE);
327 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL); 235 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.5);
236 efl_pack(bx, en);
328 237
329 elm_box_pack_end(bx, bx3); 238 efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 200));
330 elm_box_pack_end(bx, bx2);
331 evas_object_show(bx3);
332 evas_object_show(bx2);
333 239
334 evas_object_resize(win, 480, 320);
335 evas_object_show(win);
336} 240}
337 241
338#define IMAGES_SZ 5 242#define IMAGES_SZ 5
@@ -341,8 +245,7 @@ static const char *images[IMAGES_SZ] = {
341 "sky", "logo", "dog", "eet_rock", "eet_plant" }; 245 "sky", "logo", "dog", "eet_rock", "eet_plant" };
342 246
343static void 247static void
344my_efl_ui_text_item_factory_bt_image(void *data, Evas_Object *obj EINA_UNUSED, 248_on_factory_bt_image_clicked(void *data, const Efl_Event *event EINA_UNUSED)
345 void *event_info EINA_UNUSED)
346{ 249{
347 Evas_Object *en = data; 250 Evas_Object *en = data;
348 static int image_idx = 0; 251 static int image_idx = 0;
@@ -355,8 +258,7 @@ my_efl_ui_text_item_factory_bt_image(void *data, Evas_Object *obj EINA_UNUSED,
355} 258}
356 259
357static void 260static void
358my_efl_ui_text_item_factory_bt_emoticon(void *data, Evas_Object *obj EINA_UNUSED, 261_on_factory_bt_emoticon_clicked(void *data, const Efl_Event *event EINA_UNUSED)
359 void *event_info EINA_UNUSED)
360{ 262{
361 Evas_Object *en = data; 263 Evas_Object *en = data;
362 efl_text_cursor_item_insert(en, efl_text_cursor_get(en, EFL_TEXT_CURSOR_GET_MAIN), 264 efl_text_cursor_item_insert(en, efl_text_cursor_get(en, EFL_TEXT_CURSOR_GET_MAIN),
@@ -370,8 +272,7 @@ static struct
370} factories[3]; 272} factories[3];
371 273
372static void 274static void
373my_efl_ui_text_item_factory_bt_change(void *data, Evas_Object *obj EINA_UNUSED, 275_on_factory_bt_factory_clicked(void *data, const Efl_Event *event EINA_UNUSED)
374 void *event_info EINA_UNUSED)
375{ 276{
376 Evas_Object *en = data; 277 Evas_Object *en = data;
377 static int item_factory_idx = 0; 278 static int item_factory_idx = 0;
@@ -388,20 +289,20 @@ my_efl_ui_text_item_factory_bt_change(void *data, Evas_Object *obj EINA_UNUSED,
388void 289void
389test_ui_text_item_factory(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 290test_ui_text_item_factory(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
390{ 291{
391 Evas_Object *win, *bx, *bx2, *bx3, *bt, *en; 292 Evas_Object *win, *bx, *bx2, *bt, *en;
392 Efl_Text_Cursor_Cursor *main_cur, *cur; 293 Efl_Text_Cursor_Cursor *main_cur, *cur;
393 char buf[128]; 294 char buf[128];
394 Eina_File *f; 295 Eina_File *f;
395 296
396 win = elm_win_util_standard_add("entry", "Entry"); 297 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
397 elm_win_autodel_set(win, EINA_TRUE); 298 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
299 efl_text_set(efl_added, "Efl Ui Text Item Factory"),
300 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
398 301
399 bx = elm_box_add(win); 302 bx = efl_add(EFL_UI_BOX_CLASS, win);
400 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 303 efl_content_set(win, bx);
401 elm_win_resize_object_add(win, bx);
402 evas_object_show(bx);
403 304
404 en = efl_add(EFL_UI_TEXT_CLASS, win, 305 en = efl_add(EFL_UI_TEXT_CLASS, bx,
405 efl_text_multiline_set(efl_added, EINA_TRUE)); 306 efl_text_multiline_set(efl_added, EINA_TRUE));
406 307
407 factories[FACTORY_NONE].name = "None (Fallback)"; 308 factories[FACTORY_NONE].name = "None (Fallback)";
@@ -466,54 +367,34 @@ test_ui_text_item_factory(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
466 367
467 efl_text_interactive_editable_set(en, EINA_TRUE); 368 efl_text_interactive_editable_set(en, EINA_TRUE);
468 efl_ui_text_scrollable_set(en, EINA_TRUE); 369 efl_ui_text_scrollable_set(en, EINA_TRUE);
469 elm_box_pack_end(bx, en); 370 efl_pack(bx, en);
470 elm_object_focus_set(en, EINA_TRUE); 371 elm_object_focus_set(en, EINA_TRUE);
471 372
472 bx2 = elm_box_add(win); 373 bx2 = efl_add(EFL_UI_BOX_CLASS, bx);
473 elm_box_horizontal_set(bx2, EINA_TRUE); 374 efl_gfx_size_hint_weight_set(bx2, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND);
474 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0); 375 efl_ui_direction_set(bx2, EFL_UI_DIR_HORIZONTAL);
475 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL); 376
476 377 bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
477 bt = elm_button_add(win); 378 efl_text_set(bt, "Image");
478 elm_object_text_set(bt, "Image"); 379 efl_event_callback_add(bt, EFL_UI_EVENT_CLICKED, _on_factory_bt_image_clicked, en);
479 evas_object_smart_callback_add(bt, "clicked", 380 efl_gfx_size_hint_weight_set(bt, EFL_GFX_SIZE_HINT_EXPAND, 0.0);
480 my_efl_ui_text_item_factory_bt_image, en); 381 efl_pack(bx2, bt);
481 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
482 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
483 elm_box_pack_end(bx2, bt);
484 elm_object_focus_allow_set(bt, EINA_FALSE);
485 evas_object_show(bt);
486
487 bt = elm_button_add(win);
488 elm_object_text_set(bt, "Emoticon");
489 evas_object_smart_callback_add(bt, "clicked",
490 my_efl_ui_text_item_factory_bt_emoticon, en);
491 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
492 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
493 elm_box_pack_end(bx2, bt);
494 elm_object_focus_allow_set(bt, EINA_FALSE);
495 evas_object_show(bt);
496
497 bt = elm_button_add(win);
498 elm_object_text_set(bt, "Factory");
499 evas_object_smart_callback_add(bt, "clicked",
500 my_efl_ui_text_item_factory_bt_change, en);
501 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
502 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
503 elm_box_pack_end(bx2, bt);
504 elm_object_focus_allow_set(bt, EINA_FALSE); 382 elm_object_focus_allow_set(bt, EINA_FALSE);
505 evas_object_show(bt);
506 383
507 bx3 = elm_box_add(win); 384 bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
508 elm_box_horizontal_set(bx3, EINA_TRUE); 385 efl_text_set(bt, "Emoticon");
509 evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0); 386 efl_event_callback_add(bt, EFL_UI_EVENT_CLICKED, _on_factory_bt_emoticon_clicked, en);
510 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL); 387 efl_gfx_size_hint_weight_set(bt, EFL_GFX_SIZE_HINT_EXPAND, 0.0);
388 efl_pack(bx2, bt);
389 elm_object_focus_allow_set(bt, EINA_FALSE);
511 390
512 elm_box_pack_end(bx, bx3); 391 bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
513 elm_box_pack_end(bx, bx2); 392 efl_text_set(bt, "Factory");
514 evas_object_show(bx3); 393 efl_event_callback_add(bt, EFL_UI_EVENT_CLICKED, _on_factory_bt_factory_clicked, en);
515 evas_object_show(bx2); 394 efl_gfx_size_hint_weight_set(bt, EFL_GFX_SIZE_HINT_EXPAND, 0.0);
395 efl_pack(bx2, bt);
396 elm_object_focus_allow_set(bt, EINA_FALSE);
516 397
517 evas_object_resize(win, 480, 320); 398 efl_pack(bx, bx2);
518 evas_object_show(win); 399 efl_gfx_entity_size_set(win, EINA_SIZE2D(480, 320));
519} 400}
diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c
index 3a870475a7..70050f32ee 100644
--- a/src/lib/elementary/efl_ui_text.c
+++ b/src/lib/elementary/efl_ui_text.c
@@ -6,15 +6,12 @@
6#define EFL_ACCESS_TEXT_PROTECTED 6#define EFL_ACCESS_TEXT_PROTECTED
7#define EFL_ACCESS_EDITABLE_TEXT_PROTECTED 7#define EFL_ACCESS_EDITABLE_TEXT_PROTECTED
8#define ELM_LAYOUT_PROTECTED 8#define ELM_LAYOUT_PROTECTED
9#define EFL_UI_SCROLL_MANAGER_PROTECTED
9 10
10#include <Elementary.h> 11#include <Elementary.h>
11#include <Elementary_Cursor.h> 12#include <Elementary_Cursor.h>
12#include "elm_priv.h" 13#include "elm_priv.h"
13 14
14//#include "elm_entry_part.eo.h"
15//#include "elm_part_helper.h"
16//
17#include "elm_interface_scrollable.h"
18#include "elm_widget_layout.h" 15#include "elm_widget_layout.h"
19#include "elm_entry_common.h" 16#include "elm_entry_common.h"
20#include "elm_widget_entry.h" 17#include "elm_widget_entry.h"
@@ -24,7 +21,7 @@
24typedef struct _Efl_Ui_Text_Data Efl_Ui_Text_Data; 21typedef struct _Efl_Ui_Text_Data Efl_Ui_Text_Data;
25typedef struct _Efl_Ui_Text_Rectangle Efl_Ui_Text_Rectangle; 22typedef struct _Efl_Ui_Text_Rectangle Efl_Ui_Text_Rectangle;
26typedef struct _Anchor Anchor; 23typedef struct _Anchor Anchor;
27typedef struct _Item_Obj Item_Obj; 24typedef struct _Selection_Loss_Data Selection_Loss_Data;
28 25
29/** 26/**
30 * Base widget smart data extended with entry instance data. 27 * Base widget smart data extended with entry instance data.
@@ -38,6 +35,9 @@ struct _Efl_Ui_Text_Data
38 Evas_Object *mgf_clip; 35 Evas_Object *mgf_clip;
39 Evas_Object *mgf_proxy; 36 Evas_Object *mgf_proxy;
40 Eo *text_obj; 37 Eo *text_obj;
38 Eo *pan;
39 Eo *scroller;
40 Eo *manager;
41 Eo *cursor; 41 Eo *cursor;
42 Eo *cursor_bidi; 42 Eo *cursor_bidi;
43 Evas_Object *start_handler; 43 Evas_Object *start_handler;
@@ -59,10 +59,10 @@ struct _Efl_Ui_Text_Data
59 Evas_Coord downx, downy; 59 Evas_Coord downx, downy;
60 Evas_Coord ox, oy; 60 Evas_Coord ox, oy;
61 Eina_List *anchors; 61 Eina_List *anchors;
62 Eina_List *item_anchors; 62 int gen;
63 Eina_List *anchors2;
63 Eina_List *sel; 64 Eina_List *sel;
64 Eina_List *items; /** context menu item list */ 65 Eina_List *items; /** context menu item list */
65 Item_Obj *item_objs;
66 Efl_Canvas_Text_Factory *item_factory; 66 Efl_Canvas_Text_Factory *item_factory;
67 Efl_Canvas_Text_Factory *item_fallback_factory; 67 Efl_Canvas_Text_Factory *item_fallback_factory;
68 Eina_List *markup_filters; 68 Eina_List *markup_filters;
@@ -97,6 +97,11 @@ struct _Efl_Ui_Text_Data
97 Eina_Bool enabled; 97 Eina_Bool enabled;
98 } async; 98 } async;
99 99
100 struct {
101 Eina_Size2D scroll;
102 Eina_Size2D layout;
103 } last;
104 Eina_Future *sel_future;
100 Eina_Bool input_panel_return_key_disabled : 1; 105 Eina_Bool input_panel_return_key_disabled : 1;
101 Eina_Bool drag_selection_asked : 1; 106 Eina_Bool drag_selection_asked : 1;
102 Eina_Bool sel_handler_disabled : 1; 107 Eina_Bool sel_handler_disabled : 1;
@@ -109,7 +114,6 @@ struct _Efl_Ui_Text_Data
109 Eina_Bool selection_asked : 1; 114 Eina_Bool selection_asked : 1;
110 Eina_Bool auto_return_key : 1; 115 Eina_Bool auto_return_key : 1;
111 Eina_Bool have_selection : 1; 116 Eina_Bool have_selection : 1;
112 Eina_Bool deferred_cur : 1;
113 Eina_Bool deferred_decoration_selection : 1; 117 Eina_Bool deferred_decoration_selection : 1;
114 Eina_Bool deferred_decoration_cursor : 1; 118 Eina_Bool deferred_decoration_cursor : 1;
115 Eina_Bool deferred_decoration_anchor : 1; 119 Eina_Bool deferred_decoration_anchor : 1;
@@ -133,6 +137,10 @@ struct _Efl_Ui_Text_Data
133 Eina_Bool input_panel_show_on_demand : 1; 137 Eina_Bool input_panel_show_on_demand : 1;
134 Eina_Bool anchors_updated : 1; 138 Eina_Bool anchors_updated : 1;
135 Eina_Bool fallback_item_provider_disabled : 1; 139 Eina_Bool fallback_item_provider_disabled : 1;
140 Eina_Bool text_changed : 1;
141 Eina_Bool text_resized : 1;
142 Eina_Bool calc_force : 1;
143 Eina_Bool cursor_update : 1;
136}; 144};
137 145
138struct _Anchor 146struct _Anchor
@@ -140,16 +148,10 @@ struct _Anchor
140 Eo *obj; 148 Eo *obj;
141 char *name; 149 char *name;
142 Efl_Text_Annotate_Annotation *annotation; 150 Efl_Text_Annotate_Annotation *annotation;
143 Eina_List *sel; 151 Eina_List *rects;
152 int gen;
144 Eina_Bool item : 1; 153 Eina_Bool item : 1;
145}; 154 Eina_Bool updated : 1;
146
147struct _Item_Obj
148{
149 EINA_INLIST;
150 Anchor *an;
151 char *name;
152 Evas_Object *obj;
153}; 155};
154 156
155#define EFL_UI_TEXT_DATA_GET(o, sd) \ 157#define EFL_UI_TEXT_DATA_GET(o, sd) \
@@ -182,6 +184,12 @@ struct _Efl_Ui_Text_Rectangle
182 Evas_Object *obj_bg, *obj_fg, *obj; 184 Evas_Object *obj_bg, *obj_fg, *obj;
183}; 185};
184 186
187struct _Selection_Loss_Data
188{
189 Eo *obj;
190 Efl_Selection_Type stype;
191};
192
185#define MY_CLASS EFL_UI_TEXT_CLASS 193#define MY_CLASS EFL_UI_TEXT_CLASS
186#define MY_CLASS_PFX efl_ui_text 194#define MY_CLASS_PFX efl_ui_text
187#define MY_CLASS_NAME "Efl.Ui.Text" 195#define MY_CLASS_NAME "Efl.Ui.Text"
@@ -196,59 +204,8 @@ struct _Efl_Ui_Text_Rectangle
196#define EFL_UI_TEXT_CHUNK_SIZE 10000 204#define EFL_UI_TEXT_CHUNK_SIZE 10000
197#define EFL_UI_TEXT_DELAY_WRITE_TIME 2.0 205#define EFL_UI_TEXT_DELAY_WRITE_TIME 2.0
198 206
199#define ELM_PRIV_ENTRY_SIGNALS(cmd) \
200 cmd(SIG_ABORTED, "aborted", "") \
201 cmd(SIG_ACTIVATED, "activated", "") \
202 cmd(SIG_ANCHOR_CLICKED, "anchor,clicked", "") \
203 cmd(SIG_ANCHOR_DOWN, "anchor,down", "") \
204 cmd(SIG_ANCHOR_HOVER_OPENED, "anchor,hover,opened", "") \
205 cmd(SIG_ANCHOR_IN, "anchor,in", "") \
206 cmd(SIG_ANCHOR_OUT, "anchor,out", "") \
207 cmd(SIG_ANCHOR_UP, "anchor,up", "") \
208 cmd(SIG_CHANGED, "changed", "") \
209 cmd(SIG_CHANGED_USER, "changed,user", "") \
210 cmd(SIG_CLICKED, "clicked", "") \
211 cmd(SIG_CLICKED_DOUBLE, "clicked,double", "") \
212 cmd(SIG_CLICKED_TRIPLE, "clicked,triple", "") \
213 cmd(SIG_CURSOR_CHANGED, "cursor,changed", "") \
214 cmd(SIG_CURSOR_CHANGED_MANUAL, "cursor,changed,manual", "") \
215 cmd(SIG_FOCUSED, "focused", "") \
216 cmd(SIG_UNFOCUSED, "unfocused", "") \
217 cmd(SIG_LONGPRESSED, "longpressed", "") \
218 cmd(SIG_MAX_LENGTH, "maxlength,reached", "") \
219 cmd(SIG_PREEDIT_CHANGED, "preedit,changed", "") \
220 cmd(SIG_PRESS, "press", "") \
221 cmd(SIG_REDO_REQUEST, "redo,request", "") \
222 cmd(SIG_SELECTION_CHANGED, "selection,changed", "") \
223 cmd(SIG_SELECTION_CLEARED, "selection,cleared", "") \
224 cmd(SIG_SELECTION_COPY, "selection,copy", "") \
225 cmd(SIG_SELECTION_CUT, "selection,cut", "") \
226 cmd(SIG_SELECTION_PASTE, "selection,paste", "") \
227 cmd(SIG_SELECTION_START, "selection,start", "") \
228 cmd(SIG_TEXT_SET_DONE, "text,set,done", "") \
229 cmd(SIG_THEME_CHANGED, "theme,changed", "") \
230 cmd(SIG_UNDO_REQUEST, "undo,request", "") \
231 cmd(SIG_REJECTED, "rejected", "")
232
233ELM_PRIV_ENTRY_SIGNALS(ELM_PRIV_STATIC_VARIABLE_DECLARE);
234
235#define ENTRY_PASSWORD_MASK_CHARACTER 0x002A 207#define ENTRY_PASSWORD_MASK_CHARACTER 0x002A
236 208
237static const Evas_Smart_Cb_Description _smart_callbacks[] = {
238 ELM_PRIV_ENTRY_SIGNALS(ELM_PRIV_SMART_CALLBACKS_DESC)
239 {SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
240 {SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
241 {NULL, NULL}
242};
243#undef ELM_PRIV_ENTRY_SIGNALS
244
245/* static const Elm_Layout_Part_Alias_Description _content_aliases[] = */
246/* { */
247/* {"icon", "efl.icon"}, */
248/* {"end", "efl.end"}, */
249/* {NULL, NULL} */
250/* }; */
251
252static Eina_List *entries = NULL; 209static Eina_List *entries = NULL;
253 210
254struct _Mod_Api 211struct _Mod_Api
@@ -261,52 +218,31 @@ struct _Mod_Api
261static const char PART_NAME_SCROLLER[] = "scroller"; 218static const char PART_NAME_SCROLLER[] = "scroller";
262static const char PART_NAME_HANDLER_START[] = "handler/start"; 219static const char PART_NAME_HANDLER_START[] = "handler/start";
263static const char PART_NAME_HANDLER_END[] = "handler/end"; 220static const char PART_NAME_HANDLER_END[] = "handler/end";
264static const char PART_NAME_MAGNIFIER[] = "magnifier";
265static const char PART_NAME_CURSOR[] = "cursor"; 221static const char PART_NAME_CURSOR[] = "cursor";
266static const char PART_NAME_SELECTION[] = "selection"; 222static const char PART_NAME_SELECTION[] = "selection";
267static const char PART_NAME_ANCHOR[] = "anchor"; 223static const char PART_NAME_ANCHOR[] = "anchor";
268 224
269static void _create_selection_handlers(Evas_Object *obj, Efl_Ui_Text_Data *sd); 225static void _create_selection_handlers(Evas_Object *obj, Efl_Ui_Text_Data *sd);
270static void _magnifier_move(void *data);
271static void _update_decorations(Eo *obj); 226static void _update_decorations(Eo *obj);
272static void _create_text_cursors(Eo *obj, Efl_Ui_Text_Data *sd); 227static void _create_text_cursors(Eo *obj, Efl_Ui_Text_Data *sd);
273static void _efl_ui_text_changed_cb(void *data, const Efl_Event *event); 228static void _efl_ui_text_changed_cb(void *data, const Efl_Event *event);
274static void _efl_ui_text_changed_user_cb(void *data, const Efl_Event *event); 229static void _efl_ui_text_changed_user_cb(void *data, const Efl_Event *event);
275static void _efl_ui_text_selection_changed_cb(void *data, const Efl_Event *event); 230static void _efl_ui_text_selection_changed_cb(void *data, const Efl_Event *event);
276static void _efl_ui_text_cursor_changed_cb(void *data, const Efl_Event *event); 231static void _efl_ui_text_cursor_changed_cb(void *data, const Efl_Event *event);
232static void _text_size_changed_cb(void *data, const Efl_Event *event EINA_UNUSED);
233static void _scroller_size_changed_cb(void *data, const Efl_Event *event EINA_UNUSED);
234static void _text_position_changed_cb(void *data, const Efl_Event *event EINA_UNUSED);
277static void _efl_ui_text_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); 235static void _efl_ui_text_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
278static void _efl_ui_text_select_none(Eo *obj, Efl_Ui_Text_Data *sd); 236static void _efl_ui_text_select_none(Eo *obj, Efl_Ui_Text_Data *sd);
279static void _efl_ui_text_anchor_hover_end(Eo *obj, Efl_Ui_Text_Data *sd);
280static void _efl_ui_text_anchor_hover_parent_set(Eo *obj, Efl_Ui_Text_Data *sd, Evas_Object *parent);
281static const char* _efl_ui_text_selection_get(const Eo *obj, Efl_Ui_Text_Data *sd); 237static const char* _efl_ui_text_selection_get(const Eo *obj, Efl_Ui_Text_Data *sd);
282static void _edje_signal_emit(Efl_Ui_Text_Data *obj, const char *sig, const char *src); 238static void _edje_signal_emit(Efl_Ui_Text_Data *obj, const char *sig, const char *src);
283static void _decoration_defer_all(Eo *obj); 239static void _decoration_defer_all(Eo *obj);
284static inline Eo * _decoration_create(Eo *obj, Efl_Ui_Text_Data *sd, const char *source, Eina_Bool above); 240static inline Eo * _decoration_create(Eo *obj, Efl_Ui_Text_Data *sd, const char *source, Eina_Bool above);
285static void _decoration_defer(Eo *obj); 241static void _decoration_defer(Eo *obj);
286static void _anchors_clear_all(Evas_Object *o, Efl_Ui_Text_Data *sd);
287static void _unused_item_objs_free(Efl_Ui_Text_Data *sd);
288static void _clear_text_selection(Efl_Ui_Text_Data *sd); 242static void _clear_text_selection(Efl_Ui_Text_Data *sd);
289 243static void _anchors_free(Efl_Ui_Text_Data *sd);
290static Mod_Api * 244static void _selection_defer(Eo *obj, Efl_Ui_Text_Data *sd);
291_module_find(Evas_Object *obj EINA_UNUSED) 245static Eina_Position2D _decoration_calc_offset(Efl_Ui_Text_Data *sd);
292{
293 static Elm_Module *m = NULL;
294
295 if (m) goto ok; // already found - just use
296 if (!(m = _elm_module_find_as("entry/api"))) return NULL;
297 // get module api
298 m->api = malloc(sizeof(Mod_Api));
299 if (!m->api) return NULL;
300
301 ((Mod_Api *)(m->api))->obj_hook = // called on creation
302 _elm_module_symbol_get(m, "obj_hook");
303 ((Mod_Api *)(m->api))->obj_unhook = // called on deletion
304 _elm_module_symbol_get(m, "obj_unhook");
305 ((Mod_Api *)(m->api))->obj_longpress = // called on long press menu
306 _elm_module_symbol_get(m, "obj_longpress");
307ok: // ok - return api
308 return m->api;
309}
310 246
311static char * 247static char *
312_file_load(const char *file) 248_file_load(const char *file)
@@ -525,19 +461,21 @@ _hide_selection_handler(Evas_Object *obj)
525 } 461 }
526} 462}
527 463
528static Eina_Rectangle * 464static Eina_Rect
529_viewport_region_get(Evas_Object *obj) 465_viewport_region_get(Evas_Object *obj)
530{ 466{
531 EFL_UI_TEXT_DATA_GET(obj, sd); 467 EFL_UI_TEXT_DATA_GET(obj, sd);
532 Eina_Rectangle *rect = eina_rectangle_new(0, 0, 0, 0); 468 Eina_Rect rect;
533 Evas_Object *parent; 469 Evas_Object *parent;
534 470
535 if (!rect) return NULL;
536 if (sd->scroll) 471 if (sd->scroll)
537 elm_interface_scrollable_content_viewport_geometry_get 472 {
538 (obj, &rect->x, &rect->y, &rect->w, &rect->h); 473 rect = efl_ui_scrollable_viewport_geometry_get(sd->scroller);
474 }
539 else 475 else
540 evas_object_geometry_get(sd->entry_edje, &rect->x, &rect->y, &rect->w, &rect->h); 476 {
477 rect = efl_gfx_entity_geometry_get(sd->text_obj);
478 }
541 479
542 parent = elm_widget_parent_get(obj); 480 parent = elm_widget_parent_get(obj);
543 while (parent) 481 while (parent)
@@ -547,9 +485,9 @@ _viewport_region_get(Evas_Object *obj)
547 Eina_Rectangle r; 485 Eina_Rectangle r;
548 EINA_RECTANGLE_SET(&r, 0, 0, 0, 0); 486 EINA_RECTANGLE_SET(&r, 0, 0, 0, 0);
549 evas_object_geometry_get(parent, &r.x, &r.y, &r.w, &r.h); 487 evas_object_geometry_get(parent, &r.x, &r.y, &r.w, &r.h);
550 if (!eina_rectangle_intersection(rect, &r)) 488 if (!eina_rectangle_intersection(&rect.rect, &r))
551 { 489 {
552 rect->x = rect->y = rect->w = rect->h = 0; 490 rect = EINA_RECT_EMPTY();
553 break; 491 break;
554 } 492 }
555 } 493 }
@@ -566,7 +504,6 @@ _update_selection_handler(Eo *obj)
566 504
567 Evas_Coord sx, sy, sh; 505 Evas_Coord sx, sy, sh;
568 Evas_Coord ex, ey, eh; 506 Evas_Coord ex, ey, eh;
569 Evas_Coord ent_x, ent_y;
570 507
571 if (!sd->have_selection) 508 if (!sd->have_selection)
572 { 509 {
@@ -576,7 +513,8 @@ _update_selection_handler(Eo *obj)
576 513
577 if (!sd->sel_handler_disabled) 514 if (!sd->sel_handler_disabled)
578 { 515 {
579 Eina_Rectangle *rect; 516 Eina_Rect rect;
517 Eina_Position2D off;
580 Evas_Coord hx, hy; 518 Evas_Coord hx, hy;
581 Eina_Bool hidden = EINA_FALSE; 519 Eina_Bool hidden = EINA_FALSE;
582 Efl_Text_Cursor_Cursor *sel_start, *sel_end; 520 Efl_Text_Cursor_Cursor *sel_start, *sel_end;
@@ -586,20 +524,21 @@ _update_selection_handler(Eo *obj)
586 if (!sd->start_handler) 524 if (!sd->start_handler)
587 _create_selection_handlers(obj, sd); 525 _create_selection_handlers(obj, sd);
588 526
589 rect = _viewport_region_get(obj); 527 //evas_object_geometry_get(sd->entry_edje, &ent_x, &ent_y, NULL, NULL);
590
591 evas_object_geometry_get(sd->entry_edje, &ent_x, &ent_y, NULL, NULL);
592 528
593 efl_text_cursor_geometry_get(obj, sel_start, 529 efl_text_cursor_geometry_get(obj, sel_start,
594 EFL_TEXT_CURSOR_TYPE_BEFORE, 530 EFL_TEXT_CURSOR_TYPE_BEFORE,
595 &sx, &sy, NULL, &sh, 531 &sx, &sy, NULL, &sh,
596 NULL, NULL, NULL, NULL); 532 NULL, NULL, NULL, NULL);
597 hx = ent_x + sx; 533 off = _decoration_calc_offset(sd);
598 hy = ent_y + sy + sh; 534 hx = off.x + sx;
535 hy = off.y + sy + sh;
599 evas_object_move(sd->start_handler, hx, hy); 536 evas_object_move(sd->start_handler, hx, hy);
600 537
601 if (!eina_rectangle_xcoord_inside(rect, hx) || 538 rect = _viewport_region_get(obj);
602 !eina_rectangle_ycoord_inside(rect, hy)) 539
540 if (!eina_rectangle_xcoord_inside(&rect.rect, hx) ||
541 !eina_rectangle_ycoord_inside(&rect.rect, hy))
603 { 542 {
604 hidden = EINA_TRUE; 543 hidden = EINA_TRUE;
605 } 544 }
@@ -616,16 +555,17 @@ _update_selection_handler(Eo *obj)
616 sd->start_handler_shown = EINA_FALSE; 555 sd->start_handler_shown = EINA_FALSE;
617 } 556 }
618 557
558 hidden = EINA_FALSE;
619 efl_text_cursor_geometry_get(obj, sel_end, 559 efl_text_cursor_geometry_get(obj, sel_end,
620 EFL_TEXT_CURSOR_TYPE_BEFORE, 560 EFL_TEXT_CURSOR_TYPE_BEFORE,
621 &ex, &ey, NULL, &eh, 561 &ex, &ey, NULL, &eh,
622 NULL, NULL, NULL, NULL); 562 NULL, NULL, NULL, NULL);
623 hx = ent_x + ex; 563 hx = off.x + ex;
624 hy = ent_y + ey + eh; 564 hy = off.y + ey + eh;
625 evas_object_move(sd->end_handler, hx, hy); 565 evas_object_move(sd->end_handler, hx, hy);
626 566
627 if (!eina_rectangle_xcoord_inside(rect, hx) || 567 if (!eina_rectangle_xcoord_inside(&rect.rect, hx) ||
628 !eina_rectangle_ycoord_inside(rect, hy)) 568 !eina_rectangle_ycoord_inside(&rect.rect, hy))
629 { 569 {
630 hidden = EINA_TRUE; 570 hidden = EINA_TRUE;
631 } 571 }
@@ -641,7 +581,6 @@ _update_selection_handler(Eo *obj)
641 "efl,handler,hide", "efl"); 581 "efl,handler,hide", "efl");
642 sd->end_handler_shown = EINA_FALSE; 582 sd->end_handler_shown = EINA_FALSE;
643 } 583 }
644 eina_rectangle_free(rect);
645 } 584 }
646 else 585 else
647 { 586 {
@@ -666,61 +605,26 @@ _edje_entry_user_insert(Evas_Object *obj, const char *data)
666 if (!data) return; 605 if (!data) return;
667 EFL_UI_TEXT_DATA_GET(obj, sd); 606 EFL_UI_TEXT_DATA_GET(obj, sd);
668 607
669 sd->changed = EINA_TRUE;
670 edje_object_part_text_user_insert(sd->entry_edje, "efl.text", data); 608 edje_object_part_text_user_insert(sd->entry_edje, "efl.text", data);
671 elm_layout_sizing_eval(obj); 609 elm_layout_sizing_eval(obj);
672} 610}
673 611
674static Eina_Bool 612static void
675_selection_data_cb(void *data EINA_UNUSED, 613_selection_data_cb(void *data EINA_UNUSED, Eo *obj,
676 Evas_Object *obj, 614 Efl_Selection_Data *sel_data)
677 Elm_Selection_Data *sel_data)
678{ 615{
679 char *buf; 616 Efl_Text_Cursor_Cursor *cur, *start, *end;
680 617
681 if (!sel_data->data) return EINA_FALSE; 618 char *buf = eina_slice_strdup(sel_data->content);
682 EFL_UI_TEXT_DATA_GET(obj, sd);
683 619
684 buf = malloc(sel_data->len + 1); 620 efl_text_interactive_selection_cursors_get(obj, &start, &end);
685 if (!buf) 621 if (!efl_text_cursor_equal(obj, start, end))
686 {
687 ERR("Failed to allocate memory, obj: %p", obj);
688 return EINA_FALSE;
689 }
690 memcpy(buf, sel_data->data, sel_data->len);
691 buf[sel_data->len] = '\0';
692
693 if ((sel_data->format & ELM_SEL_FORMAT_IMAGE) &&
694 (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE))
695 {
696 char *entry_tag;
697 int len;
698 static const char *tag_string =
699 "<item absize=240x180 href=file://%s></item>";
700
701 len = strlen(tag_string) + strlen(buf);
702 entry_tag = alloca(len + 1);
703 snprintf(entry_tag, len + 1, tag_string, buf);
704 _edje_entry_user_insert(obj, entry_tag);
705 }
706 else if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
707 {
708 Efl_Text_Cursor_Cursor *cur, *start, *end;
709 efl_text_interactive_selection_cursors_get(obj, &start, &end);
710 if (!efl_text_cursor_equal(obj, start, end))
711 {
712 efl_canvas_text_range_delete(obj, start, end);
713 }
714 cur = efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN);
715 efl_text_cursor_text_insert(obj, cur, buf);
716 }
717 else
718 { 622 {
719 _edje_entry_user_insert(obj, buf); 623 efl_canvas_text_range_delete(obj, start, end);
720 } 624 }
625 cur = efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN);
626 efl_text_cursor_text_insert(obj, cur, buf);
721 free(buf); 627 free(buf);
722
723 return EINA_TRUE;
724} 628}
725 629
726static void 630static void
@@ -777,7 +681,7 @@ _dnd_drop_cb(void *data EINA_UNUSED,
777 681
778 if (!rv) WRN("Warning: Failed to position cursor: paste anyway"); 682 if (!rv) WRN("Warning: Failed to position cursor: paste anyway");
779 683
780 rv = _selection_data_cb(NULL, obj, drop); 684 //rv = _selection_data_cb(NULL, obj, drop);
781 685
782 return rv; 686 return rv;
783} 687}
@@ -788,8 +692,8 @@ _get_drop_format(Evas_Object *obj)
788 EFL_UI_TEXT_DATA_GET(obj, sd); 692 EFL_UI_TEXT_DATA_GET(obj, sd);
789 693
790 if ((sd->editable) && (!sd->single_line) && (!sd->password) && (!sd->disabled)) 694 if ((sd->editable) && (!sd->single_line) && (!sd->password) && (!sd->disabled))
791 return ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE; 695 return EFL_SELECTION_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE;
792 return ELM_SEL_FORMAT_MARKUP; 696 return EFL_SELECTION_FORMAT_MARKUP;
793} 697}
794 698
795/* we can't reuse layout's here, because it's on entry_edje only */ 699/* we can't reuse layout's here, because it's on entry_edje only */
@@ -809,7 +713,7 @@ _efl_ui_text_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Text_Data *sd, Ein
809 if (sd->scroll) 713 if (sd->scroll)
810 { 714 {
811 edje_object_signal_emit(sd->scr_edje, emission, "efl"); 715 edje_object_signal_emit(sd->scr_edje, emission, "efl");
812 elm_interface_scrollable_freeze_set(obj, disabled); 716 //elm_interface_scrollable_freeze_set(obj, disabled);
813 } 717 }
814 sd->disabled = disabled; 718 sd->disabled = disabled;
815 719
@@ -826,31 +730,6 @@ _efl_ui_text_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Text_Data *sd, Ein
826 return EINA_TRUE; 730 return EINA_TRUE;
827} 731}
828 732
829/* It gets the background object from from_edje object and
830 * sets the background object to to_edje object.
831 * The background object has to be moved to proper Edje object
832 * when scrollable status is changed. */
833static void
834_efl_ui_text_background_switch(Evas_Object *from_edje, Evas_Object *to_edje)
835{
836 Evas_Object *bg_obj;
837
838 if (!from_edje || !to_edje) return;
839
840 if (edje_object_part_exists(from_edje, "efl.background") &&
841 edje_object_part_exists(to_edje, "efl.background") &&
842 !edje_object_part_swallow_get(to_edje, "efl.background"))
843 {
844 bg_obj = edje_object_part_swallow_get(from_edje, "efl.background");
845
846 if (bg_obj)
847 {
848 edje_object_part_unswallow(from_edje, bg_obj);
849 edje_object_part_swallow(to_edje, "efl.background", bg_obj);
850 }
851 }
852}
853
854/* we can't issue the layout's theming code here, cause it assumes an 733/* we can't issue the layout's theming code here, cause it assumes an
855 * unique edje object, always */ 734 * unique edje object, always */
856EOLIAN static Efl_Ui_Theme_Apply 735EOLIAN static Efl_Ui_Theme_Apply
@@ -922,37 +801,12 @@ _efl_ui_text_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Text_Data *sd)
922 Evas_Object* clip = evas_object_clip_get(sd->entry_edje); 801 Evas_Object* clip = evas_object_clip_get(sd->entry_edje);
923 evas_object_clip_set(sd->hit_rect, clip); 802 evas_object_clip_set(sd->hit_rect, clip);
924 803
925 if (sd->scroll)
926 {
927 efl_ui_mirrored_set(obj, efl_ui_mirrored_get(obj));
928
929 if (sd->single_line)
930 elm_widget_element_update(obj, sd->scr_edje, PART_NAME_SCROLLER);
931
932 _efl_ui_text_background_switch(sd->entry_edje, sd->scr_edje);
933
934 str = edje_object_data_get(sd->scr_edje, "focus_highlight");
935 }
936 else
937 {
938 _efl_ui_text_background_switch(sd->scr_edje, sd->entry_edje);
939
940 str = edje_object_data_get(sd->entry_edje, "focus_highlight");
941 }
942
943 if ((str) && (!strcmp(str, "on")))
944 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
945 else
946 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
947
948 if (sd->start_handler) 804 if (sd->start_handler)
949 { 805 {
950 elm_widget_element_update(obj, sd->start_handler, PART_NAME_HANDLER_START); 806 elm_widget_element_update(obj, sd->start_handler, PART_NAME_HANDLER_START);
951 elm_widget_element_update(obj, sd->end_handler, PART_NAME_HANDLER_END); 807 elm_widget_element_update(obj, sd->end_handler, PART_NAME_HANDLER_END);
952 } 808 }
953 809
954 sd->changed = EINA_TRUE;
955
956 sd->has_text = !sd->has_text; 810 sd->has_text = !sd->has_text;
957 _efl_ui_text_guide_update(obj, !sd->has_text); 811 _efl_ui_text_guide_update(obj, !sd->has_text);
958 efl_event_thaw(obj); 812 efl_event_thaw(obj);
@@ -995,120 +849,70 @@ _cursor_geometry_recalc(Evas_Object *obj)
995 &x2, &y2, &w2, &h2); 849 &x2, &y2, &w2, &h2);
996 cx = cx + x - x2; 850 cx = cx + x - x2;
997 cy = cy + y - y2; 851 cy = cy + y - y2;
998 elm_widget_show_region_set(obj, EINA_RECT(cx, cy, cw, ch), EINA_FALSE); 852 efl_ui_scrollable_scroll(sd->scroller, EINA_RECT(cx, cy, cw, ch), EINA_FALSE);
853
999} 854}
1000 855
1001static void 856#define SIZE2D_EQ(X, Y) (((X).w == (Y).w) && ((X).h == (Y).h))
1002_layout_text_sizing_eval(Eo *obj, Evas_Coord tw, Evas_Coord th) 857
858EOLIAN static void
859_efl_ui_text_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Text_Data *sd)
1003{ 860{
1004 Eo *sw; 861 Eina_Size2D min = EINA_SIZE2D(0, 0);
1005 Evas_Coord minw, minh; 862 Eina_Size2D edmin = EINA_SIZE2D(0, 0);
863 Eina_Size2D sz = EINA_SIZE2D(0, 0);
864 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
1006 865
1007 efl_event_freeze(obj); 866 sz = efl_gfx_entity_size_get(obj);
867 if (!sd->calc_force && SIZE2D_EQ(sd->last.layout, sz) &&
868 !sd->text_changed)
869 {
870 return;
871 }
1008 872
1009 EFL_UI_TEXT_DATA_GET(obj, sd); 873 sd->single_line = !efl_text_multiline_get(sd->text_obj);
874
875 sd->calc_force = EINA_FALSE;
876 sd->last.layout.w = sz.w;
877 sd->last.layout.h = sz.h;
878 sd->text_changed = EINA_FALSE;
1010 879
1011 sw = edje_object_part_swallow_get(sd->entry_edje, "efl.text");
1012 if (sd->scroll) 880 if (sd->scroll)
1013 { 881 {
1014 Evas_Coord vw = 0, vh = 0; 882 if (sd->single_line)
1015 elm_interface_scrollable_content_viewport_geometry_get(obj, NULL, NULL, &vw, &vh);
1016 evas_object_size_hint_min_set(sw, tw, th);
1017 edje_object_size_min_calc(sd->entry_edje, &minw, &minh);
1018 evas_object_size_hint_min_set(sw, -1, -1);
1019
1020 if (vw > minw) minw = vw;
1021 efl_gfx_entity_size_set(sd->entry_edje, EINA_SIZE2D(minw, minh));
1022
1023 if (!efl_text_multiline_get(sw))
1024 { 883 {
1025 evas_object_size_hint_min_set(obj, -1, minh); 884 efl_ui_internal_text_scroller_mode_set(sd->scroller,
885 EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
1026 } 886 }
1027 } 887 else
1028 else
1029 {
1030 Eina_Bool wrap;
1031
1032 wrap = efl_text_wrap_get(sw);
1033 evas_object_size_hint_min_set(sw, tw, th);
1034 edje_object_size_min_calc(sd->entry_edje, &minw, &minh);
1035 evas_object_size_hint_min_set(sw, -1, -1);
1036 if (wrap == EFL_TEXT_FORMAT_WRAP_NONE)
1037 { 888 {
1038 _decoration_defer_all(obj); 889 efl_ui_internal_text_scroller_mode_set(sd->scroller,
1039 efl_event_thaw(obj); 890 EFL_UI_TEXT_SCROLLER_MODE_MULTILINE);
1040 evas_object_size_hint_min_set(obj, minw, minh);
1041 return;
1042 }
1043 }
1044 _decoration_defer_all(obj);
1045 efl_event_thaw(obj);
1046}
1047
1048typedef struct _Layout_Ctx Layout_Ctx;
1049struct _Layout_Ctx
1050{
1051 Eo *obj;
1052};
1053
1054static Eina_Value
1055_on_layout_complete(void *data, const Eina_Value v)
1056{
1057 Layout_Ctx *c = data;
1058 Eina_Rectangle r;
1059 if (eina_value_get(&v, &r))
1060 {
1061 _layout_text_sizing_eval(c->obj, r.w, r.h);
1062 }
1063 free(c);
1064 return v;
1065}
1066
1067EOLIAN static void
1068_efl_ui_text_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Text_Data *sd)
1069{
1070 Evas_Coord resw, resh;
1071 Eo *sw;
1072 Eina_Bool can_async;
1073 891
1074 evas_object_geometry_get(obj, NULL, NULL, &resw, &resh); 892 }
1075
1076 sw = edje_object_part_swallow_get(sd->entry_edje, "efl.text");
1077 if (!sw) return;
1078
1079 if (!sd->changed && (resw == sd->ent_w) && (resh == sd->ent_h)) return;
1080
1081 sd->changed = EINA_FALSE;
1082 sd->ent_w = resw;
1083 sd->ent_h = resh;
1084 893
1085 can_async = !sd->editable && sd->async.enabled; 894 elm_layout_sizing_eval(sd->scroller);
895 min = efl_gfx_size_hint_min_get(sd->scroller);
896 if (sd->single_line)
897 {
898 efl_ui_internal_text_scroller_mode_set(sd->scroller,
899 EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
900 edje_object_size_min_calc(wd->resize_obj, &edmin.w, &edmin.h);
901 min.w = edmin.w;
902 min.h = edmin.h;
903 efl_gfx_size_hint_restricted_min_set(obj, min);
904 }
1086 905
1087 efl_event_freeze(obj); 906 sd->cursor_update = EINA_TRUE;
1088 if (sd->scroll) 907 _decoration_defer_all(obj);
1089 {
1090 Evas_Coord vw = 0, vh = 0;
1091 elm_interface_scrollable_content_viewport_geometry_get(obj, NULL, NULL, &vw, &vh);
1092 efl_gfx_entity_size_set(sd->entry_edje, EINA_SIZE2D(vw, vh));
1093 }
1094 if (can_async)
1095 {
1096 Eina_Future *f;
1097 Layout_Ctx *c = calloc(1, sizeof(*c));
1098 c->obj = obj;
1099 efl_event_thaw(obj);
1100 f = efl_canvas_text_async_layout(sw);
1101 eina_future_then_easy(f, _on_layout_complete, NULL, NULL, NULL, c);
1102 } 908 }
1103 else 909 else
1104 { 910 {
1105 /* Don't defer - complete the sizing evaluation now */ 911 edje_object_size_min_calc(wd->resize_obj, &edmin.w, &edmin.h);
1106 Evas_Coord fw, fh; 912 efl_canvas_text_size_formatted_get(sd->text_obj, &min.w, &min.h);
1107 efl_canvas_text_size_formatted_get(obj, &fw, &fh); 913 min.w += edmin.w;
1108 efl_event_thaw(obj); 914 min.h += edmin.h;
1109 _layout_text_sizing_eval(obj, fw, fh); 915 efl_gfx_size_hint_restricted_min_set(obj, min);
1110 sd->deferred_decoration_cursor = EINA_TRUE;
1111 _decoration_defer(obj);
1112 } 916 }
1113} 917}
1114 918
@@ -1141,8 +945,7 @@ _efl_ui_text_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Text_Data *sd)
1141 945
1142 if (efl_ui_focus_object_focus_get(obj)) 946 if (efl_ui_focus_object_focus_get(obj))
1143 { 947 {
1144 Eo *sw = edje_object_part_swallow_get(sd->entry_edje, "efl.text"); 948 evas_object_focus_set(sd->text_obj, EINA_TRUE);
1145 evas_object_focus_set(sw, EINA_TRUE);
1146 949
1147 _edje_signal_emit(sd, "efl,action,focus", "efl"); 950 _edje_signal_emit(sd, "efl,action,focus", "efl");
1148 if (sd->scroll) 951 if (sd->scroll)
@@ -1216,34 +1019,6 @@ _efl_ui_text_efl_ui_widget_interest_region_get(const Eo *obj EINA_UNUSED, Efl_Ui
1216} 1019}
1217 1020
1218static void 1021static void
1219_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rect r)
1220{
1221 elm_interface_scrollable_content_region_show(obj, r.x, r.y, r.w, r.h);
1222}
1223
1224EOLIAN static Eina_Bool
1225_efl_ui_text_efl_ui_widget_widget_sub_object_del(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, Evas_Object *sobj)
1226{
1227 Eina_Bool ret = EINA_FALSE;
1228 /* unfortunately entry doesn't follow the signal pattern
1229 * elm,state,icon,{visible,hidden}, so we have to replicate this
1230 * smart function */
1231 if (sobj == elm_layout_content_get(obj, "efl.icon"))
1232 {
1233 elm_layout_signal_emit(obj, "efl,action,hide,icon", "efl");
1234 }
1235 else if (sobj == elm_layout_content_get(obj, "efl.end"))
1236 {
1237 elm_layout_signal_emit(obj, "efl,action,hide,end", "efl");
1238 }
1239
1240 ret = elm_widget_sub_object_del(efl_super(obj, MY_CLASS), sobj);
1241 if (!ret) return EINA_FALSE;
1242
1243 return EINA_TRUE;
1244}
1245
1246static void
1247_hoversel_position(Evas_Object *obj) 1022_hoversel_position(Evas_Object *obj)
1248{ 1023{
1249 Evas_Coord cx, cy, cw, ch, x, y, mw, mh, w, h; 1024 Evas_Coord cx, cy, cw, ch, x, y, mw, mh, w, h;
@@ -1404,21 +1179,11 @@ _efl_ui_text_entry_paste(Evas_Object *obj,
1404static void 1179static void
1405_paste_cb(Eo *obj) 1180_paste_cb(Eo *obj)
1406{ 1181{
1407 Elm_Sel_Format formats = ELM_SEL_FORMAT_MARKUP; 1182 Efl_Selection_Format formats = EFL_SELECTION_FORMAT_TEXT;
1408
1409 EFL_UI_TEXT_DATA_GET(obj, sd);
1410
1411 efl_event_callback_call(obj, EFL_UI_EVENT_SELECTION_PASTE, NULL);
1412
1413 sd->selection_asked = EINA_TRUE;
1414 1183
1415 if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT) 1184 efl_selection_get(obj, EFL_SELECTION_TYPE_CLIPBOARD, formats,
1416 formats = ELM_SEL_FORMAT_TEXT; 1185 NULL, _selection_data_cb, NULL, 1);
1417 else if (sd->cnp_mode != ELM_CNP_MODE_NO_IMAGE)
1418 formats |= ELM_SEL_FORMAT_IMAGE;
1419 1186
1420 elm_cnp_selection_get
1421 (obj, ELM_SEL_TYPE_CLIPBOARD, formats, _selection_data_cb, NULL);
1422} 1187}
1423 1188
1424static void 1189static void
@@ -1435,20 +1200,34 @@ _selection_clear(void *data, Elm_Sel_Type selection)
1435 EFL_UI_TEXT_DATA_GET(data, sd); 1200 EFL_UI_TEXT_DATA_GET(data, sd);
1436 1201
1437 if (!sd->have_selection) return; 1202 if (!sd->have_selection) return;
1438 if ((selection == ELM_SEL_TYPE_CLIPBOARD) || 1203 if ((selection == EFL_SELECTION_TYPE_CLIPBOARD) ||
1439 (selection == ELM_SEL_TYPE_PRIMARY)) 1204 (selection == EFL_SELECTION_TYPE_PRIMARY))
1440 { 1205 {
1441 _efl_ui_text_select_none(data, sd); 1206 _efl_ui_text_select_none(data, sd);
1442 } 1207 }
1208 _selection_defer(data, sd);
1209}
1210
1211static Eina_Value
1212_selection_lost_cb(void *data, const Eina_Value value)
1213{
1214 Selection_Loss_Data *sdata = data;
1215 _selection_clear(sdata->obj, sdata->stype);
1216 return value;
1443} 1217}
1444 1218
1445static void 1219static void
1446_selection_store(Elm_Sel_Type seltype, 1220_selection_store(Efl_Selection_Type seltype,
1447 Evas_Object *obj) 1221 Evas_Object *obj)
1448{ 1222{
1449 char *sel; 1223 char *sel;
1450 Efl_Text_Cursor_Cursor *start, *end; 1224 Efl_Text_Cursor_Cursor *start, *end;
1451 Elm_Sel_Format format = ELM_SEL_FORMAT_TEXT; 1225 Efl_Selection_Format selformat = EFL_SELECTION_FORMAT_TEXT;
1226 Eina_Slice slice;
1227 Selection_Loss_Data *ldata;
1228
1229 ldata = calloc(1, sizeof(Selection_Loss_Data));
1230 if (!ldata) return;
1452 1231
1453 EFL_UI_TEXT_DATA_GET(obj, sd); 1232 EFL_UI_TEXT_DATA_GET(obj, sd);
1454 1233
@@ -1457,10 +1236,19 @@ _selection_store(Elm_Sel_Type seltype,
1457 1236
1458 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */ 1237 if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
1459 1238
1460 elm_cnp_selection_set 1239 slice.len = strlen(sel);
1461 (obj, seltype, format, sel, strlen(sel)); 1240 slice.mem = sel;
1462 elm_cnp_selection_loss_callback_set(obj, seltype, _selection_clear, obj); 1241
1463 if (seltype == ELM_SEL_TYPE_CLIPBOARD) 1242
1243 if (sd->sel_future)
1244 {
1245 eina_future_cancel(sd->sel_future);
1246 }
1247 sd->sel_future = efl_selection_set(obj, seltype, selformat, slice, 1);
1248 ldata->obj = obj;
1249 eina_future_then_easy(sd->sel_future, _selection_lost_cb, NULL, NULL, EINA_VALUE_TYPE_UINT, ldata);
1250
1251 if (seltype == EFL_SELECTION_TYPE_CLIPBOARD)
1464 eina_stringshare_replace(&sd->cut_sel, sel); 1252 eina_stringshare_replace(&sd->cut_sel, sel);
1465 1253
1466 free(sel); 1254 free(sel);
@@ -1483,7 +1271,7 @@ _cut_cb(Eo *obj)
1483 if (!_elm_config->desktop_entry) 1271 if (!_elm_config->desktop_entry)
1484 elm_widget_scroll_hold_pop(obj); 1272 elm_widget_scroll_hold_pop(obj);
1485 1273
1486 _selection_store(ELM_SEL_TYPE_CLIPBOARD, obj); 1274 _selection_store(EFL_SELECTION_TYPE_CLIPBOARD, obj);
1487 efl_text_interactive_selection_cursors_get(obj, &start, &end); 1275 efl_text_interactive_selection_cursors_get(obj, &start, &end);
1488 efl_canvas_text_range_delete(obj, start, end); 1276 efl_canvas_text_range_delete(obj, start, end);
1489} 1277}
@@ -1510,7 +1298,7 @@ _copy_cb(Eo *obj)
1510 edje_object_signal_emit(sd->entry_edje, "efl,state,select,off", "efl"); 1298 edje_object_signal_emit(sd->entry_edje, "efl,state,select,off", "efl");
1511 elm_widget_scroll_hold_pop(obj); 1299 elm_widget_scroll_hold_pop(obj);
1512 } 1300 }
1513 _selection_store(ELM_SEL_TYPE_CLIPBOARD, obj); 1301 _selection_store(EFL_SELECTION_TYPE_CLIPBOARD, obj);
1514} 1302}
1515 1303
1516static void 1304static void
@@ -1666,175 +1454,14 @@ _menu_call(Evas_Object *obj)
1666 } 1454 }
1667} 1455}
1668 1456
1669static void
1670_magnifier_proxy_update(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1671{
1672 _magnifier_move(data);
1673}
1674
1675static void
1676_magnifier_create(void *data)
1677{
1678 EFL_UI_TEXT_DATA_GET(data, sd);
1679
1680 double scale = _elm_config->magnifier_scale;
1681 Evas *e;
1682 Evas_Coord w, h, mw, mh;
1683
1684 evas_object_del(sd->mgf_proxy);
1685 evas_object_del(sd->mgf_bg);
1686 evas_object_del(sd->mgf_clip);
1687
1688 e = evas_object_evas_get(data);
1689
1690 //Bg
1691 sd->mgf_bg = edje_object_add(e);
1692 elm_widget_element_update(data, sd->mgf_bg, PART_NAME_MAGNIFIER);
1693 evas_object_show(sd->mgf_bg);
1694
1695 //Proxy
1696 sd->mgf_proxy = evas_object_image_add(e);
1697 evas_object_event_callback_add(sd->mgf_proxy, EVAS_CALLBACK_RESIZE,
1698 _magnifier_proxy_update, data);
1699 evas_object_event_callback_add(sd->mgf_proxy, EVAS_CALLBACK_MOVE,
1700 _magnifier_proxy_update, data);
1701 edje_object_part_swallow(sd->mgf_bg, "efl.content", sd->mgf_proxy);
1702 evas_object_image_source_set(sd->mgf_proxy, data);
1703 evas_object_geometry_get(data, NULL, NULL, &w, &h);
1704
1705 //Clipper
1706 sd->mgf_clip = evas_object_rectangle_add(e);
1707 evas_object_color_set(sd->mgf_clip, 0, 0, 0, 0);
1708 evas_object_show(sd->mgf_clip);
1709 evas_object_clip_set(sd->mgf_proxy, sd->mgf_clip);
1710
1711 mw = (Evas_Coord)(scale * (float) w);
1712 mh = (Evas_Coord)(scale * (float) h);
1713 if ((mw <= 0) || (mh <= 0)) return;
1714
1715 evas_object_layer_set(sd->mgf_bg, EVAS_LAYER_MAX);
1716 evas_object_layer_set(sd->mgf_proxy, EVAS_LAYER_MAX);
1717}
1718
1719static void
1720_magnifier_move(void *data)
1721{
1722 EFL_UI_TEXT_DATA_GET(data, sd);
1723
1724 Evas_Coord x, y, w, h;
1725 Evas_Coord px, py, pw, ph;
1726 Evas_Coord cx, cy, ch;
1727 Evas_Coord ex, ey;
1728 Evas_Coord mx, my, mw, mh;
1729 Evas_Coord diffx = 0;
1730 Evas_Object *top;
1731 double fx, fy, fw, fh;
1732 double scale = _elm_config->magnifier_scale;
1733
1734 edje_object_part_text_cursor_geometry_get(sd->entry_edje, "efl.text",
1735 &cx, &cy, NULL, &ch);
1736 if (sd->scroll)
1737 {
1738 Evas_Coord ox, oy;
1739 evas_object_geometry_get(sd->scr_edje, &ex, &ey, NULL, NULL);
1740 elm_interface_scrollable_content_pos_get(data, &ox, &oy);
1741 ex -= ox;
1742 ey -= oy;
1743 }
1744 else
1745 {
1746 evas_object_geometry_get(data, &ex, &ey, NULL, NULL);
1747 }
1748 cx += ex;
1749 cy += ey;
1750
1751 //Move the Magnifier
1752 edje_object_parts_extends_calc(sd->mgf_bg, &x, &y, &w, &h);
1753 evas_object_move(sd->mgf_bg, cx - x - (w / 2), cy - y - h);
1754
1755 mx = cx - x - (w / 2);
1756 my = cy - y - h;
1757 mw = w;
1758 mh = h;
1759
1760 // keep magnifier inside window
1761 top = elm_widget_top_get(data);
1762 if (top && efl_isa(top, EFL_UI_WIN_CLASS))
1763 {
1764 Evas_Coord wh, ww;
1765 evas_object_geometry_get(top, NULL, NULL, &ww, &wh);
1766 if (mx < 0)
1767 {
1768 diffx = mx;
1769 mx = 0;
1770 }
1771 if (mx + mw > ww)
1772 {
1773 diffx = - (ww - (mx + mw));
1774 mx = ww - mw;
1775 }
1776 if (my < 0)
1777 my = 0;
1778 if (my + mh > wh)
1779 my = wh - mh;
1780 evas_object_move(sd->mgf_bg, mx, my);
1781 }
1782
1783 //Set the Proxy Render Area
1784 evas_object_geometry_get(data, &x, &y, &w, &h);
1785 evas_object_geometry_get(sd->mgf_proxy, &px, &py, &pw, &ph);
1786
1787 fx = -((cx - x) * scale) + (pw * 0.5) + diffx;
1788 fy = -((cy - y) * scale) + (ph * 0.5) - (ch * 0.5 * scale);
1789 fw = w * scale;
1790 fh = h * scale;
1791 evas_object_image_fill_set(sd->mgf_proxy, fx, fy, fw, fh);
1792
1793 //Update Clipper Area
1794 int tx = fx;
1795 int ty = fy;
1796 int tw = fw;
1797 int th = fh;
1798 if (tx > 0) px += tx;
1799 if (ty > 0) py += ty;
1800 if (-(tx - pw) > tw) pw -= (-((tx - pw) + tw));
1801 if (-(ty - ph) > th) ph -= (-((ty - ph) + th));
1802 evas_object_move(sd->mgf_clip, px, py);
1803 evas_object_resize(sd->mgf_clip, pw, ph);
1804}
1805
1806static void
1807_magnifier_hide(void *data)
1808{
1809 EFL_UI_TEXT_DATA_GET(data, sd);
1810 edje_object_signal_emit(sd->mgf_bg, "efl,action,hide,magnifier", "efl");
1811 elm_widget_scroll_freeze_pop(data);
1812 evas_object_hide(sd->mgf_clip);
1813}
1814
1815static void
1816_magnifier_show(void *data)
1817{
1818 EFL_UI_TEXT_DATA_GET(data, sd);
1819 edje_object_signal_emit(sd->mgf_bg, "efl,action,show,magnifier", "efl");
1820 elm_widget_scroll_freeze_push(data);
1821 evas_object_show(sd->mgf_clip);
1822}
1823
1824static Eina_Bool 1457static Eina_Bool
1825_long_press_cb(void *data) 1458_long_press_cb(void *data)
1826{ 1459{
1827 EFL_UI_TEXT_DATA_GET(data, sd); 1460 EFL_UI_TEXT_DATA_GET(data, sd);
1828 1461
1829 if (_elm_config->magnifier_enable)
1830 {
1831 _magnifier_create(data);
1832 _magnifier_show(data);
1833 _magnifier_move(data);
1834 }
1835 /* Context menu will not appear if context menu disabled is set 1462 /* Context menu will not appear if context menu disabled is set
1836 * as false on a long press callback */ 1463 * as false on a long press callback */
1837 else if (!_elm_config->context_menu_disabled && 1464 if (!_elm_config->context_menu_disabled &&
1838 (!_elm_config->desktop_entry)) 1465 (!_elm_config->desktop_entry))
1839 _menu_call(data); 1466 _menu_call(data);
1840 1467
@@ -1947,9 +1574,8 @@ _mouse_up_cb(void *data,
1947 /* Since context menu disabled flag was checked at long press start while mouse 1574 /* Since context menu disabled flag was checked at long press start while mouse
1948 * down, hence the same should be checked at mouse up from a long press 1575 * down, hence the same should be checked at mouse up from a long press
1949 * as well */ 1576 * as well */
1950 if ((sd->long_pressed) && (_elm_config->magnifier_enable)) 1577 if (sd->long_pressed)
1951 { 1578 {
1952 _magnifier_hide(data);
1953 if (!_elm_config->context_menu_disabled) 1579 if (!_elm_config->context_menu_disabled)
1954 { 1580 {
1955 _menu_call(data); 1581 _menu_call(data);
@@ -1991,7 +1617,7 @@ _mouse_move_cb(void *data,
1991 if (sd->disabled) return; 1617 if (sd->disabled) return;
1992 if (ev->buttons == 1) 1618 if (ev->buttons == 1)
1993 { 1619 {
1994 if ((sd->long_pressed) && (_elm_config->magnifier_enable)) 1620 if (sd->long_pressed)
1995 { 1621 {
1996 Evas_Coord x, y; 1622 Evas_Coord x, y;
1997 Eina_Bool rv; 1623 Eina_Bool rv;
@@ -2008,7 +1634,6 @@ _mouse_move_cb(void *data,
2008 else 1634 else
2009 WRN("Warning: Cannot move cursor"); 1635 WRN("Warning: Cannot move cursor");
2010 1636
2011 _magnifier_move(data);
2012 } 1637 }
2013 } 1638 }
2014 if (!sd->sel_mode) 1639 if (!sd->sel_mode)
@@ -2050,440 +1675,6 @@ _mouse_move_cb(void *data,
2050 } 1675 }
2051} 1676}
2052 1677
2053static void
2054_entry_changed_handle(void *data,
2055 const Efl_Event_Description* event,
2056 Efl_Ui_Text_Change_Info *info)
2057{
2058 Evas_Coord minh;
2059 const char *text;
2060 Eina_Bool single_line;
2061 Eo *obj = data;
2062
2063 EFL_UI_TEXT_DATA_GET(data, sd);
2064
2065 single_line = !efl_text_multiline_get(obj);
2066
2067 efl_event_freeze(obj);
2068 sd->changed = EINA_TRUE;
2069 /* Reset the size hints which are no more relevant. Keep the
2070 * height, this is a hack, but doesn't really matter cause we'll
2071 * re-eval in a moment. */
2072 evas_object_size_hint_min_get(data, NULL, &minh);
2073 evas_object_size_hint_min_set(data, -1, minh);
2074
2075 if (sd->single_line != single_line)
2076 {
2077 sd->single_line = single_line;
2078 efl_ui_widget_theme_apply(data);
2079 }
2080
2081 elm_layout_sizing_eval(data);
2082 ELM_SAFE_FREE(sd->text, eina_stringshare_del);
2083 ELM_SAFE_FREE(sd->delay_write, ecore_timer_del);
2084 efl_event_thaw(obj);
2085 if ((sd->auto_save) && (sd->file))
2086 sd->delay_write = ecore_timer_add(EFL_UI_TEXT_DELAY_WRITE_TIME,
2087 _delay_write, data);
2088
2089 _return_key_enabled_check(data);
2090 text = efl_text_get(data);
2091 if (text)
2092 {
2093 if (text[0])
2094 _efl_ui_text_guide_update(data, EINA_TRUE);
2095 else
2096 _efl_ui_text_guide_update(data, EINA_FALSE);
2097 }
2098 _validate(data);
2099
2100 /* callback - this could call callbacks that delete the
2101 * entry... thus... any access to sd after this could be
2102 * invalid */
2103 efl_event_callback_call(data, event, info);
2104}
2105
2106static void
2107_entry_changed_user_signal_cb(void *data,
2108 Evas_Object *obj EINA_UNUSED,
2109 const char *emission EINA_UNUSED,
2110 const char *source EINA_UNUSED)
2111{
2112 Elm_Entry_Change_Info info;
2113 Edje_Entry_Change_Info *edje_info = (Edje_Entry_Change_Info *)
2114 edje_object_signal_callback_extra_data_get();
2115
2116 if (edje_info)
2117 {
2118 memcpy(&info, edje_info, sizeof(info));
2119 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_CHANGED_USER, &info);
2120 }
2121 else
2122 {
2123 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_CHANGED_USER, NULL);
2124 }
2125 if (_elm_config->atspi_mode)
2126 {
2127 Efl_Access_Text_Change_Info atspi_info;
2128 if (edje_info && edje_info->insert)
2129 {
2130 atspi_info.content = edje_info->change.insert.content;
2131 atspi_info.pos = edje_info->change.insert.pos;
2132 atspi_info.len = edje_info->change.insert.plain_length;
2133 efl_access_object_event_emit(EFL_ACCESS_OBJECT_MIXIN, data, EFL_ACCESS_TEXT_EVENT_ACCESS_TEXT_INSERTED, &atspi_info);
2134 }
2135 else if (edje_info && !edje_info->insert)
2136 {
2137 atspi_info.content = edje_info->change.del.content;
2138 atspi_info.pos = MIN(edje_info->change.del.start, edje_info->change.del.end);
2139 atspi_info.len = MAX(edje_info->change.del.start, edje_info->change.del.end) - atspi_info.pos;
2140 efl_access_object_event_emit(EFL_ACCESS_OBJECT_MIXIN, data, EFL_ACCESS_TEXT_EVENT_ACCESS_TEXT_REMOVED, &atspi_info);
2141 }
2142 }
2143}
2144
2145static void
2146_entry_preedit_changed_signal_cb(void *data,
2147 Evas_Object *obj EINA_UNUSED,
2148 const char *emission EINA_UNUSED,
2149 const char *source EINA_UNUSED)
2150{
2151 _entry_changed_handle(data, EFL_UI_TEXT_EVENT_PREEDIT_CHANGED, NULL);
2152}
2153
2154static void
2155_entry_undo_request_signal_cb(void *data,
2156 Evas_Object *obj EINA_UNUSED,
2157 const char *emission EINA_UNUSED,
2158 const char *source EINA_UNUSED)
2159{
2160 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_UNDO_REQUEST, NULL);
2161}
2162
2163static void
2164_entry_redo_request_signal_cb(void *data,
2165 Evas_Object *obj EINA_UNUSED,
2166 const char *emission EINA_UNUSED,
2167 const char *source EINA_UNUSED)
2168{
2169 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_REDO_REQUEST, NULL);
2170}
2171
2172static void
2173_entry_cursor_changed_signal_cb(void *data,
2174 Evas_Object *obj EINA_UNUSED,
2175 const char *emission EINA_UNUSED,
2176 const char *source EINA_UNUSED)
2177{
2178 EFL_UI_TEXT_DATA_GET(data, sd);
2179 sd->cursor_pos = edje_object_part_text_cursor_pos_get
2180 (sd->entry_edje, "efl.text", EDJE_CURSOR_MAIN);
2181 sd->cur_changed = EINA_TRUE;
2182 if (efl_ui_focus_object_focus_get(data))
2183 {
2184 edje_object_signal_emit(sd->entry_edje, "efl,action,show,cursor", "efl");
2185 }
2186 else
2187 {
2188 edje_object_signal_emit(sd->entry_edje, "efl,action,hide,cursor", "efl");
2189 }
2190
2191 sd->deferred_decoration_cursor = EINA_TRUE;
2192 _decoration_defer(obj);
2193
2194 if (_elm_config->atspi_mode)
2195 efl_access_object_event_emit(EFL_ACCESS_OBJECT_MIXIN, data, EFL_ACCESS_TEXT_EVENT_ACCESS_TEXT_CARET_MOVED, NULL);
2196}
2197
2198static void
2199_entry_cursor_changed_manual_signal_cb(void *data,
2200 Evas_Object *obj EINA_UNUSED,
2201 const char *emission EINA_UNUSED,
2202 const char *source EINA_UNUSED)
2203{
2204 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_CURSOR_CHANGED_MANUAL, NULL);
2205 if (_elm_config->atspi_mode)
2206 efl_access_object_event_emit(EFL_ACCESS_OBJECT_MIXIN, data, EFL_ACCESS_TEXT_EVENT_ACCESS_TEXT_CARET_MOVED, NULL);
2207}
2208
2209static void
2210_signal_anchor_geoms_do_things_with_lol(Efl_Ui_Text_Data *sd,
2211 Elm_Entry_Anchor_Info *ei)
2212{
2213 Evas_Textblock_Rectangle *r;
2214 const Eina_List *geoms, *l;
2215 Evas_Coord px, py, x, y;
2216
2217 geoms = edje_object_part_text_anchor_geometry_get
2218 (sd->entry_edje, "efl.text", ei->name);
2219
2220 if (!geoms) return;
2221
2222 evas_object_geometry_get(
2223 edje_object_part_object_get(sd->entry_edje, "efl.text"),
2224 &x, &y, NULL, NULL);
2225 evas_pointer_canvas_xy_get
2226 (evas_object_evas_get(sd->entry_edje), &px, &py);
2227
2228 EINA_LIST_FOREACH(geoms, l, r)
2229 {
2230 if (((r->x + x) <= px) && ((r->y + y) <= py) &&
2231 ((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
2232 {
2233 ei->x = r->x + x;
2234 ei->y = r->y + y;
2235 ei->w = r->w;
2236 ei->h = r->h;
2237 break;
2238 }
2239 }
2240}
2241
2242static void
2243_entry_anchor_down_signal_cb(void *data,
2244 Evas_Object *obj EINA_UNUSED,
2245 const char *emission EINA_UNUSED,
2246 const char *source EINA_UNUSED)
2247{
2248 Elm_Entry_Anchor_Info ei;
2249 const char *p;
2250 char *p2;
2251
2252 EFL_UI_TEXT_DATA_GET(data, sd);
2253
2254 p = emission + sizeof("nchor,mouse,down,");
2255 ei.button = strtol(p, &p2, 10);
2256 ei.name = p2 + 1;
2257 ei.x = ei.y = ei.w = ei.h = 0;
2258
2259 _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2260
2261 if (!sd->disabled)
2262 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_ANCHOR_DOWN, &ei);
2263}
2264
2265static void
2266_entry_anchor_up_signal_cb(void *data,
2267 Evas_Object *obj EINA_UNUSED,
2268 const char *emission EINA_UNUSED,
2269 const char *source EINA_UNUSED)
2270{
2271 Elm_Entry_Anchor_Info ei;
2272 const char *p;
2273 char *p2;
2274
2275 EFL_UI_TEXT_DATA_GET(data, sd);
2276
2277 p = emission + sizeof("nchor,mouse,up,");
2278 ei.button = strtol(p, &p2, 10);
2279 ei.name = p2 + 1;
2280 ei.x = ei.y = ei.w = ei.h = 0;
2281
2282 _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2283
2284 if (!sd->disabled)
2285 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_ANCHOR_UP, &ei);
2286}
2287
2288static void
2289_anchor_hover_del_cb(void *data,
2290 Evas *e EINA_UNUSED,
2291 Evas_Object *obj EINA_UNUSED,
2292 void *event_info EINA_UNUSED)
2293{
2294 EFL_UI_TEXT_DATA_GET(data, sd);
2295
2296 ELM_SAFE_FREE(sd->anchor_hover.pop, evas_object_del);
2297 evas_object_event_callback_del_full
2298 (sd->anchor_hover.hover, EVAS_CALLBACK_DEL, _anchor_hover_del_cb, obj);
2299}
2300
2301static void
2302_anchor_hover_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED)
2303{
2304 EFL_UI_TEXT_DATA_GET(data, sd);
2305 _efl_ui_text_anchor_hover_end(data, sd);
2306}
2307
2308static void
2309_entry_hover_anchor_clicked_do(Evas_Object *obj,
2310 Elm_Entry_Anchor_Info *info)
2311{
2312 Evas_Object *hover_parent;
2313 Evas_Coord x, w, y, h, px, py;
2314 Elm_Entry_Anchor_Hover_Info ei;
2315
2316 EFL_UI_TEXT_DATA_GET(obj, sd);
2317
2318 if (sd->hoversel) return;
2319
2320 ei.anchor_info = info;
2321
2322 sd->anchor_hover.pop = elm_icon_add(obj);
2323 evas_object_move(sd->anchor_hover.pop, info->x, info->y);
2324 evas_object_resize(sd->anchor_hover.pop, info->w, info->h);
2325
2326 sd->anchor_hover.hover = elm_hover_add(obj);
2327 evas_object_event_callback_add
2328 (sd->anchor_hover.hover, EVAS_CALLBACK_DEL, _anchor_hover_del_cb, obj);
2329 efl_ui_mirrored_set
2330 (sd->anchor_hover.hover, efl_ui_mirrored_get(obj));
2331 if (sd->anchor_hover.hover_style)
2332 elm_object_style_set
2333 (sd->anchor_hover.hover, sd->anchor_hover.hover_style);
2334
2335 hover_parent = sd->anchor_hover.hover_parent;
2336 if (!hover_parent) hover_parent = obj;
2337 elm_hover_parent_set(sd->anchor_hover.hover, hover_parent);
2338 elm_hover_target_set(sd->anchor_hover.hover, sd->anchor_hover.pop);
2339 ei.hover = sd->anchor_hover.hover;
2340
2341 evas_object_geometry_get(hover_parent, &x, &y, &w, &h);
2342 ei.hover_parent.x = x;
2343 ei.hover_parent.y = y;
2344 ei.hover_parent.w = w;
2345 ei.hover_parent.h = h;
2346 px = info->x + (info->w / 2);
2347 py = info->y + (info->h / 2);
2348 ei.hover_left = 1;
2349 if (px < (x + (w / 3))) ei.hover_left = 0;
2350 ei.hover_right = 1;
2351 if (px > (x + ((w * 2) / 3))) ei.hover_right = 0;
2352 ei.hover_top = 1;
2353 if (py < (y + (h / 3))) ei.hover_top = 0;
2354 ei.hover_bottom = 1;
2355 if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0;
2356
2357 /* Swap right and left because they switch sides in RTL */
2358 if (efl_ui_mirrored_get(sd->anchor_hover.hover))
2359 {
2360 Eina_Bool tmp = ei.hover_left;
2361
2362 ei.hover_left = ei.hover_right;
2363 ei.hover_right = tmp;
2364 }
2365
2366 efl_event_callback_call(obj, EFL_UI_TEXT_EVENT_ANCHOR_HOVER_OPENED, &ei);
2367 efl_event_callback_add
2368 (sd->anchor_hover.hover, EFL_UI_EVENT_CLICKED, _anchor_hover_clicked_cb, obj);
2369
2370 /* FIXME: Should just check if there's any callback registered to
2371 * the smart events instead. This is used to determine if anyone
2372 * cares about the hover or not. */
2373 if (!elm_layout_content_get(sd->anchor_hover.hover, "middle") &&
2374 !elm_layout_content_get(sd->anchor_hover.hover, "left") &&
2375 !elm_layout_content_get(sd->anchor_hover.hover, "right") &&
2376 !elm_layout_content_get(sd->anchor_hover.hover, "top") &&
2377 !elm_layout_content_get(sd->anchor_hover.hover, "bottom"))
2378 {
2379 ELM_SAFE_FREE(sd->anchor_hover.hover, evas_object_del);
2380 }
2381 else
2382 evas_object_show(sd->anchor_hover.hover);
2383}
2384
2385static void
2386_entry_anchor_move_signal_cb(void *data EINA_UNUSED,
2387 Evas_Object *obj EINA_UNUSED,
2388 const char *emission EINA_UNUSED,
2389 const char *source EINA_UNUSED)
2390{
2391}
2392
2393static void
2394_entry_anchor_in_signal_cb(void *data,
2395 Evas_Object *obj EINA_UNUSED,
2396 const char *emission EINA_UNUSED,
2397 const char *source EINA_UNUSED)
2398{
2399 Elm_Entry_Anchor_Info ei;
2400
2401 EFL_UI_TEXT_DATA_GET(data, sd);
2402
2403 ei.name = emission + sizeof("nchor,mouse,in,");
2404 ei.button = 0;
2405 ei.x = ei.y = ei.w = ei.h = 0;
2406
2407 _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2408
2409 if (!sd->disabled)
2410 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_ANCHOR_IN, &ei);
2411}
2412
2413static void
2414_entry_anchor_out_signal_cb(void *data,
2415 Evas_Object *obj EINA_UNUSED,
2416 const char *emission EINA_UNUSED,
2417 const char *source EINA_UNUSED)
2418{
2419 Elm_Entry_Anchor_Info ei;
2420
2421 EFL_UI_TEXT_DATA_GET(data, sd);
2422
2423 ei.name = emission + sizeof("nchor,mouse,out,");
2424 ei.button = 0;
2425 ei.x = ei.y = ei.w = ei.h = 0;
2426
2427 _signal_anchor_geoms_do_things_with_lol(sd, &ei);
2428
2429 if (!sd->disabled)
2430 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_ANCHOR_OUT, &ei);
2431}
2432
2433static void
2434_entry_key_enter_signal_cb(void *data,
2435 Evas_Object *obj EINA_UNUSED,
2436 const char *emission EINA_UNUSED,
2437 const char *source EINA_UNUSED)
2438{
2439 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_ACTIVATED, NULL);
2440}
2441
2442static void
2443_entry_key_escape_signal_cb(void *data,
2444 Evas_Object *obj EINA_UNUSED,
2445 const char *emission EINA_UNUSED,
2446 const char *source EINA_UNUSED)
2447{
2448 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_ABORTED, NULL);
2449}
2450
2451static void
2452_entry_mouse_down_signal_cb(void *data,
2453 Evas_Object *obj EINA_UNUSED,
2454 const char *emission EINA_UNUSED,
2455 const char *source EINA_UNUSED)
2456{
2457 efl_event_callback_call(data, EFL_UI_TEXT_EVENT_PRESS, NULL);
2458}
2459
2460static void
2461_entry_mouse_clicked_signal_cb(void *data,
2462 Evas_Object *obj EINA_UNUSED,
2463 const char *emission EINA_UNUSED,
2464 const char *source EINA_UNUSED)
2465{
2466 efl_event_callback_call(data, EFL_UI_EVENT_CLICKED, NULL);
2467}
2468
2469static void
2470_entry_mouse_double_signal_cb(void *data,
2471 Evas_Object *obj EINA_UNUSED,
2472 const char *emission EINA_UNUSED,
2473 const char *source EINA_UNUSED)
2474{
2475 efl_event_callback_call(data, EFL_UI_EVENT_CLICKED_DOUBLE, NULL);
2476}
2477
2478static void
2479_entry_mouse_triple_signal_cb(void *data,
2480 Evas_Object *obj EINA_UNUSED,
2481 const char *emission EINA_UNUSED,
2482 const char *source EINA_UNUSED)
2483{
2484 efl_event_callback_call(data, EFL_UI_EVENT_CLICKED_TRIPLE, NULL);
2485}
2486
2487static Evas_Object * 1678static Evas_Object *
2488_item_get(void *data, const char *item) 1679_item_get(void *data, const char *item)
2489{ 1680{
@@ -2506,25 +1697,6 @@ _item_get(void *data, const char *item)
2506 return o; 1697 return o;
2507} 1698}
2508 1699
2509static void
2510_markup_filter_cb(void *data,
2511 Evas_Object *edje EINA_UNUSED,
2512 const char *part EINA_UNUSED,
2513 char **text)
2514{
2515 Eina_List *l;
2516 Elm_Entry_Markup_Filter *tf;
2517
2518 EFL_UI_TEXT_DATA_GET(data, sd);
2519
2520 EINA_LIST_FOREACH(sd->markup_filters, l, tf)
2521 {
2522 tf->func(tf->data, data, text);
2523 if (!*text)
2524 break;
2525 }
2526}
2527
2528EOLIAN static void 1700EOLIAN static void
2529_efl_ui_text_efl_layout_signal_signal_emit(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, const char *emission, const char *source) 1701_efl_ui_text_efl_layout_signal_signal_emit(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, const char *emission, const char *source)
2530{ 1702{
@@ -2565,145 +1737,16 @@ _efl_ui_text_efl_layout_signal_signal_callback_del(Eo *obj EINA_UNUSED, Efl_Ui_T
2565 return ok; 1737 return ok;
2566} 1738}
2567 1739
2568#if 0
2569static Eina_Bool
2570_efl_ui_text_content_set(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, const char *part, Evas_Object *content)
2571{
2572 Eina_Bool int_ret = EINA_FALSE;
2573 int_ret = efl_content_set(efl_part(efl_super(obj, MY_CLASS), part), content);
2574 if (!int_ret) return EINA_FALSE;
2575
2576 /* too bad entry does not follow the pattern
2577 * "efl,state,{icon,end},visible", we have to repeat ourselves */
2578 if (!part || !strcmp(part, "icon") || !strcmp(part, "efl.icon"))
2579 efl_ui_text_icon_visible_set(obj, EINA_TRUE);
2580
2581 if (!part || !strcmp(part, "end") || !strcmp(part, "efl.end"))
2582 efl_ui_text_end_visible_set(obj, EINA_TRUE);
2583
2584 return EINA_TRUE;
2585}
2586
2587
2588static Evas_Object*
2589_efl_ui_text_content_unset(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, const char *part)
2590{
2591 Evas_Object *ret = NULL;
2592 ret = efl_content_unset(efl_part(efl_super(obj, MY_CLASS), part));
2593 if (!ret) return NULL;
2594
2595 /* too bad entry does not follow the pattern
2596 * "efl,state,{icon,end},hidden", we have to repeat ourselves */
2597 if (!part || !strcmp(part, "icon") || !strcmp(part, "efl.icon"))
2598 efl_ui_text_icon_visible_set(obj, EINA_FALSE);
2599
2600 if (!part || !strcmp(part, "end") || !strcmp(part, "efl.end"))
2601 efl_ui_text_end_visible_set(obj, EINA_FALSE);
2602
2603 return ret;
2604}
2605#endif
2606
2607static char *
2608_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
2609{
2610#if 0
2611 const char *txt;
2612
2613 EFL_UI_TEXT_DATA_GET(obj, sd);
2614
2615 if (sd->password) return NULL;
2616
2617 txt = elm_widget_access_info_get(obj);
2618
2619 if (!txt)
2620 return _elm_util_mkup_to_text(efl_ui_text_entry_get(obj));
2621 else return strdup(txt);
2622#else
2623 (void) data;
2624 (void) obj;
2625 return NULL;
2626#endif
2627}
2628
2629static char *
2630_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj)
2631{
2632 Eina_Strbuf *buf;
2633 char *ret;
2634
2635 EFL_UI_TEXT_DATA_GET(obj, sd);
2636
2637 ret = NULL;
2638 buf = eina_strbuf_new();
2639
2640 if (elm_widget_disabled_get(obj))
2641 eina_strbuf_append(buf, "State: Disabled");
2642
2643 if (!sd->editable)
2644 {
2645 if (!eina_strbuf_length_get(buf))
2646 eina_strbuf_append(buf, "State: Not Editable");
2647 else eina_strbuf_append(buf, ", Not Editable");
2648 }
2649
2650 if (sd->password)
2651 {
2652 if (!eina_strbuf_length_get(buf))
2653 eina_strbuf_append(buf, "State: Password");
2654 else eina_strbuf_append(buf, ", Password");
2655 }
2656
2657 if (!eina_strbuf_length_get(buf)) goto buf_free;
2658
2659 ret = eina_strbuf_string_steal(buf);
2660
2661buf_free:
2662 eina_strbuf_free(buf);
2663 return ret;
2664}
2665
2666static void 1740static void
2667_efl_ui_text_resize_internal(Evas_Object *obj) 1741_selection_handlers_offset_calc(Evas_Object *obj, Evas_Object *handler)
2668{ 1742{
2669 EFL_UI_TEXT_DATA_GET(obj, sd);
2670
2671 if (sd->line_wrap)
2672 {
2673 elm_layout_sizing_eval(obj);
2674 }
2675 else if (sd->scroll)
2676 {
2677 Evas_Coord vw = 0, vh = 0;
2678
2679 elm_interface_scrollable_content_viewport_geometry_get
2680 (obj, NULL, NULL, &vw, &vh);
2681 evas_object_resize(sd->entry_edje, vw, vh);
2682 }
2683
2684 if (sd->hoversel) _hoversel_position(obj);
2685 _decoration_defer_all(obj);
2686}
2687
2688static void
2689_resize_cb(void *data,
2690 Evas *e EINA_UNUSED,
2691 Evas_Object *obj EINA_UNUSED,
2692 void *event_info EINA_UNUSED)
2693{
2694 _efl_ui_text_resize_internal(data);
2695}
2696
2697static void
2698_selection_handlers_offset_calc(Evas_Object *obj, Evas_Object *handler, Evas_Coord canvasx, Evas_Coord canvasy)
2699{
2700 Evas_Coord ex, ey;
2701 Evas_Coord cx, cy, cw, ch; 1743 Evas_Coord cx, cy, cw, ch;
2702 Evas_Coord hh; 1744 Evas_Coord hh;
1745 Eina_Position2D pos;
2703 1746
2704 EFL_UI_TEXT_DATA_GET(obj, sd); 1747 EFL_UI_TEXT_DATA_GET(obj, sd);
2705 1748
2706 evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL); 1749 pos = efl_gfx_entity_position_get(sd->text_obj);
2707 efl_text_cursor_geometry_get(obj, 1750 efl_text_cursor_geometry_get(obj,
2708 efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN), 1751 efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN),
2709 EFL_TEXT_CURSOR_TYPE_BEFORE, 1752 EFL_TEXT_CURSOR_TYPE_BEFORE,
@@ -2711,36 +1754,33 @@ _selection_handlers_offset_calc(Evas_Object *obj, Evas_Object *handler, Evas_Coo
2711 NULL, NULL, NULL, NULL); 1754 NULL, NULL, NULL, NULL);
2712 edje_object_size_min_calc(handler, NULL, &hh); 1755 edje_object_size_min_calc(handler, NULL, &hh);
2713 1756
2714 sd->ox = canvasx - (ex + cx + (cw / 2)); 1757 sd->ox = pos.x + cx + (cw / 2);
2715 if (ch > hh) 1758 if (ch > hh)
2716 sd->oy = canvasy - (ey + cy + ch); 1759 {
1760 sd->oy = pos.y + cy + ch;
1761 }
2717 else 1762 else
2718 sd->oy = canvasy - (ey + cy + (ch / 2)); 1763 {
1764 sd->oy = pos.y + cy + (ch / 2);
1765 }
2719 1766
2720 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); 1767 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
2721 sd->long_pressed = EINA_FALSE; 1768 sd->long_pressed = EINA_FALSE;
2722 if (_elm_config->magnifier_enable)
2723 {
2724 _magnifier_create(obj);
2725 _magnifier_show(obj);
2726 _magnifier_move(obj);
2727 }
2728} 1769}
2729 1770
2730static void 1771static void
2731_start_handler_mouse_down_cb(void *data, 1772_start_handler_mouse_down_cb(void *data,
2732 Evas *e EINA_UNUSED, 1773 Evas *e EINA_UNUSED,
2733 Evas_Object *obj EINA_UNUSED, 1774 Evas_Object *obj EINA_UNUSED,
2734 void *event_info) 1775 void *event_info EINA_UNUSED)
2735{ 1776{
2736 EFL_UI_TEXT_DATA_GET(data, sd); 1777 EFL_UI_TEXT_DATA_GET(data, sd);
2737 1778
2738 Evas_Event_Mouse_Down *ev = event_info;
2739 int start_pos, end_pos, pos; 1779 int start_pos, end_pos, pos;
2740 Efl_Text_Cursor_Cursor *sel_start, *sel_end; 1780 Efl_Text_Cursor_Cursor *sel_start, *sel_end;
2741 Efl_Text_Cursor_Cursor *main_cur; 1781 Efl_Text_Cursor_Cursor *main_cur;
2742 1782
2743 Eo *text_obj = edje_object_part_swallow_get(sd->entry_edje, "efl.text"); 1783 Eo *text_obj = sd->text_obj;
2744 1784
2745 sd->start_handler_down = EINA_TRUE; 1785 sd->start_handler_down = EINA_TRUE;
2746 1786
@@ -2748,8 +1788,8 @@ _start_handler_mouse_down_cb(void *data,
2748 efl_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end); 1788 efl_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end);
2749 main_cur = efl_text_cursor_get(text_obj, EFL_TEXT_CURSOR_GET_MAIN); 1789 main_cur = efl_text_cursor_get(text_obj, EFL_TEXT_CURSOR_GET_MAIN);
2750 1790
2751 start_pos = efl_text_cursor_position_get(obj, sel_start); 1791 start_pos = efl_text_cursor_position_get(text_obj, sel_start);
2752 end_pos = efl_text_cursor_position_get(obj, sel_end); 1792 end_pos = efl_text_cursor_position_get(text_obj, sel_end);
2753 1793
2754 if (start_pos <= end_pos) 1794 if (start_pos <= end_pos)
2755 { 1795 {
@@ -2761,8 +1801,8 @@ _start_handler_mouse_down_cb(void *data,
2761 pos = end_pos; 1801 pos = end_pos;
2762 sd->sel_handler_cursor = sel_end; 1802 sd->sel_handler_cursor = sel_end;
2763 } 1803 }
2764 efl_text_cursor_position_set(obj, main_cur, pos); 1804 efl_text_cursor_position_set(text_obj, main_cur, pos);
2765 _selection_handlers_offset_calc(data, sd->start_handler, ev->canvas.x, ev->canvas.y); 1805 _selection_handlers_offset_calc(data, sd->start_handler);
2766} 1806}
2767 1807
2768static void 1808static void
@@ -2774,8 +1814,6 @@ _start_handler_mouse_up_cb(void *data,
2774 EFL_UI_TEXT_DATA_GET(data, sd); 1814 EFL_UI_TEXT_DATA_GET(data, sd);
2775 1815
2776 sd->start_handler_down = EINA_FALSE; 1816 sd->start_handler_down = EINA_FALSE;
2777 if (_elm_config->magnifier_enable)
2778 _magnifier_hide(data);
2779 /* Context menu should not appear, even in case of selector mode, if the 1817 /* Context menu should not appear, even in case of selector mode, if the
2780 * flag is false (disabled) */ 1818 * flag is false (disabled) */
2781 if ((!_elm_config->context_menu_disabled) && 1819 if ((!_elm_config->context_menu_disabled) &&
@@ -2802,40 +1840,38 @@ _start_handler_mouse_move_cb(void *data,
2802 cy = ev->cur.canvas.y - sd->oy - ey; 1840 cy = ev->cur.canvas.y - sd->oy - ey;
2803 if (cx <= 0) cx = 1; 1841 if (cx <= 0) cx = 1;
2804 1842
2805 efl_text_cursor_coord_set(obj, sd->sel_handler_cursor, cx, cy); 1843 efl_text_cursor_coord_set(sd->text_obj, sd->sel_handler_cursor, cx, cy);
2806 pos = efl_text_cursor_position_get(obj, sd->sel_handler_cursor); 1844 pos = efl_text_cursor_position_get(sd->text_obj, sd->sel_handler_cursor);
2807 1845
2808 /* Set the main cursor. */ 1846 /* Set the main cursor. */
2809 efl_text_cursor_position_set(obj, efl_text_cursor_get(data, EFL_TEXT_CURSOR_GET_MAIN), pos); 1847 efl_text_cursor_position_set(sd->text_obj,
1848 efl_text_cursor_get(sd->text_obj, EFL_TEXT_CURSOR_GET_MAIN), pos);
2810 1849
2811 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); 1850 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
2812 sd->long_pressed = EINA_FALSE; 1851 sd->long_pressed = EINA_FALSE;
2813 if (_elm_config->magnifier_enable)
2814 _magnifier_move(data);
2815} 1852}
2816 1853
2817static void 1854static void
2818_end_handler_mouse_down_cb(void *data, 1855_end_handler_mouse_down_cb(void *data,
2819 Evas *e EINA_UNUSED, 1856 Evas *e EINA_UNUSED,
2820 Evas_Object *obj EINA_UNUSED, 1857 Evas_Object *obj EINA_UNUSED,
2821 void *event_info) 1858 void *event_info EINA_UNUSED)
2822{ 1859{
2823 EFL_UI_TEXT_DATA_GET(data, sd); 1860 EFL_UI_TEXT_DATA_GET(data, sd);
2824 1861
2825 Evas_Event_Mouse_Down *ev = event_info;
2826 Efl_Text_Cursor_Cursor *sel_start, *sel_end; 1862 Efl_Text_Cursor_Cursor *sel_start, *sel_end;
2827 Efl_Text_Cursor_Cursor *main_cur; 1863 Efl_Text_Cursor_Cursor *main_cur;
2828 int pos, start_pos, end_pos; 1864 int pos, start_pos, end_pos;
2829 1865
2830 sd->end_handler_down = EINA_TRUE; 1866 sd->end_handler_down = EINA_TRUE;
2831 1867
2832 Eo *text_obj = edje_object_part_swallow_get(sd->entry_edje, "efl.text"); 1868 Eo *text_obj = sd->text_obj;
2833 1869
2834 efl_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end); 1870 efl_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end);
2835 main_cur = efl_text_cursor_get(text_obj, EFL_TEXT_CURSOR_GET_MAIN); 1871 main_cur = efl_text_cursor_get(text_obj, EFL_TEXT_CURSOR_GET_MAIN);
2836 1872
2837 start_pos = efl_text_cursor_position_get(obj, sel_start); 1873 start_pos = efl_text_cursor_position_get(text_obj, sel_start);
2838 end_pos = efl_text_cursor_position_get(obj, sel_end); 1874 end_pos = efl_text_cursor_position_get(text_obj, sel_end);
2839 1875
2840 if (start_pos < end_pos) 1876 if (start_pos < end_pos)
2841 { 1877 {
@@ -2848,8 +1884,8 @@ _end_handler_mouse_down_cb(void *data,
2848 sd->sel_handler_cursor = sel_start; 1884 sd->sel_handler_cursor = sel_start;
2849 } 1885 }
2850 1886
2851 efl_text_cursor_position_set(obj, main_cur, pos); 1887 efl_text_cursor_position_set(text_obj, main_cur, pos);
2852 _selection_handlers_offset_calc(data, sd->end_handler, ev->canvas.x, ev->canvas.y); 1888 _selection_handlers_offset_calc(data, sd->end_handler);
2853} 1889}
2854 1890
2855static void 1891static void
@@ -2861,8 +1897,6 @@ _end_handler_mouse_up_cb(void *data,
2861 EFL_UI_TEXT_DATA_GET(data, sd); 1897 EFL_UI_TEXT_DATA_GET(data, sd);
2862 1898
2863 sd->end_handler_down = EINA_FALSE; 1899 sd->end_handler_down = EINA_FALSE;
2864 if (_elm_config->magnifier_enable)
2865 _magnifier_hide(data);
2866 /* Context menu appear was checked in case of selector start, and hence 1900 /* Context menu appear was checked in case of selector start, and hence
2867 * the same should be checked at selector end as well */ 1901 * the same should be checked at selector end as well */
2868 if ((!_elm_config->context_menu_disabled) && 1902 if ((!_elm_config->context_menu_disabled) &&
@@ -2889,14 +1923,12 @@ _end_handler_mouse_move_cb(void *data,
2889 cy = ev->cur.canvas.y - sd->oy - ey; 1923 cy = ev->cur.canvas.y - sd->oy - ey;
2890 if (cx <= 0) cx = 1; 1924 if (cx <= 0) cx = 1;
2891 1925
2892 efl_text_cursor_coord_set(obj, sd->sel_handler_cursor, cx, cy); 1926 efl_text_cursor_coord_set(sd->text_obj, sd->sel_handler_cursor, cx, cy);
2893 pos = efl_text_cursor_position_get(obj, sd->sel_handler_cursor); 1927 pos = efl_text_cursor_position_get(sd->text_obj, sd->sel_handler_cursor);
2894 /* Set the main cursor. */ 1928 /* Set the main cursor. */
2895 efl_text_cursor_position_set(obj, efl_text_cursor_get(data, EFL_TEXT_CURSOR_GET_MAIN), pos); 1929 efl_text_cursor_position_set(sd->text_obj, efl_text_cursor_get(data, EFL_TEXT_CURSOR_GET_MAIN), pos);
2896 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); 1930 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
2897 sd->long_pressed = EINA_FALSE; 1931 sd->long_pressed = EINA_FALSE;
2898 if (_elm_config->magnifier_enable)
2899 _magnifier_move(data);
2900} 1932}
2901 1933
2902static void 1934static void
@@ -2937,8 +1969,6 @@ _efl_ui_text_efl_gfx_entity_position_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Pos
2937 efl_gfx_entity_position_set(sd->hit_rect, pos); 1969 efl_gfx_entity_position_set(sd->hit_rect, pos);
2938 1970
2939 if (sd->hoversel) _hoversel_position(obj); 1971 if (sd->hoversel) _hoversel_position(obj);
2940
2941 _update_selection_handler(obj);
2942} 1972}
2943 1973
2944EOLIAN static void 1974EOLIAN static void
@@ -3009,21 +2039,32 @@ _efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
3009 2039
3010 elm_widget_sub_object_parent_add(obj); 2040 elm_widget_sub_object_parent_add(obj);
3011 2041
3012 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 2042 text_obj = efl_add(EFL_UI_INTERNAL_TEXT_INTERACTIVE_CLASS, obj);
3013 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_ENTRY); 2043 sd->text_obj = text_obj;
3014 efl_event_callback_add(obj, EFL_EVENT_CALLBACK_ADD, _cb_added, NULL); 2044 efl_composite_attach(obj, text_obj);
3015 efl_event_callback_add(obj, EFL_EVENT_CALLBACK_DEL, _cb_deleted, NULL);
3016 2045
3017 sd->entry_edje = wd->resize_obj; 2046 sd->entry_edje = wd->resize_obj;
3018
3019 sd->cnp_mode = ELM_CNP_MODE_PLAINTEXT; 2047 sd->cnp_mode = ELM_CNP_MODE_PLAINTEXT;
3020 sd->line_wrap = ELM_WRAP_WORD; 2048 sd->line_wrap = ELM_WRAP_WORD;
3021 sd->context_menu = EINA_TRUE; 2049 sd->context_menu = EINA_TRUE;
3022 sd->auto_save = EINA_TRUE; 2050 sd->auto_save = EINA_TRUE;
3023 sd->editable = EINA_TRUE; 2051 sd->editable = EINA_TRUE;
3024 sd->sel_allow = EINA_TRUE; 2052 sd->sel_allow = EINA_TRUE;
2053 sd->drop_format = EFL_SELECTION_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE;
2054 sd->last.scroll = EINA_SIZE2D(0, 0);
2055 sd->sel_handler_disabled = EINA_TRUE;
2056
2057 return obj;
2058}
2059
2060EOLIAN static Eo *
2061_efl_ui_text_efl_object_finalize(Eo *obj,
2062 Efl_Ui_Text_Data *sd)
2063{
2064 obj = efl_finalize(efl_super(obj, MY_CLASS));
2065
2066 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
3025 2067
3026 sd->drop_format = ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE;
3027 elm_drop_target_add(obj, sd->drop_format, 2068 elm_drop_target_add(obj, sd->drop_format,
3028 _dnd_enter_cb, NULL, 2069 _dnd_enter_cb, NULL,
3029 _dnd_leave_cb, NULL, 2070 _dnd_leave_cb, NULL,
@@ -3036,65 +2077,39 @@ _efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
3036 elm_widget_theme_style_get(obj))) 2077 elm_widget_theme_style_get(obj)))
3037 CRI("Failed tp set layout!"); 2078 CRI("Failed tp set layout!");
3038 2079
3039 text_obj = efl_add(EFL_UI_INTERNAL_TEXT_INTERACTIVE_CLASS, obj); 2080 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_ENTRY);
3040 2081 efl_event_callback_add(obj, EFL_EVENT_CALLBACK_ADD, _cb_added, NULL);
3041 efl_composite_attach(obj, text_obj); 2082 efl_event_callback_add(obj, EFL_EVENT_CALLBACK_DEL, _cb_deleted, NULL);
3042 sd->text_obj = text_obj;
3043 2083
3044 // FIXME: use the theme, when a proper theming option is available 2084 // FIXME: use the theme, when a proper theming option is available
3045 // (possibly, text_classes). 2085 // (possibly, text_classes).
3046 // For now, set this for easier setup 2086 // For now, set this for easier setup
3047 efl_text_font_set(text_obj, "Sans", 12); 2087 efl_text_font_set(sd->text_obj, "Sans", 12);
3048 efl_text_normal_color_set(text_obj, 255, 255, 255, 255); 2088 efl_text_normal_color_set(sd->text_obj, 255, 255, 255, 255);
3049 efl_text_interactive_editable_set(obj, EINA_FALSE); 2089 sd->single_line = !efl_text_multiline_get(sd->text_obj);
2090 efl_text_set(sd->text_obj, "");
3050 2091
3051 sd->single_line = !efl_text_multiline_get(text_obj); 2092 sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj);
2093
2094 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
3052 2095
3053 edje_object_part_swallow(sd->entry_edje, "efl.text", text_obj);
3054 evas_object_size_hint_weight_set 2096 evas_object_size_hint_weight_set
3055 (sd->entry_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 2097 (sd->entry_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3056 evas_object_size_hint_align_set 2098 evas_object_size_hint_align_set
3057 (sd->entry_edje, EVAS_HINT_FILL, EVAS_HINT_FILL); 2099 (sd->entry_edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
3058 efl_event_callback_add(text_obj, EFL_UI_TEXT_EVENT_CHANGED_USER, 2100 efl_event_callback_add(sd->text_obj, EFL_UI_TEXT_EVENT_CHANGED_USER,
3059 _efl_ui_text_changed_user_cb, obj); 2101 _efl_ui_text_changed_user_cb, obj);
3060 efl_event_callback_add(text_obj, EFL_CANVAS_TEXT_EVENT_CHANGED, 2102 efl_event_callback_add(sd->text_obj, EFL_CANVAS_TEXT_EVENT_CHANGED,
3061 _efl_ui_text_changed_cb, obj); 2103 _efl_ui_text_changed_cb, obj);
3062 efl_event_callback_add(text_obj, EFL_TEXT_INTERACTIVE_EVENT_SELECTION_CHANGED, 2104 efl_event_callback_add(sd->text_obj, EFL_TEXT_INTERACTIVE_EVENT_SELECTION_CHANGED,
3063 _efl_ui_text_selection_changed_cb, obj); 2105 _efl_ui_text_selection_changed_cb, obj);
3064 efl_event_callback_add(text_obj, EFL_CANVAS_TEXT_EVENT_CURSOR_CHANGED, 2106 efl_event_callback_add(sd->text_obj, EFL_CANVAS_TEXT_EVENT_CURSOR_CHANGED,
3065 _efl_ui_text_cursor_changed_cb, obj); 2107 _efl_ui_text_cursor_changed_cb, obj);
2108 efl_event_callback_add(sd->text_obj, EFL_GFX_ENTITY_EVENT_MOVE,
2109 _text_position_changed_cb, obj);
3066 evas_object_event_callback_add(sd->entry_edje, EVAS_CALLBACK_MOVE, 2110 evas_object_event_callback_add(sd->entry_edje, EVAS_CALLBACK_MOVE,
3067 _efl_ui_text_move_cb, obj); 2111 _efl_ui_text_move_cb, obj);
3068 2112
3069 /* Async layout */
3070 if (sd->async.enabled)
3071 {
3072#if 0
3073 efl_event_callback_add(text_obj,
3074 EFL_CANVAS_TEXT_EVENT_ASYNC_LAYOUT_COMPLETE,
3075 _on_layout_complete, obj);
3076#endif
3077 }
3078
3079 sd->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
3080 evas_object_data_set(sd->hit_rect, "_elm_leaveme", obj);
3081
3082 Evas_Object* clip = evas_object_clip_get(sd->entry_edje);
3083 evas_object_clip_set(sd->hit_rect, clip);
3084
3085 evas_object_smart_member_add(sd->hit_rect, obj);
3086 elm_widget_sub_object_add(obj, sd->hit_rect);
3087
3088 /* common scroller hit rectangle setup */
3089 evas_object_color_set(sd->hit_rect, 0, 0, 0, 0);
3090 evas_object_show(sd->hit_rect);
3091 evas_object_repeat_events_set(sd->hit_rect, EINA_TRUE);
3092
3093 elm_interface_scrollable_objects_set(obj, sd->entry_edje, sd->hit_rect);
3094
3095 edje_object_text_markup_filter_callback_add
3096 (sd->entry_edje, "efl.text", _markup_filter_cb, obj);
3097
3098 evas_object_event_callback_add 2113 evas_object_event_callback_add
3099 (sd->entry_edje, EVAS_CALLBACK_KEY_DOWN, _key_down_cb, obj); 2114 (sd->entry_edje, EVAS_CALLBACK_KEY_DOWN, _key_down_cb, obj);
3100 evas_object_event_callback_add 2115 evas_object_event_callback_add
@@ -3104,104 +2119,22 @@ _efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
3104 evas_object_event_callback_add 2119 evas_object_event_callback_add
3105 (sd->entry_edje, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, obj); 2120 (sd->entry_edje, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, obj);
3106 2121
3107 /* this code can't go in smart_resize. sizing gets wrong */ 2122 efl_event_callback_add(obj, EFL_GFX_ENTITY_EVENT_RESIZE,
3108 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize_cb, obj); 2123 _text_size_changed_cb, obj);
3109
3110 edje_object_signal_callback_add
3111 (sd->entry_edje, "entry,changed,user", "efl.text",
3112 _entry_changed_user_signal_cb, obj);
3113 edje_object_signal_callback_add
3114 (sd->entry_edje, "preedit,changed", "efl.text",
3115 _entry_preedit_changed_signal_cb, obj);
3116
3117 edje_object_signal_callback_add
3118 (sd->entry_edje, "cursor,changed", "efl.text",
3119 _entry_cursor_changed_signal_cb, obj);
3120 edje_object_signal_callback_add
3121 (sd->entry_edje, "cursor,changed,manual", "efl.text",
3122 _entry_cursor_changed_manual_signal_cb, obj);
3123 edje_object_signal_callback_add
3124 (sd->entry_edje, "anchor,mouse,down,*", "efl.text",
3125 _entry_anchor_down_signal_cb, obj);
3126 edje_object_signal_callback_add
3127 (sd->entry_edje, "anchor,mouse,up,*", "efl.text",
3128 _entry_anchor_up_signal_cb, obj);
3129 edje_object_signal_callback_add
3130 (sd->entry_edje, "anchor,mouse,move,*", "efl.text",
3131 _entry_anchor_move_signal_cb, obj);
3132 edje_object_signal_callback_add
3133 (sd->entry_edje, "anchor,mouse,in,*", "efl.text",
3134 _entry_anchor_in_signal_cb, obj);
3135 edje_object_signal_callback_add
3136 (sd->entry_edje, "anchor,mouse,out,*", "efl.text",
3137 _entry_anchor_out_signal_cb, obj);
3138 edje_object_signal_callback_add
3139 (sd->entry_edje, "entry,key,enter", "efl.text",
3140 _entry_key_enter_signal_cb, obj);
3141 edje_object_signal_callback_add
3142 (sd->entry_edje, "entry,key,escape", "efl.text",
3143 _entry_key_escape_signal_cb, obj);
3144 edje_object_signal_callback_add
3145 (sd->entry_edje, "mouse,down,1", "efl.text",
3146 _entry_mouse_down_signal_cb, obj);
3147 edje_object_signal_callback_add
3148 (sd->entry_edje, "mouse,clicked,1", "efl.text",
3149 _entry_mouse_clicked_signal_cb, obj);
3150 edje_object_signal_callback_add
3151 (sd->entry_edje, "mouse,down,1,double", "efl.text",
3152 _entry_mouse_double_signal_cb, obj);
3153 edje_object_signal_callback_add
3154 (sd->entry_edje, "mouse,down,1,triple", "efl.text",
3155 _entry_mouse_triple_signal_cb, obj);
3156 edje_object_signal_callback_add
3157 (sd->entry_edje, "entry,undo,request", "efl.text",
3158 _entry_undo_request_signal_cb, obj);
3159 edje_object_signal_callback_add
3160 (sd->entry_edje, "entry,redo,request", "efl.text",
3161 _entry_redo_request_signal_cb, obj);
3162 2124
3163 efl_text_set(sd->text_obj, "");
3164
3165 elm_object_sub_cursor_set
3166 (wd->resize_obj, obj, ELM_CURSOR_XTERM);
3167 elm_widget_can_focus_set(obj, EINA_TRUE); 2125 elm_widget_can_focus_set(obj, EINA_TRUE);
3168 if (_elm_config->desktop_entry)
3169 edje_object_part_text_select_allow_set
3170 (sd->entry_edje, "efl.text", EINA_TRUE);
3171 2126
3172 efl_ui_text_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL); 2127 efl_ui_text_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
3173 efl_ui_text_input_panel_enabled_set(obj, EINA_TRUE); 2128 efl_ui_text_input_panel_enabled_set(obj, EINA_TRUE);
3174 efl_ui_text_prediction_allow_set(obj, EINA_TRUE); 2129 efl_ui_text_prediction_allow_set(obj, EINA_TRUE);
3175 efl_ui_text_input_hint_set(obj, ELM_INPUT_HINT_AUTO_COMPLETE); 2130 efl_ui_text_input_hint_set(obj, ELM_INPUT_HINT_AUTO_COMPLETE);
3176 2131
3177 sd->autocapital_type = (Elm_Autocapital_Type)edje_object_part_text_autocapital_type_get
3178 (sd->entry_edje, "efl.text");
3179
3180 entries = eina_list_prepend(entries, obj);
3181
3182 // module - find module for entry
3183 sd->api = _module_find(obj);
3184 // if found - hook in
3185 if ((sd->api) && (sd->api->obj_hook)) sd->api->obj_hook(obj);
3186
3187 _mirrored_set(obj, efl_ui_mirrored_get(obj)); 2132 _mirrored_set(obj, efl_ui_mirrored_get(obj));
3188 2133
3189 // access
3190 _elm_access_object_register(obj, sd->entry_edje);
3191 _elm_access_text_set
3192 (_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("Entry"));
3193 _elm_access_callback_set
3194 (_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
3195 _elm_access_callback_set
3196 (_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, NULL);
3197
3198 if (_elm_config->desktop_entry)
3199 sd->sel_handler_disabled = EINA_TRUE;
3200
3201 sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj);
3202 _create_text_cursors(obj, sd); 2134 _create_text_cursors(obj, sd);
3203 2135
3204 return obj; 2136 return obj;
2137
3205} 2138}
3206 2139
3207EOLIAN static void 2140EOLIAN static void
@@ -3209,7 +2142,6 @@ _efl_ui_text_efl_object_destructor(Eo *obj, Efl_Ui_Text_Data *sd)
3209{ 2142{
3210 Elm_Entry_Context_Menu_Item *it; 2143 Elm_Entry_Context_Menu_Item *it;
3211 Elm_Entry_Markup_Filter *tf; 2144 Elm_Entry_Markup_Filter *tf;
3212 Eo *text_obj;
3213 2145
3214 if (sd->delay_write) 2146 if (sd->delay_write)
3215 { 2147 {
@@ -3217,12 +2149,6 @@ _efl_ui_text_efl_object_destructor(Eo *obj, Efl_Ui_Text_Data *sd)
3217 if (sd->auto_save) _save_do(obj); 2149 if (sd->auto_save) _save_do(obj);
3218 } 2150 }
3219 2151
3220 if (sd->scroll)
3221 elm_interface_scrollable_content_viewport_resize_cb_set(obj, NULL);
3222
3223 _efl_ui_text_anchor_hover_end(obj, sd);
3224 _efl_ui_text_anchor_hover_parent_set(obj, sd, NULL);
3225
3226 efl_event_freeze(obj); 2152 efl_event_freeze(obj);
3227 2153
3228 eina_stringshare_del(sd->file); 2154 eina_stringshare_del(sd->file);
@@ -3269,32 +2195,13 @@ _efl_ui_text_efl_object_destructor(Eo *obj, Efl_Ui_Text_Data *sd)
3269 evas_object_del(sd->end_handler); 2195 evas_object_del(sd->end_handler);
3270 } 2196 }
3271 2197
3272 _anchors_clear_all(obj, sd); 2198 _anchors_free(sd);
3273 _unused_item_objs_free(sd);
3274 _clear_text_selection(sd); 2199 _clear_text_selection(sd);
3275 2200
3276 text_obj = edje_object_part_swallow_get(sd->entry_edje, "efl.text");
3277 efl_event_callback_del(text_obj, EFL_UI_TEXT_EVENT_CHANGED_USER,
3278 _efl_ui_text_changed_user_cb, obj);
3279 efl_event_callback_del(text_obj, EFL_CANVAS_TEXT_EVENT_CHANGED,
3280 _efl_ui_text_changed_cb, obj);
3281 efl_event_callback_del(text_obj, EFL_TEXT_INTERACTIVE_EVENT_SELECTION_CHANGED,
3282 _efl_ui_text_selection_changed_cb, obj);
3283 efl_event_callback_del(text_obj, EFL_CANVAS_TEXT_EVENT_CURSOR_CHANGED,
3284 _efl_ui_text_cursor_changed_cb, obj);
3285 evas_object_event_callback_del_full(sd->entry_edje, EVAS_CALLBACK_MOVE,
3286 _efl_ui_text_move_cb, obj);
3287
3288 // XXX: explicitly delete the object, as it's been reparented to the canvas, due to
3289 // a specific behavior of SWALLOW parts.
3290 efl_del(sd->text_obj);
3291 sd->text_obj = NULL;
3292
3293 ecore_job_del(sd->deferred_decoration_job); 2201 ecore_job_del(sd->deferred_decoration_job);
3294 sd->deferred_decoration_job = NULL; 2202 sd->deferred_decoration_job = NULL;
3295 2203
3296 if (sd->item_factory) efl_unref(sd->item_factory); 2204 if (sd->item_factory) efl_unref(sd->item_factory);
3297 if (sd->item_fallback_factory) efl_del(sd->item_fallback_factory);
3298 2205
3299 efl_destructor(efl_super(obj, MY_CLASS)); 2206 efl_destructor(efl_super(obj, MY_CLASS));
3300} 2207}
@@ -3344,8 +2251,8 @@ _efl_ui_text_password_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
3344static void 2251static void
3345_efl_ui_text_calc_force(Eo *obj, Efl_Ui_Text_Data *sd) 2252_efl_ui_text_calc_force(Eo *obj, Efl_Ui_Text_Data *sd)
3346{ 2253{
2254 sd->calc_force = EINA_TRUE;
3347 edje_object_calc_force(sd->entry_edje); 2255 edje_object_calc_force(sd->entry_edje);
3348 sd->changed = EINA_TRUE;
3349 elm_layout_sizing_eval(obj); 2256 elm_layout_sizing_eval(obj);
3350} 2257}
3351 2258
@@ -3378,7 +2285,7 @@ _efl_ui_text_entry_insert(Eo *obj, Efl_Ui_Text_Data *sd, const char *entry)
3378{ 2285{
3379 Efl_Text_Cursor_Cursor *cur_obj = efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN); 2286 Efl_Text_Cursor_Cursor *cur_obj = efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN);
3380 efl_text_cursor_text_insert(obj, cur_obj, entry); 2287 efl_text_cursor_text_insert(obj, cur_obj, entry);
3381 sd->changed = EINA_TRUE; 2288 sd->text_changed = EINA_TRUE;
3382 elm_layout_sizing_eval(obj); 2289 elm_layout_sizing_eval(obj);
3383} 2290}
3384 2291
@@ -3432,7 +2339,8 @@ _efl_ui_text_select_none(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
3432 efl_event_callback_call(obj, EFL_UI_EVENT_SELECTION_CLEARED, NULL); 2339 efl_event_callback_call(obj, EFL_UI_EVENT_SELECTION_CLEARED, NULL);
3433 2340
3434 sd->have_selection = EINA_FALSE; 2341 sd->have_selection = EINA_FALSE;
3435 edje_object_part_text_select_none(sd->entry_edje, "efl.text"); 2342 _edje_signal_emit(sd, "selection,cleared", "efl.text");
2343 efl_text_interactive_select_none(sd->text_obj);
3436 2344
3437 _hide_selection_handler(obj); 2345 _hide_selection_handler(obj);
3438} 2346}
@@ -3543,7 +2451,7 @@ _efl_ui_text_cnp_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Efl_Selection_Format cn
3543{ 2451{
3544 /* FIXME: CnP format handling really odd... */ 2452 /* FIXME: CnP format handling really odd... */
3545 2453
3546 Elm_Sel_Format dnd_format = ELM_SEL_FORMAT_MARKUP; 2454 Elm_Sel_Format dnd_format = EFL_SELECTION_FORMAT_MARKUP;
3547 Elm_Sel_Format cnp_format = cnp_mode; 2455 Elm_Sel_Format cnp_format = cnp_mode;
3548 2456
3549 if (cnp_mode != EFL_SELECTION_FORMAT_TARGETS) 2457 if (cnp_mode != EFL_SELECTION_FORMAT_TARGETS)
@@ -3559,7 +2467,7 @@ _efl_ui_text_cnp_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Efl_Selection_Format cn
3559 if (sd->cnp_mode == cnp_format) return; 2467 if (sd->cnp_mode == cnp_format) return;
3560 sd->cnp_mode = cnp_format; 2468 sd->cnp_mode = cnp_format;
3561 if (sd->cnp_mode == EFL_SELECTION_FORMAT_TEXT) 2469 if (sd->cnp_mode == EFL_SELECTION_FORMAT_TEXT)
3562 dnd_format = ELM_SEL_FORMAT_TEXT; 2470 dnd_format = EFL_SELECTION_FORMAT_TEXT;
3563 else if (cnp_mode == EFL_SELECTION_FORMAT_IMAGE) 2471 else if (cnp_mode == EFL_SELECTION_FORMAT_IMAGE)
3564 dnd_format |= ELM_SEL_FORMAT_IMAGE; 2472 dnd_format |= ELM_SEL_FORMAT_IMAGE;
3565 2473
@@ -3582,86 +2490,36 @@ _efl_ui_text_cnp_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
3582 return sd->cnp_mode; 2490 return sd->cnp_mode;
3583} 2491}
3584 2492
3585static void
3586_efl_ui_text_content_viewport_resize_cb(Evas_Object *obj,
3587 Evas_Coord w EINA_UNUSED, Evas_Coord h EINA_UNUSED)
3588{
3589 _efl_ui_text_resize_internal(obj);
3590}
3591
3592static void
3593_scroll_cb(Evas_Object *obj, void *data EINA_UNUSED)
3594{
3595 EFL_UI_TEXT_DATA_GET(obj, sd);
3596 /* here we need to emit the signal that the elm_scroller would have done */
3597 efl_event_callback_call(obj, EFL_UI_EVENT_SCROLL, NULL);
3598
3599 if (sd->have_selection)
3600 _update_selection_handler(obj);
3601}
3602
3603EOLIAN static void 2493EOLIAN static void
3604_efl_ui_text_scrollable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool scroll) 2494_efl_ui_text_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool scroll)
3605{ 2495{
3606 scroll = !!scroll;
3607 if (sd->scroll == scroll) return; 2496 if (sd->scroll == scroll) return;
3608 sd->scroll = scroll; 2497 sd->scroll = scroll;
3609 2498
3610 if (sd->scroll) 2499 if (scroll)
3611 { 2500 {
3612 /* we now must re-theme ourselves to a scroller decoration 2501 efl_ref(sd->text_obj);
3613 * and move the entry looking object to be the content of the 2502 sd->scroller = efl_add(EFL_UI_INTERNAL_TEXT_SCROLLER_CLASS, obj);
3614 * scrollable view */ 2503 efl_ui_scrollbar_bar_mode_set(sd->scroller, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO);
3615 elm_widget_resize_object_set(obj, NULL); 2504 efl_content_set(sd->scroller, sd->text_obj);
3616 elm_widget_sub_object_add(obj, sd->entry_edje);
3617
3618 if (!sd->scr_edje)
3619 {
3620 sd->scr_edje = edje_object_add(evas_object_evas_get(obj));
3621
3622 elm_widget_element_update(obj, sd->scr_edje, PART_NAME_SCROLLER);
3623 2505
3624 evas_object_size_hint_weight_set 2506 edje_object_part_swallow(sd->entry_edje, "efl.text", NULL);
3625 (sd->scr_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 2507 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->scroller);
3626 evas_object_size_hint_align_set 2508 efl_ui_internal_text_scroller_text_object_set(sd->scroller, sd->text_obj);
3627 (sd->scr_edje, EVAS_HINT_FILL, EVAS_HINT_FILL); 2509 evas_object_clip_set(sd->cursor,
3628 2510 efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller));
3629 evas_object_propagate_events_set(sd->scr_edje, EINA_TRUE); 2511 efl_event_callback_add(sd->scroller, EFL_GFX_ENTITY_EVENT_RESIZE,
3630 } 2512 _scroller_size_changed_cb, obj);
3631
3632 elm_widget_resize_object_set(obj, sd->scr_edje);
3633
3634 elm_interface_scrollable_objects_set(obj, sd->scr_edje, sd->hit_rect);
3635
3636 elm_interface_scrollable_scroll_cb_set(obj, _scroll_cb);
3637
3638 elm_interface_scrollable_bounce_allow_set(obj, sd->h_bounce, sd->v_bounce);
3639 if (sd->single_line)
3640 elm_interface_scrollable_policy_set(obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
3641 else
3642 elm_interface_scrollable_policy_set(obj, sd->policy_h, sd->policy_v);
3643 elm_interface_scrollable_content_set(obj, sd->entry_edje);
3644 elm_interface_scrollable_content_viewport_resize_cb_set(obj, _efl_ui_text_content_viewport_resize_cb);
3645 elm_widget_on_show_region_hook_set(obj, NULL, _show_region_hook, NULL);
3646 } 2513 }
3647 else 2514 else
3648 { 2515 {
3649 if (sd->scr_edje) 2516 efl_content_set(sd->scroller, NULL);
3650 { 2517 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
3651 elm_interface_scrollable_content_set(obj, NULL); 2518 efl_unref(sd->text_obj);
3652 evas_object_hide(sd->scr_edje); 2519 efl_del(sd->scroller);
3653 } 2520 sd->scroller = NULL;
3654 elm_widget_resize_object_set(obj, sd->entry_edje);
3655
3656 if (sd->scr_edje)
3657 elm_widget_sub_object_add(obj, sd->scr_edje);
3658
3659 elm_interface_scrollable_objects_set(obj, sd->entry_edje, sd->hit_rect);
3660
3661 elm_widget_on_show_region_hook_set(obj, NULL, NULL, NULL);
3662 } 2521 }
3663 _update_decorations(obj); 2522 elm_layout_sizing_eval(obj);
3664 efl_ui_widget_theme_apply(obj);
3665} 2523}
3666 2524
3667EOLIAN static Eina_Bool 2525EOLIAN static Eina_Bool
@@ -3671,22 +2529,6 @@ _efl_ui_text_scrollable_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
3671} 2529}
3672 2530
3673EOLIAN static void 2531EOLIAN static void
3674_efl_ui_text_elm_interface_scrollable_policy_set(Eo *obj, Efl_Ui_Text_Data *sd, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
3675{
3676 sd->policy_h = h;
3677 sd->policy_v = v;
3678 elm_interface_scrollable_policy_set(efl_super(obj, MY_CLASS), sd->policy_h, sd->policy_v);
3679}
3680
3681EOLIAN static void
3682_efl_ui_text_elm_interface_scrollable_bounce_allow_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool h_bounce, Eina_Bool v_bounce)
3683{
3684 sd->h_bounce = h_bounce;
3685 sd->v_bounce = v_bounce;
3686 elm_interface_scrollable_bounce_allow_set(efl_super(obj, MY_CLASS), h_bounce, v_bounce);
3687}
3688
3689EOLIAN static void
3690_efl_ui_text_input_panel_layout_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Elm_Input_Panel_Layout layout) 2532_efl_ui_text_input_panel_layout_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Elm_Input_Panel_Layout layout)
3691{ 2533{
3692 sd->input_panel_layout = layout; 2534 sd->input_panel_layout = layout;
@@ -3878,40 +2720,6 @@ _efl_ui_text_input_panel_show_on_demand_get(const Eo *obj EINA_UNUSED, Efl_Ui_Te
3878 return sd->input_panel_show_on_demand; 2720 return sd->input_panel_show_on_demand;
3879} 2721}
3880 2722
3881/* START - ANCHOR HOVER */
3882static void
3883_anchor_parent_del_cb(void *data,
3884 Evas *e EINA_UNUSED,
3885 Evas_Object *obj EINA_UNUSED,
3886 void *event_info EINA_UNUSED)
3887{
3888 EFL_UI_TEXT_DATA_GET(data, sd);
3889
3890 sd->anchor_hover.hover_parent = NULL;
3891}
3892
3893static void
3894_efl_ui_text_anchor_hover_parent_set(Eo *obj, Efl_Ui_Text_Data *sd, Evas_Object *parent)
3895{
3896 if (sd->anchor_hover.hover_parent)
3897 evas_object_event_callback_del_full
3898 (sd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL,
3899 _anchor_parent_del_cb, obj);
3900 sd->anchor_hover.hover_parent = parent;
3901 if (sd->anchor_hover.hover_parent)
3902 evas_object_event_callback_add
3903 (sd->anchor_hover.hover_parent, EVAS_CALLBACK_DEL,
3904 _anchor_parent_del_cb, obj);
3905}
3906
3907static void
3908_efl_ui_text_anchor_hover_end(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
3909{
3910 ELM_SAFE_FREE(sd->anchor_hover.hover, evas_object_del);
3911 ELM_SAFE_FREE(sd->anchor_hover.pop, evas_object_del);
3912}
3913/* END - ANCHOR HOVER */
3914
3915EOLIAN static Eina_Bool 2723EOLIAN static Eina_Bool
3916_efl_ui_text_efl_ui_widget_on_access_activate(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, Efl_Ui_Activate act) 2724_efl_ui_text_efl_ui_widget_on_access_activate(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, Efl_Ui_Activate act)
3917{ 2725{
@@ -3965,10 +2773,9 @@ _efl_ui_text_efl_access_text_string_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_D
3965{ 2773{
3966 Evas_Textblock_Cursor *cur = NULL, *cur2 = NULL; 2774 Evas_Textblock_Cursor *cur = NULL, *cur2 = NULL;
3967 char *ret = NULL; 2775 char *ret = NULL;
3968 Eo *text_obj = edje_object_part_swallow_get(pd->entry_edje, "efl.text");
3969 2776
3970 cur = evas_object_textblock_cursor_new(text_obj); 2777 cur = evas_object_textblock_cursor_new(pd->text_obj);
3971 cur2 = evas_object_textblock_cursor_new(text_obj); 2778 cur2 = evas_object_textblock_cursor_new(pd->text_obj);
3972 if (!cur || !cur2) goto fail; 2779 if (!cur || !cur2) goto fail;
3973 2780
3974 evas_textblock_cursor_pos_set(cur, *start_offset); 2781 evas_textblock_cursor_pos_set(cur, *start_offset);
@@ -4047,7 +2854,7 @@ _efl_ui_text_efl_access_text_access_text_get(const Eo *obj EINA_UNUSED, Efl_Ui_T
4047{ 2854{
4048 Evas_Textblock_Cursor *cur = NULL, *cur2 = NULL; 2855 Evas_Textblock_Cursor *cur = NULL, *cur2 = NULL;
4049 char *ret = NULL; 2856 char *ret = NULL;
4050 Eo *text_obj = edje_object_part_swallow_get(pd->entry_edje, "efl.text"); 2857 Eo *text_obj = pd->text_obj;
4051 2858
4052 cur = evas_object_textblock_cursor_new(text_obj); 2859 cur = evas_object_textblock_cursor_new(text_obj);
4053 cur2 = evas_object_textblock_cursor_new(text_obj); 2860 cur2 = evas_object_textblock_cursor_new(text_obj);
@@ -4143,7 +2950,7 @@ _efl_ui_text_efl_access_text_offset_at_point_get(const Eo *obj, Efl_Ui_Text_Data
4143{ 2950{
4144 Evas_Textblock_Cursor *cur; 2951 Evas_Textblock_Cursor *cur;
4145 int ret; 2952 int ret;
4146 Eo *text_obj = edje_object_part_swallow_get(pd->entry_edje, "efl.text"); 2953 Eo *text_obj = pd->text_obj;
4147 2954
4148 if (!text_obj) return -1; 2955 if (!text_obj) return -1;
4149 2956
@@ -4176,7 +2983,7 @@ _efl_ui_text_efl_access_text_character_extents_get(const Eo *obj, Efl_Ui_Text_Da
4176{ 2983{
4177 Evas_Textblock_Cursor *cur; 2984 Evas_Textblock_Cursor *cur;
4178 int ret; 2985 int ret;
4179 Eo *text_obj = edje_object_part_swallow_get(pd->entry_edje, "efl.text"); 2986 Eo *text_obj = pd->text_obj;
4180 2987
4181 if (!text_obj) return EINA_FALSE; 2988 if (!text_obj) return EINA_FALSE;
4182 2989
@@ -4208,7 +3015,7 @@ _efl_ui_text_efl_access_text_range_extents_get(const Eo *obj, Efl_Ui_Text_Data *
4208 Evas_Textblock_Cursor *cur1, *cur2; 3015 Evas_Textblock_Cursor *cur1, *cur2;
4209 int ret; 3016 int ret;
4210 int x, xx, y, yy; 3017 int x, xx, y, yy;
4211 Eo *text_obj = edje_object_part_swallow_get(pd->entry_edje, "efl.text"); 3018 Eo *text_obj = pd->text_obj;
4212 3019
4213 if (!text_obj) return EINA_FALSE; 3020 if (!text_obj) return EINA_FALSE;
4214 3021
@@ -4415,7 +3222,7 @@ EOLIAN static Eina_Bool
4415_efl_ui_text_efl_access_editable_text_delete(Eo *obj, Efl_Ui_Text_Data *pd, int start_offset, int end_offset) 3222_efl_ui_text_efl_access_editable_text_delete(Eo *obj, Efl_Ui_Text_Data *pd, int start_offset, int end_offset)
4416{ 3223{
4417 Evas_Textblock_Cursor *cur1, *cur2; 3224 Evas_Textblock_Cursor *cur1, *cur2;
4418 Eo *text_obj = edje_object_part_swallow_get(pd->entry_edje, "efl.text"); 3225 Eo *text_obj = pd->text_obj;
4419 3226
4420 if (!text_obj) return EINA_FALSE; 3227 if (!text_obj) return EINA_FALSE;
4421 3228
@@ -4484,7 +3291,7 @@ _efl_ui_text_efl_access_object_i18n_name_get(const Eo *obj, Efl_Ui_Text_Data *pd
4484EOLIAN static Efl_Text_Cursor_Cursor * 3291EOLIAN static Efl_Text_Cursor_Cursor *
4485_efl_ui_text_cursor_new(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd EINA_UNUSED) 3292_efl_ui_text_cursor_new(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd EINA_UNUSED)
4486{ 3293{
4487 Eo *text_obj = edje_object_part_swallow_get(sd->entry_edje, "efl.text"); 3294 Eo *text_obj = sd->text_obj;
4488 return efl_text_cursor_new(text_obj); 3295 return efl_text_cursor_new(text_obj);
4489} 3296}
4490 3297
@@ -4500,27 +3307,25 @@ static inline Eo *
4500_decoration_create(Eo *obj, Efl_Ui_Text_Data *sd, 3307_decoration_create(Eo *obj, Efl_Ui_Text_Data *sd,
4501 const char *group_name, Eina_Bool above) 3308 const char *group_name, Eina_Bool above)
4502{ 3309{
4503 Eo *ret = efl_add(EFL_CANVAS_LAYOUT_CLASS, sd->entry_edje); 3310 Eo *ret = NULL;
4504 Eo *text_obj = edje_object_part_swallow_get(sd->entry_edje, "efl.text"); 3311 Eo *clip = efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller);
3312
3313 ret = efl_add(EFL_CANVAS_LAYOUT_CLASS, obj);
4505 elm_widget_element_update(obj, ret, group_name); 3314 elm_widget_element_update(obj, ret, group_name);
4506 evas_object_smart_member_add(ret, sd->entry_edje); 3315 evas_object_smart_member_add(ret, sd->entry_edje);
4507 if (above) 3316 if (above)
4508 { 3317 {
4509 evas_object_stack_above(ret, text_obj); 3318 evas_object_stack_above(ret, sd->text_obj);
4510 } 3319 }
4511 else 3320 else
4512 { 3321 {
4513 evas_object_stack_below(ret, text_obj); 3322 evas_object_stack_below(ret, NULL);
4514 } 3323 }
4515 evas_object_clip_set(ret, evas_object_clip_get(text_obj)); 3324 evas_object_clip_set(ret, clip);
4516 evas_object_pass_events_set(ret, EINA_TRUE); 3325 evas_object_pass_events_set(ret, EINA_TRUE);
4517 return ret; 3326 return ret;
4518} 3327}
4519 3328
4520/**
4521 * Creates the cursors, if not created.
4522 */
4523
4524static void 3329static void
4525_create_text_cursors(Eo *obj, Efl_Ui_Text_Data *sd) 3330_create_text_cursors(Eo *obj, Efl_Ui_Text_Data *sd)
4526{ 3331{
@@ -4534,23 +3339,27 @@ _create_text_cursors(Eo *obj, Efl_Ui_Text_Data *sd)
4534 } 3339 }
4535} 3340}
4536 3341
4537static void 3342static Eina_Position2D
4538_decoration_calc_offset(Efl_Ui_Text_Data *sd, Evas_Coord *_x, Evas_Coord *_y) 3343_decoration_calc_offset(Efl_Ui_Text_Data *sd)
4539{ 3344{
4540 Evas_Coord x, y; 3345 Eina_Position2D ret;
4541 Eo *text_obj = edje_object_part_swallow_get(sd->entry_edje, "efl.text"); 3346 Eina_Position2D text;
3347 Eina_Position2D ed = EINA_POSITION2D(0,0), scr = EINA_POSITION2D(0, 0);
4542 3348
4543 evas_object_geometry_get(text_obj, &x, &y, NULL, NULL); 3349 text = efl_gfx_entity_position_get(sd->text_obj);
4544 3350
4545 if (_x) *_x = x; 3351 ret.x = ed.x + scr.x + text.x;
4546 if (_y) *_y = y; 3352 ret.y = ed.y + scr.y + text.y;
3353
3354 return ret;
4547} 3355}
4548 3356
4549static void 3357static void
4550_update_text_cursors(Eo *obj) 3358_update_text_cursors(Eo *obj)
4551{ 3359{
4552 Evas_Coord x, y, w, h, xx, yy, ww, hh; 3360 Evas_Coord xx, yy, ww, hh;
4553 Evas_Coord xx2, yy2; 3361 Evas_Coord xx2, yy2;
3362 Eina_Position2D off;
4554 Eina_Bool bidi_cursor; 3363 Eina_Bool bidi_cursor;
4555 Eo *text_obj; 3364 Eo *text_obj;
4556 3365
@@ -4559,11 +3368,10 @@ _update_text_cursors(Eo *obj)
4559 if (!sd->deferred_decoration_cursor) return; 3368 if (!sd->deferred_decoration_cursor) return;
4560 sd->deferred_decoration_cursor = EINA_FALSE; 3369 sd->deferred_decoration_cursor = EINA_FALSE;
4561 3370
4562 text_obj = edje_object_part_swallow_get(sd->entry_edje, "efl.text"); 3371 text_obj = sd->text_obj;
4563 3372
4564 x = y = w = h = -1;
4565 xx = yy = ww = hh = -1; 3373 xx = yy = ww = hh = -1;
4566 _decoration_calc_offset(sd, &x, &y); 3374 off =_decoration_calc_offset(sd);
4567 bidi_cursor = efl_text_cursor_geometry_get(obj, 3375 bidi_cursor = efl_text_cursor_geometry_get(obj,
4568 efl_text_cursor_get(text_obj, EFL_TEXT_CURSOR_GET_MAIN), 3376 efl_text_cursor_get(text_obj, EFL_TEXT_CURSOR_GET_MAIN),
4569 EFL_TEXT_CURSOR_TYPE_BEFORE, &xx, &yy, &ww, &hh, &xx2, &yy2, 3377 EFL_TEXT_CURSOR_TYPE_BEFORE, &xx, &yy, &ww, &hh, &xx2, &yy2,
@@ -4572,14 +3380,14 @@ _update_text_cursors(Eo *obj)
4572 if (hh < 1) hh = 1; 3380 if (hh < 1) hh = 1;
4573 if (sd->cursor) 3381 if (sd->cursor)
4574 { 3382 {
4575 evas_object_move(sd->cursor, x + xx, y + yy); 3383 evas_object_move(sd->cursor, off.x + xx, off.y + yy);
4576 evas_object_resize(sd->cursor, ww, hh); 3384 evas_object_resize(sd->cursor, ww, hh);
4577 } 3385 }
4578 if (sd->cursor_bidi) 3386 if (sd->cursor_bidi)
4579 { 3387 {
4580 if (bidi_cursor) 3388 if (bidi_cursor)
4581 { 3389 {
4582 evas_object_move(sd->cursor_bidi, x + xx2, y + yy2 + (hh / 2)); 3390 evas_object_move(sd->cursor_bidi, off.x + xx2, off.y + yy2 + (hh / 2));
4583 evas_object_resize(sd->cursor, ww, hh / 2); 3391 evas_object_resize(sd->cursor, ww, hh / 2);
4584 evas_object_resize(sd->cursor_bidi, ww, hh / 2); 3392 evas_object_resize(sd->cursor_bidi, ww, hh / 2);
4585 evas_object_show(sd->cursor_bidi); 3393 evas_object_show(sd->cursor_bidi);
@@ -4589,7 +3397,11 @@ _update_text_cursors(Eo *obj)
4589 evas_object_hide(sd->cursor_bidi); 3397 evas_object_hide(sd->cursor_bidi);
4590 } 3398 }
4591 } 3399 }
4592 _cursor_geometry_recalc(obj); 3400 if (sd->cursor_update)
3401 {
3402 sd->cursor_update = EINA_FALSE;
3403 _cursor_geometry_recalc(obj);
3404 }
4593} 3405}
4594 3406
4595static void 3407static void
@@ -4607,7 +3419,7 @@ _clear_text_selection(Efl_Ui_Text_Data *sd)
4607static void 3419static void
4608_update_text_selection(Eo *obj, Eo *text_obj) 3420_update_text_selection(Eo *obj, Eo *text_obj)
4609{ 3421{
4610 Evas_Coord x, y; 3422 Eina_Position2D off;
4611 Efl_Text_Cursor_Cursor *sel_start, *sel_end; 3423 Efl_Text_Cursor_Cursor *sel_start, *sel_end;
4612 3424
4613 Eina_List *l; 3425 Eina_List *l;
@@ -4620,7 +3432,7 @@ _update_text_selection(Eo *obj, Eo *text_obj)
4620 if (!sd->deferred_decoration_selection) return; 3432 if (!sd->deferred_decoration_selection) return;
4621 sd->deferred_decoration_selection = EINA_FALSE; 3433 sd->deferred_decoration_selection = EINA_FALSE;
4622 3434
4623 _decoration_calc_offset(sd, &x, &y); 3435 off = _decoration_calc_offset(sd);
4624 3436
4625 efl_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end); 3437 efl_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end);
4626 3438
@@ -4647,7 +3459,7 @@ _update_text_selection(Eo *obj, Eo *text_obj)
4647 3459
4648 if (rect->obj_bg) 3460 if (rect->obj_bg)
4649 { 3461 {
4650 evas_object_move(rect->obj_bg, x + r->x, y + r->y); 3462 evas_object_move(rect->obj_bg, off.x + r->x, off.y + r->y);
4651 evas_object_resize(rect->obj_bg, r->w, r->h); 3463 evas_object_resize(rect->obj_bg, r->w, r->h);
4652 } 3464 }
4653 } 3465 }
@@ -4672,124 +3484,20 @@ _update_text_selection(Eo *obj, Eo *text_obj)
4672} 3484}
4673 3485
4674static void 3486static void
4675_item_obj_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 3487_anchors_free(Efl_Ui_Text_Data *sd)
4676{
4677 Item_Obj *io = data;
4678 Anchor *an = io->an;
4679
4680 if (!an)
4681 {
4682 ERR("Failed to free item object struct. Anchor is NULL!");
4683 return;
4684 }
4685
4686 EFL_UI_TEXT_DATA_GET(an->obj, sd);
4687 sd->item_objs = (Item_Obj *)eina_inlist_remove(EINA_INLIST_GET(sd->item_objs),
4688 EINA_INLIST_GET(io));
4689 io->an = NULL;
4690 free(io->name);
4691 free(io);
4692}
4693
4694static Evas_Object *
4695_item_obj_get(Anchor *an, Evas_Object *o, Evas_Object *smart, Evas_Object *clip)
4696{ 3488{
4697 Item_Obj *io; 3489 Anchor *an;
4698 Eo *obj = an->obj;
4699 Evas_Object *item_obj;
4700
4701 if (!an->name) return NULL;
4702
4703 EFL_UI_TEXT_DATA_GET(obj, sd);
4704
4705 EINA_INLIST_FOREACH(sd->item_objs, io)
4706 {
4707 if (!io->an && io->name && !strcmp(an->name, io->name))
4708 {
4709 io->an = an;
4710 return io->obj;
4711 }
4712 }
4713
4714 io = calloc(1, sizeof(Item_Obj));
4715
4716 item_obj = _item_get(obj, an->name);
4717 evas_object_event_callback_add(item_obj, EVAS_CALLBACK_DEL, _item_obj_del_cb, io);
4718 evas_object_smart_member_add(item_obj, smart);
4719 evas_object_stack_above(item_obj, o);
4720 evas_object_clip_set(item_obj, clip);
4721 evas_object_pass_events_set(item_obj, EINA_TRUE);
4722 evas_object_show(item_obj);
4723
4724 io->an = an;
4725 io->name = strdup(an->name);
4726 io->obj = item_obj;
4727 sd->item_objs = (Item_Obj *)eina_inlist_append(EINA_INLIST_GET(sd->item_objs),
4728 EINA_INLIST_GET(io));
4729
4730 return io->obj;
4731}
4732
4733static void
4734_unused_item_objs_free(Efl_Ui_Text_Data *sd)
4735{
4736 Item_Obj *io;
4737 Eina_Inlist *l;
4738
4739 EINA_INLIST_FOREACH_SAFE(sd->item_objs, l, io)
4740 {
4741 if (!io->an)
4742 {
4743 if (io->obj)
4744 {
4745 evas_object_event_callback_del_full(io->obj, EVAS_CALLBACK_DEL, _item_obj_del_cb, io);
4746 evas_object_del(io->obj);
4747 }
4748
4749 sd->item_objs = (Item_Obj *)eina_inlist_remove(EINA_INLIST_GET(sd->item_objs),
4750 EINA_INLIST_GET(io));
4751 free(io->name);
4752 free(io);
4753 }
4754 }
4755}
4756 3490
4757static void 3491 EINA_LIST_FREE(sd->anchors, an)
4758_anchors_clear(Eina_List **_list)
4759{
4760 Eina_List *list = *_list;
4761 while (list)
4762 { 3492 {
4763 Anchor *an = list->data; 3493 Efl_Ui_Text_Rectangle *rect;
4764 3494 EINA_LIST_FREE(an->rects, rect)
4765 while (an->sel)
4766 { 3495 {
4767 Efl_Ui_Text_Rectangle *sel = an->sel->data; 3496 free(rect);
4768 if (sel->obj_bg) evas_object_del(sel->obj_bg);
4769 if (sel->obj_fg) evas_object_del(sel->obj_fg);
4770 if (!an->item && sel->obj) evas_object_del(sel->obj);
4771 free(sel);
4772 an->sel = eina_list_remove_list(an->sel, an->sel);
4773 } 3497 }
4774 free(an->name); 3498 free(an->name);
4775 free(an); 3499 free(an);
4776 list = eina_list_remove_list(list, list);
4777 } 3500 }
4778
4779 *_list = list;
4780}
4781
4782static void
4783_anchors_clear_all(Evas_Object *o EINA_UNUSED, Efl_Ui_Text_Data *sd)
4784{
4785 Item_Obj *io;
4786
4787 _anchors_clear(&sd->anchors);
4788 _anchors_clear(&sd->item_anchors);
4789
4790 /* Detach anchors from cached objects */
4791 EINA_INLIST_FOREACH(sd->item_objs, io)
4792 io->an = NULL;
4793} 3501}
4794 3502
4795static char * 3503static char *
@@ -4833,311 +3541,232 @@ _anchor_format_parse(const char *item)
4833 return tmp; 3541 return tmp;
4834} 3542}
4835 3543
4836/* Recreates the anchors in the text. */ 3544static Anchor *
4837static void 3545_anchor_get(Eo *obj, Efl_Ui_Text_Data *sd, Efl_Text_Annotate_Annotation *an)
4838_anchors_create(Eo *obj, Efl_Ui_Text_Data *sd)
4839{ 3546{
4840 Eina_Iterator *it; 3547 Anchor *anc;
4841 Anchor *an = NULL; 3548 Eina_List *i;
4842 Efl_Text_Cursor_Cursor *start, *end; 3549 const char *str;
4843 Efl_Text_Annotate_Annotation *anchor;
4844
4845 Eo *text_obj = edje_object_part_swallow_get(sd->entry_edje, "efl.text");
4846 _anchors_clear_all(obj, sd);
4847
4848 start = efl_text_cursor_new(text_obj);
4849 end = efl_text_cursor_new(text_obj);
4850
4851 /* Retrieve all annotations in the text. */
4852 efl_text_cursor_paragraph_first(obj, start);
4853 efl_text_cursor_paragraph_last(obj, end);
4854 3550
4855 it = efl_text_range_annotations_get(obj, start, end); 3551 str = efl_text_annotation_get(obj, an);
4856 efl_text_cursor_free(text_obj, start);
4857 efl_text_cursor_free(text_obj, end);
4858 3552
4859 EINA_ITERATOR_FOREACH(it, anchor) 3553 EINA_LIST_FOREACH(sd->anchors, i, anc)
4860 { 3554 {
4861 Eina_Bool is_anchor = EINA_FALSE; 3555 if (anc->annotation == an) break;
4862 Eina_Bool is_item = EINA_FALSE; 3556 }
4863 3557
4864 if (efl_text_annotation_is_item(obj, anchor)) 3558 if (!anc && (efl_text_annotation_is_item(obj, an) || !strncmp(str, "a ", 2)))
4865 { 3559 {
4866 is_anchor = EINA_TRUE; 3560 const char *p;
4867 is_item = EINA_TRUE;
4868 }
4869 else if (!strncmp(efl_text_annotation_get(obj, anchor), "a ", 2))
4870 {
4871 is_anchor = EINA_TRUE;
4872 }
4873 3561
4874 if (is_anchor) 3562 anc = calloc(1, sizeof(Anchor));
3563 if (anc)
4875 { 3564 {
4876 const char *p; 3565 anc->obj = obj;
4877 const char *item_str = efl_text_annotation_get(obj, anchor); 3566 anc->annotation = an;
4878 3567 anc->item = efl_text_annotation_is_item(obj, an);
4879 an = calloc(1, sizeof(Anchor)); 3568 p = strstr(str, "href=");
4880 if (!an)
4881 break;
4882
4883 an->obj = obj;
4884 an->annotation = anchor;
4885 an->item = is_item;
4886 p = strstr(item_str, "href=");
4887 if (p) 3569 if (p)
4888 { 3570 {
4889 an->name = _anchor_format_parse(p); 3571 anc->name = _anchor_format_parse(p);
4890 } 3572 }
4891 sd->anchors = eina_list_append(sd->anchors, an); 3573 sd->anchors = eina_list_append(sd->anchors, anc);
4892