summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2017-11-14 17:07:29 +0900
committerThiep Ha <thiepha@gmail.com>2017-12-08 11:17:23 +0900
commitc409fa9e638b4eb062d9eb8faeba51b5ba823402 (patch)
treec187d579e9cafc7407c4930d6a785e67024b1d7a
parent089e06faa2f4550fdf99a111247dfc234f2405f8 (diff)
downloadefl-c409fa9e638b4eb062d9eb8faeba51b5ba823402.tar.gz
add drop for container, has not tested yet
-rw-r--r--src/lib/efl/interfaces/efl_dnd_types.eot9
-rw-r--r--src/lib/efl/interfaces/efl_selection_types.eot2
-rw-r--r--src/lib/elementary/efl_selection_manager.c149
-rw-r--r--src/lib/elementary/efl_selection_manager_private.h10
4 files changed, 116 insertions, 54 deletions
diff --git a/src/lib/efl/interfaces/efl_dnd_types.eot b/src/lib/efl/interfaces/efl_dnd_types.eot
index a5a9607b4b..3d3c728471 100644
--- a/src/lib/efl/interfaces/efl_dnd_types.eot
+++ b/src/lib/efl/interfaces/efl_dnd_types.eot
@@ -61,18 +61,19 @@ struct Efl.Dnd.Drag_Accept {
struct Efl.Dnd.Drag_Pos {
x: int; [[Evas Coordinate]]
y: int; [[Evas Coordinate]]
- action: Efl.Selection.Action;
- format: Efl.Selection.Format;
+ action: Efl.Selection.Action; [[The drag action]]
+ format: Efl.Selection.Format; [[The drag format]]
+ item: ptr(Efl.Object); [[The item object. It is only available for container object.]]
}
-struct Efl.Dnd.Drag_Item_Container_Pos {
+/*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: ptr(Efl.Object); [[The item object]]
diff --git a/src/lib/efl/interfaces/efl_selection_types.eot b/src/lib/efl/interfaces/efl_selection_types.eot
index e30cf03aa1..ca1d4b1f3f 100644
--- a/src/lib/efl/interfaces/efl_selection_types.eot
+++ b/src/lib/efl/interfaces/efl_selection_types.eot
@@ -50,6 +50,8 @@ struct Efl.Selection.Data
data: void_ptr; [[The selection data, type determined by format member]]
len: int; [[The length of the selection data]]
action: Efl.Selection.Action; [[The action to perform with the data @since 1.8]]
+
+ item: ptr(Efl.Object); [[item of under the drag position. It is only available for container]]
}
function Efl.Selection.Data_Ready {
diff --git a/src/lib/elementary/efl_selection_manager.c b/src/lib/elementary/efl_selection_manager.c
index 804bf0c227..c7a8c766c1 100644
--- a/src/lib/elementary/efl_selection_manager.c
+++ b/src/lib/elementary/efl_selection_manager.c
@@ -481,11 +481,31 @@ _efl_sel_manager_x11_selection_notify(void *udata, int type EINA_UNUSED, void *e
}
if (dropable)
{
- sel_debug("has dropable");
Drop_Format *df;
Eina_Inlist *itr;
- ddata.x = pd->savedtypes->x;
- ddata.y = pd->savedtypes->y;
+ if (!dropable->is_container)
+ {
+ sel_debug("has dropable");
+ ddata.x = pd->savedtypes->x;
+ ddata.y = pd->savedtypes->y;
+ ddata.item = NULL;
+ }
+ else
+ {
+ sel_debug("Drop on container");
+ Evas_Coord x0 = 0, y0 = 0;
+ Evas_Coord xret = 0, yret = 0;
+ evas_object_geometry_get(dropable->obj, &x0, &y0, NULL, NULL);
+ //get item
+ Efl_Object *it = NULL;
+ if (dropable->item_func)
+ dropable->item_func(dropable->item_func_data,
+ dropable->obj, pd->savedtypes->x + x0, pd->savedtypes->y + y0,
+ &xret, &yret);
+ ddata.x = xret;
+ ddata.y = yret;
+ ddata.item = it;
+ }
EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df)
if (df->format & dropable->last.format)
{
@@ -1104,7 +1124,6 @@ _x11_drag_mouse_up(void *data, int etype EINA_UNUSED, void *event)
return EINA_TRUE;
}
-
static void
_x11_drag_move(void *data, Ecore_X_Xdnd_Position *pos)
{
@@ -1121,6 +1140,7 @@ _x11_drag_move(void *data, Ecore_X_Xdnd_Position *pos)
dp.y = pos->position.y;
dp.action = pd->drag_action;
//dp.format = ;//
+ //for drag side
efl_event_callback_call(pd->drag_obj, EFL_DND_EVENT_DRAG_POS, &dp);
}
@@ -1513,8 +1533,24 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Dropable *dropable, Eva
sel_debug("same obj dropable %p\n", dropable->obj);
evas_object_geometry_get(dropable->obj, &ox, &oy, NULL, NULL);
Efl_Dnd_Drag_Pos pos_data;
- pos_data.x = x - ox;
- pos_data.y = y - oy;
+ if (!dropable->is_container)
+ {
+ pos_data.x = x - ox;
+ pos_data.y = y - oy;
+ pos_data.item = NULL;
+ }
+ else
+ {
+ Evas_Coord xret = 0, yret = 0;
+ Efl_Object *it = NULL;
+
+ if (dropable->item_func)
+ it = dropable->item_func(dropable->item_func_data, dropable->obj,
+ x, y, &xret, &yret);
+ pos_data.x = xret;
+ pos_data.y = yret;
+ pos_data.item = it;
+ }
pos_data.format = dropable->last.format;
pos_data.action = action;
EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df)
@@ -1586,8 +1622,23 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Dropable *dropable, Eva
Drop_Format *df;
Efl_Dnd_Drag_Pos pos_data;
- pos_data.x = x - ox;
- pos_data.y = y - oy;
+ if (!dropable->is_container)
+ {
+ pos_data.x = x - ox;
+ pos_data.y = y - oy;
+ pos_data.item = NULL;
+ }
+ else
+ {
+ Evas_Coord xret = 0, yret = 0;
+ Efl_Object *it = NULL;
+ if (dropable->item_func)
+ it = dropable->item_func(dropable->item_func_data, dropable->obj,
+ x, y, &xret, &yret);
+ pos_data.x = xret;
+ pos_data.y = yret;
+ pos_data.item = it;
+ }
pos_data.format = dropable->last.format;
pos_data.action = action;
EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df)
@@ -1990,11 +2041,32 @@ found:
pd->savedtypes->imgfile);
if (pd->savedtypes->imgfile)
{
- ddata.x = pd->savedtypes->x;
- ddata.y = pd->savedtypes->y;
+ Drop_Format *df;
+
+ if (!dropable->is_container)
+ {
+ ddata.x = pd->savedtypes->x;
+ ddata.y = pd->savedtypes->y;
+ ddata.item = NULL;
+ }
+ else
+ {
+ //for container
+ Efl_Object *it = NULL;
+ Evas_Coord x0 = 0, y0 = 0;
+ Evas_Coord xret = 0, yret = 0;
+
+ evas_object_geometry_get(dropable->obj, &x0, &y0, NULL, NULL);
+ if (dropable->item_func)
+ it = dropable->item_func(dropable->item_func_data, dropable->obj,
+ pd->savedtypes->x + x0, pd->savedtypes->y + y0,
+ &xret, &yret);
+ ddata.x = xret;
+ ddata.y = yret;
+ ddata.item = it;
+ }
ddata.action = act;
- Drop_Format *df;
EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df)
{
if (df->format & EFL_SELECTION_FORMAT_IMAGE)
@@ -2221,46 +2293,13 @@ _drop_item_container_del(Efl_Selection_Manager_Data *pd, Efl_Object *cont, Eina_
return EINA_FALSE;
}
-static void
-_item_container_drop_cb(void *data, Efl_Event *ev)
-{
-}
-
-static void
-_item_container_pos_cb(void *data, Efl_Event *ev)
-{
- Efl_Selection_Manager_Data *pd = data;
- Item_Container_Drop_Info *di = NULL;
- Efl_Dnd_Drag_Pos *drag_pos = ev->info;
- Efl_Object *item = NULL;
-
- di = eina_list_search_unsorted(pd->cont_drop_list, _drop_item_container_cmp, ev->object);
- int xret = 0, yret = 0;
- int xo = 0, yo = 0;
- evas_object_geometry_get(ev->object, &xo, &yo, NULL, NULL);
- if (di->item_func)
- {
- Efl_Object *it;
- it = di->item_func(di->item_func_data, ev->object, drag_pos->x + xo, drag_pos->y + yo, &xret, &yret);
- //Efl_Dnd_Drag_Pos *it_drag_pos = calloc(1, sizeof(Efl_Dnd_Drag_Pos));
- Efl_Dnd_Drag_Item_Container_Pos *it_drag_pos = calloc(1, sizeof(*it_drag_pos));
- if (!it_drag_pos) return;
- it_drag_pos->format = drag_pos->format;
- it_drag_pos->action = drag_pos->action;
- it_drag_pos->x = xret;
- it_drag_pos->y = yret;
- it_drag_pos->item = it;
- //FIXME: which event type???
- //efl_event_callback_call(ev->object, EFL_DND_EVENT_CONTAINER_DRAG_POS, it_drag_pos);
- efl_event_callback_call(ev->object, EFL_DND_EVENT_DRAG_POS, it_drag_pos);
- }
-}
-
EOLIAN static void
_efl_selection_manager_drop_item_container_add(Eo *obj, Efl_Selection_Manager_Data *pd, Efl_Object *cont, Efl_Selection_Format format, void *item_func_data, Efl_Dnd_Item_Get item_func, Eina_Free_Cb item_func_free_cb, Efl_Input_Device *seat)
{
ERR("In");
Item_Container_Drop_Info *di;
+ Dropable *dropable = NULL;
+
if (_drop_item_container_del(pd, cont, EINA_FALSE))
{
di = eina_list_search_unsorted(pd->cont_drop_list, _drop_item_container_cmp, obj);
@@ -2276,11 +2315,21 @@ _efl_selection_manager_drop_item_container_add(Eo *obj, Efl_Selection_Manager_Da
}
di->item_func = item_func;
di->item_func_data = item_func_data;
- //TODO: combine container and normal drop event
- //->need to know which case is container, which case is not
- efl_event_callback_add(cont, EFL_DND_EVENT_DRAG_POS, _item_container_pos_cb, pd);
- efl_event_callback_add(cont, EFL_DND_EVENT_DRAG_DROP, _item_container_drop_cb, pd);
+ dropable = efl_key_data_get(cont, "__elm_dropable");
+ if (!dropable)
+ {
+ dropable = calloc(1, sizeof(Dropable));
+ if (!dropable) return;
+ dropable->last.in = EINA_FALSE;
+ pd->drops = eina_list_append(pd->drops, dropable);
+ if (!pd->drops) return;
+ dropable->obj = cont;
+ efl_key_data_set(cont, "__elm_dropable", dropable);
+ }
+ dropable->is_container = EINA_TRUE;
+ dropable->item_func = item_func;
+ dropable->item_func_data = item_func_data;
efl_selection_manager_drop_target_add(obj, cont, format, seat);
}
diff --git a/src/lib/elementary/efl_selection_manager_private.h b/src/lib/elementary/efl_selection_manager_private.h
index 029be10610..6a5ea439a8 100644
--- a/src/lib/elementary/efl_selection_manager_private.h
+++ b/src/lib/elementary/efl_selection_manager_private.h
@@ -145,6 +145,11 @@ struct _Dropable
const char *type;
Efl_Selection_Format format;
} last;
+
+ //for container
+ Efl_Dnd_Item_Get item_func;
+ void *item_func_data;
+ Eina_Bool is_container;
};
typedef struct _Item_Container_Drop_Info Item_Container_Drop_Info;
@@ -197,6 +202,11 @@ struct _Efl_Selection_Manager_Data
Ecore_Event_Handler *drop_handler;
const char *text_uri;
Eina_List *cont_drop_list;
+
+
+ //for container
+ //Eina_Bool drag_container;
+ //Eina_Bool drop_container;
};
#endif