summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2015-08-24 11:12:05 +0300
committerDaniel Hirt <daniel.hirt@samsung.com>2015-08-24 11:12:05 +0300
commitc548079e02299b8b186f14d71c3b095199be93d7 (patch)
tree622fa147b7022e9dc413750cbc63f408a8c73019
parent513d988c7d3b611b2c77d167ac4d69039d023e4f (diff)
Enhance Paragraph Decoration
-rw-r--r--src/lib/eo_preload.c216
1 files changed, 156 insertions, 60 deletions
diff --git a/src/lib/eo_preload.c b/src/lib/eo_preload.c
index 9615c87..59494cd 100644
--- a/src/lib/eo_preload.c
+++ b/src/lib/eo_preload.c
@@ -140,6 +140,8 @@ EAPI Eina_List *
140_evas_textblock_par_rects_get(const Evas_Object *obj); 140_evas_textblock_par_rects_get(const Evas_Object *obj);
141EAPI Eina_List * 141EAPI Eina_List *
142_evas_textblock_items_get(const Evas_Object *obj); 142_evas_textblock_items_get(const Evas_Object *obj);
143EAPI Eina_List *
144_evas_textblock_paragraphs_get(const Evas_Object *obj);
143 145
144static Evas_Object * 146static Evas_Object *
145_elm_parent_get(Evas_Object *obj) 147_elm_parent_get(Evas_Object *obj)
@@ -155,16 +157,6 @@ _elm_parent_get(Evas_Object *obj)
155} 157}
156 158
157/******** Tooltip *********/ 159/******** Tooltip *********/
158typedef struct
159{
160 int idx;
161 Evas_Coord x, y, w, h;
162 Evas_Textblock_Item_Type type;
163 Evas_Script_Type script;
164 Eina_Rectangle *rect;
165 Eina_Bool is_rtl : 1;
166} Textblock_Item_Debug_Data;
167
168int g_idx = 0; 160int g_idx = 0;
169Evas_Object *g_label = NULL; 161Evas_Object *g_label = NULL;
170 162
@@ -188,6 +180,62 @@ _entry_tooltip_content_cb(void *data EINA_UNUSED,
188 return g_label; 180 return g_label;
189} 181}
190 182
183/* Textblock Decorate */
184static void
185_textblock_handle_mouse_in(void *data)
186{
187 printf("Handle Textblock in\n");
188 Debug_Rect *r = data;
189 char buf[1024];
190 Debug_Decorate *dec = data;
191 Evas_Object *tb;
192 Evas_Coord ox, oy;
193
194 /* Print to the buf */
195 tb = elm_entry_textblock_get(r->dec->obj);
196 evas_object_geometry_get(tb, &ox, &oy, NULL, NULL);
197 sprintf(buf, "Entry %p<ps>"
198 "Position: (%d,%d)",
199 r->dec->obj, ox, oy);
200 INF("-- Setting text: %s", buf);
201 if (g_label)
202 {
203 elm_object_part_text_set(g_label, "elm.text", buf);
204 }
205}
206
207static Eina_Bool
208_textblock_mouse_in_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
209{
210 printf("Textblock mouse_in\n");
211 /* When entering (back to) the textblock, clear stack */
212 while(g_in_stack)
213 {
214 In_Stack_Item *tmp = g_in_stack;
215 g_in_stack = (In_Stack_Item *) eina_inlist_remove(EINA_INLIST_GET(g_in_stack),
216 EINA_INLIST_GET(g_in_stack));
217 free(tmp);
218 }
219 _in_stack_push(&g_in_stack, obj, data, _textblock_handle_mouse_in);
220 _textblock_handle_mouse_in(data);
221 return EINA_TRUE;
222}
223
224
225/* Item Decorate */
226typedef struct _Textblock_Item_Debug_Data Textblock_Item_Debug_Data;
227
228struct _Textblock_Item_Debug_Data
229{
230 int idx;
231 Evas_Coord x, y, w, h;
232 Evas_Textblock_Item_Type type;
233 Evas_Script_Type script;
234 Eina_Rectangle *rect;
235 int bidi_level;
236 Eina_Bool is_rtl : 1;
237};
238
191static void 239static void
192_handle_item_in(void *data) 240_handle_item_in(void *data)
193{ 241{
@@ -201,11 +249,12 @@ _handle_item_in(void *data)
201 sprintf(buf, 249 sprintf(buf,
202 "Text Item %d<ps>" 250 "Text Item %d<ps>"
203 "Coords: (%d,%d), Size: %dx%d<ps>" 251 "Coords: (%d,%d), Size: %dx%d<ps>"
204 "Dir: %s, Script: %s", 252 "Dir: %s, Script: %s, Bidi_level: %d",
205 d->idx, 253 d->idx,
206 d->x, d->y, d->w, d->h, 254 d->x, d->y, d->w, d->h,
207 (d->is_rtl ? "RTL" : "LTR"), 255 (d->is_rtl ? "RTL" : "LTR"),
208 evas_scripts[d->script]); 256 evas_scripts[d->script],
257 d->bidi_level);
209 } 258 }
210 else 259 else
211 { 260 {
@@ -222,23 +271,56 @@ _handle_item_in(void *data)
222 } 271 }
223} 272}
224 273
274static Eina_Bool
275_item_mouse_in(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
276{
277 if (!g_in_stack || (g_in_stack->obj != obj))
278 {
279 printf("Item mouse_in\n");
280 _in_stack_push(&g_in_stack, obj, data, _handle_item_in);
281 _handle_item_in(data);
282 }
283 return EINA_TRUE;
284}
285
286static Eina_Bool
287_item_mouse_out(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
288{
289 printf("Item mouse_out\n");
290 _in_stack_pop(&g_in_stack, obj);
291 if (g_in_stack)
292 {
293 g_in_stack->func(g_in_stack->data);
294 }
295
296 return EINA_TRUE;
297}
298
299/* Paragraphs Decorate */
300typedef struct
301{
302 int idx;
303 int lines;
304 Evas_Coord x, y, w, h;
305 Eina_Rectangle *rect;
306 Eina_Bool is_rtl : 1;
307} Textblock_Paragraph_Debug_Data;
308
225static void 309static void
226_textblock_handle_mouse_in(void *data) 310_handle_paragraph_in(void *data)
227{ 311{
228 printf("Handle Textblock in\n");
229 Debug_Rect *r = data;
230 char buf[1024]; 312 char buf[1024];
231 Debug_Decorate *dec = data; 313 Debug_Rect *r = data;
232 Evas_Object *tb; 314 Textblock_Paragraph_Debug_Data *d = r->src_data;
233 Evas_Coord ox, oy; 315
234 316 sprintf(buf,
235 /* Print to the buf */ 317 "Paragraph %d<ps>"
236 tb = elm_entry_textblock_get(r->dec->obj); 318 "Coords: (%d,%d) Size: %dx%d<ps>"
237 evas_object_geometry_get(tb, &ox, &oy, NULL, NULL); 319 "Lines: %d",
238 sprintf(buf, "Entry %p<ps>" 320 d->idx,
239 "Position: (%d,%d)", 321 d->x, d->y, d->w, d->h,
240 r->dec->obj, ox, oy); 322 d->lines);
241 INF("-- Setting text: %s", buf); 323 INF(" -- Setting text: %s", buf);
242 if (g_label) 324 if (g_label)
243 { 325 {
244 elm_object_part_text_set(g_label, "elm.text", buf); 326 elm_object_part_text_set(g_label, "elm.text", buf);
@@ -246,21 +328,21 @@ _textblock_handle_mouse_in(void *data)
246} 328}
247 329
248static Eina_Bool 330static Eina_Bool
249_item_mouse_in(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) 331_paragraph_mouse_in(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
250{ 332{
251 if (!g_in_stack || (g_in_stack->obj != obj)) 333 if (!g_in_stack || (g_in_stack->obj != obj))
252 { 334 {
253 printf("Item mouse_in\n"); 335 printf("Paragraph mouse_in\n");
254 _in_stack_push(&g_in_stack, obj, data, _handle_item_in); 336 _in_stack_push(&g_in_stack, obj, data, _handle_paragraph_in);
255 _handle_item_in(data); 337 _handle_paragraph_in(data);
256 } 338 }
257 return EINA_TRUE; 339 return EINA_TRUE;
258} 340}
259 341
260static Eina_Bool 342static Eina_Bool
261_item_mouse_out(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) 343_paragraph_mouse_out(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
262{ 344{
263 printf("Item mouse_out\n"); 345 printf("paragraph mouse_out\n");
264 _in_stack_pop(&g_in_stack, obj); 346 _in_stack_pop(&g_in_stack, obj);
265 if (g_in_stack) 347 if (g_in_stack)
266 { 348 {
@@ -269,6 +351,45 @@ _item_mouse_out(void *data, Eo *obj, const Eo_Event_Description *desc, void *eve
269 351
270 return EINA_TRUE; 352 return EINA_TRUE;
271} 353}
354static void
355_textblock_populate_paragraphs(Evas_Object *tb, Debug_Decorate *dec)
356{
357 Eina_List *rects;
358 Textblock_Paragraph_Debug_Data *d;
359 Evas_Coord tx, ty;
360 evas_object_geometry_get(tb, &tx, &ty, NULL, NULL);
361 Evas_Coord ex, ey;
362 ex = ey = 0;
363 //evas_object_geometry_get(dec->obj, &ex, &ey, NULL, NULL);
364 INF("Entry position (%d,%d)", ex, ey);
365 Evas_Coord sl;
366 eo_do(tb, evas_obj_textblock_style_insets_get(&sl, NULL, NULL, NULL));
367 INF("Left inset: %d", sl);
368
369 /* Decorate Items */
370 rects = _evas_textblock_paragraphs_get(tb);
371 EINA_LIST_FREE(rects, d)
372 {
373 Debug_Rect *r = malloc(sizeof(Debug_Rect));
374 Rect_Color c = colors[color_idx];
375 CYCLE_ARR(colors, color_idx);
376
377 r->obj = evas_object_rectangle_add(tb);
378 r->src_data = d;
379 r->dec = dec;
380 evas_object_repeat_events_set(r->obj, EINA_TRUE);
381 eo_do(r->obj, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_IN, _paragraph_mouse_in, r));
382 eo_do(r->obj, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_OUT, _paragraph_mouse_out, r));
383 evas_object_color_set(r->obj, c.r, c.g, c.b, c.a);
384 evas_object_resize(r->obj, d->rect->w, d->rect->h);
385 evas_object_move(r->obj, tx + ex + sl + d->rect->x, ty + d->rect->y);
386 dec->rects = (Debug_Rect *)eina_inlist_append(
387 EINA_INLIST_GET(dec->rects),
388 EINA_INLIST_GET(r));
389 evas_object_show(r->obj);
390 eina_rectangle_free(d->rect);
391 }
392}
272 393
273static void 394static void
274_textblock_populate_items(Evas_Object *tb, Debug_Decorate *dec) 395_textblock_populate_items(Evas_Object *tb, Debug_Decorate *dec)
@@ -278,7 +399,8 @@ _textblock_populate_items(Evas_Object *tb, Debug_Decorate *dec)
278 Evas_Coord tx, ty; 399 Evas_Coord tx, ty;
279 evas_object_geometry_get(tb, &tx, &ty, NULL, NULL); 400 evas_object_geometry_get(tb, &tx, &ty, NULL, NULL);
280 Evas_Coord ex, ey; 401 Evas_Coord ex, ey;
281 evas_object_geometry_get(dec->obj, &ex, &ey, NULL, NULL); 402 ex = ey = 0;
403 //evas_object_geometry_get(dec->obj, &ex, &ey, NULL, NULL);
282 INF("Entry position (%d,%d)", ex, ey); 404 INF("Entry position (%d,%d)", ex, ey);
283 Evas_Coord sl; 405 Evas_Coord sl;
284 eo_do(tb, evas_obj_textblock_style_insets_get(&sl, NULL, NULL, NULL)); 406 eo_do(tb, evas_obj_textblock_style_insets_get(&sl, NULL, NULL, NULL));
@@ -311,33 +433,6 @@ _textblock_populate_items(Evas_Object *tb, Debug_Decorate *dec)
311} 433}
312 434
313static Eina_Bool 435static Eina_Bool
314_textblock_mouse_in_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
315{
316 printf("Textblock mouse_in\n");
317#if 0
318 if (!g_in_stack || (g_in_stack->obj != obj))
319 {
320 printf("Textblock in\n");
321
322 _in_stack_push(&g_in_stack, obj, data, _textblock_handle_mouse_in);
323 _textblock_handle_mouse_in(data);
324 }
325#else
326 /* When entering (back to) the textblock, clear stack */
327 while(g_in_stack)
328 {
329 In_Stack_Item *tmp = g_in_stack;
330 g_in_stack = (In_Stack_Item *) eina_inlist_remove(EINA_INLIST_GET(g_in_stack),
331 EINA_INLIST_GET(g_in_stack));
332 free(tmp);
333 }
334 _in_stack_push(&g_in_stack, obj, data, _textblock_handle_mouse_in);
335 _textblock_handle_mouse_in(data);
336#endif
337 return EINA_TRUE;
338}
339
340static Eina_Bool
341_textblock_mouse_out_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) 436_textblock_mouse_out_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
342{ 437{
343 printf("Textblock out\n"); 438 printf("Textblock out\n");
@@ -377,6 +472,7 @@ _textblock_rects_populate(Evas_Object *tb, Debug_Decorate *dec)
377 * for in/out events to function like indented in this 472 * for in/out events to function like indented in this
378 * tool */ 473 * tool */
379 _textblock_bg_add(tb, dec); 474 _textblock_bg_add(tb, dec);
475 _textblock_populate_paragraphs(tb, dec);
380 _textblock_populate_items(tb, dec); 476 _textblock_populate_items(tb, dec);
381} 477}
382 478