From 4a905a22a485388a5e4ba9fb25ff5ca381420ba7 Mon Sep 17 00:00:00 2001 From: Daniel Hirt Date: Thu, 9 Nov 2017 17:53:20 +0200 Subject: 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 --- src/lib/elementary/efl_ui_text_factory_emoticons.c | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/lib/elementary/efl_ui_text_factory_emoticons.c (limited to 'src/lib/elementary/efl_ui_text_factory_emoticons.c') diff --git a/src/lib/elementary/efl_ui_text_factory_emoticons.c b/src/lib/elementary/efl_ui_text_factory_emoticons.c new file mode 100644 index 0000000000..55818af33d --- /dev/null +++ b/src/lib/elementary/efl_ui_text_factory_emoticons.c @@ -0,0 +1,52 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#include +#include +#include "elm_priv.h" + +#define MY_CLASS EFL_UI_TEXT_FACTORY_EMOTICONS_CLASS + +typedef struct _Efl_Ui_Text_Factory_Emoticons_Data Efl_Ui_Text_Factory_Emoticons_Data; + +struct _Efl_Ui_Text_Factory_Emoticons_Data +{ + const char *name; +}; + +EOLIAN static Eo * +_efl_ui_text_factory_emoticons_efl_object_constructor(Eo *obj, + Efl_Ui_Text_Factory_Emoticons_Data *pd EINA_UNUSED) +{ + obj = efl_constructor(efl_super(obj, MY_CLASS)); + return obj; +} + +EOLIAN static void +_efl_ui_text_factory_emoticons_efl_object_destructor(Eo *obj, + Efl_Ui_Text_Factory_Emoticons_Data *pd EINA_UNUSED) +{ + efl_destructor(efl_super(obj, MY_CLASS)); +} + + +EOLIAN static Efl_Canvas_Object +*_efl_ui_text_factory_emoticons_efl_canvas_text_factory_create( + Eo *obj EINA_UNUSED, + Efl_Ui_Text_Factory_Emoticons_Data *pd EINA_UNUSED, + Efl_Canvas_Object *object, + const char *key) +{ + Eo *o; + const char *style = elm_widget_style_get(object); + + o = edje_object_add(evas_object_evas_get(object)); + if (!_elm_theme_object_set + (object, o, "text", key, style)) + _elm_theme_object_set + (object, o, "text/emoticon", "wtf", style); + return o; +} + +#include "efl_ui_text_factory_emoticons.eo.c" -- cgit v1.2.1