diff options
author | Thiep Ha <thiepha@gmail.com> | 2018-01-09 16:37:27 +0900 |
---|---|---|
committer | Thiep Ha <thiepha@gmail.com> | 2018-01-11 17:56:24 +0900 |
commit | 35339504b0db553083abeccd0bf5c1dcd05b4acc (patch) | |
tree | 606b393e5bcb242890a8abf40acb0f1e935314f7 | |
parent | e6ab4b41ed8487bf93c5a174a7b06317c2b7e824 (diff) | |
download | efl-35339504b0db553083abeccd0bf5c1dcd05b4acc.tar.gz |
dnd: add efl_ui_dnd_container
efl_ui_dnd_container is the interface of dnd for container objects.
-rw-r--r-- | src/Makefile_Elementary.am | 1 | ||||
-rw-r--r-- | src/lib/elementary/Elementary.h | 1 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_dnd.c | 67 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_dnd_container.eo | 50 | ||||
-rw-r--r-- | src/lib/elementary/elm_config.c | 21 | ||||
-rw-r--r-- | src/lib/elementary/elm_config.h | 19 | ||||
-rw-r--r-- | src/lib/elementary/elm_priv.h | 2 |
7 files changed, 155 insertions, 6 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index c000a86fd3..75204582fe 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -99,6 +99,7 @@ elm_public_eolian_files = \ lib/elementary/elm_code_widget.eo \ lib/elementary/efl_selection.eo \ lib/elementary/efl_ui_dnd.eo \ + lib/elementary/efl_ui_dnd_container.eo \ $(NULL) # More public files -- FIXME diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h index a9cdb945c9..36057bdcea 100644 --- a/src/lib/elementary/Elementary.h +++ b/src/lib/elementary/Elementary.h @@ -326,6 +326,7 @@ EAPI extern Elm_Version *elm_version; # include <efl_ui_pan.eo.h> # include <efl_selection.eo.h> # include <efl_ui_dnd.eo.h> +# include <efl_ui_dnd_container.eo.h> #endif /* include deprecated calls last of all */ diff --git a/src/lib/elementary/efl_ui_dnd.c b/src/lib/elementary/efl_ui_dnd.c index 761abfe474..731229d121 100644 --- a/src/lib/elementary/efl_ui_dnd.c +++ b/src/lib/elementary/efl_ui_dnd.c @@ -13,6 +13,12 @@ #include <Elementary_Cursor.h> #include "elm_priv.h" +typedef struct _Efl_Ui_Dnd_Container_Data Efl_Ui_Dnd_Container_Data; +struct _Efl_Ui_Dnd_Container_Data +{ + unsigned int drag_delay_time; +}; + extern int _wl_default_seat_id_get(Evas_Object *obj); static inline Eo* @@ -37,7 +43,6 @@ _efl_ui_dnd_drag_start(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format forma Efl_Selection_Action action, void *icon_func_data, Efl_Dnd_Drag_Icon_Create icon_func, Eina_Free_Cb icon_func_free_cb, unsigned int seat) { - ERR("In"); Eo *sel_man = _selection_manager_get(obj); efl_selection_manager_drag_start(sel_man, obj, format, data, action, icon_func_data, icon_func, icon_func_free_cb, @@ -47,7 +52,6 @@ _efl_ui_dnd_drag_start(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format forma EOLIAN static void _efl_ui_dnd_drag_cancel(Eo *obj, void *pd EINA_UNUSED, unsigned int seat) { - ERR("In"); Eo *sel_man = _selection_manager_get(obj); efl_selection_manager_drag_cancel(sel_man, obj, seat); } @@ -55,7 +59,6 @@ _efl_ui_dnd_drag_cancel(Eo *obj, void *pd EINA_UNUSED, unsigned int seat) EOLIAN static void _efl_ui_dnd_drag_action_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Action action, unsigned int seat) { - ERR("In"); Eo *sel_man = _selection_manager_get(obj); efl_selection_manager_drag_action_set(sel_man, obj, action, seat); } @@ -64,8 +67,6 @@ _efl_ui_dnd_drag_action_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Action EOLIAN static void _efl_ui_dnd_drop_target_add(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, unsigned int seat) { - ERR("In"); - Eo *sel_man = _selection_manager_get(obj); efl_selection_manager_drop_target_add(sel_man, obj, format, seat); } @@ -73,9 +74,63 @@ _efl_ui_dnd_drop_target_add(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format EOLIAN static void _efl_ui_dnd_drop_target_del(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, unsigned int seat) { - ERR("In"); Eo *sel_man = _selection_manager_get(obj); efl_selection_manager_drop_target_del(sel_man, obj, format, seat); } +EOLIAN static double +_efl_ui_dnd_container_drag_delay_time_get(Eo *obj EINA_UNUSED, Efl_Ui_Dnd_Container_Data *pd) +{ + return pd->drag_delay_time; +} + +EOLIAN static void +_efl_ui_dnd_container_drag_delay_time_set(Eo *obj EINA_UNUSED, Efl_Ui_Dnd_Container_Data *pd, double drag_delay_time) +{ + pd->drag_delay_time = drag_delay_time; +} + +EOLIAN static void +_efl_ui_dnd_container_drag_item_add(Eo *obj, Efl_Ui_Dnd_Container_Data *pd, + void *data_func_data, Efl_Dnd_Drag_Data_Get data_func, Eina_Free_Cb data_func_free_cb, + void *item_func_data, Efl_Dnd_Item_Get item_func, Eina_Free_Cb item_func_free_cb, + void *icon_func_data, Efl_Dnd_Drag_Icon_Create icon_func, Eina_Free_Cb icon_func_free_cb, + void *icon_list_func_data, Efl_Dnd_Drag_Icon_List_Create icon_list_func, Eina_Free_Cb icon_list_func_free_cb, + unsigned int seat) +{ + double drag_delay_time = pd->drag_delay_time; + double anim_time = elm_config_drag_anim_duration_get(); + Eo *sel_man = _selection_manager_get(obj); + efl_selection_manager_container_drag_item_add(sel_man, obj, drag_delay_time, anim_time, + data_func_data, data_func, data_func_free_cb, + item_func_data, item_func, item_func_free_cb, + icon_func_data, icon_func, icon_func_free_cb, + icon_list_func_data, icon_list_func, icon_list_func_free_cb, + seat); +} + +static void +_efl_ui_dnd_container_drag_item_del(Eo *obj, Efl_Ui_Dnd_Container_Data *pd EINA_UNUSED, unsigned int seat) +{ + Eo *sel_man = _selection_manager_get(obj); + efl_selection_manager_container_drag_item_del(sel_man, obj, seat); +} +EOLIAN static void +_efl_ui_dnd_container_drop_item_add(Eo *obj, Efl_Ui_Dnd_Container_Data *pd EINA_UNUSED, + Efl_Selection_Format format, + void *item_func_data, Efl_Dnd_Item_Get item_func, Eina_Free_Cb item_func_free_cb, + unsigned int seat) +{ + Eo *sel_man = _selection_manager_get(obj); + efl_selection_manager_container_drop_item_add(sel_man, obj, format, item_func_data, item_func, item_func_free_cb, seat); +} + +EOLIAN static void +_efl_ui_dnd_container_drop_item_del(Eo *obj, Efl_Ui_Dnd_Container_Data *pd EINA_UNUSED, unsigned int seat) +{ + Eo *sel_man = _selection_manager_get(obj); + efl_selection_manager_container_drop_item_del(sel_man, obj, seat); +} + #include "efl_ui_dnd.eo.c" +#include "efl_ui_dnd_container.eo.c" diff --git a/src/lib/elementary/efl_ui_dnd_container.eo b/src/lib/elementary/efl_ui_dnd_container.eo new file mode 100644 index 0000000000..abafe55661 --- /dev/null +++ b/src/lib/elementary/efl_ui_dnd_container.eo @@ -0,0 +1,50 @@ +import efl_ui_dnd_types; + +mixin Efl.Ui.Dnd.Container { + methods { + @property drag_delay_time { + [[The time since mouse down happens to drag starts.]] + set { + legacy: null; + } + get { + legacy: null; + } + values { + time: double; [[The drag delay time]] + } + } + drag_item_add { //drag_item_callback //property + [[This registers a drag for items in a container. Many items can be + dragged at a time. During dragging, there are three events emitted: + EFL_DND_EVENT_DRAG_POS, EFL_DND_EVENT_DRAG_ACCEPT, EFL_DND_EVENT_DRAG_DONE.]] + params { + //@in time_to_drag: double; [[Time since mouse down happens to drag starts]] //drag_delay: property + //@in anim_durataion: double; [[animation duration]] //just config + @in data_func: Efl.Dnd.Drag_Data_Get; [[Data and its format]] + @in item_func: Efl.Dnd.Item_Get; [[Item to determine drag start]] + @in icon_func: Efl.Dnd.Drag_Icon_Create; [[Icon used during drag]] + @in icon_list_func: Efl.Dnd.Drag_Icon_List_Create; [[Icons used for animations CHECKING ]] + @in seat: uint; [[Specified seat for multiple seats case.]] + } + } + drag_item_del { //remove + [[Remove drag function of items in the container object.]] + params { + @in seat: uint; [[Specified seat for multiple seats case.]] + } + } + drop_item_add { + params { + @in format: Efl.Selection.Format; [[Accepted data formats]] + @in item_func: Efl.Dnd.Item_Get; [[Get item at specific position]] + @in seat: uint; [[Specified seat for multiple seats case.]] + } + } + drop_item_del { + params { + @in seat: uint; [[Specified seat for multiple seats case.]] + } + } + } +} diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c index 8d83a5686a..2841c140cf 100644 --- a/src/lib/elementary/elm_config.c +++ b/src/lib/elementary/elm_config.c @@ -508,6 +508,7 @@ _desc_init(void) ELM_CONFIG_VAL(D, T, entry_select_allow, T_UCHAR); ELM_CONFIG_VAL(D, T, offline, T_UCHAR); ELM_CONFIG_VAL(D, T, powersave, T_INT); + ELM_CONFIG_VAL(D, T, drag_anim_duration, T_DOUBLE); #undef T #undef D #undef T_INT @@ -1821,6 +1822,7 @@ _config_load(void) _elm_config->icon_theme = eina_stringshare_add(ELM_CONFIG_ICON_THEME_ELEMENTARY); _elm_config->popup_scrollable = EINA_FALSE; _elm_config->entry_select_allow = EINA_TRUE; + _elm_config->drag_anim_duration = 0.0; _env_get(); } @@ -2021,6 +2023,7 @@ _elm_config_reload_do(void) KEEP_VAL(gl_msaa); KEEP_STR(icon_theme); KEEP_VAL(entry_select_allow); + KEEP_VAL(drag_anim_duration); _elm_config->priv = prev_config->priv; _config_free(prev_config); @@ -2791,6 +2794,9 @@ _env_get(void) if (s) _elm_config->popup_vertical_align = _elm_atof(s); s = getenv("ELM_POPUP_SCROLLABLE"); if (s) _elm_config->popup_scrollable = atoi(s); + + s = getenv("EFL_UI_DND_DRAG_ANIM_DURATION"); + if (s) _elm_config->drag_anim_duration = _elm_atof(s); } static void @@ -4637,6 +4643,20 @@ elm_config_powersave_set(int set) _elm_config->powersave = set; } +EAPI double +elm_config_drag_anim_duration_get(void) +{ + if (!_elm_config) return 0.0; + return _elm_config->drag_anim_duration; +} + +EAPI void +elm_config_drag_anim_duration_set(double set) +{ + if (!_elm_config) return; + _elm_config->drag_anim_duration = set; +} + void _elm_config_profile_set(const char *profile) { @@ -5074,6 +5094,7 @@ _efl_config_global_efl_config_config_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNU CONFIG_GETS(web_backend); CONFIG_GETB(offline); CONFIG_GETI(powersave); + CONFIG_GETD(drag_anim_duration); const size_t len = sizeof("audio_mute") - 1; if (!strncmp(name, "audio_mute", len)) diff --git a/src/lib/elementary/elm_config.h b/src/lib/elementary/elm_config.h index aa83915d1b..a9f428f01d 100644 --- a/src/lib/elementary/elm_config.h +++ b/src/lib/elementary/elm_config.h @@ -2201,6 +2201,25 @@ EAPI int elm_config_powersave_get(void); */ EAPI void elm_config_powersave_set(int set); +/** + * Get the animation duration for container objects + * + * @return Animation duration + * + * @since 1.21 + * @see elm_config_drag_anim_duration_set() + */ +EAPI double elm_config_drag_anim_duration_get(); + +/** + * Set the animation duration for container objects + * + * @param set Animation duration + * + * @since 1.21 + * @see elm_config_drag_anim_duration_get() + */ +EAPI void elm_config_drag_anim_duration_set(); /* new efl.config interface helpers in C */ diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h index 1a79d5ba81..bfb77147b4 100644 --- a/src/lib/elementary/elm_priv.h +++ b/src/lib/elementary/elm_priv.h @@ -327,6 +327,7 @@ struct _Elm_Config_Flags Eina_Bool gl_msaa : 1; Eina_Bool icon_theme : 1; Eina_Bool entry_select_allow : 1; // unused + Eina_Bool drag_anim_duration : 1; }; struct _Elm_Config @@ -463,6 +464,7 @@ struct _Elm_Config unsigned char entry_select_allow; Eina_Bool offline; int powersave; + double drag_anim_duration; /* Not part of the EET file */ Eina_Bool is_mirrored : 1; |