Canvas text: add annotation_positions_get method
authorDaniel Hirt <daniel.hirt@samsung.com>
Wed, 5 Oct 2016 14:10:14 +0000 (17:10 +0300)
committerDaniel Hirt <daniel.hirt@samsung.com>
Wed, 5 Oct 2016 14:12:22 +0000 (17:12 +0300)
We need a method that allows us to place the cursors at the start and end of an
annotation. This is required for things like getting the geometry of a range.

@feature

src/lib/evas/canvas/efl_canvas_text.eo
src/lib/evas/canvas/evas_object_textblock.c

index 79b3000..4e5dca4 100644 (file)
@@ -341,6 +341,24 @@ class Efl.Canvas.Text (Efl.Canvas.Object, Efl.Text)
          }
          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 the start and end
+           positions of the given annotation $annotation.
+
+           @since 1.18
+         ]]
+         legacy: null;
+         params {
+             @in annotation: const(Efl.Canvas.Text.Annotation)*; [[Annotation
+                 handle to query]]
+             @in start: Efl.Canvas.Text.Cursor; [[Cursor to be set to the start
+             position of the annotation in the text]]
+             @in end: Efl.Canvas.Text.Cursor; [[Cursor to be set to the end
+             position of the annotation in the text]]
+         }
+      }
    }
    implements {
       Efl.Object.constructor;
index 30649bd..2b01c0a 100644 (file)
@@ -14043,6 +14043,21 @@ _efl_canvas_text_object_item_geometry_get(Eo *eo_obj, Efl_Canvas_Text_Data *o EI
    return _evas_textblock_cursor_format_item_geometry_get(&cur, cx, cy, cw, ch);
 }
 
+EOLIAN static void
+_efl_canvas_text_annotation_positions_get(Eo *eo_obj,
+      Efl_Canvas_Text_Data *o EINA_UNUSED,
+      const Efl_Canvas_Text_Annotation *annotation,
+      Efl_Canvas_Text_Cursor *start_obj, Efl_Canvas_Text_Cursor *end_obj)
+{
+   Efl_Canvas_Text_Cursor_Data *start, *end;
+
+   start = efl_data_scope_get(start_obj, EFL_CANVAS_TEXT_CURSOR_CLASS);
+   end = efl_data_scope_get(end_obj, EFL_CANVAS_TEXT_CURSOR_CLASS);
+
+   _textblock_cursor_pos_at_fnode_set(eo_obj, start, annotation->start_node);
+   _textblock_cursor_pos_at_fnode_set(eo_obj, end, annotation->end_node);
+}
+
 /**
  * @}
  */