summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2019-11-27 13:04:31 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2019-11-27 13:04:32 +0900
commitc7f37fe61852ea45dce071e0f80f98adcce08981 (patch)
tree964906c510dd0af5310157ab0ebbcc4c29d42543 /src/bin
parentf10c91cda9795a43e6984814b7394383cf9da812 (diff)
downloadefl-c7f37fe61852ea45dce071e0f80f98adcce08981.tar.gz
Efl.Text.Attribute_Factory
Summary: Implementation of new Efl.Text.Attribute_Factory class which replace the annotation interface. Currently, we have two public methods: ``` void efl_text_attribute_factory_attribute_insert(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end, const char *format) unsigned int efl_text_attribute_factory_attribute_clear(const Efl_Text_Cursor *start, const Efl_Text_Cursor *end); ``` Other methods will be internal methods, for the time being, we will redesign internal methods Reviewers: woohyun, tasn, segfaultxavi, bu5hm4n, zmike Subscribers: zmike, q66, cedric, segfaultxavi, bu5hm4n, a.srour, #committers, #reviewers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10646
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_efl_ui_text.c162
2 files changed, 2 insertions, 162 deletions
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index a78850aa31..1d91bf5a4b 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -366,7 +366,6 @@ void test_code_diff_inline(void *data, Evas_Object *obj, void *event_info);
void test_efl_ui_text(void *data, Evas_Object *obj, void *event_info);
void test_efl_ui_text_inputfield(void *data, Evas_Object *obj, void *event_info);
void test_efl_ui_text_label(void *data, Evas_Object *obj, void *event_info);
-void test_ui_text_item_factory(void *data, Evas_Object *obj, void *event_info);
void test_evas_mask(void *data, Edje_Object *obj, void *event_info);
void test_gfx_filters(void *data, Evas_Object *obj, void *event_info);
void test_evas_snapshot(void *data, Evas_Object *obj, void *event_info);
@@ -941,7 +940,6 @@ add_tests:
ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Text", test_efl_ui_text);
ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Text Input Field", test_efl_ui_text_inputfield);
ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Text Label", test_efl_ui_text_label);
- ADD_TEST_EO(NULL, "Entries", "Ui.Text Item Factory", test_ui_text_item_factory);
ADD_TEST_EO(NULL, "Entries", "Efl.Ui.Tags", test_ui_tags);
//------------------------------//
diff --git a/src/bin/elementary/test_efl_ui_text.c b/src/bin/elementary/test_efl_ui_text.c
index d56fddb78d..e06006703e 100644
--- a/src/bin/elementary/test_efl_ui_text.c
+++ b/src/bin/elementary/test_efl_ui_text.c
@@ -5,6 +5,7 @@
#include <Efl_Ui.h>
#include <Elementary.h>
#include "elm_priv.h" //FIXME remove this once efl.ui.text doesn't need elm_general.h
+
static void
_apply_style(Eo *obj, size_t start_pos, size_t end_pos, const char *style)
{
@@ -16,7 +17,7 @@ _apply_style(Eo *obj, size_t start_pos, size_t end_pos, const char *style)
efl_text_cursor_position_set(start, start_pos);
efl_text_cursor_position_set(end, end_pos);
- efl_text_annotation_insert(obj, efl_text_cursor_handle_get(start), efl_text_cursor_handle_get(end), style);
+ efl_text_attribute_factory_attribute_insert(start, end, style);
efl_del(start);
efl_del(end);
@@ -235,162 +236,3 @@ test_efl_ui_text_inputfield(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED
efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 200));
}
-
-#define IMAGES_SZ 5
-
-static const char *images[IMAGES_SZ] = {
- "sky", "logo", "dog", "eet_rock", "eet_plant" };
-
-static void
-_on_factory_bt_image_clicked(void *data, const Efl_Event *event EINA_UNUSED)
-{
- Evas_Object *en = data;
- static int image_idx = 0;
-
- image_idx = (image_idx + 1) % IMAGES_SZ;
-
- efl_text_cursor_item_insert(en, efl_text_cursor_handle_get(efl_text_interactive_main_cursor_get(en)),
- images[image_idx], "size=32x32");
- printf("Inserted image: key = %s\n", images[image_idx]);
-}
-
-static void
-_on_factory_bt_emoticon_clicked(void *data, const Efl_Event *event EINA_UNUSED)
-{
- Evas_Object *en = data;
- efl_text_cursor_item_insert(en, efl_text_cursor_handle_get(efl_text_interactive_main_cursor_get(en)),
- "emoticon/evil-laugh", "size=32x32");
-}
-
-static struct
-{
- const char *name;
- Eo *item_factory;
-} factories[3];
-
-static void
-_on_factory_bt_factory_clicked(void *data, const Efl_Event *event EINA_UNUSED)
-{
- Evas_Object *en = data;
- static int item_factory_idx = 0;
-
- item_factory_idx = (item_factory_idx + 1) % 3;
- efl_ui_text_item_factory_set(en, factories[item_factory_idx].item_factory);
- printf("Factory set to: %s\n", factories[item_factory_idx].name);
-}
-
-#define FACTORY_NONE 0
-#define FACTORY_IMAGE 1
-#define FACTORY_EMOTICON 2
-
-void
-test_ui_text_item_factory(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
-{
- Evas_Object *win, *bx, *bx2, *bt, *en;
- Efl_Text_Cursor *main_cur, *cur;
- char buf[128];
- Eina_File *f;
-
- win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
- efl_text_set(efl_added, "Efl Ui Text Item Factory"),
- efl_ui_win_autodel_set(efl_added, EINA_TRUE));
-
- bx = efl_add(EFL_UI_BOX_CLASS, win);
- efl_content_set(win, bx);
-
- en = efl_add(EFL_UI_TEXT_CLASS, bx,
- efl_text_multiline_set(efl_added, EINA_TRUE));
-
- factories[FACTORY_NONE].name = "None (Fallback)";
- factories[FACTORY_NONE].item_factory = NULL;
-
- factories[FACTORY_IMAGE].name = "Image Factory";
- factories[FACTORY_IMAGE].item_factory =
- efl_add(EFL_UI_TEXT_FACTORY_IMAGES_CLASS, en);
-
- factories[FACTORY_EMOTICON].name = "Emoticon Factory";
- factories[FACTORY_EMOTICON].item_factory =
- efl_add(EFL_UI_TEXT_FACTORY_EMOTICONS_CLASS, en);
-
- // Test assigning file path source
- snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
- efl_ui_text_factory_images_matches_add(factories[FACTORY_IMAGE].item_factory,
- images[0], buf, NULL);
- snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
- efl_ui_text_factory_images_matches_add(factories[FACTORY_IMAGE].item_factory,
- images[1], buf, NULL);
- snprintf(buf, sizeof(buf), "%s/images/mystrale.jpg", elm_app_data_dir_get());
- efl_ui_text_factory_images_matches_add(factories[FACTORY_IMAGE].item_factory,
- images[2], buf, NULL);
-
- // Open EET source w/ key
- snprintf(buf, sizeof(buf), "%s/images/image_items.eet", elm_app_data_dir_get());
- f = eina_file_open(buf, EINA_FALSE);
- if (f)
- {
- efl_ui_text_factory_images_matches_mmap_add(
- factories[FACTORY_IMAGE].item_factory,
- "eet_rock", f, "rock");
- efl_ui_text_factory_images_matches_mmap_add(
- factories[FACTORY_IMAGE].item_factory,
- "eet_plant", f, "plant");
- eina_file_close(f);
- }
- else
- {
- printf("Error loading test file. Please review test.");
- }
-
-
- printf("Added Efl.Ui.Text object\n");
- efl_text_set(en, "Hello world! Goodbye world! This is a test text for the"
- " new UI Text widget.\xE2\x80\xA9This is the next paragraph.\nThis"
- " is the next line.\nThis is Yet another line! Line and paragraph"
- " separators are actually different!");
- efl_text_font_set(en, "Sans", 14);
- efl_text_normal_color_set(en, 255, 255, 255, 255);
-
- main_cur = efl_text_interactive_main_cursor_get(en);
- cur = efl_ui_text_cursor_create(en);
-
- efl_text_cursor_position_set(cur, 2);
- efl_text_cursor_item_insert(en, efl_text_cursor_handle_get(cur), "emoticon/happy", "size=32x32");
- efl_text_cursor_position_set(cur, 50);
-
- snprintf(buf, sizeof(buf), "file://%s/images/sky_01.jpg", elm_app_data_dir_get());
- efl_text_cursor_item_insert(en, efl_text_cursor_handle_get(cur), buf, "size=32x32");
- efl_text_cursor_position_set(main_cur, 5);
-
- efl_text_interactive_editable_set(en, EINA_TRUE);
- efl_ui_text_scrollable_set(en, EINA_TRUE);
- efl_pack(bx, en);
- elm_object_focus_set(en, EINA_TRUE);
-
- bx2 = efl_add(EFL_UI_BOX_CLASS, bx);
- efl_gfx_hint_weight_set(bx2, EFL_GFX_HINT_EXPAND, EFL_GFX_HINT_EXPAND);
- efl_ui_layout_orientation_set(bx2, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
-
- bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
- efl_text_set(bt, "Image");
- efl_event_callback_add(bt, EFL_INPUT_EVENT_CLICKED, _on_factory_bt_image_clicked, en);
- efl_gfx_hint_weight_set(bt, EFL_GFX_HINT_EXPAND, 0.0);
- efl_pack(bx2, bt);
- elm_object_focus_allow_set(bt, EINA_FALSE);
-
- bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
- efl_text_set(bt, "Emoticon");
- efl_event_callback_add(bt, EFL_INPUT_EVENT_CLICKED, _on_factory_bt_emoticon_clicked, en);
- efl_gfx_hint_weight_set(bt, EFL_GFX_HINT_EXPAND, 0.0);
- efl_pack(bx2, bt);
- elm_object_focus_allow_set(bt, EINA_FALSE);
-
- bt = efl_add(EFL_UI_BUTTON_CLASS, bx2);
- efl_text_set(bt, "Factory");
- efl_event_callback_add(bt, EFL_INPUT_EVENT_CLICKED, _on_factory_bt_factory_clicked, en);
- efl_gfx_hint_weight_set(bt, EFL_GFX_HINT_EXPAND, 0.0);
- efl_pack(bx2, bt);
- elm_object_focus_allow_set(bt, EINA_FALSE);
-
- efl_pack(bx, bx2);
- efl_gfx_entity_size_set(win, EINA_SIZE2D(480, 320));
-}