Page MenuHomePhabricator

Finalize Efl.Canvas.Text API
Closed, ResolvedPublic

Description

This ticket includes introductory of the changes made for text implementation in Efl.Canvas (formerly Evas Canvas).
It serves as a discussion point for all developers and users.

NOTE: Discussion status: OPEN

Efl.Canvas.Text.Cursor

Legacy code examples:

evas_textblock_cursor_next(cur);
evas_textblock_cursor_compare(cur1, cur1);

The Efl.Canvas.Text.Cursor was introduced.
Current API examples:

efl_canvas_text_cursor_next(cur);
efl_canvas_text_cursor(compare);

Annotations

Annotations wraps around and simplifies formatting of ranges ([start, end] indices) in the text.
Instead of inserting markup tags (read ahead for the future of markups tags), the user places start and end cursors and sets a formatting ("annotation") on the resultant range.

Efl_Canvas_Text_Cursor *start, *end;
Efl_Canvas_Text_Annoation *an;

efl_canvas_text_cursor_position_set(start, 0);
efl_canvas_text_cursor_position_set(end, 5);
// Insert formatting instructions in the text from position 0 to 4, getting back an "annotation handle" for the affected range
an = efl_canvas_text_annotation_insert(text_obj, start, end, "color=#ff0 font_weight=bold");

Current API examples:

efl_canvas_text_annotation_insert(obj, start_cur, end_cur, "font_weight=bold");

Deprecation of markups

Efl.Canvas.Text will not support inline tags (markup). Instead, it will sets formats using Efl.Canvas.Text.Annotation API.
A Markup language can then be implemented at a higher level (Efl.Ui), utilizing the Annotation API.
This is in effort to make Efl.Canvas.Text simple to use.

Note that formatting is not deprecated, as we need to implement this at Evas level.
There are two ways to format the text:

  • Efl.Canvas.Text.style_{set, get} // using the 'DEFAULT' keyword to set a global style/format on the object
  • Efl.Canvas.Text.annotation_{insert, del} // set a format on a specific range in the text
herdsman created this task.May 3 2017, 1:47 AM
herdsman updated the task description. (Show Details)May 3 2017, 1:50 AM
woohyun added a subscriber: woohyun.May 3 2017, 7:00 PM

Hello. :)

I think Efl.Canvas.Text.style_{set, get} is not something easy to use.
And, it's rellay hard to know whether the style is applied well,
because there is no compile error about wrong style setting.

This style setting can be changed to various property set/get APIs.
Such as, the APIs for ellipsis, font, font_color, font_size, align, valign, .... etc.

With OOP languages, we can easily use Efl.Canvas.Text Class with -
Efl.Canvas.Text textObject = new Efl.Canvas.Text();
textObject.setEllipsis = true;
textObject.setFontSize = 34;
....

How do you think about this ?

We can drop style_{set, get} in favor of API.
However, I need someone to comment on style_user_push, as it currently uses this function (styles can be "push" and "pop" from the stack.

Personally, I prefer your suggestion.

I think - style_user_push/pop is nothing but set of style properties.
That is, it's only used for defining current textblock's properties.
We can make a good parser which will interpret the style statement to the textblock properties.
(I think there has already been similar function for that)

So, my conclusion is, we should go with text properties (not styles) for making developing be easy :)

style_{set, get} can remain in legacy.

Regarding to where we define the font properties (font, size): we currently have "Text Classes" support built in EDC.
I was not aware of its functionality until just recently.
Anyway, you are able to define "global text classes" in the EDC, in the following manner:

text_classes {
   text_class { name: "efl_ui_text";
      font: "Sans";
      size: 10;
   }
}

I prefer if we don't create another specification sheet for us to parse, and instead make use of the above at the widget level:

  • Read the text class for "efl_ui_text"
  • Set the Efl.Font.Properties on Efl.Canvas.Text using the respective Text Class.

From experimenting with the text class logic, it will require a bit of modification to extend its operation beyond supporting the built-in TEXTBLOCK parts.
If we go this path, I suggest involving its original developer.

herdsman added a comment.EditedMay 9 2017, 8:58 AM

@woohyun, I managed to use on the text classes defined at the file-scope (global scope in the .edc - as the example given in my previous reply).
Note that it required a small modification for edje/elm internals, so elm_config changes are reflected for the app without requiring a restart.

Let me know what you think.

Description needs update now that T5493: Efl.Canvas.Text: replace 'style' with actual API is in, once namespace issue is fixed.

zmike added a project: efl.Aug 22 2017, 3:37 PM
bu5hm4n added a project: Restricted Project.Jun 11 2018, 2:53 AM
zmike edited projects, added Restricted Project; removed efl.Jun 11 2018, 6:57 AM
bu5hm4n edited projects, added efl: layout engine, efl: widgets, Restricted Project; removed Restricted Project, Restricted Project.Jun 11 2018, 8:59 AM
herdsman closed this task as Resolved.Dec 21 2018, 1:19 AM