From: Youngbok Shin Date: Wed, 8 Nov 2017 11:39:37 +0000 (+0900) Subject: edje: add plugin keyword and feature X-Git-Tag: submit/sandbox/upgrade/efl120/20180319.053334~1061 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=630ff578b2caa8c975082a3f8faa53f866c47e36;p=platform%2Fupstream%2Fefl.git edje: add plugin keyword and feature @tizen_feature Change-Id: Ib1cf9958ebdcaf2e6039f336b13110f3843c126e --- diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c index 833e306..73a09f1 100644 --- a/src/bin/edje/edje_cc_handlers.c +++ b/src/bin/edje/edje_cc_handlers.c @@ -564,6 +564,14 @@ static void st_collections_group_noinherit_script(void); static void st_images_vector(void); static void _handle_vector_image(void); +// TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN +static void ob_plugins_plug(void); +static void st_collections_plugins_plugin_name(void); +static void st_collections_plugins_plugin_source(void); +static void st_collections_plugins_plugin_param(void); +#endif +// /*****/ #define STRDUP(x) eina_strdup(x) @@ -723,6 +731,16 @@ New_Statement_Handler statement_handlers[] = TEXT_CLASS_STATEMENTS("collections.") SIZE_CLASS_STATEMENTS("collections.") {"collections.base_scale", st_collections_base_scale}, +// TIZEN_ONLY(20150110): Add plugins keyword. +#ifdef PLUGIN + {"collections.plugins.plugin.name", st_collections_plugins_plugin_name}, + {"collections.plugins.plugin.source", st_collections_plugins_plugin_source}, + {"collections.plugins.plugin.param", st_collections_plugins_plugin_param}, + {"collections.group.plugins.plugin.name", st_collections_plugins_plugin_name}, /* dup */ + {"collections.group.plugins.plugin.source", st_collections_plugins_plugin_source}, /* dup */ + {"collections.group.plugins.plugin.param", st_collections_plugins_plugin_param}, /* dup */ +#endif +// {"collections.translation.file.locale", st_collections_group_translation_file_locale}, {"collections.translation.file.source", st_collections_group_translation_file_source}, {"collections.group.translation.file.locale", st_collections_group_translation_file_locale}, @@ -1433,6 +1451,14 @@ New_Object_Handler object_handlers[] = {"collections.text_classes.text_class", ob_text_class}, /* dup */ {"collections.size_classes", NULL}, /* dup */ {"collections.size_classes.size_class", ob_size_class}, /* dup */ +// TIZEN_ONLY(20150110): Add plugins keyword. +#ifdef PLUGIN + {"collections.plugins", NULL}, /* dup */ + {"collections.plugins.plugin", ob_plugins_plug}, /* dup */ + {"collections.group.plugins", NULL}, /* dup */ + {"collections.group.plugins.plugin", ob_plugins_plug}, /* dup */ +#endif +// {"collections.sounds", NULL}, {"collections.group.sounds", NULL}, /* dup */ {"collections.sounds.sample", NULL}, @@ -2103,6 +2129,11 @@ _edje_program_copy(Edje_Program *ep, Edje_Program *ep2) ep->tween.v4 = ep2->tween.v4; ep->tween.use_duration_factor = ep2->tween.use_duration_factor; ep->sample_name = STRDUP(ep2->sample_name); +// TIZEN_ONLY(20150110): Add plugins keyword. +#ifdef PLUGIN + ep->plugin_name = STRDUP(ep2->plugin_name); +#endif +// ep->tone_name = STRDUP(ep2->tone_name); ep->duration = ep2->duration; ep->speed = ep2->speed; @@ -4070,6 +4101,73 @@ st_collections_group_vibration_sample_name(void) check_arg_count(1); } +//////////////////////////////////////////////////////////// +// TIZEN_ONLY(20150110): Add plugin keyword. +//////////////////////////////////////////////////////////// +#ifdef PLUGIN +static void +ob_plugins_plug(void) +{ + Edje_Plugin *plug; + + plug = mem_alloc(SZ(Edje_Plugin)); + edje_file->plugins = eina_list_append(edje_file->plugins, plug); +} + +static void +st_collections_plugins_plugin_source(void) +{ + Edje_Plugin *plug; + + check_arg_count(1); + plug = eina_list_data_get(eina_list_last(edje_file->plugins)); + if (plug->source) + { + ERR("parse error %s:%i. There is already a basic source for the plugin: %s", + file_in, line - 1, plug->name); + exit(-1); + } + plug->source = parse_str(0); +} + +static void +st_collections_plugins_plugin_param(void) +{ + Edje_Plugin *plug; + + check_arg_count(1); + plug = eina_list_data_get(eina_list_last(edje_file->plugins)); + if (plug->param) + { + ERR("parse error %s:%i. There is already a basic param for the plugin: %s", + file_in, line - 1, plug->name); + exit(-1); + } + plug->param = parse_str(0); +} + +static void +st_collections_plugins_plugin_name(void) +{ + Edje_Plugin *plug, *tplug; + Eina_List *l; + + check_arg_count(1); + plug = eina_list_data_get(eina_list_last(edje_file->plugins)); + plug->name = parse_str(0); + EINA_LIST_FOREACH(edje_file->plugins, l, tplug) + { + if (plug->name && tplug->name && (plug != tplug) && (!strcmp(plug->name, tplug->name))) + { + ERR("parse error %s:%i. There is already a style named \"%s\"", + file_in, line - 1, plug->name); + exit(-1); + } + } +} +#endif +////////////////////////////////////////////////////////////// + /** @page edcref @property @@ -15339,6 +15437,9 @@ st_collections_group_programs_program_in(void) @li PARAM_COPY "src_part" "src_param" "dst_part" "dst_param" @li PARAM_SET "part" "param" "value" @li PLAY_SAMPLE "sample name" speed (channel) +// TIZEN_ONLY(20150110): Add plugin keyword. + @li RUN_PLUGIN "plugin name" +// @li PLAY_TONE "tone name" duration_in_seconds( Range 0.1 to 10.0 ) @li PLAY_VIBRATION "sample name" repeat (repeat count) @li PHYSICS_IMPULSE 10 -23.4 0 @@ -15401,6 +15502,11 @@ st_collections_group_programs_program_action(void) "PHYSICS_STOP", EDJE_ACTION_TYPE_PHYSICS_STOP, "PHYSICS_ROT_SET", EDJE_ACTION_TYPE_PHYSICS_ROT_SET, "PLAY_VIBRATION", EDJE_ACTION_TYPE_VIBRATION_SAMPLE, + // TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + "RUN_PLUGIN", EDJE_ACTION_TYPE_RUN_PLUGIN, +#endif + // NULL); if (ep->action == EDJE_ACTION_TYPE_STATE_SET) { @@ -15475,6 +15581,14 @@ st_collections_group_programs_program_action(void) } ep->duration = parse_float_range(2, 0.1, 10.0); } +// TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + else if (ep->action == EDJE_ACTION_TYPE_RUN_PLUGIN) + { + ep->plugin_name = parse_str(1); + } +#endif +// else if (ep->action == EDJE_ACTION_TYPE_VIBRATION_SAMPLE) { ep->vibration_name = parse_str(1); @@ -15586,6 +15700,13 @@ st_collections_group_programs_program_action(void) case EDJE_ACTION_TYPE_FOCUS_OBJECT: check_min_arg_count(1); break; +// TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + case EDJE_ACTION_TYPE_RUN_PLUGIN: + check_arg_count(2); + break; +#endif +// default: check_arg_count(3); } diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h index 183d60f..1ab6d44 100644 --- a/src/lib/edje/Edje_Common.h +++ b/src/lib/edje/Edje_Common.h @@ -1871,6 +1871,10 @@ typedef enum _Edje_Tween_Mode EDJE_TWEEN_MODE_OPT_FROM_CURRENT = (1 << 31) /**< Options from current tween mode value */ } Edje_Tween_Mode; +// TIZEN_ONLY(20150110): Add plugin keyword. +#define PLUGIN +// + /** * @typedef Edje_Action_Type * @@ -1904,8 +1908,17 @@ typedef enum _Edje_Action_Type EDJE_ACTION_TYPE_PHYSICS_STOP = 22, /**< @since 1.8 @brief Physics stop action value */ EDJE_ACTION_TYPE_PHYSICS_ROT_SET = 23, /**< @since 1.8 @brief Physics rotation set action value */ EDJE_ACTION_TYPE_VIBRATION_SAMPLE = 24, /**< @since 1.10 @brief vibration sample action value */ + // TIZEN_ONLY(20150110): Add plugin keyword. + //EDJE_ACTION_TYPE_MO = 25, /**< @since 1.15 @brief Mo action value */ + //EDJE_ACTION_TYPE_LAST = 26 /**< Last action value */ +#ifdef PLUGIN + EDJE_ACTION_TYPE_RUN_PLUGIN = 25, + EDJE_ACTION_TYPE_MO = 26, /**< @since 1.15 @brief Mo action value */ + EDJE_ACTION_TYPE_LAST = 27 +#else EDJE_ACTION_TYPE_MO = 25, /**< @since 1.15 @brief Mo action value */ EDJE_ACTION_TYPE_LAST = 26 /**< Last action value */ +#endif } Edje_Action_Type; /** diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index 7bb5a07..e2094cf 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -8047,6 +8047,54 @@ EAPI Eina_Bool edje_edit_program_run(Evas_Object *obj, const char *prog); */ EAPI Eina_Bool edje_edit_program_stop_all(Evas_Object *obj); +// TIZEN_ONLY(20170421): Add plugin keyword. +#ifdef PLUGIN + +/** Get the list of all plugins. + * Use edje_edit_string_list_free() when you don't need the list anymore. + * + * @param obj Object being edited. + * + * @if MOBILE @since_tizen 3.0 + * @elseif WEARABLE @since_tizen 3.0 + * @endif + * + * @return A List containing all plugins found inside of given set in the edje file. + */ +EAPI Eina_List * +edje_edit_plugins_list_get(Evas_Object *obj); + +/** Get plugin name of the program. + * + * @param obj Object being edited. + * @param prog The name of the program. + * + * @if MOBILE @since_tizen 3.0 + * @elseif WEARABLE @since_tizen 3.0 + * @endif + * + * @return const char* plugin name on success, NULL otherwise. + */ +EAPI const char * +edje_edit_program_plugin_get(Evas_Object *obj, const char *prog); +/** Set plugin name of the program. + * + * @param obj Object being edited. + * @param prog The name of the program. + * @param name The name of the plugin. + * + * @if MOBILE @since_tizen 3.0 + * @elseif WEARABLE @since_tizen 3.0 + * @endif + * + * @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool +edje_edit_program_plugin_set(Evas_Object *obj, const char *prog, const char *name); +#endif + + + /** * @brief Sets parts into intermediate state of programs transition. * diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c index 049a6a4..bb92cc3 100644 --- a/src/lib/edje/edje_data.c +++ b/src/lib/edje/edje_data.c @@ -4,6 +4,11 @@ EAPI Eet_Data_Descriptor * _edje_edd_edje_file = NULL; EAPI Eet_Data_Descriptor * _edje_edd_edje_part_collection = NULL; Eet_Data_Descriptor *_edje_edd_edje_string = NULL; +// TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN +Eet_Data_Descriptor *_edje_edd_edje_plugin = NULL; +#endif +// Eet_Data_Descriptor *_edje_edd_edje_style = NULL; Eet_Data_Descriptor *_edje_edd_edje_style_tag = NULL; Eet_Data_Descriptor *_edje_edd_edje_color_tree_node = NULL; @@ -245,6 +250,11 @@ EAPI void _edje_edd_shutdown(void) { FREED(_edje_edd_edje_string); + // TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + FREED(_edje_edd_edje_plugin); +#endif + // FREED(_edje_edd_edje_style); FREED(_edje_edd_edje_style_tag); FREED(_edje_edd_edje_color_class); @@ -556,6 +566,18 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style, Edje_Style, "name", name, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_style, Edje_Style, "tags", tags, _edje_edd_edje_style_tag); + // TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + /* Plugin */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Plugin); + _edje_edd_edje_plugin = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_plugin, Edje_Plugin, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_plugin, Edje_Plugin, "source", source, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_plugin, Edje_Plugin, "param", param, EET_T_STRING); +#endif + // + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Color_Tree_Node); _edje_edd_edje_color_tree_node = eet_data_descriptor_file_new(&eddc); @@ -617,6 +639,11 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "image_dir", image_dir, _edje_edd_edje_image_directory); EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "model_dir", model_dir, _edje_edd_edje_model_directory); EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "sound_dir", sound_dir, _edje_edd_edje_sound_directory); + // TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, "plugins", plugins, _edje_edd_edje_plugin); +#endif + // EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "mo_dir", mo_dir, _edje_edd_edje_mo_directory); EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "filter_dir", filter_dir, _edje_edd_edje_filter_directory); @@ -661,6 +688,9 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "in.range", in.range, EET_T_DOUBLE); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "action", action, EET_T_INT); + // TIZEN_ONLY(20150119): Fix to load module for plugin. + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "plugin_name", plugin_name, EET_T_STRING); + // EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "sample_name", sample_name, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "tone_name", tone_name, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "duration", duration, EET_T_DOUBLE); diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 0d39dc0..c0a690a 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -11057,6 +11057,10 @@ edje_edit_program_add(Evas_Object *obj, const char *name) epr->channel = EDJE_CHANNEL_EFFECT; epr->tone_name = NULL; epr->duration = 0.1; +// TIZEN_ONLY(20170421): Add plugin keyword. +#ifdef PLUGIN + epr->plugin_name = NULL; +#endif //Update table_programs ed->collection->patterns.table_programs_size++; @@ -11144,6 +11148,10 @@ edje_edit_program_del(Evas_Object *obj, const char *prog) _edje_if_string_free(ed, &epr->state2); _edje_if_string_free(ed, &epr->sample_name); _edje_if_string_free(ed, &epr->tone_name); +// TIZEN_ONLY(20170421): Add plugin keyword. +#ifdef PLUGIN + _edje_if_string_free(ed, &epr->plugin_name); +#endif EINA_LIST_FREE(epr->targets, prt) free(prt); @@ -11226,6 +11234,50 @@ edje_edit_program_stop_all(Evas_Object *obj) return EINA_TRUE; } +// TIZEN_ONLY(20170421): Add plugin keyword. +#ifdef PLUGIN +EAPI Eina_List * +edje_edit_plugins_list_get(Evas_Object *obj) +{ + Eina_List *plugins = NULL, *l; + Edje_Plugin *plg= NULL; + + GET_ED_OR_RETURN(NULL); + + if (!ed->file) return NULL; + if (!ed->file->plugins) return NULL; + + EINA_LIST_FOREACH(ed->file->plugins, l, plg) + { + plugins = eina_list_append(plugins, eina_stringshare_add(plg->name)); + } + + return plugins; +} + +EAPI const char * +edje_edit_program_plugin_get(Evas_Object *obj, const char *prog) +{ + GET_EPR_OR_RETURN(NULL); + + if (!epr->plugin_name) return NULL; + return eina_stringshare_add(epr->plugin_name); +} + +EAPI Eina_Bool +edje_edit_program_plugin_set(Evas_Object *obj, const char *prog, const char *name) +{ + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + if (!name) return EINA_FALSE; + + _edje_if_string_replace(ed, &epr->plugin_name, name); + + return EINA_TRUE; +} +#endif + EAPI Eina_Bool edje_edit_program_transition_state_set(Evas_Object *obj, const char *prog, double position) { diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c index 080cca5..cf207a9 100644 --- a/src/lib/edje/edje_load.c +++ b/src/lib/edje/edje_load.c @@ -2175,6 +2175,22 @@ _edje_file_free(Edje_File *edf) free(edf->vibration_dir); } + + // TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + Edje_Plugin *plugin; + EINA_LIST_FREE(edf->plugins, plugin) + { + if (edf->free_strings) + { + if (plugin->name) eina_stringshare_del(plugin->name); + if (plugin->source) eina_stringshare_del(plugin->source); + if (plugin->param)eina_stringshare_del(plugin->param); + } + free(plugin); + } +#endif + // if (edf->mo_dir) { unsigned int i; @@ -2257,6 +2273,11 @@ _edje_program_free(Edje_Program *pr, Eina_Bool free_strings) if (pr->sample_name) eina_stringshare_del(pr->sample_name); if (pr->tone_name) eina_stringshare_del(pr->tone_name); if (pr->seat) eina_stringshare_del(pr->seat); + // TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + if (pr->plugin_name) eina_stringshare_del(pr->plugin_name); +#endif + // } EINA_LIST_FREE(pr->targets, prt) free(prt); diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 3b8799c..f801a0c 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -564,6 +564,11 @@ struct _Edje_File Edje_Gfx_Filter_Directory *filter_dir; Eina_List *styles; + // TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + Eina_List *plugins; +#endif + // Eina_List *color_tree; Eina_Hash *color_tree_hash; @@ -724,6 +729,17 @@ struct _Edje_Model_Directory_Entry int id; /* the id no. of the image */ }; +// TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN +struct _Edje_Plugin /*External Plugin*/ +{ + const char *name; /* the name of the plugin */ + const char *source; /* the source of the plugin */ + const char *param; +}; +#endif +// + struct _Edje_Sound_Sample /*Sound Sample*/ { const char *name; /* the nominal name of the sound */ @@ -808,6 +824,11 @@ struct _Edje_Program /* a conditional program to be run */ const char *source; /* if part that emitted this (name) matches this glob */ const char *sample_name; const char *tone_name; + // TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + const char *plugin_name; +#endif + // const char *vibration_name; double duration; double speed; @@ -2374,6 +2395,11 @@ EAPI void _edje_edd_shutdown(void); EAPI extern Eet_Data_Descriptor *_edje_edd_edje_file; EAPI extern Eet_Data_Descriptor *_edje_edd_edje_part_collection; +// TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN +EAPI extern Eet_Data_Descriptor *_edje_edd_edje_plugin; +#endif +// extern Eina_List *_edje_animators; extern Eina_Inlist *_edje_edjes; @@ -3128,6 +3154,12 @@ void _animation_get(Eo *obj, void *_pd, va_list *list); void edje_signal_init(void); void edje_signal_shutdown(void); +// TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN +typedef Eina_Bool (*Edje_Module_Plugin_Run) (const Evas_Object *obj, const char *name, const char *param); +#endif +// + Eina_Bool _edje_real_part_mouse_events_get(Edje *ed, Edje_Real_Part *rp); void _edje_real_part_mouse_events_set(Edje *ed, Edje_Real_Part *rp, Eina_Bool mouse_events); Eina_Bool _edje_real_part_repeat_events_get(Edje *ed, Edje_Real_Part *rp); diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c index dd6e73c..53c9998 100644 --- a/src/lib/edje/edje_program.c +++ b/src/lib/edje/edje_program.c @@ -1039,7 +1039,43 @@ low_mem_current: goto break_prog; _edje_multisense_internal_sound_tone_play(ed, pr->tone_name, pr->duration, pr->channel); break; - + // TIZEN_ONLY(20150110): Add plugin keyword. +#ifdef PLUGIN + case EDJE_ACTION_TYPE_RUN_PLUGIN: + // TIZEN_ONLY(20150119): Fix to load module for plugin. + if (_edje_block_break(ed)) + { + goto break_prog; + } + Eina_List *l; + Edje_Plugin *p; + EINA_LIST_FOREACH(ed->file->plugins, l, p) + { + if (pr->plugin_name && p->name && !strcmp(pr->plugin_name, p->name) + && p->source) + { + Eina_Module *mod; + mod = _edje_module_handle_load(p->source); + if (!mod) + { + WRN("moudle could not be loaded: %s", p->source); + break; + } + Edje_Module_Plugin_Run run_cb; + run_cb = eina_module_symbol_get(mod, "edje_plugin_run"); + if (!run_cb) + { + WRN("plugin module does not have edje_plugin_run function"); + break; + } + else + if (!run_cb(ed->obj, p->name, p->param)) WRN("edje plugin run failed"); + } + } + // + break; +#endif + // case EDJE_ACTION_TYPE_VIBRATION_SAMPLE: if (_edje_block_break(ed)) goto break_prog;