dnd: add efl_ui_dnd

Efl_Ui_Dnd is the interface for drag and drop of elm_cnp.
This commit is contained in:
Thiep Ha 2018-01-09 16:22:49 +09:00
parent f191d6821f
commit e6ab4b41ed
6 changed files with 176 additions and 34 deletions

View File

@ -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)

View File

@ -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 */

View File

@ -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,

View File

@ -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"

View File

@ -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]]
}
}

View File

@ -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;