diff options
author | Thiep Ha <thiepha@gmail.com> | 2017-12-11 17:55:23 +0900 |
---|---|---|
committer | Thiep Ha <thiepha@gmail.com> | 2017-12-14 13:45:56 +0900 |
commit | 7d01677f9fdf2fac917e9c77c3574639a956ece6 (patch) | |
tree | 673729f0944e7ee6d39110cca3d97aa0c63d058f | |
parent | 02693b45c4b06830de240d1660da7190b28a04a5 (diff) | |
download | efl-7d01677f9fdf2fac917e9c77c3574639a956ece6.tar.gz |
move interfaces from efl to elementary, separate dnd to ui_dnd and ui_dnd_container
26 files changed, 495 insertions, 554 deletions
diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index e9f63cdaa1..0584602894 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -80,12 +80,8 @@ efl_eolian_files = \ lib/efl/interfaces/efl_gfx_color_class.eo \ lib/efl/interfaces/efl_gfx_text_class.eo \ lib/efl/interfaces/efl_gfx_size_class.eo \ - lib/efl/interfaces/efl_selection.eo \ - lib/efl/interfaces/efl_dnd.eo \ $(efl_eolian_legacy_files) \ $(NULL) -#lib/efl/interfaces/efl_dnd_drag.eo -#lib/efl/interfaces/efl_dnd_drop.eo efl_eolian_type_files = \ lib/efl/interfaces/efl_gfx_types.eot \ @@ -93,8 +89,6 @@ efl_eolian_type_files = \ lib/efl/interfaces/efl_input_types.eot \ lib/efl/interfaces/efl_types.eot \ lib/efl/interfaces/efl_text_types.eot \ - lib/efl/interfaces/efl_selection_types.eot \ - lib/efl/interfaces/efl_dnd_types.eot \ $(NULL) efl_eolian_files_h = $(efl_eolian_files:%.eo=%.eo.h) \ diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index abc87bb025..679c574211 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -87,11 +87,10 @@ elm_public_eolian_files = \ lib/elementary/efl_access_window.eo \ lib/elementary/efl_config_global.eo \ lib/elementary/elm_code_widget.eo \ - lib/elementary/efl_cnp.eo \ + lib/elementary/efl_selection.eo \ lib/elementary/efl_ui_dnd.eo \ + lib/elementary/efl_ui_dnd_container.eo \ $(NULL) -#lib/elementary/efl_ui_dnd_drag.eo -#lib/elementary/efl_ui_dnd_drop.eo # More public files -- FIXME elm_public_eolian_files += \ @@ -219,7 +218,9 @@ elm_legacy_eolian_files = \ elm_eolian_type_files = \ lib/elementary/elm_general.eot \ - lib/elementary/efl_ui.eot + lib/elementary/efl_ui.eot \ + lib/elementary/efl_selection_types.eot \ + lib/elementary/efl_ui_dnd_types.eot elm_public_eolian_c = $(elm_public_eolian_files:%.eo=%.eo.c) elm_public_eolian_h = $(elm_public_eolian_files:%.eo=%.eo.h) \ @@ -738,9 +739,9 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/efl_ui_focus_parent_provider_gen.c \ lib/elementary/efl_ui_focus_util.c \ lib/elementary/elm_widget_item_static_focus.c \ - lib/elementary/efl_cnp.c \ - lib/elementary/efl_dnd.c \ lib/elementary/efl_selection_manager.c \ + lib/elementary/efl_selection.c \ + lib/elementary/efl_ui_dnd.c \ $(NULL) diff --git a/src/bin/elementary/test_efl_dnd.c b/src/bin/elementary/test_efl_dnd.c index b841851b3c..ae1bef61e6 100644 --- a/src/bin/elementary/test_efl_dnd.c +++ b/src/bin/elementary/test_efl_dnd.c @@ -43,7 +43,7 @@ _selection_data_ready_cb(void *data, Eo *obj, Efl_Selection_Data *seldata) /* static void -_selection_loss_cb(void *data, Efl_Event const *event) +_selection_lost_cb(void *data, Efl_Event const *event) { Eo *obj = data; ERR("obj: %p has lost selection; %p", obj, event->object); @@ -63,7 +63,7 @@ _selection_progress_cb(void *data, Efl_Event const *event) */ static void -_selection_loss_event_cb(void *data EINA_UNUSED, const Efl_Event *event) +_selection_lost_event_cb(void *data EINA_UNUSED, const Efl_Event *event) { Eo *obj = event->object; ERR("Lost selection for obj: %p", obj); @@ -90,8 +90,10 @@ _selection_get_btn_cb(void *data, Evas_Object *obj, void *event_info) static void _selection_set_btn_cb(void *data, Evas_Object *obj, void *event_info) { - efl_selection_set(obj, EFL_SELECTION_TYPE_PRIMARY, EFL_SELECTION_FORMAT_TARGETS, - "new", 4, 1); + Eina_Slice sel_data = EINA_SLICE_STR("new"); + efl_selection_set(obj, EFL_SELECTION_TYPE_PRIMARY, EFL_SELECTION_FORMAT_TARGETS, sel_data, 1); + //fl_selection_set(obj, EFL_SELECTION_TYPE_PRIMARY, EFL_SELECTION_FORMAT_TARGETS, + // "new", 4, 1); } static void @@ -110,7 +112,7 @@ _canvas_focus_in_cb(void *data EINA_UNUSED, const Efl_Event *event) int seat_id = efl_input_device_seat_id_get(seat); if (!drop_added) { - efl_dnd_drop_target_add(drop_bt, EFL_SELECTION_FORMAT_TEXT, seat_id); + efl_ui_dnd_drop_target_add(drop_bt, EFL_SELECTION_FORMAT_TEXT, seat_id); } drop_added = EINA_TRUE; @@ -196,11 +198,12 @@ _en_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event) printf("dnd start\n"); Evas_Object *en = data; int seat_id = efl_input_device_seat_id_get(seat); + Eina_Slice drag_data = EINA_SLICE_STR("dnd Text"); - efl_event_callback_add(en, EFL_DND_EVENT_DRAG_POS, _dnd_drag_pos_cb, en); - efl_event_callback_add(en, EFL_DND_EVENT_DRAG_ACCEPT, _dnd_drag_accept_cb, en); - efl_event_callback_add(en, EFL_DND_EVENT_DRAG_DONE, _dnd_drag_done_cb, en); - efl_dnd_drag_start(en, EFL_SELECTION_FORMAT_TEXT, "dnd Text", 9, + efl_event_callback_add(en, EFL_UI_DND_EVENT_DRAG_POS, _dnd_drag_pos_cb, en); + efl_event_callback_add(en, EFL_UI_DND_EVENT_DRAG_ACCEPT, _dnd_drag_accept_cb, en); + efl_event_callback_add(en, EFL_UI_DND_EVENT_DRAG_DONE, _dnd_drag_done_cb, en); + efl_ui_dnd_drag_start(en, EFL_SELECTION_FORMAT_TEXT, drag_data, EFL_SELECTION_ACTION_COPY, en, _drag_icon_cb, NULL, seat_id); } @@ -243,10 +246,10 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) bt = efl_add(EFL_UI_BUTTON_CLASS, win); efl_text_set(bt, "test sel/drop"); efl_gfx_visible_set(bt, EINA_TRUE); - efl_event_callback_add(bt, EFL_DND_EVENT_DRAG_ENTER, _dnd_drop_enter_cb, bt); - efl_event_callback_add(bt, EFL_DND_EVENT_DRAG_LEAVE, _dnd_drop_leave_cb, bt); - efl_event_callback_add(bt, EFL_DND_EVENT_DRAG_POS, _dnd_drop_pos_cb, bt); - efl_event_callback_add(bt, EFL_DND_EVENT_DRAG_DROP, _dnd_drop_drop_cb, bt); + efl_event_callback_add(bt, EFL_UI_DND_EVENT_DRAG_ENTER, _dnd_drop_enter_cb, bt); + efl_event_callback_add(bt, EFL_UI_DND_EVENT_DRAG_LEAVE, _dnd_drop_leave_cb, bt); + efl_event_callback_add(bt, EFL_UI_DND_EVENT_DRAG_POS, _dnd_drop_pos_cb, bt); + efl_event_callback_add(bt, EFL_UI_DND_EVENT_DRAG_DROP, _dnd_drop_drop_cb, bt); drop_bt = bt; elm_box_pack_end(bx, bt); @@ -264,13 +267,13 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) //efl_selection_get(bt, EFL_SELECTION_TYPE_PRIMARY, EFL_SELECTION_FORMAT_TEXT, NULL, _selection_data_ready_cb, NULL, seat); - //efl_event_callback_add(bt, EFL_SELECTION_EVENT_SELECTION_LOSS, _selection_loss_event_cb, NULL); + //efl_event_callback_add(bt, EFL_SELECTION_EVENT_SELECTION_LOST, _selection_lost_event_cb, NULL); - /*Efl_Future *f = efl_selection_loss_feedback(bt, EFL_SELECTION_TYPE_PRIMARY); + /*Efl_Future *f = efl_selection_lost_feedback(bt, EFL_SELECTION_TYPE_PRIMARY); if (f) { printf("register future callbacks\n"); - efl_future_then(f, _selection_loss_cb, NULL, NULL, bt); + efl_future_then(f, _selection_lost_cb, NULL, NULL, bt); }*/ // @@ -321,7 +324,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) bt = elm_button_add(win); elm_object_text_set(bt, "Selection Set"); evas_object_smart_callback_add(bt, "clicked", _selection_set_btn_cb, win); - efl_event_callback_add(bt, EFL_SELECTION_EVENT_SELECTION_LOSS, _selection_loss_event_cb, NULL); + efl_event_callback_add(bt, EFL_SELECTION_EVENT_SELECTION_LOST, _selection_lost_event_cb, NULL); evas_object_show(bt); elm_box_pack_end(hbox, bt); diff --git a/src/lib/efl/CMakeLists.txt b/src/lib/efl/CMakeLists.txt index 91649ba401..6637bedfc4 100644 --- a/src/lib/efl/CMakeLists.txt +++ b/src/lib/efl/CMakeLists.txt @@ -60,10 +60,6 @@ set(PUBLIC_EO_FILES interfaces/efl_vpath_file.eo interfaces/efl_vpath_file_core.eo interfaces/efl_vpath_manager.eo - interfaces/efl_selection_types.eot - interfaces/efl_dnd_types.eot - interfaces/efl_selection.eo - interfaces/efl_dnd.eo ) set(PUBLIC_HEADERS diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 556e417602..1e706270bd 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -172,12 +172,12 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; #include "interfaces/efl_text_markup_util.eo.h" /* Selection and dnd interfaces */ -#include "interfaces/efl_selection_types.eot.h" -#include "interfaces/efl_dnd_types.eot.h" -#include "interfaces/efl_selection.eo.h" +//#include "interfaces/efl_selection_types.eot.h" +//#include "interfaces/efl_dnd_types.eot.h" +//#include "interfaces/efl_selection.eo.h" //#include "interfaces/efl_dnd_drag.eo.h" //#include "interfaces/efl_dnd_drop.eo.h" -#include "interfaces/efl_dnd.eo.h" +//#include "interfaces/efl_dnd.eo.h" #else diff --git a/src/lib/efl/interfaces/efl_dnd.eo b/src/lib/efl/interfaces/efl_dnd.eo deleted file mode 100644 index 750fe308de..0000000000 --- a/src/lib/efl/interfaces/efl_dnd.eo +++ /dev/null @@ -1,95 +0,0 @@ -import efl_selection_types; -import efl_dnd_types; - -interface Efl.Dnd (Efl.Selection) { - //eo_prefix: efl_dnd; - methods { - drag_start { - [[This starts a drag and drop process at the drag side. - During dragging, there are three events emitted as belows: - - EFL_DND_EVENT_DRAG_POS - - EFL_DND_EVENT_DRAG_ACCEPT - - EFL_DND_EVENT_DRAG_DONE - ]] - params { - @in format: Efl.Selection.Format; [[The data format]] - @in buf: const(void_ptr); //same for selection with slice - @in len: int; [[The data's length.]] - @in action: Efl.Selection.Action; [[Action when data is transferred]] - @in icon_func: Efl.Dnd.Drag_Icon_Create; [[Function pointer to create icon]] - @in seat: uint @optional; [[Specified seat for multiple seats case.]] - } - } - drag_action_set { //CHECKING - [[This sets the action for the drag]] - params { - @in action: Efl.Selection.Action; [[Drag action]] - @in seat: uint @optional; [[Specified seat for multiple seats case.]] - } - } - drag_cancel { - [[This cancels the on-going drag]] - params { - @in seat: uint @optional; [[Specified seat for multiple seats case.]] - } - } - drag_item_container_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]] - //@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 @optional; [[Specified seat for multiple seats case.]] - } - } - drag_item_container_del { //remove - [[Remove drag function of items in the container object.]] - params { - @in seat: uint @optional; [[Specified seat for multiple seats case.]] - } - } - drop_target_add { //change to property (keys: format, seat, value: boolean) - [[There are four events emitted: EFL_DND_EVENT_DRAG_ENTER, EFL_DND_EVENT_DRAG_LEAVE, - EFL_DND_EVENT_DRAG_POS, EFL_DND_EVENT_DRAG_DROP.]] - params { - @in format: Efl.Selection.Format; [[Accepted data format]] - @in seat: uint @optional; [[Specified seat for multiple seats case.]] - } - } - drop_target_del { //remove - params { - @in format: Efl.Selection.Format; [[Accepted data format]] - @in seat: uint @optional; [[Specified seat for multiple seats case.]] - } - } - drop_item_container_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 @optional; [[Specified seat for multiple seats case.]] - } - } - drop_item_container_del { - params { - @in seat: uint @optional; [[Specified seat for multiple seats case.]] - } - } - } - implements { - } - events { - drag,accept; [[accept drag data]] - drag,done; [[drag is done (mouse up)]] - drag,enter; [[called when the drag object enters this object]] - drag,leave; [[called when the drag object leaves this object]] - drag,pos; [[called when the drag object changes drag position]] - drag,drop; [[called when the drag object dropped on this object]] - drag,item,container,drop; [[called when the selected data is 'dropped' on container]] - } -} diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index daf2a6a0f2..625060f16c 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -74,10 +74,10 @@ #include "interfaces/efl_ui_selectable.eo.c" #include "interfaces/efl_ui_zoom.eo.c" -#include "interfaces/efl_selection.eo.c" -//#include "interfaces/efl_dnd_drag.eo.c" -//#include "interfaces/efl_dnd_drop.eo.c" -#include "interfaces/efl_dnd.eo.c" +//#include "interfaces/efl_selection.eo.c" +////#include "interfaces/efl_dnd_drag.eo.c" +////#include "interfaces/efl_dnd_drop.eo.c" +//#include "interfaces/efl_dnd.eo.c" EAPI void __efl_internal_init(void) diff --git a/src/lib/efl/interfaces/efl_selection.eo b/src/lib/efl/interfaces/efl_selection.eo deleted file mode 100644 index ef08625b3a..0000000000 --- a/src/lib/efl/interfaces/efl_selection.eo +++ /dev/null @@ -1,50 +0,0 @@ -import efl_selection_types; - -interface Efl.Selection { - [[Efl Copy and Paste class]] - //legacy_prefix: elm_cnp; - //eo_prefix: efl_selection; - methods { - selection_set { - params { - @in type: Efl.Selection.Type; [[Selection Type]] - @in format: Efl.Selection.Format; [[Selection Format]] - //@in data: Eina.Slice; - @in buf: const(void_ptr); - @in len: int; [[The buffer's length.]] - //@in seat: Efl.Input.Device @optional;[[Specified seat for multiple seats case.]] - @in seat: uint @optional;[[Specified seat for multiple seats case.]] - } - } - selection_get { - params { - @in type: Efl.Selection.Type; [[Selection Type]] - @in format: Efl.Selection.Format; [[Selection Format]] - @in data_func: Efl.Selection.Data_Ready; [[Data ready function pointer]] - //@in seat: Efl.Input.Device @optional;[[Specified seat for multiple seats case.]] - @in seat: uint @optional;[[Specified seat for multiple seats case.]] - } - } - selection_clear { - params { - @in type: Efl.Selection.Type; [[Selection Type]] - //@in seat: Efl.Input.Device @optional; [[Specified seat for multiple seats case.]] - @in seat: uint @optional; [[Specified seat for multiple seats case.]] - } - } - //selection_has { //change to property selection_owner - has_owner { - params { - //@in type: Efl.Selection.Type (Efl.Selection.Type.clipboard); - @in seat: uint @optional; [[Specified seat for multiple seats case.]] - } - return: bool; - } - } - implements { - } - events { - selection,loss; [[Called when selection has lost]] - selection,changed; [[Called when display server's selection has changed]] - } -} diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h index 60c64f2b96..f8c65dd160 100644 --- a/src/lib/elementary/Elementary.h +++ b/src/lib/elementary/Elementary.h @@ -149,6 +149,14 @@ EAPI extern Elm_Version *elm_version; # include <efl_ui_translatable.eo.h> # include <efl_ui_focus_composition.eo.h> # include <efl_ui_focus_layer.eo.h> +# include "efl_selection_types.eot.h" +# include "efl_ui_dnd_types.eot.h" +# include <efl_selection.eo.h> +//# include <efl_ui_dnd_drag.eo.h> +//# include <efl_ui_dnd_drop.eo.h> +# include <efl_ui_dnd.eo.h> +# include <efl_ui_dnd_container.eo.h> +//# include <efl_selection_manager.eo.h> //private #endif #include <elm_tooltip.h> @@ -312,11 +320,6 @@ EAPI extern Elm_Version *elm_version; # include <efl_ui_spin.eo.h> # include <efl_ui_spin_button.eo.h> # include <efl_ui_image_factory.eo.h> -# include <efl_cnp.eo.h> -//# include <efl_ui_dnd_drag.eo.h> -//# include <efl_ui_dnd_drop.eo.h> -# include <efl_ui_dnd.eo.h> -# include <efl_selection_manager.eo.h> #endif /* include deprecated calls last of all */ diff --git a/src/lib/elementary/bak.efl_ui_dnd.eo b/src/lib/elementary/bak.efl_ui_dnd.eo new file mode 100644 index 0000000000..8158922a2e --- /dev/null +++ b/src/lib/elementary/bak.efl_ui_dnd.eo @@ -0,0 +1,16 @@ +import efl_selection_types; +import efl_dnd_types; + +mixin Efl.Ui.Dnd (Efl.Dnd) { + implements { + Efl.Dnd.drag_start; + Efl.Dnd.drag_cancel; + Efl.Dnd.drag_action_set; + Efl.Dnd.drag_item_container_add; + Efl.Dnd.drag_item_container_del; + Efl.Dnd.drop_target_add; + Efl.Dnd.drop_target_del; + Efl.Dnd.drop_item_container_add; + Efl.Dnd.drop_item_container_del; + } +} diff --git a/src/lib/elementary/efl_cnp.eo b/src/lib/elementary/efl_cnp.eo deleted file mode 100644 index a0c57a08d5..0000000000 --- a/src/lib/elementary/efl_cnp.eo +++ /dev/null @@ -1,19 +0,0 @@ -import efl_selection_types; - -mixin Efl.Cnp (Efl.Selection) { - [[Efl Copy and Paste class]] - //legacy_prefix: elm_cnp; - //eo_prefix: efl_cnp; - methods { - } - implements { - Efl.Selection.selection_set; - Efl.Selection.selection_get; - Efl.Selection.selection_clear; - Efl.Selection.has_owner; - //Efl.Selection.selection_loss_feedback; - } - /*events { - selection,loss; [[Called when selection is lost]] - }*/ -} diff --git a/src/lib/elementary/efl_cnp_private.h b/src/lib/elementary/efl_cnp_private.h deleted file mode 100644 index 22badd6131..0000000000 --- a/src/lib/elementary/efl_cnp_private.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef EFL_CNP_PRIVATE_H -#define EFL_CNP_PRIVATE_H - -#ifdef HAVE_CONFIG_H -# include "elementary_config.h" -#endif - -#define EFL_CNP_PROTECTED - -#include <Elementary.h> -#include "elm_priv.h" - -typedef struct _Efl_Cnp_Data Efl_Cnp_Data; -typedef struct _Efl_Cnp_Atom Efl_Cnp_Atom; - -struct _Efl_Cnp_Atom -{ - const char *name; - Ecore_X_Atom x_atom; -}; - -struct _Efl_Cnp_Data -{ - -}; - -#endif diff --git a/src/lib/elementary/efl_dnd_private.h b/src/lib/elementary/efl_dnd_private.h deleted file mode 100644 index ac6e09ef9b..0000000000 --- a/src/lib/elementary/efl_dnd_private.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef EFL_DND_PRIVATE_H -#define EFL_DND_PRIVATE_H - -#include "efl_selection_private.h" - -#ifdef HAVE_CONFIG_H -# include "elementary_config.h" -#endif - -#define EFL_DND_PROTECTED - -#include <Elementary.h> -#include "elm_priv.h" - -//typedef struct _Efl_Ui_Dnd_Drag_Data Efl_Ui_Dnd_Drag_Data; -//typedef struct _Efl_Ui_Dnd_Drop_Data Efl_Ui_Dnd_Drop_Data; -typedef struct _Efl_Ui_Dnd_Data Efl_Ui_Dnd_Data; - -struct _Efl_Ui_Dnd_Data -{ - int type; - Ecore_Event_Handler *notify_handler; - Efl_Promise *promise; - - //icon create - Efl_Dnd_Drag_Icon_Create icon_create; - void *icon_create_data; - Eina_Free_Cb icon_create_free_cb; - // - Efl_Selection_Action action; - Efl_Selection_Format format; -}; - -/*struct _Efl_Ui_Dnd_Drop_Data -{ - Efl_Promise *promise; - Efl_Selection_Format format; -};*/ - -#endif diff --git a/src/lib/elementary/efl_cnp.c b/src/lib/elementary/efl_selection.c index ff8ad276de..23e842e5f0 100644 --- a/src/lib/elementary/efl_cnp.c +++ b/src/lib/elementary/efl_selection.c @@ -7,13 +7,27 @@ //#define ELM_INTERFACE_ATSPI_TEXT_EDITABLE_PROTECTED //#define ELM_LAYOUT_PROTECTED +#define EFL_SELECTION_MANAGER_BETA + #include <Elementary.h> #include "elm_priv.h" -#include "efl_cnp_private.h" +typedef struct _Efl_Selection_Data_Priv Efl_Selection_Data_Priv; +typedef struct _Efl_Selection_Atom Efl_Selection_Atom; + +struct _Efl_Selection_Atom +{ + const char *name; + Ecore_X_Atom x_atom; +}; + +struct _Efl_Selection_Data_Priv +{ + +}; -#define MY_CLASS EFL_CNP_MIXIN -#define MY_CLASS_NAME "Efl.Cnp" +#define MY_CLASS EFL_SELECTION_MIXIN +#define MY_CLASS_NAME "Efl.Selection" static inline Eo* _selection_manager_get(Eo *obj) @@ -33,7 +47,7 @@ _selection_manager_get(Eo *obj) } EOLIAN static void -_efl_cnp_efl_selection_selection_get(Eo *obj, Efl_Cnp_Data *pd, Efl_Selection_Type type, Efl_Selection_Format format, +_efl_selection_selection_get(Eo *obj, void *pd, Efl_Selection_Type type, Efl_Selection_Format format, void *data_func_data, Efl_Selection_Data_Ready data_func, Eina_Free_Cb data_func_free_cb, unsigned int seat) { ERR("In"); @@ -45,16 +59,16 @@ _efl_cnp_efl_selection_selection_get(Eo *obj, Efl_Cnp_Data *pd, Efl_Selection_Ty } EOLIAN static void -_efl_cnp_efl_selection_selection_set(Eo *obj, Efl_Cnp_Data *pd, Efl_Selection_Type type, Efl_Selection_Format format, const void *buf, int len, unsigned int seat) +_efl_selection_selection_set(Eo *obj, void *pd, Efl_Selection_Type type, Efl_Selection_Format format, Eina_Slice data, unsigned int seat) { ERR("In"); Eo *sel_man = _selection_manager_get(obj); ERR("sel_man: %p", sel_man); - efl_selection_manager_selection_set(sel_man, obj, type, format, buf, len, seat); + efl_selection_manager_selection_set(sel_man, obj, type, format, data, seat); } EOLIAN static void -_efl_cnp_efl_selection_selection_clear(Eo *obj, Efl_Cnp_Data *pd, Efl_Selection_Type type, unsigned int seat) +_efl_selection_selection_clear(Eo *obj, void *pd, Efl_Selection_Type type, unsigned int seat) { ERR("In"); Eo *sel_man = _selection_manager_get(obj); @@ -62,7 +76,7 @@ _efl_cnp_efl_selection_selection_clear(Eo *obj, Efl_Cnp_Data *pd, Efl_Selection_ } EOLIAN static Eina_Bool -_efl_cnp_efl_selection_has_owner(Eo *obj, Efl_Cnp_Data *pd, unsigned int seat) +_efl_selection_has_owner(Eo *obj, void *pd, unsigned int seat) { ERR("In"); Eo *sel_man = _selection_manager_get(obj); @@ -85,11 +99,11 @@ _x11_efl_cnp_selection_clear_cb(void *data, int type, void *event) //Selection loss event callback:: name //future or event??? /*EOLIAN static Efl_Future * -_efl_cnp_efl_selection_selection_loss_feedback(Eo *obj, Efl_Cnp_Data *pd, Efl_Selection_Type type) +_efl_selection_selection_loss_feedback(Eo *obj, void *pd, Efl_Selection_Type type) { ERR("In"); Eo *sel_man = _selection_manager_get(obj); return efl_selection_manager_selection_loss_feedback(sel_man, obj, type); }*/ -#include "efl_cnp.eo.c" +#include "efl_selection.eo.c" diff --git a/src/lib/elementary/efl_selection.eo b/src/lib/elementary/efl_selection.eo new file mode 100644 index 0000000000..5ed60afa39 --- /dev/null +++ b/src/lib/elementary/efl_selection.eo @@ -0,0 +1,118 @@ +import efl_selection_types; + +/*enum Efl.Selection.Type +{ + [[Selection type]] + primary, [[Primary text selection (highlighted or selected text)]] + secondary, [[Used when primary selection is in use]] + dnd, [[Drag and Drop]] + clipboard [[Clipboard selectio (ctrl+C)]] +} + +//should be more general: Efl.Data.Format??? +enum Efl.Selection.Format +{ + [[Selection format]] + targets = -1, [[For matching every possible atom]] + none = 0x0, [[Content is from outside of Elementary]] + text = 0x01, [[Plain unformatted text: Used for things that don't want rich markup]] + markup = 0x2, [[Edje textblock markup, including inline images]] + image = 0x4, [[Images]] + vcard = 0x08, [[Vcards]] + html = 0x10 [[Raw HTML-like data (eg. webkit)]] +} + +enum Efl.Selection.Action +{ + [[Defines the kind of action associated with the drop data]] + unknown, [[Action type is unknown]] + copy, [[Copy the data]] + move, [[Move the data]] + private, [[Private action type]] + ask, [[Ask the user what to do]] + list, [[List the data]] + link, [[Link the data]] + description [[Describe the data]] +} + +struct Efl.Selection.Data +{ + [[Structure holding the info about selected data]] + x: int; [[The coordinates of the drop (DND operations only)]] + y: int; [[The coordinates of the drop (DND operations only)]] + format: Efl.Selection.Format; [[The format of the selection]] + //data: Eina.Slice; + data: void_ptr; [[The selection data, type determined by format member]] + //len: uint; [[The length of the selection data]] + len: int; [[The length of the selection data]] + action: Efl.Selection.Action; [[The action to perform with the data @since 1.8]] + //hovered_item: Efl.Object; [[item under the drag position. It is only available for container (CHECKING]] + item: Efl.Object; [[item under the drag position. It is only available for container (CHECKING]] +} + +function Efl.Selection.Data_Ready { //FIXME: promise + [[Function pointer for getting selection]] + params { + @in obj: ptr(Eo); //CHECKING + @in seldata: ptr(Efl.Selection.Data); + } +}; + +struct Efl.Selection.Changed +{ + type: Efl.Selection.Type; [[The selection type]] + seat: int; [[The seat on which the selection changed, or NULL for "default"]] + display: void_ptr; [[The display connection object, NULL under X11]] + exist: bool; [[EINA_TRUE if the selection has an owner]] +}*/ + +mixin Efl.Selection { + [[Efl Copy and Paste class]] + //legacy_prefix: elm_cnp; + //eo_prefix: efl_selection; + //data: Efl_Selection_Data_Priv; + data: null; + methods { + selection_set { + params { + @in type: Efl.Selection.Type; [[Selection Type]] + @in format: Efl.Selection.Format; [[Selection Format]] + @in data: Eina.Slice; + ////@in buf: const(void_ptr); + ///@in len: int; [[The buffer's length.]] + //@in seat: Efl.Input.Device @optional;[[Specified seat for multiple seats case.]] + @in seat: uint @optional;[[Specified seat for multiple seats case.]] + } + } + selection_get { + params { + @in type: Efl.Selection.Type; [[Selection Type]] + @in format: Efl.Selection.Format; [[Selection Format]] + @in data_func: Efl.Selection.Data_Ready; [[Data ready function pointer]] + //@in seat: Efl.Input.Device @optional;[[Specified seat for multiple seats case.]] + @in seat: uint @optional;[[Specified seat for multiple seats case.]] + } + } + selection_clear { + params { + @in type: Efl.Selection.Type; [[Selection Type]] + //@in seat: Efl.Input.Device @optional; [[Specified seat for multiple seats case.]] + @in seat: uint @optional; [[Specified seat for multiple seats case.]] + } + } + //selection_has { //change to property selection_owner + has_owner { + params { + //@in type: Efl.Selection.Type (Efl.Selection.Type.clipboard); + @in seat: uint @optional; [[Specified seat for multiple seats case.]] + } + return: bool; + } + } + implements { + } + events { + selection,lost; [[Called when selection has lost]] + selection,changed; [[Called when display server's selection has changed]] + } +} diff --git a/src/lib/elementary/efl_selection_manager.c b/src/lib/elementary/efl_selection_manager.c index 98e56059cb..c4b12e8be2 100644 --- a/src/lib/elementary/efl_selection_manager.c +++ b/src/lib/elementary/efl_selection_manager.c @@ -33,7 +33,7 @@ static void _item_container_del_internal(Sel_Manager_Drag_Container *dc, Eina_Bo void efl_selection_manager_drop_target_del(Eo *obj, Efl_Object *target_obj, Efl_Selection_Format format, unsigned int seat); void efl_selection_manager_selection_clear(Eo *obj, Efl_Object *owner, Efl_Selection_Type type, unsigned int seat); -void efl_selection_manager_drag_start(Eo *obj, Efl_Object *drag_obj, Efl_Selection_Format format, const void *buf, int len, 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); +void efl_selection_manager_drag_start(Eo *obj, Efl_Object *drag_obj, Efl_Selection_Format format, Eina_Slice, 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); #ifdef HAVE_ELEMENTARY_X static Ecore_X_Atom _x11_dnd_action_rev_map(Efl_Selection_Action action); @@ -813,7 +813,7 @@ _efl_sel_manager_x11_selection_notify(void *udata, int type EINA_UNUSED, void *e ERR("last format: %d, df format: %d", dropable->last.format, df->format); if (df->format & dropable->last.format) { - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_DROP, &ddata); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); } } } @@ -878,7 +878,7 @@ _x11_selection_clear(void *data, int type EINA_UNUSED, void *event) sel = seat_sel->sel_list + i; - efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOSS, NULL); + efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL); sel->active = EINA_FALSE; sel->owner = NULL; @@ -898,19 +898,19 @@ _x11_general_converter(char *target EINA_UNUSED, void *data, int size EINA_UNUSE //FIXME: Check this case: remove or not if (data_ret) { - *data_ret = malloc(sel->len * sizeof(char) + 1); + *data_ret = malloc(sel->data.len * sizeof(char) + 1); if (!*data_ret) return EINA_FALSE; - memcpy(*data_ret, sel->buf, sel->len); - ((char**)(data_ret))[0][sel->len] = 0; + memcpy(*data_ret, sel->data.mem, sel->data.len); + ((char**)(data_ret))[0][sel->data.len] = 0; } - if (size_ret) *size_ret = sel->len; + if (size_ret) *size_ret = sel->data.len; } else { - if (sel->buf) + if (sel->data.mem) { - if (data_ret) *data_ret = strdup(sel->buf); - if (size_ret) *size_ret = strlen(sel->buf); + if (data_ret) *data_ret = strdup(sel->data.mem); + if (size_ret) *size_ret = strlen(sel->data.mem); } else { @@ -970,8 +970,8 @@ _x11_vcard_send(char *target EINA_UNUSED, void *data EINA_UNUSED, int size EINA_ sel_debug("Vcard send called"); sel = *(Sel_Manager_Selection **)data; - if (data_ret) *data_ret = strdup(sel->buf); - if (size_ret) *size_ret = strlen(sel->buf); + if (data_ret) *data_ret = strdup(sel->data.mem); + if (size_ret) *size_ret = strlen(sel->data.mem); return EINA_TRUE; } @@ -989,12 +989,12 @@ _x11_text_converter(char *target, void *data, int size EINA_UNUSED, void **data_ sel_debug("none"); if (data_ret) { - *data_ret = malloc(sel->len * sizeof(char) + 1); + *data_ret = malloc(sel->data.len * sizeof(char) + 1); if (!*data_ret) return EINA_FALSE; - memcpy(*data_ret, data, sel->len); - ((char**)(data_ret))[0][sel->len] = 0; + memcpy(*data_ret, data, sel->data.len); + ((char**)(data_ret))[0][sel->data.len] = 0; } - if (size_ret) *size_ret = sel->len; + if (size_ret) *size_ret = sel->data.len; return EINA_TRUE; } @@ -1003,14 +1003,14 @@ _x11_text_converter(char *target, void *data, int size EINA_UNUSED, void **data_ if ((sel->format & EFL_SELECTION_FORMAT_MARKUP) || (sel->format & EFL_SELECTION_FORMAT_HTML)) { - *data_ret = _elm_util_mkup_to_text(sel->buf); + *data_ret = _elm_util_mkup_to_text(sel->data.mem); if (size_ret && *data_ret) *size_ret = strlen(*data_ret); sel_debug("markup or html: %s", (const char *)*data_ret); } else if (sel->format & EFL_SELECTION_FORMAT_TEXT) { - ecore_x_selection_converter_text(target, sel->buf, - strlen(sel->buf), + ecore_x_selection_converter_text(target, sel->data.mem, + sel->data.len, data_ret, size_ret, ttype, typesize); sel_debug("text"); @@ -1035,25 +1035,15 @@ _x11_text_converter(char *target, void *data, int size EINA_UNUSED, void **data_ static void _x11_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd, Efl_Object *owner, - Efl_Selection_Type type, Efl_Selection_Format format, - const void *buf, int len, Sel_Manager_Seat_Selection *seat_sel) + Efl_Selection_Type type, Efl_Selection_Format format, Eina_Slice data, + Sel_Manager_Seat_Selection *seat_sel) { Ecore_X_Window xwin = _x11_xwin_get(owner); Sel_Manager_Selection *sel = seat_sel->sel_list + type; + free(sel->data.mem); + sel->data = eina_slice_dup(data); sel->active = EINA_TRUE; - if (sel->buf) - { - free(sel->buf); - } - sel->buf = malloc(len); - if (!sel->buf) - { - ERR("failed to allocate buf"); - return; - } - sel->buf = memcpy(sel->buf, buf, len); - sel->len = len; sel->format = format; sel->set(xwin, &sel, sizeof(&sel)); @@ -1071,14 +1061,14 @@ _x11_efl_sel_manager_selection_get(Eo *obj, Efl_Selection_Manager_Data *pd, if (sel->active) { - if (sel->buf && + if (sel->data.mem && ((format == sel->format) || (xwin == 0))) { sel_debug("use local data"); Efl_Selection_Data seldata; - seldata.data = sel->buf; - seldata.len = sel->len; + seldata.data = sel->data.mem; + seldata.len = sel->data.len; seldata.x = seldata.y = 0; seldata.format = sel->format; sel->data_func(sel->data_func_data, sel->request_obj, &seldata); @@ -1128,7 +1118,7 @@ _x11_drag_mouse_up(void *data, int etype EINA_UNUSED, void *event) } } if (!have_drop_list) ecore_x_dnd_aware_set(xwin, EINA_FALSE); - efl_event_callback_call(seat_sel->drag_obj, EFL_DND_EVENT_DRAG_DONE, NULL); + efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_DONE, NULL); if (seat_sel->drag_win) { if (seat_sel->drag_obj) @@ -1182,7 +1172,7 @@ _x11_drag_move(void *data, Ecore_X_Xdnd_Position *pos) dp.y = pos->position.y; dp.action = seat_sel->drag_action; //for drag side - efl_event_callback_call(seat_sel->drag_obj, EFL_DND_EVENT_DRAG_POS, &dp); + efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_POS, &dp); } static void @@ -1217,13 +1207,17 @@ _x11_dnd_status(void *data, int etype EINA_UNUSED, void *ev) { sel_debug("Won't accept accept\n"); } - efl_event_callback_call(seat_sel->drag_obj, EFL_DND_EVENT_DRAG_ACCEPT, &seat_sel->accept); + efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_ACCEPT, &seat_sel->accept); return EINA_TRUE; } static void -_x11_efl_sel_manager_drag_start(Eo *obj, Efl_Selection_Manager_Data *pd, Efl_Object *drag_obj, Efl_Selection_Format format, const void *buf, int len, 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) +_x11_efl_sel_manager_drag_start(Eo *obj, Efl_Selection_Manager_Data *pd, + Efl_Object *drag_obj, Efl_Selection_Format format, + Eina_Slice data, 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) { Ecore_X_Window xwin = _x11_xwin_get(drag_obj); Ecore_X_Window xdragwin; @@ -1256,7 +1250,8 @@ _x11_efl_sel_manager_drag_start(Eo *obj, Efl_Selection_Manager_Data *pd, Efl_Obj sel->active = EINA_TRUE; sel->request_obj = drag_obj; sel->format = format; - sel->buf = buf ? strdup(buf) : NULL; + if (sel->data.mem) free(sel->data.mem); + sel->data = eina_slice_dup(data); sel->action = action; seat_sel->drag_obj = drag_obj; seat_sel->drag_action = action; @@ -1409,7 +1404,7 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d { if (df->format & dropable->last.format) { - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_POS, &pos_data); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); } } } @@ -1427,12 +1422,12 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df) { if (df->format &dropable->last.format) - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_ENTER, NULL); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL); } EINA_INLIST_FOREACH_SAFE(last_dropable->format_list, itr, df) { if (df->format & last_dropable->last.format) - efl_event_callback_call(last_dropable->obj, EFL_DND_EVENT_DRAG_LEAVE, NULL); + efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL); } } else // leave last obj @@ -1445,7 +1440,7 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d EINA_INLIST_FOREACH_SAFE(last_dropable->format_list, itr, df) { if (df->format & last_dropable->last.format) - efl_event_callback_call(last_dropable->obj, EFL_DND_EVENT_DRAG_LEAVE, NULL); + efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL); } } } @@ -1485,8 +1480,8 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d { if (df->format & dropable->last.format) { - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_ENTER, NULL); - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_POS, &pos_data); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); } } } @@ -1835,7 +1830,7 @@ found: ddata.data = (char *)seat_sel->saved_types->imgfile; ddata.len = strlen(ddata.data); if (df->format & dropable->last.format) - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_DROP, &ddata); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); } else { @@ -2275,7 +2270,7 @@ _wl_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd, win = _wl_window_get(owner); if (sel->owner != owner) - efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOSS, NULL); + efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL); if (sel->owner) evas_object_event_callback_del_full(sel->owner, EVAS_CALLBACK_DEL, @@ -2473,7 +2468,7 @@ _wl_dnd_end(void *data, int type EINA_UNUSED, void *event) if (ev->serial != sel->drag_serial) return ECORE_CALLBACK_RENEW; - efl_event_callback_call(seat_sel->drag_obj, EFL_DND_EVENT_DRAG_DONE, NULL); + efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_DONE, NULL); if (seat_sel->drag_win) { if (!seat_sel->accept) @@ -3051,7 +3046,7 @@ _wl_dropable_handle(Sel_Manager_Seat_Selection *seat_sel, Sel_Manager_Dropable * { if (df->format & dropable->last.format) { - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_POS, &pos_data); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); } } @@ -3067,7 +3062,7 @@ _wl_dropable_handle(Sel_Manager_Seat_Selection *seat_sel, Sel_Manager_Dropable * EINA_INLIST_FOREACH_SAFE(last_dropable->format_list, itr, df) { if (df->format & last_dropable->last.format) - efl_event_callback_call(last_dropable->obj, EFL_DND_EVENT_DRAG_LEAVE, NULL); + efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL); } } /* We enter the new dropable */ @@ -3105,8 +3100,8 @@ _wl_dropable_handle(Sel_Manager_Seat_Selection *seat_sel, Sel_Manager_Dropable * { if (df->format & dropable->last.format) { - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_ENTER, NULL); - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_POS, &pos_data); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); } } } @@ -3203,7 +3198,7 @@ _wl_dropable_data_handle(Sel_Manager_Selection *sel, Ecore_Wl2_Event_Offer_Data_ EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df) { if (df->format & dropable->last.format) - efl_event_callback_call(dropable->obj, EFL_DND_EVENT_DRAG_DROP, &ddata); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); } } } @@ -3394,7 +3389,7 @@ _wl_dnd_position(void *data, int type EINA_UNUSED, void *event) seat_sel->accept = will_accept; - efl_event_callback_call(seat_sel->drag_obj, EFL_DND_EVENT_DRAG_ACCEPT, &seat_sel->accept); + efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_ACCEPT, &seat_sel->accept); return ECORE_CALLBACK_PASS_ON; } @@ -3655,7 +3650,7 @@ _cocoa_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd, return efl_selection_manager_selection_clear(pd->sel_man, owner, type, seat_sel->seat); if (len <= 0) return; - efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOSS, NULL); + efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL); if (sel->owner) evas_object_event_callback_del_full(sel->owner, EVAS_CALLBACK_DEL, _cocoa_sel_obj_del_cb, sel); @@ -3854,7 +3849,7 @@ _win32_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd, sel = seat_sel->sel_list + type; if (sel->owner != owner) - efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOSS, NULL); + efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL); if (sel->owner) evas_object_event_callback_del_full(sel->owner, EVAS_CALLBACK_DEL, _win32_sel_obj_del, sel); @@ -4072,10 +4067,10 @@ _cont_obj_drag_start(void *data) Sel_Manager_Drag_Container *dc = data; dc->timer = NULL; - efl_event_callback_add(dc->cont, EFL_DND_EVENT_DRAG_DONE, _cont_obj_drag_done_cb, dc); + efl_event_callback_add(dc->cont, EFL_UI_DND_EVENT_DRAG_DONE, _cont_obj_drag_done_cb, dc); elm_widget_scroll_freeze_push(dc->cont); efl_selection_manager_drag_start(dc->pd->sel_man, dc->cont, dc->format, - dc->buf, dc->len, dc->action, + dc->data, dc->action, dc->icon_func_data, dc->icon_func, dc->icon_func_free_cb, dc->seat); @@ -4153,8 +4148,8 @@ _cont_obj_anim_start(void *data) } dc->timer = NULL; dc->format = EFL_SELECTION_FORMAT_TARGETS; //default - dc->buf = NULL; - dc->len = 0; + free(dc->data.mem); + dc->data.len = 0; dc->action = EFL_SELECTION_ACTION_COPY; //default dc->icons = NULL; @@ -4165,7 +4160,7 @@ _cont_obj_anim_start(void *data) if (dc->drag_data_func) { dc->drag_data_func(dc->drag_data_func_data, dc->cont, - &dc->format, &dc->buf, &dc->len, &dc->action); + &dc->format, &dc->data, &dc->action); if (EINA_DBL_EQ(dc->anim_duration, 0.0)) { _cont_obj_drag_start(dc); @@ -4321,8 +4316,8 @@ EOLIAN static void _efl_selection_manager_selection_set(Eo *obj, Efl_Selection_Manager_Data *pd, Efl_Object *owner, Efl_Selection_Type type, Efl_Selection_Format format, - const void *buf, int len, unsigned int seat) - //Eina_Slice *data, unsigned int seat) + //const void *buf, int len, unsigned int seat) + Eina_Slice data, unsigned int seat) { ERR("In"); Sel_Manager_Seat_Selection *seat_sel; @@ -4368,14 +4363,14 @@ _efl_selection_manager_selection_set(Eo *obj, Efl_Selection_Manager_Data *pd, *lt = pd->loss_type; efl_promise_value_set(pd->promise, lt, _selection_loss_data_clear_cb);*/ - efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOSS, NULL); + efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL); } sel->owner = owner; #ifdef HAVE_ELEMENTARY_X sel->xwin = xwin; - return _x11_efl_sel_manager_selection_set(pd, owner, type, format, buf, len, seat_sel); + return _x11_efl_sel_manager_selection_set(pd, owner, type, format, data, seat_sel); #endif #ifdef HAVE_ELEMENTARY_WL2 return _wl_efl_sel_manager_selection_set(pd, owner, type, format, buf, len, seat_sel); @@ -4459,11 +4454,11 @@ _efl_selection_manager_selection_clear(Eo *obj, Efl_Selection_Manager_Data *pd, } sel->active = EINA_FALSE; #ifdef HAVE_ELEMENTARY_X - seat_sel->sel_list[type].len = 0; - if (seat_sel->sel_list[type].buf) + seat_sel->sel_list[type].data.len = 0; + if (seat_sel->sel_list[type].data.mem) { - free(seat_sel->sel_list[type].buf); - seat_sel->sel_list[type].buf = NULL; + free(seat_sel->sel_list[type].data.mem); + seat_sel->sel_list[type].data.mem = NULL; } if (sel->xwin != 0) local = EINA_TRUE; @@ -4473,7 +4468,7 @@ _efl_selection_manager_selection_clear(Eo *obj, Efl_Selection_Manager_Data *pd, } else { - efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOSS, NULL); + efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL); seat_sel->sel_list[type].owner = NULL; } #endif @@ -4490,7 +4485,7 @@ _efl_selection_manager_selection_clear(Eo *obj, Efl_Selection_Manager_Data *pd, _cocoa_sel_obj_del_req_cb, sel); sel->owner = NULL; sel->request_obj = NULL; - ELM_SAFE_FREE(sel->buf, free); + ELM_SAFE_FREE(sel->data.mem, free); sel->len = 0; ecore_cocoa_clipboard_clear(); @@ -4520,13 +4515,13 @@ _efl_selection_manager_selection_has_owner(Eo *obj, Efl_Selection_Manager_Data * //TODO: Should we add DRAG_START event??? EOLIAN static void -_efl_selection_manager_drag_start(Eo *obj, Efl_Selection_Manager_Data *pd, Efl_Object *drag_obj, Efl_Selection_Format format, const void *buf, int len, 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) +_efl_selection_manager_drag_start(Eo *obj, Efl_Selection_Manager_Data *pd, Efl_Object *drag_obj, Efl_Selection_Format format, Eina_Slice data, 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) { #ifdef HAVE_ELEMENTARY_X - _x11_efl_sel_manager_drag_start(obj, pd, drag_obj, format, buf, len, action, icon_func_data, icon_func, icon_func_free_cb, seat); + _x11_efl_sel_manager_drag_start(obj, pd, drag_obj, format, data, action, icon_func_data, icon_func, icon_func_free_cb, seat); #endif #ifdef HAVE_ELEMENTARY_WL2 - _wl_efl_sel_manager_drag_start(obj, pd, drag_obj, format, buf, len, action, icon_func_data, icon_func, icon_func_free_cb, seat); + _wl_efl_sel_manager_drag_start(obj, pd, drag_obj, format, data, action, icon_func_data, icon_func, icon_func_free_cb, seat); #endif #ifdef HAVE_ELEMENTARY_WIN32 #endif diff --git a/src/lib/elementary/efl_selection_manager.eo b/src/lib/elementary/efl_selection_manager.eo index c4be1d0dc4..7df10397bc 100644 --- a/src/lib/elementary/efl_selection_manager.eo +++ b/src/lib/elementary/efl_selection_manager.eo @@ -1,13 +1,15 @@ -class Efl.Selection.Manager (Efl.Object, Efl.Selection, Efl.Dnd) { +import efl_ui_dnd_types; + +class Efl.Selection.Manager (Efl.Object, Efl.Ui.Dnd) { methods { selection_set @beta { params { @in owner: Efl.Object; [[Seleciton owner]] @in type: Efl.Selection.Type; [[Selection Type]] @in format: Efl.Selection.Format; [[Selection Format]] - //@in data: Eina.Slice; - @in buf: const(void_ptr); - @in len: int; [[The buffer's length.]] + @in data: Eina.Slice; + ////@in buf: const(void_ptr); + ////@in len: int; [[The buffer's length.]] //@in seat: Efl.Input.Device @optional;[[Specified seat for multiple seats case.]] @in seat: uint @optional;[[Specified seat for multiple seats case.]] } @@ -41,16 +43,14 @@ class Efl.Selection.Manager (Efl.Object, Efl.Selection, Efl.Dnd) { drag_start @beta { [[This starts a drag and drop process at the drag side. During dragging, there are three events emitted as belows: - - EFL_DND_EVENT_DRAG_POS - - EFL_DND_EVENT_DRAG_ACCEPT - - EFL_DND_EVENT_DRAG_DONE + - EFL_UI_DND_EVENT_DRAG_POS + - EFL_UI_DND_EVENT_DRAG_ACCEPT + - EFL_UI_DND_EVENT_DRAG_DONE ]] params { @in drag_obj: Efl.Object; [[The drag object]] @in format: Efl.Selection.Format; [[The data format]] - //@in data: Eina.Slice; - @in buf: const(void_ptr); - @in len: int; [[The data's length.]] + @in data: Eina.Slice; @in action: Efl.Selection.Action; [[Action when data is transferred]] @in icon_func: Efl.Dnd.Drag_Icon_Create; [[Function pointer to create icon]] //@in seat: Efl.Input.Device @optional; [[Specified seat for multiple seats case.]] @@ -76,7 +76,7 @@ class Efl.Selection.Manager (Efl.Object, Efl.Selection, Efl.Dnd) { drag_item_container_add @beta { [[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.]] + EFL_UI_DND_EVENT_DRAG_POS, EFL_UI_DND_EVENT_DRAG_ACCEPT, EFL_UI_DND_EVENT_DRAG_DONE.]] params { @in cont: Efl.Object; [[Container object]] //@in format: Efl.Selection.Format; [[The data format]] diff --git a/src/lib/elementary/efl_selection_manager_private.h b/src/lib/elementary/efl_selection_manager_private.h index 20329ee8ac..075dc19794 100644 --- a/src/lib/elementary/efl_selection_manager_private.h +++ b/src/lib/elementary/efl_selection_manager_private.h @@ -88,8 +88,7 @@ struct _Saved_Type struct _Sel_Manager_Selection { const char *debug; - char *buf; - unsigned int len; + Eina_Rw_Slice data; Efl_Selection_Format request_format; #ifdef HAVE_ELEMENTARY_X Eina_Bool (*set) (Ecore_X_Window, const void *data, int size); @@ -184,8 +183,7 @@ struct _Sel_Manager_Drag_Container Evas *e; Efl_Object *cont; Efl_Selection_Format format; - void *buf; - int len; + Eina_Slice data; Efl_Selection_Action action; Eina_List *icons; Eina_Size2D final_icon; diff --git a/src/lib/elementary/efl_selection_private.h b/src/lib/elementary/efl_selection_private.h deleted file mode 100644 index e17e39b65d..0000000000 --- a/src/lib/elementary/efl_selection_private.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef EFL_SELECTION_PRIVATE_H -#define EFL_SELECTION_PRIVATE_H - - -//try to make common stuff for selection & dnd, so that we can separate them -#if 0 -#ifdef HAVE_CONFIG_H -# include "elementary_config.h" -#endif - -#include <Elementary.h> -#include "elm_priv.h" - -enum -{ - SELECTION_ATOM_TARGETS = 0, - SELECTION_ATOM_ATOM, - SELECTION_ATOM_LISTING_ATOMS = SELECTION_ATOM_ATOM, - SELECTION_ATOM_TEXT_URILIST, - SELECTION_ATOM_TEXT_X_VCARD, - SELECTION_ATOM_IMAGE_PNG, - SELECTION_ATOM_IMAGE_JPEG, - SELECTION_ATOM_IMAGE_BMP, - SELECTION_ATOM_IMAGE_GIF, - SELECTION_ATOM_IMAGE_TIFF, - SELECTION_ATOM_IMAGE_SVG, - SELECTION_ATOM_IMAGE_XPM, - SELECTION_ATOM_IMAGE_TGA, - SELECTION_ATOM_IMAGE_PPM, - SELECTION_ATOM_XELM, - SELECTION_ATOM_UTF8STRING, - SELECTION_ATOM_STRING, - SELECTION_ATOM_COMPOUND_TEXT, - SELECTION_ATOM_TEXT, - SELECTION_ATOM_TEXT_PLAIN_UTF8, - SELECTION_ATOM_TEXT_PLAIN, - - SELECTION_N_ATOMS, -}; - -typedef struct _Tmp_Info Tmp_Info; -typedef struct _Saved_Type Saved_Type; -typedef struct _X11_Cnp_Selection X11_Cnp_Selection; - -typedef Eina_Bool (*X11_Converter_Fn_Cb) (char *target, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *ttype, int *typesize); -typedef int (*X11_Response_Handler_Cb) (X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *); -typedef Eina_Bool (*X11_Data_Preparer_Cb) (Efl_Selection_Manager_Data *pd, Ecore_X_Event_Selection_Notify *, Efl_Selection_Data *, Tmp_Info **); - -typedef struct _Efl_Sel_Atom Efl_Sel_Atom; - -struct _Tmp_Info -{ - char *filename; - void *map; - int fd; - int len; -}; - -struct _Saved_Type -{ - const char **types; - char *imgfile; - int ntypes; - int x, y; - Eina_Bool textreq: 1; -}; - - -struct _X11_Cnp_Selection -{ - const char *debug; - Evas_Object *widget; - char *selbuf; - unsigned int len; - Efl_Selection_Format request_format; - //Elm_Drop_Cb datacb; - Eina_Bool (*set) (Ecore_X_Window, const void *data, int size); - Eina_Bool (*clear) (void); - void (*request) (Ecore_X_Window, const char *target); - //Elm_Selection_Loss_Cb loss_cb; - //void *loss_data; - - Efl_Selection_Format format; - Ecore_X_Selection ecore_sel; - Ecore_X_Window xwin; - //Elm_Xdnd_Action action; - - Eo *owner; - - Eo *request_obj; - void *data_func_data; - Efl_Selection_Data_Ready data_func; - Eina_Free_Cb data_func_free_cb; -}; - -typedef struct _Seat_Selection Seat_Selection; - -struct _Seat_Selection -{ - const char *seat_name; - X11_Cnp_Selection *sellist; -}; - - -struct _Efl_Sel_Atom -{ - const char *name; - Efl_Selection_Format format; -#ifdef HAVE_ELEMENTARY_X - /* Called by ecore to do conversion */ - X11_Converter_Fn_Cb x_converter; - X11_Data_Preparer_Cb x_data_preparer; - /* Atom */ - Ecore_X_Atom x_atom; -#endif -#ifdef HAVE_ELEMENTARY_WL2 - Wl_Converter_Fn_Cb wl_converter; - Wl_Data_Preparer_Cb wl_data_preparer; -#endif - - void *_term; -}; -#endif - - - -#endif diff --git a/src/lib/efl/interfaces/efl_selection_types.eot b/src/lib/elementary/efl_selection_types.eot index 55ec751913..6e33ac541b 100644 --- a/src/lib/efl/interfaces/efl_selection_types.eot +++ b/src/lib/elementary/efl_selection_types.eot @@ -4,7 +4,7 @@ enum Efl.Selection.Type primary, [[Primary text selection (highlighted or selected text)]] secondary, [[Used when primary selection is in use]] dnd, [[Drag and Drop]] - clipboard [[Clipboard selectio (ctrl+C)]] + clipboard [[Clipboard selection (ctrl+C)]] } //should be more general: Efl.Data.Format??? diff --git a/src/lib/elementary/efl_dnd.c b/src/lib/elementary/efl_ui_dnd.c index 84adbcf422..5bfe3d7d44 100644 --- a/src/lib/elementary/efl_dnd.c +++ b/src/lib/elementary/efl_ui_dnd.c @@ -7,12 +7,12 @@ #define ELM_INTERFACE_ATSPI_TEXT_EDITABLE_PROTECTED #define ELM_LAYOUT_PROTECTED +#define EFL_SELECTION_MANAGER_BETA + #include <Elementary.h> #include <Elementary_Cursor.h> #include "elm_priv.h" -#include "efl_dnd_private.h" - //#define MY_CLASS_DRAG EFL_UI_DND_DRAG_MIXIN //#define MY_CLASS_DROP EFL_UI_DND_DROP_MIXIN @@ -36,22 +36,22 @@ _selection_manager_get(Eo *obj) } EOLIAN static void -_efl_ui_dnd_efl_dnd_drag_start(Eo *obj, Efl_Ui_Dnd_Data *pd, Efl_Selection_Format format, const void *buf, int len, +_efl_ui_dnd_drag_start(Eo *obj, void *pd, Efl_Selection_Format format, Eina_Slice data, 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"); - pd->icon_create = icon_func; - pd->icon_create_data = icon_func_data; - pd->icon_create_free_cb = icon_func_free_cb; + //pd->icon_create = icon_func; + //pd->icon_create_data = icon_func_data; + //pd->icon_create_free_cb = icon_func_free_cb; //TODO: check seat Eo *sel_man = _selection_manager_get(obj); - efl_selection_manager_drag_start(sel_man, obj, format, buf, len, action, icon_func_data, icon_func, icon_func_free_cb, seat); + efl_selection_manager_drag_start(sel_man, obj, format, data, action, icon_func_data, icon_func, icon_func_free_cb, seat); } EOLIAN static void -_efl_ui_dnd_efl_dnd_drag_cancel(Eo *obj, Efl_Ui_Dnd_Data *pd, unsigned int seat) +_efl_ui_dnd_drag_cancel(Eo *obj, void *pd, unsigned int seat) { ERR("In"); Eo *sel_man = _selection_manager_get(obj); @@ -59,15 +59,34 @@ _efl_ui_dnd_efl_dnd_drag_cancel(Eo *obj, Efl_Ui_Dnd_Data *pd, unsigned int seat) } EOLIAN static void -_efl_ui_dnd_efl_dnd_drag_action_set(Eo *obj, Efl_Ui_Dnd_Data *pd , Efl_Selection_Action action, unsigned int seat) +_efl_ui_dnd_drag_action_set(Eo *obj, void *pd , Efl_Selection_Action action, unsigned int seat) { ERR("In"); Eo *sel_man = _selection_manager_get(obj); efl_selection_manager_drag_action_set(sel_man, action, seat); } + +EOLIAN static void +_efl_ui_dnd_drop_target_add(Eo *obj, void *pd, Efl_Selection_Format format, unsigned int seat) +{ + ERR("In"); + //pd->format = format; + + Eo *sel_man = _selection_manager_get(obj); + efl_selection_manager_drop_target_add(sel_man, obj, format, seat); +} + +EOLIAN static void +_efl_ui_dnd_drop_target_del(Eo *obj, void *pd, 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 void -_efl_ui_dnd_efl_dnd_drag_item_container_add(Eo *obj, Efl_Ui_Dnd_Data *pd, double time_to_drag, double anim_time, +_efl_ui_dnd_container_drag_item_add(Eo *obj, void *pd, double time_to_drag, double anim_time, 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, @@ -85,33 +104,14 @@ _efl_ui_dnd_efl_dnd_drag_item_container_add(Eo *obj, Efl_Ui_Dnd_Data *pd, double } static void -_efl_ui_dnd_efl_dnd_drag_item_container_del(Eo *obj, Efl_Ui_Dnd_Data *pd, unsigned int seat) +_efl_ui_dnd_container_drag_item_del(Eo *obj, void *pd, unsigned int seat) { ERR("In"); Eo *sel_man = _selection_manager_get(obj); efl_selection_manager_drag_item_container_del(sel_man, obj, seat); } - -EOLIAN static void -_efl_ui_dnd_efl_dnd_drop_target_add(Eo *obj, Efl_Ui_Dnd_Data *pd, Efl_Selection_Format format, unsigned int seat) -{ - ERR("In"); - pd->format = format; - - Eo *sel_man = _selection_manager_get(obj); - efl_selection_manager_drop_target_add(sel_man, obj, format, seat); -} - -EOLIAN static void -_efl_ui_dnd_efl_dnd_drop_target_del(Eo *obj, Efl_Ui_Dnd_Data *pd, 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 void -_efl_ui_dnd_efl_dnd_drop_item_container_add(Eo *obj, Efl_Ui_Dnd_Data *pd, Efl_Selection_Format format, void *item_func_data, Efl_Dnd_Item_Get item_func, Eina_Free_Cb item_func_free_cb, unsigned int seat) +_efl_ui_dnd_container_drop_item_add(Eo *obj, void *pd, Efl_Selection_Format format, void *item_func_data, Efl_Dnd_Item_Get item_func, Eina_Free_Cb item_func_free_cb, unsigned int seat) { ERR("In"); Eo *sel_man = _selection_manager_get(obj); @@ -119,7 +119,7 @@ _efl_ui_dnd_efl_dnd_drop_item_container_add(Eo *obj, Efl_Ui_Dnd_Data *pd, Efl_Se } EOLIAN static void -_efl_ui_dnd_efl_dnd_drop_item_container_del(Eo *obj, Efl_Ui_Dnd_Data *pd, unsigned int seat) +_efl_ui_dnd_container_drop_item_del(Eo *obj, void *pd, unsigned int seat) { ERR("In"); Eo *sel_man = _selection_manager_get(obj); @@ -128,3 +128,4 @@ _efl_ui_dnd_efl_dnd_drop_item_container_del(Eo *obj, Efl_Ui_Dnd_Data *pd, unsign #include "efl_ui_dnd.eo.c" +#include "efl_ui_dnd_container.eo.c" diff --git a/src/lib/elementary/efl_ui_dnd.eo b/src/lib/elementary/efl_ui_dnd.eo index 8158922a2e..9fc53bd955 100644 --- a/src/lib/elementary/efl_ui_dnd.eo +++ b/src/lib/elementary/efl_ui_dnd.eo @@ -1,16 +1,134 @@ -import efl_selection_types; -import efl_dnd_types; +import efl_ui_dnd_types; -mixin Efl.Ui.Dnd (Efl.Dnd) { + +/*function Efl.Dnd.Drag_Icon_Create { + [[Function pointer for creating icon at the drag side.]] + params { + @in win: ptr(Eo); [[The window to create the objects relative to]] + //@in drag_obj: Efl.Gfx; + //Eina_Position2D + @out xoff: int; [[A return coordinate for the X offset at which to place the drag icon object relative to the source drag object]] + @out yoff: int; [[A return coordinate for the Y offset at which to place the drag icon object relative to the source drag object]] + } + return: ptr(Eo); //Eo + //return: Efl.Gfx; [[The drag icon object]] //Efl.Canvas.Object +}; + +function Efl.Dnd.Drag_Data_Get { + [[Function pointer for getting data and format at the drag side.]] + params { + @in obj: ptr(Eo); [[The container object]] + @out format: Efl.Selection.Format; [[Data format]] + //Eina_Slice + @out drag_data: Eina.Slice; [[Data]] + @out action: Efl.Selection.Action; [[The drag action]] + } +}; + +function Efl.Dnd.Item_Get { + [[Function pointer to find out which item is under position (x, y)]] + params { + @in obj: ptr(Eo); [[The container object]] + @in x: int; [[The x coordinate to get item]] + @in y: int; [[The y coordinate to get item]] + @out xret: int; [[x position relative to item (left (-1), middle (0), right (1)]] + @out yret: int; [[y position relative to item (upper (-1), middle (0), bottom (1)]] + } + return: ptr(Eo); [[Object under x,y coordinates or NULL if not found]] +}; + +function Efl.Dnd.Drag_Icon_List_Create { + [[Function pointer to create list of icons at the drag side. + These icons are used for animation on combining selection icons + to one icon.]] + params { + @in obj: ptr(Eo); [[The container object]] + } + return: ptr(Eina_List); +}; + +struct Efl.Dnd.Drag_Accept { + accepted: bool; +} + +struct Efl.Dnd.Drag_Pos { + x: int; [[Evas Coordinate]] + y: int; [[Evas Coordinate]] + action: Efl.Selection.Action; [[The drag action]] + format: Efl.Selection.Format; [[The drag format]] + item: Efl.Object; [[The item object. It is only available for container object.]] +} + +/*struct Efl.Dnd.Drag_Item_Container_Pos { + item: ptr(Efl.Object); [[The item object]] + x: int; [[Evas Coordinate]] + y: int; [[Evas Coordinate]] + action: Efl.Selection.Action; [[The drag action]] + format: Efl.Selection.Format; [[The drag format]] +}* + +struct Efl.Dnd.Drag_Item_Container_Drop { + item: Efl.Object; [[The item object]] + data: Efl.Selection.Data; [[The selection data]] + x: int; [[x position relative to item (left (-1), middle (0), right (1)]] + y: int; [[y position relative to item (upper (-1), middle (0), bottom (1)]] +}*/ + +mixin Efl.Ui.Dnd { + //eo_prefix: efl_dnd; + data: null; + methods { + drag_start { + [[This starts a drag and drop process at the drag side. + During dragging, there are three events emitted as belows: + - EFL_DND_EVENT_DRAG_POS + - EFL_DND_EVENT_DRAG_ACCEPT + - EFL_DND_EVENT_DRAG_DONE + ]] + params { + @in format: Efl.Selection.Format; [[The data format]] + @in data: Eina.Slice; [[The drag data]] + @in action: Efl.Selection.Action; [[Action when data is transferred]] + @in icon_func: Efl.Dnd.Drag_Icon_Create; [[Function pointer to create icon]] + @in seat: uint @optional; [[Specified seat for multiple seats case.]] + } + } + drag_action_set { //CHECKING + [[This sets the action for the drag]] + params { + @in action: Efl.Selection.Action; [[Drag action]] + @in seat: uint @optional; [[Specified seat for multiple seats case.]] + } + } + drag_cancel { + [[This cancels the on-going drag]] + params { + @in seat: uint @optional; [[Specified seat for multiple seats case.]] + } + } + drop_target_add { //change to property (keys: format, seat, value: boolean) + [[There are four events emitted: EFL_DND_EVENT_DRAG_ENTER, EFL_DND_EVENT_DRAG_LEAVE, + EFL_DND_EVENT_DRAG_POS, EFL_DND_EVENT_DRAG_DROP.]] + params { + @in format: Efl.Selection.Format; [[Accepted data format]] + @in seat: uint @optional; [[Specified seat for multiple seats case.]] + } + } + drop_target_del { //remove + params { + @in format: Efl.Selection.Format; [[Accepted data format]] + @in seat: uint @optional; [[Specified seat for multiple seats case.]] + } + } + } implements { - Efl.Dnd.drag_start; - Efl.Dnd.drag_cancel; - Efl.Dnd.drag_action_set; - Efl.Dnd.drag_item_container_add; - Efl.Dnd.drag_item_container_del; - Efl.Dnd.drop_target_add; - Efl.Dnd.drop_target_del; - Efl.Dnd.drop_item_container_add; - Efl.Dnd.drop_item_container_del; + } + events { + drag,accept; [[accept drag data]] + drag,done; [[drag is done (mouse up)]] + drag,enter; [[called when the drag object enters this object]] + drag,leave; [[called when the drag object leaves this object]] + drag,pos; [[called when the drag object changes drag position]] + drag,drop; [[called when the drag object dropped on this object]] } } 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..cd18f9e018 --- /dev/null +++ b/src/lib/elementary/efl_ui_dnd_container.eo @@ -0,0 +1,43 @@ +import efl_ui_dnd_types; + +mixin Efl.Ui.Dnd.Container { + data: null; + methods { + 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]] + //@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 @optional; [[Specified seat for multiple seats case.]] + } + } + drag_item_del { //remove + [[Remove drag function of items in the container object.]] + params { + @in seat: uint @optional; [[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 @optional; [[Specified seat for multiple seats case.]] + } + } + drop_item_del { + params { + @in seat: uint @optional; [[Specified seat for multiple seats case.]] + } + } + } + events { + drag,item,container,drop; [[called when the selected data is 'dropped' on container]] + } +} diff --git a/src/lib/efl/interfaces/efl_dnd_types.eot b/src/lib/elementary/efl_ui_dnd_types.eot index 014f7a58a2..26a4845cfb 100644 --- a/src/lib/efl/interfaces/efl_dnd_types.eot +++ b/src/lib/elementary/efl_ui_dnd_types.eot @@ -18,9 +18,7 @@ function Efl.Dnd.Drag_Data_Get { params { @in obj: ptr(Eo); [[The container object]] @out format: Efl.Selection.Format; [[Data format]] - //Eina_Slice - @out buf: void_ptr; [[Data]] - @out len: int; [[The data's length]] + @out drag_data: Eina.Slice; [[Data]] @out action: Efl.Selection.Action; [[The drag action]] } }; diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h index 802938458b..36bc4ce69f 100644 --- a/src/lib/elementary/elm_priv.h +++ b/src/lib/elementary/elm_priv.h @@ -56,6 +56,7 @@ #include "efl_ui_focus_parent_provider.eo.h" #include "efl_ui_focus_parent_provider_standard.eo.h" #include "elm_widget_item_static_focus.eo.h" +#include "efl_selection_manager.eo.h" #ifdef HAVE_LANGINFO_H # include <langinfo.h> diff --git a/src/lib/elementary/elm_widget.eo b/src/lib/elementary/elm_widget.eo index 8afedd09d4..95f1cf9e4c 100644 --- a/src/lib/elementary/elm_widget.eo +++ b/src/lib/elementary/elm_widget.eo @@ -21,7 +21,7 @@ struct Elm.Widget.Focus_State { abstract Elm.Widget (Efl.Canvas.Group, Efl.Access, Efl.Access.Component, Efl.Ui.Focus.User, Efl.Part, Efl.Ui.Focus.Object, Efl.Ui.Base, Efl.Ui.Cursor, - Efl.Ui.Translatable, Efl.Cnp, Efl.Ui.Dnd) + Efl.Ui.Translatable, Efl.Selection, Efl.Ui.Dnd) { [[Elementary widget abstract class]] legacy_prefix: elm_widget; |