Page MenuHomePhabricator

Text interface: Finalize Efl.Ui.Text API
Open, TODOPublic

Description

This ticket includes introductory of the changes made for text implementation in Efl.Ui.Text (formerly Elm.Entry, Elm.Label).
It serves as a discussion point for all developers and users.

NOTE: Discussion status: OPEN

Overview

Efl.Ui.Text.Interactive (interface)

Inheritance:

Efl.Text

Efl.Ui.Internal.Text.Interactive (class)

Inheritance:

Efl.Canvas.Text

Efl.Ui.Text (class)

Replaces both Elm.Entry and Elm.Label

Inheritance:

Elm.Layout
Elm.Layout.Interface.Scrollable (mixin)

Composition:

Efl.Ui.Internal.Text.Interactive (composite)

Implements:

Efl.Ui.Text_Interactive (via composition)

Usage

Instantiating the object:

// Create a simple label object
Eo *ui_text = efl_add(EFL_UI_TEXT_CLASS, parent);

// Enable user interaction (cursor)
efl_ui_text_interactive_editable_set(ui_text, EINA_TRUE);
// Enable scrolling
efl_ui_text_scrollable_set(ui_text, EINA_TRUE);
// Set a text
efl_text_set(ui_text, "Hello world");

Using formatting API directly on an Efl.Ui.Text object

/* Applying formatting */

Efl_Canvas_Text_Annotation *an, *an2;

// Get cursor to mark a range
Eo *start, *end;
start = efl_canvas_text_cursor_get(ui_text);
end = efl_ui_text_cursor_new(ui_text);

// Applying a format (yellow and bold) to "Hello"
efl_canvas_text_cursor_position_set(start, 0);
efl_canvas_text_cursor_position_set(end, 5);
// Insert formatting instructions in the text, getting back an "annotation" handle for the affected range
an = efl_canvas_text_annotation_insert(ui_text, start, end, "color=#ff0 font_weight=bold");

// Applying a format to "lO Wor"
efl_canvas_text_cursor_position_set(start, 3);
efl_canvas_text_cursor_position_set(end, 9);
an2 = efl_canvas_text_annotation_insert(ui_text, start, end, "font_size=16");

// Replace the first annotation of "Hello" (to red and underlined)
efl_canvas_text_annotation_set(ui_text, an, "color=#f00 underline=on underline_color=#f00");

// Delete the second annotation
efl_canvas_text_annotation_del(ui_text, an2);
IMPORTANT: efl_canvas_text_cursor_new and efl_ui_text_cursor_new should probably be unified under a new Efl.Text.Cursor interface.
herdsman created this task.Apr 27 2017, 6:24 AM
herdsman created this object with visibility "Task Author".
herdsman created this object with edit policy "Task Author".
herdsman updated the task description. (Show Details)Apr 30 2017, 4:24 AM
herdsman updated the task description. (Show Details)May 3 2017, 1:49 AM
herdsman changed the visibility from "Task Author" to "All Users".
herdsman changed the edit policy from "Task Author" to "All Users".
herdsman changed the visibility from "All Users" to "Public (No Login Required)".
id213sin added a subscriber: id213sin.EditedJul 7 2017, 2:40 AM

@herdsman
I'm looking into text interface.
I want to suggest few things. Please, check the following things.

  1. efl_text_font.eo A. There is no style set/get. It needs to set font with its style string. B. Font size should be provided in pt, px, dp. For this, we need to provide APIs for handling DPI.
  1. efl_text_cursor.eo A. Cursor ligature handle is needed. For supporting international languages. B. Cursor should be controlled with geometry. It also need to efl_ui_text*.

If I have additional opinions, I'll share opinions here. :)

Hi @id213sin,
Thanks for giving this a review.
Regarding your comments:

  1. As requested, I added Efl.Text.Style, Efl.Text.Font and Efl.Text.Format interfaces so you'd be able to set properties globally on the text object.

This essentially leaves usage of "style strings" out of the final API.
As an example, instead of doing:

efl_canvas_text_style_set(obj, NULL, "DEFAULT='font=Sans font_size=14 color=#fff'");

You would do the following:

efl_text_font_set(obj, "Sans", 14);
efl_text_normal_color_set(obj, 255, 255, 255);
  1. Please elaborate on the requirements of a ligature handle.
  1. cursor_coord_set and other cursor API are part of the Efl.Text.Cursor interface. Efl.Ui.Text implements them (via composition).

Appreciate the feedback.

@herdsman
Sorry, I think my previous comment was too simple to explain each items. :(

  1. As requested, I added Efl.Text.Style, Efl.Text.Font and Efl.Text.Format interfaces so you'd be able to set properties globally on the text object.

I didn't talk about "Efl.Text.Style". I wanted to add "Efl.Text.Font.font_style".
As you know, I submitted a patch to give style string to Fontconfig.

// evas_font_dir.c:807
if (fdesc->style)
    FcPatternAddString (p_nm, FC_STYLE, (FcChar8*) fdesc->style);

The "style" keyword was misused before the patch. It is a separated property of font. So, I think we need to add a method for it.

B. Font size should be provided in pt, px, dp. For this, we need to provide APIs for handling DPI.

EFL support font size without "unit". Currently, "font_size" supports "px" unit.
There is some consideration for DPI of font, but no API to public for this. (pt, dp is based on DPI)
So, currently, we don't supporting pt, dp units.
This was too poor text interface for modern age. We need to support other font size units.

  1. Please elaborate on the requirements of a ligature handle.

We support "ligature" based(?) languages from many of international products.
Normally, once a ligature is made, platform does not allow to put cursor between the ligature.
There are characters only for ligature (combination with other characters) and it shouldn't be appear alone in input field.
But, there is no consideration for ligature in EFL and EFL allows to put cursor anywhere.
It is really bad user experience. And almost every platforms care about this. (MS office, MS Windows, Gedit, browers ...)
It should be supported.

  1. cursor_coord_set and other cursor API are part of the Efl.Text.Cursor interface. Efl.Ui.Text implements them (via composition).

That sounds great! :) Actually, it is related to D4324.

Thank you for comments for my feedback.
I'll check text interfaces more and give more feedback to you. :)

  1. Fc font style - please elaborate on the usage and reference the related commits here, please.
  1. "Size units" - again, need to elaborate on a separate ticket. Please, elaborate in that new ticket before we go to implementing this.
  1. You might be meaning "grapheme" and NOT "ligature". It is OK to traverse a ligature's characters like "ff".

Anyway, the grapheme logic shouldn't require an API. It is a basic Unicode compliance, and we should always have this enabled.
If this seems sensible, please open a new ticket for a feature request, and let's discuss there.

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, 9:00 AM