diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 4c65a7920e..b584ca3892 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -20,6 +20,7 @@ efl_eolian_files = \ lib/efl/interfaces/efl_text_style.eo \ lib/efl/interfaces/efl_text_format.eo \ lib/efl/interfaces/efl_text_cursor.eo \ + lib/efl/interfaces/efl_text_annotate.eo \ lib/efl/interfaces/efl_text_properties.eo \ lib/efl/interfaces/efl_gfx_stack.eo \ lib/efl/interfaces/efl_gfx_view.eo \ diff --git a/src/bin/elementary/test_efl_ui_text.c b/src/bin/elementary/test_efl_ui_text.c index ba8870e25d..99c23a5c34 100644 --- a/src/bin/elementary/test_efl_ui_text.c +++ b/src/bin/elementary/test_efl_ui_text.c @@ -17,7 +17,7 @@ _apply_style(Eo *obj, size_t start_pos, size_t end_pos, const char *style) efl_text_cursor_position_set(obj, start, start_pos); efl_text_cursor_position_set(obj, end, end_pos); - efl_canvas_text_annotation_insert(obj, start, end, style); + efl_text_annotation_insert(obj, start, end, style); efl_text_cursor_free(obj, start); efl_text_cursor_free(obj, end); @@ -114,7 +114,7 @@ static void my_efl_ui_text_bt_4(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { Evas_Object *en = data; - efl_canvas_text_cursor_object_item_insert(en, efl_text_cursor_get(en), + efl_text_cursor_object_item_insert(en, efl_text_cursor_get(en), "size=32x32 href=emoticon"); } @@ -185,14 +185,14 @@ test_efl_ui_text(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve cur = efl_text_cursor_new(en); efl_text_cursor_position_set(en, cur, 2); - efl_canvas_text_cursor_object_item_insert(en, cur, "size=32x32 href=emoticon"); + efl_text_cursor_object_item_insert(en, cur, "size=32x32 href=emoticon"); efl_text_cursor_position_set(en, cur, 50); - efl_canvas_text_cursor_object_item_insert(en, cur, "size=32x32 href=emoticon"); + efl_text_cursor_object_item_insert(en, cur, "size=32x32 href=emoticon"); efl_text_cursor_position_set(en, main_cur, 5); efl_text_cursor_position_set(en, cur, 20); - efl_canvas_text_annotation_insert(en, main_cur, cur, "a href=#hello"); + efl_text_annotation_insert(en, main_cur, cur, "a href=#hello"); efl_ui_text_interactive_editable_set(en, EINA_TRUE); efl_ui_text_scrollable_set(en, EINA_TRUE); diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index eb06539b41..8730bd643a 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -152,6 +152,7 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; #include "interfaces/efl_text_style.eo.h" #include "interfaces/efl_text_format.eo.h" #include "interfaces/efl_text_cursor.eo.h" +#include "interfaces/efl_text_annotate.eo.h" #else diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 0b977a589f..9ea0cd2dd5 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -18,6 +18,7 @@ #include "interfaces/efl_text_style.eo.c" #include "interfaces/efl_text_format.eo.c" #include "interfaces/efl_text_cursor.eo.c" +#include "interfaces/efl_text_annotate.eo.c" #include "interfaces/efl_gfx.eo.c" #include "interfaces/efl_gfx_buffer.eo.c" diff --git a/src/lib/efl/interfaces/efl_text_annotate.eo b/src/lib/efl/interfaces/efl_text_annotate.eo new file mode 100644 index 0000000000..dec3dbae76 --- /dev/null +++ b/src/lib/efl/interfaces/efl_text_annotate.eo @@ -0,0 +1,146 @@ +import eina_types; +import efl_text_types; + +interface Efl.Text.Annotate { + [[Cursor API + + @since 1.20 + ]] + eo_prefix: efl_text; + methods { + // Annotation + @property annotation { + [[A new format for $annotation. + + This will replace the format applied by $annotation with $format. + Assumes that $annotation is a handle for an existing annotation, + i.e. one that was added using @.annotation_insert to this object. + Otherwise, this will fail and return $false. + + @since 1.18 + ]] + set { + legacy: null; + return: bool; [[$true on success, $false otherwise.]] + } + get { + legacy: null; + } + keys { + annotation: ptr(Efl.Canvas.Text.Annotation); [[Given annotation]] + } + values { + format: string; [[The new format for the given annotation]] + } + } + range_annotations_get { + [[Returns an iterator of all the handles in a range. + + @since 1.18 + ]] + legacy: null; + params { + @in start: ptr(const(Efl.Text.Cursor.Cursor_Data)); [[Start of range]] + @in end: ptr(const(Efl.Text.Cursor.Cursor_Data)); [[End of range]] + } + return: free(own(iterator), + eina_iterator_free); [[Handle of the Annotation]] + } + annotation_insert { + [[Inserts an annotation format in a specified range [$start, $end - 1]. + + The $format will be applied to the given range, and the $annotation + handle will be returned for further handling. + + @since 1.18 + ]] + legacy: null; + params { + @in start: ptr(Efl.Text.Cursor.Cursor_Data); [[Start of range]] + @in end: ptr(Efl.Text.Cursor.Cursor_Data); [[End of range]] + @in format: string; [[Annotation format]] + } + return: ptr(Efl.Canvas.Text.Annotation); [[Handle of inserted annotation]] + } + annotation_del { + [[Deletes given annotation. + + All formats applied by $annotation will be removed and it will be + deleted. + + @since 1.18 + ]] + legacy: null; + params { + @in annotation: ptr(Efl.Canvas.Text.Annotation); [[Annotation to be + removed]] + } + return: bool; [[$true on success, $false otherwise.]] + } + object_item_geometry_get { + [[Queries a given object item for its geometry. + + Note that the provided annotation should be an object item type. + + @since 1.18 + ]] + legacy: null; + params { + @in an: ptr(const(Efl.Canvas.Text.Annotation)); [[Given annotation to query]] + @out x: int; [[X coordinate of the annotation]] + @out y: int; [[Y coordinate of the annotation]] + @out w: int; [[Width of the annotation]] + @out h: int; [[Height of the annotation]] + } + return: bool; [[$true if given annotation is an object item, $false otherwise]] + } + annotation_positions_get { + [[Sets given cursors to the start and end positions of the annotation. + + The cursors $start and $end will be set to the start and end + positions of the given annotation $annotation. + + @since 1.18 + ]] + legacy: null; + params { + @in annotation: ptr(const(Efl.Canvas.Text.Annotation)); [[Annotation + handle to query]] + @in start: ptr(Efl.Text.Cursor.Cursor_Data); [[Cursor to be set to the start + position of the annotation in the text]] + @in end: ptr(Efl.Text.Cursor.Cursor_Data); [[Cursor to be set to the end + position of the annotation in the text]] + } + } + // Cursor + @property cursor_object_item_annotation { + [[The object-item annotation at the cursor's position.]] + get { + legacy: null; + } + values { + annotation: ptr(Efl.Canvas.Text.Annotation); [[Annotation]] + } + keys { + cur: ptr(Efl.Text.Cursor.Cursor_Data); + } + } + cursor_object_item_insert { + [[Inserts a object item at specified position. + + This adds a placeholder to be queried by higher-level code, + which in turn place graphics on top of it. It essentially places an + OBJECT REPLACEMENT CHARACTER and set a special annotation to it. + ]] + legacy: null; + params { + cur: ptr(Efl.Text.Cursor.Cursor_Data); + @in format: string; [[Format of the inserted item. + See Format styles.]] + } + return: ptr(Efl.Canvas.Text.Annotation); [[The annotation handle of the + inserted item.]] + } + } +} + diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c index 314b1e4c3f..a9b9a478e3 100644 --- a/src/lib/elementary/efl_ui_text.c +++ b/src/lib/elementary/efl_ui_text.c @@ -4392,7 +4392,7 @@ _textblock_node_format_to_atspi_text_attr(Eo *obj, Elm_Atspi_Text_Attribute *ret; const char *txt; - txt = efl_canvas_text_annotation_get(obj, annotation); + txt = efl_text_annotation_get(obj, annotation); if (!txt) return NULL; ret = calloc(1, sizeof(Elm_Atspi_Text_Attribute)); @@ -4426,7 +4426,7 @@ _efl_ui_text_elm_interface_atspi_text_attribute_get(Eo *obj, Efl_Ui_Text_Data *_ evas_textblock_cursor_pos_set(cur1, *start_offset); evas_textblock_cursor_pos_set(cur2, *end_offset); - annotations = efl_canvas_text_range_annotations_get(obj, cur1, cur2); + annotations = efl_text_range_annotations_get(obj, cur1, cur2); evas_textblock_cursor_free(cur1); evas_textblock_cursor_free(cur2); @@ -4472,7 +4472,7 @@ _efl_ui_text_elm_interface_atspi_text_attributes_get(Eo *obj, Efl_Ui_Text_Data * evas_textblock_cursor_pos_set(cur1, *start_offset); evas_textblock_cursor_pos_set(cur2, *end_offset); - annotations = efl_canvas_text_range_annotations_get(obj, cur1, cur2); + annotations = efl_text_range_annotations_get(obj, cur1, cur2); evas_textblock_cursor_free(cur1); evas_textblock_cursor_free(cur2); @@ -4506,7 +4506,7 @@ _efl_ui_text_elm_interface_atspi_text_default_attributes_get(Eo *obj, Efl_Ui_Tex efl_text_cursor_paragraph_first(obj, start); efl_text_cursor_paragraph_last(obj, end); - annotations = efl_canvas_text_range_annotations_get(obj, start, end); + annotations = efl_text_range_annotations_get(obj, start, end); EINA_ITERATOR_FOREACH(annotations, an) { @@ -4988,7 +4988,7 @@ _anchors_create(Eo *obj, Efl_Ui_Text_Data *sd) efl_text_cursor_paragraph_first(obj, start); efl_text_cursor_paragraph_last(obj, end); - it = efl_canvas_text_range_annotations_get(obj, start, end); + it = efl_text_range_annotations_get(obj, start, end); efl_text_cursor_free(text_obj, start); efl_text_cursor_free(text_obj, end); @@ -4997,13 +4997,13 @@ _anchors_create(Eo *obj, Efl_Ui_Text_Data *sd) Eina_Bool is_anchor = EINA_FALSE; Eina_Bool is_item = EINA_FALSE; - if (efl_canvas_text_object_item_geometry_get(obj, anchor, + if (efl_text_object_item_geometry_get(obj, anchor, NULL, NULL, NULL, NULL)) { is_anchor = EINA_TRUE; is_item = EINA_TRUE; } - else if (!strncmp(efl_canvas_text_annotation_get(obj, anchor), "a ", 2)) + else if (!strncmp(efl_text_annotation_get(obj, anchor), "a ", 2)) { is_anchor = EINA_TRUE; } @@ -5011,7 +5011,7 @@ _anchors_create(Eo *obj, Efl_Ui_Text_Data *sd) if (is_anchor) { const char *p; - const char *item_str = efl_canvas_text_annotation_get(obj, anchor); + const char *item_str = efl_text_annotation_get(obj, anchor); an = calloc(1, sizeof(Anchor)); if (!an) @@ -5118,7 +5118,7 @@ _anchors_update(Eo *o, Efl_Ui_Text_Data *sd) ob = _item_obj_get(an, o, smart, clip); rect->obj = ob; - efl_canvas_text_object_item_geometry_get(an->obj, + efl_text_object_item_geometry_get(an->obj, an->annotation, &cx, &cy, &cw, &ch); evas_object_move(rect->obj, x + cx, y + cy); evas_object_resize(rect->obj, cw, ch); @@ -5134,7 +5134,7 @@ _anchors_update(Eo *o, Efl_Ui_Text_Data *sd) start = efl_text_cursor_new(o); end = efl_text_cursor_new(o); - efl_canvas_text_annotation_positions_get(o, an->annotation, + efl_text_annotation_positions_get(o, an->annotation, start, end); range = efl_canvas_text_range_geometry_get(o, start, end); diff --git a/src/lib/evas/canvas/efl_canvas_text.eo b/src/lib/evas/canvas/efl_canvas_text.eo index 6f01268175..e8b883c4e7 100644 --- a/src/lib/evas/canvas/efl_canvas_text.eo +++ b/src/lib/evas/canvas/efl_canvas_text.eo @@ -3,7 +3,7 @@ import efl_text_types; struct Efl.Canvas.Text.Style; [[EFL text style data structure]] class Efl.Canvas.Text (Efl.Canvas.Object, Efl.Text, Efl.Text.Properties, Efl.Canvas.Filter.Internal, -Efl.Text.Font, Efl.Text.Style, Efl.Text.Format, Efl.Text.Cursor) +Efl.Text.Font, Efl.Text.Style, Efl.Text.Format, Efl.Text.Cursor, Efl.Text.Annotate) { [[Efl canvas text class]] legacy_prefix: evas_object_textblock; @@ -252,139 +252,6 @@ Efl.Text.Font, Efl.Text.Style, Efl.Text.Format, Efl.Text.Cursor) @since 1.18 ]] } - // Annotation - @property annotation { - [[A new format for $annotation. - - This will replace the format applied by $annotation with $format. - Assumes that $annotation is a handle for an existing annotation, - i.e. one that was added using @.annotation_insert to this object. - Otherwise, this will fail and return $false. - - @since 1.18 - ]] - set { - legacy: null; - return: bool; [[$true on success, $false otherwise.]] - } - get { - legacy: null; - } - keys { - annotation: ptr(Efl.Canvas.Text.Annotation); [[Given annotation]] - } - values { - format: string; [[The new format for the given annotation]] - } - } - range_annotations_get { - [[Returns an iterator of all the handles in a range. - - @since 1.18 - ]] - legacy: null; - params { - @in start: ptr(const(Efl.Text.Cursor.Cursor_Data)); [[Start of range]] - @in end: ptr(const(Efl.Text.Cursor.Cursor_Data)); [[End of range]] - } - return: free(own(iterator), - eina_iterator_free); [[Handle of the Annotation]] - } - annotation_insert { - [[Inserts an annotation format in a specified range [$start, $end - 1]. - - The $format will be applied to the given range, and the $annotation - handle will be returned for further handling. - - @since 1.18 - ]] - legacy: null; - params { - @in start: ptr(Efl.Text.Cursor.Cursor_Data); [[Start of range]] - @in end: ptr(Efl.Text.Cursor.Cursor_Data); [[End of range]] - @in format: string; [[Annotation format]] - } - return: ptr(Efl.Canvas.Text.Annotation); [[Handle of inserted annotation]] - } - annotation_del { - [[Deletes given annotation. - - All formats applied by $annotation will be removed and it will be - deleted. - - @since 1.18 - ]] - legacy: null; - params { - @in annotation: ptr(Efl.Canvas.Text.Annotation); [[Annotation to be - removed]] - } - return: bool; [[$true on success, $false otherwise.]] - } - object_item_geometry_get { - [[Queries a given object item for its geometry. - - Note that the provided annotation should be an object item type. - - @since 1.18 - ]] - legacy: null; - params { - @in an: ptr(const(Efl.Canvas.Text.Annotation)); [[Given annotation to query]] - @out x: int; [[X coordinate of the annotation]] - @out y: int; [[Y coordinate of the annotation]] - @out w: int; [[Width of the annotation]] - @out h: int; [[Height of the annotation]] - } - return: bool; [[$true if given annotation is an object item, $false otherwise]] - } - annotation_positions_get { - [[Sets given cursors to the start and end positions of the annotation. - - The cursors $start and $end will be set to the start and end - positions of the given annotation $annotation. - - @since 1.18 - ]] - legacy: null; - params { - @in annotation: ptr(const(Efl.Canvas.Text.Annotation)); [[Annotation - handle to query]] - @in start: ptr(Efl.Text.Cursor.Cursor_Data); [[Cursor to be set to the start - position of the annotation in the text]] - @in end: ptr(Efl.Text.Cursor.Cursor_Data); [[Cursor to be set to the end - position of the annotation in the text]] - } - } - // Cursor - @property cursor_object_item_annotation { - [[The object-item annotation at the cursor's position.]] - get { - legacy: null; - } - values { - annotation: ptr(Efl.Canvas.Text.Annotation); [[Annotation]] - } - keys { - cur: ptr(Efl.Text.Cursor.Cursor_Data); - } - } - cursor_object_item_insert { - [[Inserts a object item at specified position. - - This adds a placeholder to be queried by higher-level code, - which in turn place graphics on top of it. It essentially places an - OBJECT REPLACEMENT CHARACTER and set a special annotation to it. - ]] - legacy: null; - params { - cur: ptr(Efl.Text.Cursor.Cursor_Data); - @in format: string; [[Format of the inserted item. - See Format styles.]] - } - return: ptr(Efl.Canvas.Text.Annotation); [[The annotation handle of the - inserted item.]] - } } implements { Efl.Object.constructor; @@ -458,6 +325,14 @@ Efl.Text.Font, Efl.Text.Style, Efl.Text.Format, Efl.Text.Cursor) Efl.Text.Cursor.cursor_coord_set; Efl.Text.Cursor.cursor_text_insert; Efl.Text.Cursor.cursor_char_delete; + Efl.Text.Annotate.annotation { set; get; } + Efl.Text.Annotate.range_annotations_get; + Efl.Text.Annotate.annotation_insert; + Efl.Text.Annotate.annotation_del; + Efl.Text.Annotate.object_item_geometry_get; + Efl.Text.Annotate.annotation_positions_get; + Efl.Text.Annotate.cursor_object_item_annotation { get; } + Efl.Text.Annotate.cursor_object_item_insert; } events { cursor,changed; diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index c518e4ce3d..a9bd949ee6 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -14522,7 +14522,7 @@ _textblock_annotation_set(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o, } EOLIAN static const char * -_efl_canvas_text_annotation_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, +_efl_canvas_text_efl_text_annotate_annotation_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Canvas_Text_Annotation *annotation) { if (!annotation || (annotation->obj != eo_obj)) @@ -14535,7 +14535,7 @@ _efl_canvas_text_annotation_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o } EOLIAN static Eina_Bool -_efl_canvas_text_annotation_set(Eo *eo_obj, +_efl_canvas_text_efl_text_annotate_annotation_set(Eo *eo_obj, Efl_Canvas_Text_Data *o, Efl_Canvas_Text_Annotation *annotation, const char *format) { @@ -14606,7 +14606,7 @@ _evas_textblock_annotations_clear(Efl_Canvas_Text_Data *o) } EOLIAN static Eina_Bool -_efl_canvas_text_annotation_del(Eo *eo_obj EINA_UNUSED, +_efl_canvas_text_efl_text_annotate_annotation_del(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o, Efl_Canvas_Text_Annotation *annotation) { if (!annotation || (annotation->obj != eo_obj)) @@ -14695,7 +14695,7 @@ _textblock_annotation_insert(Eo *eo_obj, Efl_Canvas_Text_Data *o, } EOLIAN static Efl_Canvas_Text_Annotation * -_efl_canvas_text_annotation_insert(Eo *eo_obj, Efl_Canvas_Text_Data *o, +_efl_canvas_text_efl_text_annotate_annotation_insert(Eo *eo_obj, Efl_Canvas_Text_Data *o, Efl_Canvas_Text_Cursor *start, Efl_Canvas_Text_Cursor *end, const char *format) { @@ -14708,7 +14708,7 @@ _efl_canvas_text_annotation_insert(Eo *eo_obj, Efl_Canvas_Text_Data *o, } EOLIAN static Eina_Iterator * -_efl_canvas_text_range_annotations_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, +_efl_canvas_text_efl_text_annotate_range_annotations_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, const Evas_Textblock_Cursor *start, const Evas_Textblock_Cursor *end) { Eina_List *lst = NULL; @@ -14734,7 +14734,7 @@ _efl_canvas_text_range_annotations_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_D } EOLIAN static Efl_Canvas_Text_Annotation * -_efl_canvas_text_cursor_object_item_insert(Eo *eo_obj, Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Canvas_Text_Cursor *cur, const char *format) +_efl_canvas_text_efl_text_annotate_cursor_object_item_insert(Eo *eo_obj, Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Canvas_Text_Cursor *cur, const char *format) { Efl_Canvas_Text_Annotation *ret = _textblock_annotation_insert(cur->obj, o, cur, cur, format, EINA_TRUE); @@ -14743,13 +14743,13 @@ _efl_canvas_text_cursor_object_item_insert(Eo *eo_obj, Efl_Canvas_Text_Data *o E } EOLIAN static Efl_Canvas_Text_Annotation * -_efl_canvas_text_cursor_object_item_annotation_get(Eo *eo_obj EINA_UNUSED, +_efl_canvas_text_efl_text_annotate_cursor_object_item_annotation_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Canvas_Text_Cursor *cur) { Eina_Iterator *it; Efl_Canvas_Text_Annotation *data, *ret = NULL; - it = efl_canvas_text_range_annotations_get(cur->obj, + it = efl_text_range_annotations_get(cur->obj, cur, cur); EINA_ITERATOR_FOREACH(it, data) { @@ -14764,7 +14764,7 @@ _efl_canvas_text_cursor_object_item_annotation_get(Eo *eo_obj EINA_UNUSED, } EOLIAN static Eina_Bool -_efl_canvas_text_object_item_geometry_get(Eo *eo_obj, Efl_Canvas_Text_Data *o EINA_UNUSED, +_efl_canvas_text_efl_text_annotate_object_item_geometry_get(Eo *eo_obj, Efl_Canvas_Text_Data *o EINA_UNUSED, const Efl_Canvas_Text_Annotation *an, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) { Efl_Canvas_Text_Cursor_Data cur; @@ -14779,7 +14779,7 @@ _efl_canvas_text_object_item_geometry_get(Eo *eo_obj, Efl_Canvas_Text_Data *o EI } EOLIAN static void -_efl_canvas_text_annotation_positions_get(Eo *eo_obj, +_efl_canvas_text_efl_text_annotate_annotation_positions_get(Eo *eo_obj, Efl_Canvas_Text_Data *o EINA_UNUSED, const Efl_Canvas_Text_Annotation *annotation, Efl_Canvas_Text_Cursor *start, Efl_Canvas_Text_Cursor *end)