summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_textblock.c
diff options
context:
space:
mode:
authorSubodhKumar <s7158.kumar@samsung.com>2018-09-17 00:28:22 +0300
committerDaniel Hirt <hirt.danny@gmail.com>2018-09-17 17:38:24 +0300
commitf107ea24325c66ce5a2fcb7beb3947ebe77c66ef (patch)
treeefac5a4b68090007fa19df413096f03bcb05a644 /src/lib/edje/edje_textblock.c
parent70d0fd0d52f4deac18132cc80672aab6d31bb06f (diff)
edje: Remove hack code
Summary: special calculation for textblock is for fit calculation. This is obvious from code that fit is being calculated before text is actually been set to textblock. I am not sure whether this is intentional or mistake but it make sense to calculate fit after text is being set so that formatted and native calculation can be proper. @fix Test Plan: NA Reviewers: cedric, zmike, herdsman, devilhorns Subscribers: stefan_schmidt, #reviewers, #committers, shilpasingh Tags: #efl Differential Revision: https://phab.enlightenment.org/D6045
Diffstat (limited to '')
-rw-r--r--src/lib/edje/edje_textblock.c167
1 files changed, 73 insertions, 94 deletions
diff --git a/src/lib/edje/edje_textblock.c b/src/lib/edje/edje_textblock.c
index 312238735c..6786b0d91a 100644
--- a/src/lib/edje/edje_textblock.c
+++ b/src/lib/edje/edje_textblock.c
@@ -460,92 +460,92 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
460 if (ep->part->scale) 460 if (ep->part->scale)
461 evas_object_scale_set(ep->object, TO_DOUBLE(sc)); 461 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
462 462
463 if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y)) 463 if (stl)
464 { 464 {
465 double base_s = 1.0; 465 if (evas_object_textblock_style_get(ep->object) != stl->style)
466 double orig_s; 466 evas_object_textblock_style_set(ep->object, stl->style);
467 double s = base_s; 467 // FIXME: need to account for editing
468 468 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
469 if (ep->part->scale) base_s = TO_DOUBLE(sc);
470 efl_gfx_entity_scale_set(ep->object, base_s);
471 efl_canvas_text_size_native_get(ep->object, &tw, &th);
472
473 orig_s = base_s;
474 /* Now make it bigger so calculations will be more accurate
475 * and less influenced by hinting... */
476 {
477 orig_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
478 orig_s * TO_INT(params->eval.w) / tw);
479 efl_gfx_entity_scale_set(ep->object, orig_s);
480 efl_canvas_text_size_native_get(ep->object, &tw, &th);
481 }
482 if (chosen_desc->text.fit_x)
483 { 469 {
484 if (tw > 0) 470 // do nothing - should be done elsewhere
485 { 471 }
486 s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, 472 else
487 orig_s * TO_INT(params->eval.w) / tw); 473 {
488 efl_gfx_entity_scale_set(ep->object, s); 474 evas_object_textblock_text_markup_set(ep->object, text);
489 efl_canvas_text_size_native_get(ep->object, NULL, NULL);
490 }
491 } 475 }
492 if (chosen_desc->text.fit_y) 476
477 if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
493 { 478 {
494 if (th > 0) 479 double base_s = 1.0;
480 double orig_s;
481 double s = base_s;
482
483 if (ep->part->scale) base_s = TO_DOUBLE(sc);
484 efl_gfx_entity_scale_set(ep->object, base_s);
485 efl_canvas_text_size_native_get(ep->object, &tw, &th);
486
487 orig_s = base_s;
488 /* Now make it bigger so calculations will be more accurate
489 * and less influenced by hinting... */
490 {
491 orig_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
492 orig_s * TO_INT(params->eval.w) / tw);
493 efl_gfx_entity_scale_set(ep->object, orig_s);
494 efl_canvas_text_size_native_get(ep->object, &tw, &th);
495 }
496 if (chosen_desc->text.fit_x)
495 { 497 {
496 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, 498 if (tw > 0)
497 orig_s * TO_INT(params->eval.h) / th);
498 /* If we already have X fit, restrict Y to be no bigger
499 * than what we got with X. */
500 if (!((chosen_desc->text.fit_x) && (tmp_s > s)))
501 { 499 {
502 s = tmp_s; 500 s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
501 orig_s * TO_INT(params->eval.w) / tw);
502 efl_gfx_entity_scale_set(ep->object, s);
503 efl_canvas_text_size_native_get(ep->object, NULL, NULL);
503 } 504 }
505 }
506 if (chosen_desc->text.fit_y)
507 {
508 if (th > 0)
509 {
510 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
511 orig_s * TO_INT(params->eval.h) / th);
512 /* If we already have X fit, restrict Y to be no bigger
513 * than what we got with X. */
514 if (!((chosen_desc->text.fit_x) && (tmp_s > s)))
515 {
516 s = tmp_s;
517 }
504 518
505 efl_gfx_entity_scale_set(ep->object, s); 519 efl_gfx_entity_scale_set(ep->object, s);
506 efl_canvas_text_size_native_get(ep->object, NULL, NULL); 520 efl_canvas_text_size_native_get(ep->object, NULL, NULL);
521 }
507 } 522 }
508 }
509 523
510 /* Final tuning, try going down 90% at a time, hoping it'll 524 /* Final tuning, try going down 90% at a time, hoping it'll
511 * actually end up being correct. */ 525 * actually end up being correct. */
512 {
513 int i = 5; /* Tries before we give up. */
514 Evas_Coord fw, fh;
515 efl_canvas_text_size_native_get(ep->object, &fw, &fh);
516
517 /* If we are still too big, try reducing the size to
518 * 95% each try. */
519 while ((i > 0) &&
520 ((chosen_desc->text.fit_x && (fw > TO_INT(params->eval.w))) ||
521 (chosen_desc->text.fit_y && (fh > TO_INT(params->eval.h)))))
522 { 526 {
523 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, s * 0.95); 527 int i = 5; /* Tries before we give up. */
524 528 Evas_Coord fw, fh;
525 /* Break if we are not making any progress. */
526 if (EQ(tmp_s, s))
527 break;
528 s = tmp_s;
529
530 efl_gfx_entity_scale_set(ep->object, s);
531 efl_canvas_text_size_native_get(ep->object, &fw, &fh); 529 efl_canvas_text_size_native_get(ep->object, &fw, &fh);
532 i--;
533 }
534 }
535 }
536 530
537 if (stl) 531 /* If we are still too big, try reducing the size to
538 { 532 * 95% each try. */
539 if (evas_object_textblock_style_get(ep->object) != stl->style) 533 while ((i > 0) &&
540 evas_object_textblock_style_set(ep->object, stl->style); 534 ((chosen_desc->text.fit_x && (fw > TO_INT(params->eval.w))) ||
541 // FIXME: need to account for editing 535 (chosen_desc->text.fit_y && (fh > TO_INT(params->eval.h)))))
542 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) 536 {
543 { 537 double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, s * 0.95);
544 // do nothing - should be done elsewhere 538
545 } 539 /* Break if we are not making any progress. */
546 else 540 if (EQ(tmp_s, s))
547 { 541 break;
548 evas_object_textblock_text_markup_set(ep->object, text); 542 s = tmp_s;
543
544 efl_gfx_entity_scale_set(ep->object, s);
545 efl_canvas_text_size_native_get(ep->object, &fw, &fh);
546 i--;
547 }
548 }
549 } 549 }
550 550
551 if ((ed->file->efl_version.major >= 1) && (ed->file->efl_version.minor >= 19)) 551 if ((ed->file->efl_version.major >= 1) && (ed->file->efl_version.minor >= 19))
@@ -569,24 +569,3 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
569 evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y)); 569 evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y));
570 } 570 }
571} 571}
572
573void
574_edje_textblock_recalc_apply(Edje *ed, Edje_Real_Part *ep,
575 Edje_Calc_Params *params,
576 Edje_Part_Description_Text *chosen_desc)
577{
578 /* FIXME: this is just an hack. */
579 FLOAT_T sc;
580
581#if 0
582 _get_text(ep);
583#endif
584
585 sc = DIV(ed->scale, ed->file->base_scale);
586 if (EQ(sc, ZERO)) sc = DIV(_edje_scale, ed->file->base_scale);
587 if (chosen_desc->text.fit_x || chosen_desc->text.fit_y)
588 {
589 _edje_part_recalc_single_textblock(sc, ed, ep, chosen_desc, params,
590 NULL, NULL, NULL, NULL);
591 }
592}