Add code for sticker input in demo 53/252453/1
authorInHong Han <inhong1.han@samsung.com>
Thu, 28 Jan 2021 08:02:30 +0000 (17:02 +0900)
committerInHong Han <inhong1.han@samsung.com>
Thu, 28 Jan 2021 08:03:52 +0000 (17:03 +0900)
Change-Id: Id3a2672c482294e4d2e54d44e2fe56bf6d88e169

ism/demos/isf_mime_type_efl.cpp

index 524ecc9..d5f8fef 100644 (file)
 #include "isf_demo_efl.h"
 #include "isf_mime_type_efl.h"
 
+static Evas_Object *item_provider(void *data, Evas_Object *en, const char *item)
+{
+    Evas_Object *obj = NULL;
+
+    obj = elm_image_add(en);
+    elm_image_file_set(obj, item, NULL);
+    elm_image_animated_set(obj, EINA_TRUE);
+    elm_image_animated_play_set(obj, EINA_TRUE);
+    evas_object_show(obj);
+
+    return obj;
+}
+
+static void _imf_event_commit_content_cb(void *data, Ecore_IMF_Context *ctx, void *event_info)
+{
+    Ecore_IMF_Event_Commit_Content *commit_content = (Ecore_IMF_Event_Commit_Content *)event_info;
+    Evas_Object *obj = (Evas_Object *)data;
+
+    if (!commit_content || !obj) return;
+
+    char buf[4096];
+    const char *text = elm_object_text_get(obj);
+    if (text)
+        snprintf(buf, sizeof(buf), "%s<br><item absize=300x300 vsize=full href=%s></item>", text, commit_content->content_uri);
+    else
+        snprintf(buf, sizeof(buf), "<item absize=300x300 vsize=full href=%s></item>", commit_content->content_uri);
+
+    elm_object_text_set(obj, buf);
+    elm_entry_cursor_end_set(obj);
+    evas_object_show(obj);
+}
+
 static Evas_Object *_create_ef_layout (Evas_Object *parent, const char *label, const char *guide_text, const char *mime_type)
 {
     Evas_Object *en;
@@ -35,6 +67,9 @@ static Evas_Object *_create_ef_layout (Evas_Object *parent, const char *label, c
     ic = (Ecore_IMF_Context *)elm_entry_imf_context_get (en);
 
     ecore_imf_context_mime_type_accept_set (ic, mime_type);
+    elm_entry_single_line_set (en, EINA_FALSE);
+    ecore_imf_context_event_callback_add(ic, ECORE_IMF_CALLBACK_COMMIT_CONTENT, _imf_event_commit_content_cb, (void *)en);
+    elm_entry_item_provider_append(en, item_provider, NULL);
 
     return ef;
 }