diff options
author | Thiep Ha <thiepha@gmail.com> | 2018-01-09 16:22:49 +0900 |
---|---|---|
committer | Thiep Ha <thiepha@gmail.com> | 2018-01-11 17:56:24 +0900 |
commit | e6ab4b41ed8487bf93c5a174a7b06317c2b7e824 (patch) | |
tree | 68d6f3ee2a66222ce6710674c2ad57265948994a | |
parent | f191d6821f0fd94389dc92c8353b769eaacad28a (diff) | |
download | efl-e6ab4b41ed8487bf93c5a174a7b06317c2b7e824.tar.gz |
dnd: add efl_ui_dnd
Efl_Ui_Dnd is the interface for drag and drop of elm_cnp.
-rw-r--r-- | src/Makefile_Elementary.am | 2 | ||||
-rw-r--r-- | src/lib/elementary/Elementary.h | 7 | ||||
-rw-r--r-- | src/lib/elementary/efl_selection_manager.c | 56 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_dnd.c | 81 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_dnd.eo | 62 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_widget.eo | 2 |
6 files changed, 176 insertions, 34 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index a1712eca5e..c000a86fd3 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -98,6 +98,7 @@ elm_public_eolian_files = \ lib/elementary/efl_config_global.eo \ lib/elementary/elm_code_widget.eo \ lib/elementary/efl_selection.eo \ + lib/elementary/efl_ui_dnd.eo \ $(NULL) # More public files -- FIXME @@ -763,6 +764,7 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/efl_ui_pan.c \ lib/elementary/efl_selection_manager.c \ lib/elementary/efl_selection.c \ + lib/elementary/efl_ui_dnd.c \ $(NULL) diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h index 2e5e4cb5b7..a9cdb945c9 100644 --- a/src/lib/elementary/Elementary.h +++ b/src/lib/elementary/Elementary.h @@ -321,10 +321,11 @@ EAPI extern Elm_Version *elm_version; # include <efl_ui_list_pan.eo.h> # include <efl_ui_scroll_manager.eo.h> # include <efl_ui_scroller.eo.h> -# include "efl_selection_types.eot.h" -# include "efl_ui_dnd_types.eot.h" +# include <efl_selection_types.eot.h> +# include <efl_ui_dnd_types.eot.h> # include <efl_ui_pan.eo.h> -# include "efl_selection.eo.h" +# include <efl_selection.eo.h> +# include <efl_ui_dnd.eo.h> #endif /* include deprecated calls last of all */ diff --git a/src/lib/elementary/efl_selection_manager.c b/src/lib/elementary/efl_selection_manager.c index 6aaf9d8eed..91cc4a6149 100644 --- a/src/lib/elementary/efl_selection_manager.c +++ b/src/lib/elementary/efl_selection_manager.c @@ -864,7 +864,7 @@ _efl_sel_manager_x11_selection_notify(void *udata, int type EINA_UNUSED, void *e if (df->format & dropable->last.format) { sel_debug("calling Drop event on: %p", dropable->obj); - //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); } } } @@ -1221,7 +1221,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_UI_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) @@ -1275,7 +1275,7 @@ _x11_drag_move(void *data, Ecore_X_Xdnd_Position *pos) dp.pos.y = pos->position.y; dp.action = seat_sel->drag_action; //for drag side - //efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_POS, &dp); + efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_POS, &dp); } static void @@ -1310,7 +1310,7 @@ _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_UI_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; } @@ -1500,10 +1500,8 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d pos_data.action = action; EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df) { - if (df->format & dropable->last.format) - { - //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); - } + if (df->format & dropable->last.format) + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); } } else @@ -1519,13 +1517,13 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d Drop_Format *df; EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df) { - //if (df->format &dropable->last.format) - // efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL); + if (df->format &dropable->last.format) + 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_UI_DND_EVENT_DRAG_LEAVE, NULL); + if (df->format & last_dropable->last.format) + efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL); } } else // leave last obj @@ -1537,8 +1535,8 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d Drop_Format *df; 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_UI_DND_EVENT_DRAG_LEAVE, NULL); + if (df->format & last_dropable->last.format) + efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL); } } } @@ -1576,8 +1574,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_UI_DND_EVENT_DRAG_ENTER, NULL); - //efl_event_callback_call(dropable->obj, EFL_UI_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); } } } @@ -1927,8 +1925,8 @@ found: ddata.format = EFL_SELECTION_FORMAT_IMAGE; ddata.data.mem = (char *)seat_sel->saved_types->imgfile; ddata.data.len = strlen(ddata.data.mem); - //if (df->format & dropable->last.format) - // efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); + if (df->format & dropable->last.format) + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); } else { @@ -2599,7 +2597,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_UI_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) @@ -3178,9 +3176,7 @@ _wl_dropable_handle(Sel_Manager_Seat_Selection *seat_sel, Sel_Manager_Dropable * EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df) { if (df->format & dropable->last.format) - { - //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); - } + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); } return; @@ -3194,8 +3190,8 @@ _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_UI_DND_EVENT_DRAG_LEAVE, NULL); + if (df->format & last_dropable->last.format) + efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL); } } /* We enter the new dropable */ @@ -3229,8 +3225,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_UI_DND_EVENT_DRAG_ENTER, NULL); - //efl_event_callback_call(dropable->obj, EFL_UI_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); } } } @@ -3322,8 +3318,8 @@ _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_UI_DND_EVENT_DRAG_DROP, &ddata); + if (df->format & dropable->last.format) + efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); } } } @@ -3509,7 +3505,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_UI_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; } @@ -4268,7 +4264,7 @@ _cont_obj_drag_start(void *data) Sel_Manager_Drag_Container *dc = data; dc->timer = NULL; - //efl_event_callback_add(dc->cont, EFL_UI_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, eina_rw_slice_slice_get(dc->data), dc->action, diff --git a/src/lib/elementary/efl_ui_dnd.c b/src/lib/elementary/efl_ui_dnd.c new file mode 100644 index 0000000000..761abfe474 --- /dev/null +++ b/src/lib/elementary/efl_ui_dnd.c @@ -0,0 +1,81 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED +#define ELM_INTERFACE_ATSPI_TEXT_PROTECTED +#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" + +extern int _wl_default_seat_id_get(Evas_Object *obj); + +static inline Eo* +_selection_manager_get(Eo *obj) +{ + Eo *top = elm_widget_top_get(obj); + if (!top) + { + top = obj; + } + Eo *sel_man = efl_key_data_get(top, "__selection_manager"); + if (!sel_man) + { + sel_man = efl_add(EFL_SELECTION_MANAGER_CLASS, top); + efl_key_data_set(top, "__selection_manager", sel_man); + } + return sel_man; +} + +EOLIAN static void +_efl_ui_dnd_drag_start(Eo *obj, void *pd EINA_UNUSED, 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"); + 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, + seat); +} + +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); +} + +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); +} + + +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); +} + +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); +} + +#include "efl_ui_dnd.eo.c" diff --git a/src/lib/elementary/efl_ui_dnd.eo b/src/lib/elementary/efl_ui_dnd.eo new file mode 100644 index 0000000000..192644e7b1 --- /dev/null +++ b/src/lib/elementary/efl_ui_dnd.eo @@ -0,0 +1,62 @@ +import efl_ui_dnd_types; + +mixin Efl.Ui.Dnd { + data: null; + methods { + drag_start { + [[Start a drag and drop process at the drag side. + During dragging, there are three events emitted as belows: + - EFL_UI_DND_EVENT_DRAG_POS + - EFL_UI_DND_EVENT_DRAG_ACCEPT + - EFL_UI_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; [[Specified seat for multiple seats case.]] + } + } + drag_action_set { + [[Set the action for the drag]] + params { + @in action: Efl.Selection.Action; [[Drag action]] + @in seat: uint; [[Specified seat for multiple seats case.]] + } + } + drag_cancel { + [[Cancel the on-going drag]] + params { + @in seat: uint; [[Specified seat for multiple seats case.]] + } + } + drop_target_add { + [[Make the current object as drop targert. + There are four events emitted: + - EFL_UI_DND_EVENT_DRAG_ENTER + - EFL_UI_DND_EVENT_DRAG_LEAVE + - EFL_UI_DND_EVENT_DRAG_POS + - EFL_UI_DND_EVENT_DRAG_DROP.]] + params { + @in format: Efl.Selection.Format; [[Accepted data format]] + @in seat: uint; [[Specified seat for multiple seats case.]] + } + } + drop_target_del { + [[Delete the dropable status from object]] + params { + @in format: Efl.Selection.Format; [[Accepted data format]] + @in seat: uint; [[Specified seat for multiple seats case.]] + } + } + } + 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_widget.eo b/src/lib/elementary/efl_ui_widget.eo index d0c1797c80..50fe8073e2 100644 --- a/src/lib/elementary/efl_ui_widget.eo +++ b/src/lib/elementary/efl_ui_widget.eo @@ -17,7 +17,7 @@ struct Efl.Ui.Widget.Focus_State { abstract Efl.Ui.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.Selection) + Efl.Ui.Translatable, Efl.Selection, Efl.Ui.Dnd) { [[Elementary widget abstract class]] legacy_prefix: elm_widget; |