diff options
author | Daniel Hirt <hirt.danny@gmail.com> | 2017-11-09 17:53:20 +0200 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2018-01-18 10:20:28 -0800 |
commit | 4a905a22a485388a5e4ba9fb25ff5ca381420ba7 (patch) | |
tree | 213dc03c164320ebd8edd7e5959fc31a9706c629 /src/lib/evas | |
parent | 2eac0dd89d01544902d029604fe7328aca765c25 (diff) | |
download | efl-4a905a22a485388a5e4ba9fb25ff5ca381420ba7.tar.gz |
Canvas image: add Efl.Canvas.Text.Factory + use in Ui.Text
This interface has a simple 'create' method to create Efl.Canvas.Object
given a key.
This is used higher-up in Ui.Text in the next commit.
Ui text: add ability to set item factories
Added API to set an item factory object.
This is similar to the previous item providers (that worked with
callbacks).
You instantiate a factory object and set it on the Ui.Text object.
Each factory implements the "create" method from
Efl.Canvas.Text.Item_Factory.
This also includes 3 public factories (Image, Emoticon and Fallback):
- Image factory: creates images from added entries (key strings)
- Emoticon factory: creates emoticons by querying the theme
- Fallback: creates image, then falls back to emoticon
If no factory is set, then the fallback (internal) factory is used.
See the added "Ui.text Item Factory" test in elementary_test for an
example of usage.
@feature
Diffstat (limited to 'src/lib/evas')
-rw-r--r-- | src/lib/evas/Evas_Eo.h | 1 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_canvas_text.eo | 7 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_canvas_text_factory.eo | 25 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_textblock.c | 31 |
4 files changed, 57 insertions, 7 deletions
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index d6664a2ddd..f2b2f6d372 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -21,6 +21,7 @@ */ //#include "canvas/efl_canvas_text_cursor.eo.h" #include "canvas/efl_canvas_text.eo.h" +#include "canvas/efl_canvas_text_factory.eo.h" /** * @} */ diff --git a/src/lib/evas/canvas/efl_canvas_text.eo b/src/lib/evas/canvas/efl_canvas_text.eo index a021fbacef..73367b0f58 100644 --- a/src/lib/evas/canvas/efl_canvas_text.eo +++ b/src/lib/evas/canvas/efl_canvas_text.eo @@ -345,10 +345,11 @@ class Efl.Canvas.Text (Efl.Canvas.Object, Efl.Text, Efl.Text.Properties, 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_is_item; + Efl.Text.Annotate.item_geometry_get; Efl.Text.Annotate.annotation_positions_get; - Efl.Text.Annotate.cursor_object_item_annotation { get; } - Efl.Text.Annotate.cursor_object_item_insert; + Efl.Text.Annotate.cursor_item_annotation { get; } + Efl.Text.Annotate.cursor_item_insert; Efl.Text.Markup.markup { set; get; } Efl.Text.Markup.cursor_markup_insert; Efl.Gfx.scale { set; } diff --git a/src/lib/evas/canvas/efl_canvas_text_factory.eo b/src/lib/evas/canvas/efl_canvas_text_factory.eo new file mode 100644 index 0000000000..240cfb4669 --- /dev/null +++ b/src/lib/evas/canvas/efl_canvas_text_factory.eo @@ -0,0 +1,25 @@ +interface Efl.Canvas.Text.Factory () +{ + [[Object factory that creates Efl.Canvas.Object objects. + + Translates a given key to an object (item), to be later placed in a text + for higher level usages. The translation implementation is left to be + decided by the inheriting class, whether it is by treating the $key as an + image path, or a key associated with a real-path in a hashtable + or something else entirely. + + @since 1.21 + ]] + methods { + create { + [[Translates a given $key to an item object, and returns the object. + The returned object should be owned by the passed $object. + ]] + params { + object: Efl.Canvas.Object; [[The parent of the created object]] + key: string; [[Key that is associated to an item object]] + } + return: Efl.Canvas.Object @owned; + } + } +} diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index 70c5618390..1a0023da5f 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -15123,16 +15123,24 @@ _efl_canvas_text_efl_text_annotate_range_annotations_get(Eo *eo_obj EINA_UNUSED, } EOLIAN static Efl_Text_Annotate_Annotation * -_efl_canvas_text_efl_text_annotate_cursor_object_item_insert(Eo *eo_obj, Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Text_Cursor_Cursor *cur, const char *format) +_efl_canvas_text_efl_text_annotate_cursor_item_insert(Eo *eo_obj, + Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Text_Cursor_Cursor *cur, + const char *item, const char *format) { + Eina_Strbuf *buf = eina_strbuf_new(); + + eina_strbuf_append_printf(buf, "%s href=%s", format, item); + Efl_Text_Annotate_Annotation *ret = - _textblock_annotation_insert(cur->obj, o, cur, cur, format, EINA_TRUE); + _textblock_annotation_insert(cur->obj, o, cur, cur, + eina_strbuf_string_get(buf), EINA_TRUE); + eina_strbuf_free(buf); efl_event_callback_legacy_call(eo_obj, EFL_CANVAS_TEXT_EVENT_CHANGED, NULL); return ret; } EOLIAN static Efl_Text_Annotate_Annotation * -_efl_canvas_text_efl_text_annotate_cursor_object_item_annotation_get(Eo *eo_obj EINA_UNUSED, +_efl_canvas_text_efl_text_annotate_cursor_item_annotation_get(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Text_Cursor_Cursor *cur) { Eina_Iterator *it; @@ -15153,7 +15161,21 @@ _efl_canvas_text_efl_text_annotate_cursor_object_item_annotation_get(Eo *eo_obj } EOLIAN static Eina_Bool -_efl_canvas_text_efl_text_annotate_object_item_geometry_get(Eo *eo_obj, Efl_Canvas_Text_Data *o EINA_UNUSED, +_efl_canvas_text_efl_text_annotate_annotation_is_item(Eo *eo_obj EINA_UNUSED, + Efl_Canvas_Text_Data *o EINA_UNUSED, + Efl_Text_Annotate_Annotation *annotation) +{ + if (!annotation || (annotation->obj != eo_obj)) + { + ERR("Used invalid handle or of a different object"); + return EINA_FALSE; + } + + return annotation->is_item; +} + +EOLIAN static Eina_Bool +_efl_canvas_text_efl_text_annotate_item_geometry_get(Eo *eo_obj, Efl_Canvas_Text_Data *o EINA_UNUSED, const Efl_Text_Annotate_Annotation *an, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) { Efl_Text_Cursor_Cursor cur; @@ -16264,3 +16286,4 @@ _efl_canvas_text_async_layout(Eo *eo_obj EINA_UNUSED, Efl_Canvas_Text_Data *o) } #include "canvas/efl_canvas_text.eo.c" +#include "canvas/efl_canvas_text_factory.eo.c" // interface |