summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2018-01-09 16:22:49 +0900
committerThiep Ha <thiepha@gmail.com>2018-01-11 17:56:24 +0900
commite6ab4b41ed8487bf93c5a174a7b06317c2b7e824 (patch)
tree68d6f3ee2a66222ce6710674c2ad57265948994a
parentf191d6821f0fd94389dc92c8353b769eaacad28a (diff)
dnd: add efl_ui_dnd
Efl_Ui_Dnd is the interface for drag and drop of elm_cnp.
-rw-r--r--src/Makefile_Elementary.am2
-rw-r--r--src/lib/elementary/Elementary.h7
-rw-r--r--src/lib/elementary/efl_selection_manager.c56
-rw-r--r--src/lib/elementary/efl_ui_dnd.c81
-rw-r--r--src/lib/elementary/efl_ui_dnd.eo62
-rw-r--r--src/lib/elementary/efl_ui_widget.eo2
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 = \
98 lib/elementary/efl_config_global.eo \ 98 lib/elementary/efl_config_global.eo \
99 lib/elementary/elm_code_widget.eo \ 99 lib/elementary/elm_code_widget.eo \
100 lib/elementary/efl_selection.eo \ 100 lib/elementary/efl_selection.eo \
101 lib/elementary/efl_ui_dnd.eo \
101 $(NULL) 102 $(NULL)
102 103
103# More public files -- FIXME 104# More public files -- FIXME
@@ -763,6 +764,7 @@ lib_elementary_libelementary_la_SOURCES = \
763 lib/elementary/efl_ui_pan.c \ 764 lib/elementary/efl_ui_pan.c \
764 lib/elementary/efl_selection_manager.c \ 765 lib/elementary/efl_selection_manager.c \
765 lib/elementary/efl_selection.c \ 766 lib/elementary/efl_selection.c \
767 lib/elementary/efl_ui_dnd.c \
766 $(NULL) 768 $(NULL)
767 769
768 770
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;
321# include <efl_ui_list_pan.eo.h> 321# include <efl_ui_list_pan.eo.h>
322# include <efl_ui_scroll_manager.eo.h> 322# include <efl_ui_scroll_manager.eo.h>
323# include <efl_ui_scroller.eo.h> 323# include <efl_ui_scroller.eo.h>
324# include "efl_selection_types.eot.h" 324# include <efl_selection_types.eot.h>
325# include "efl_ui_dnd_types.eot.h" 325# include <efl_ui_dnd_types.eot.h>
326# include <efl_ui_pan.eo.h> 326# include <efl_ui_pan.eo.h>
327# include "efl_selection.eo.h" 327# include <efl_selection.eo.h>
328# include <efl_ui_dnd.eo.h>
328#endif 329#endif
329 330
330/* include deprecated calls last of all */ 331/* 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
864 if (df->format & dropable->last.format) 864 if (df->format & dropable->last.format)
865 { 865 {
866 sel_debug("calling Drop event on: %p", dropable->obj); 866 sel_debug("calling Drop event on: %p", dropable->obj);
867 //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); 867 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata);
868 } 868 }
869 } 869 }
870 } 870 }
@@ -1221,7 +1221,7 @@ _x11_drag_mouse_up(void *data, int etype EINA_UNUSED, void *event)
1221 } 1221 }
1222 } 1222 }
1223 if (!have_drop_list) ecore_x_dnd_aware_set(xwin, EINA_FALSE); 1223 if (!have_drop_list) ecore_x_dnd_aware_set(xwin, EINA_FALSE);
1224 //efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_DONE, NULL); 1224 efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_DONE, NULL);
1225 if (seat_sel->drag_win) 1225 if (seat_sel->drag_win)
1226 { 1226 {
1227 if (seat_sel->drag_obj) 1227 if (seat_sel->drag_obj)
@@ -1275,7 +1275,7 @@ _x11_drag_move(void *data, Ecore_X_Xdnd_Position *pos)
1275 dp.pos.y = pos->position.y; 1275 dp.pos.y = pos->position.y;
1276 dp.action = seat_sel->drag_action; 1276 dp.action = seat_sel->drag_action;
1277 //for drag side 1277 //for drag side
1278 //efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_POS, &dp); 1278 efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_POS, &dp);
1279} 1279}
1280 1280
1281static void 1281static void
@@ -1310,7 +1310,7 @@ _x11_dnd_status(void *data, int etype EINA_UNUSED, void *ev)
1310 { 1310 {
1311 sel_debug("Won't accept accept\n"); 1311 sel_debug("Won't accept accept\n");
1312 } 1312 }
1313 //efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_ACCEPT, &seat_sel->accept); 1313 efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_ACCEPT, &seat_sel->accept);
1314 1314
1315 return EINA_TRUE; 1315 return EINA_TRUE;
1316} 1316}
@@ -1500,10 +1500,8 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d
1500 pos_data.action = action; 1500 pos_data.action = action;
1501 EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df) 1501 EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df)
1502 { 1502 {
1503 if (df->format & dropable->last.format) 1503 if (df->format & dropable->last.format)
1504 { 1504 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data);
1505 //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data);
1506 }
1507 } 1505 }
1508 } 1506 }
1509 else 1507 else
@@ -1519,13 +1517,13 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d
1519 Drop_Format *df; 1517 Drop_Format *df;
1520 EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df) 1518 EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df)
1521 { 1519 {
1522 //if (df->format &dropable->last.format) 1520 if (df->format &dropable->last.format)
1523 // efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL); 1521 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL);
1524 } 1522 }
1525 EINA_INLIST_FOREACH_SAFE(last_dropable->format_list, itr, df) 1523 EINA_INLIST_FOREACH_SAFE(last_dropable->format_list, itr, df)
1526 { 1524 {
1527 //if (df->format & last_dropable->last.format) 1525 if (df->format & last_dropable->last.format)
1528 // efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL); 1526 efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL);
1529 } 1527 }
1530 } 1528 }
1531 else // leave last obj 1529 else // leave last obj
@@ -1537,8 +1535,8 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d
1537 Drop_Format *df; 1535 Drop_Format *df;
1538 EINA_INLIST_FOREACH_SAFE(last_dropable->format_list, itr, df) 1536 EINA_INLIST_FOREACH_SAFE(last_dropable->format_list, itr, df)
1539 { 1537 {
1540 //if (df->format & last_dropable->last.format) 1538 if (df->format & last_dropable->last.format)
1541 // efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL); 1539 efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL);
1542 } 1540 }
1543 } 1541 }
1544 } 1542 }
@@ -1576,8 +1574,8 @@ _x11_dnd_dropable_handle(Efl_Selection_Manager_Data *pd, Sel_Manager_Dropable *d
1576 { 1574 {
1577 if (df->format & dropable->last.format) 1575 if (df->format & dropable->last.format)
1578 { 1576 {
1579 //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL); 1577 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL);
1580 //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); 1578 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data);
1581 } 1579 }
1582 } 1580 }
1583 } 1581 }
@@ -1927,8 +1925,8 @@ found:
1927 ddata.format = EFL_SELECTION_FORMAT_IMAGE; 1925 ddata.format = EFL_SELECTION_FORMAT_IMAGE;
1928 ddata.data.mem = (char *)seat_sel->saved_types->imgfile; 1926 ddata.data.mem = (char *)seat_sel->saved_types->imgfile;
1929 ddata.data.len = strlen(ddata.data.mem); 1927 ddata.data.len = strlen(ddata.data.mem);
1930 //if (df->format & dropable->last.format) 1928 if (df->format & dropable->last.format)
1931 // efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); 1929 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata);
1932 } 1930 }
1933 else 1931 else
1934 { 1932 {
@@ -2599,7 +2597,7 @@ _wl_dnd_end(void *data, int type EINA_UNUSED, void *event)
2599 if (ev->serial != sel->drag_serial) 2597 if (ev->serial != sel->drag_serial)
2600 return ECORE_CALLBACK_RENEW; 2598 return ECORE_CALLBACK_RENEW;
2601 2599
2602 //efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_DONE, NULL); 2600 efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_DONE, NULL);
2603 if (seat_sel->drag_win) 2601 if (seat_sel->drag_win)
2604 { 2602 {
2605 if (!seat_sel->accept) 2603 if (!seat_sel->accept)
@@ -3178,9 +3176,7 @@ _wl_dropable_handle(Sel_Manager_Seat_Selection *seat_sel, Sel_Manager_Dropable *
3178 EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df) 3176 EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df)
3179 { 3177 {
3180 if (df->format & dropable->last.format) 3178 if (df->format & dropable->last.format)
3181 { 3179 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data);
3182 //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data);
3183 }
3184 } 3180 }
3185 3181
3186 return; 3182 return;
@@ -3194,8 +3190,8 @@ _wl_dropable_handle(Sel_Manager_Seat_Selection *seat_sel, Sel_Manager_Dropable *
3194 3190
3195 EINA_INLIST_FOREACH_SAFE(last_dropable->format_list, itr, df) 3191 EINA_INLIST_FOREACH_SAFE(last_dropable->format_list, itr, df)
3196 { 3192 {
3197 //if (df->format & last_dropable->last.format) 3193 if (df->format & last_dropable->last.format)
3198 // efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL); 3194 efl_event_callback_call(last_dropable->obj, EFL_UI_DND_EVENT_DRAG_LEAVE, NULL);
3199 } 3195 }
3200 } 3196 }
3201 /* We enter the new dropable */ 3197 /* We enter the new dropable */
@@ -3229,8 +3225,8 @@ _wl_dropable_handle(Sel_Manager_Seat_Selection *seat_sel, Sel_Manager_Dropable *
3229 { 3225 {
3230 if (df->format & dropable->last.format) 3226 if (df->format & dropable->last.format)
3231 { 3227 {
3232 //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL); 3228 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_ENTER, NULL);
3233 //efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data); 3229 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_POS, &pos_data);
3234 } 3230 }
3235 } 3231 }
3236 } 3232 }
@@ -3322,8 +3318,8 @@ _wl_dropable_data_handle(Sel_Manager_Selection *sel, Ecore_Wl2_Event_Offer_Data_
3322 3318
3323 EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df) 3319 EINA_INLIST_FOREACH_SAFE(dropable->format_list, itr, df)
3324 { 3320 {
3325 //if (df->format & dropable->last.format) 3321 if (df->format & dropable->last.format)
3326 // efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata); 3322 efl_event_callback_call(dropable->obj, EFL_UI_DND_EVENT_DRAG_DROP, &ddata);
3327 } 3323 }
3328 } 3324 }
3329 } 3325 }
@@ -3509,7 +3505,7 @@ _wl_dnd_position(void *data, int type EINA_UNUSED, void *event)
3509 } 3505 }
3510 3506
3511 seat_sel->accept = will_accept; 3507 seat_sel->accept = will_accept;
3512 //efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_ACCEPT, &seat_sel->accept); 3508 efl_event_callback_call(seat_sel->drag_obj, EFL_UI_DND_EVENT_DRAG_ACCEPT, &seat_sel->accept);
3513 3509
3514 return ECORE_CALLBACK_PASS_ON; 3510 return ECORE_CALLBACK_PASS_ON;
3515} 3511}
@@ -4268,7 +4264,7 @@ _cont_obj_drag_start(void *data)
4268 Sel_Manager_Drag_Container *dc = data; 4264 Sel_Manager_Drag_Container *dc = data;
4269 4265
4270 dc->timer = NULL; 4266 dc->timer = NULL;
4271 //efl_event_callback_add(dc->cont, EFL_UI_DND_EVENT_DRAG_DONE, _cont_obj_drag_done_cb, dc); 4267 efl_event_callback_add(dc->cont, EFL_UI_DND_EVENT_DRAG_DONE, _cont_obj_drag_done_cb, dc);
4272 elm_widget_scroll_freeze_push(dc->cont); 4268 elm_widget_scroll_freeze_push(dc->cont);
4273 efl_selection_manager_drag_start(dc->pd->sel_man, dc->cont, dc->format, 4269 efl_selection_manager_drag_start(dc->pd->sel_man, dc->cont, dc->format,
4274 eina_rw_slice_slice_get(dc->data), dc->action, 4270 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 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
6#define ELM_INTERFACE_ATSPI_TEXT_PROTECTED
7#define ELM_INTERFACE_ATSPI_TEXT_EDITABLE_PROTECTED
8#define ELM_LAYOUT_PROTECTED
9
10#define EFL_SELECTION_MANAGER_BETA
11
12#include <Elementary.h>
13#include <Elementary_Cursor.h>
14#include "elm_priv.h"
15
16extern int _wl_default_seat_id_get(Evas_Object *obj);
17
18static inline Eo*
19_selection_manager_get(Eo *obj)
20{
21 Eo *top = elm_widget_top_get(obj);
22 if (!top)
23 {
24 top = obj;
25 }
26 Eo *sel_man = efl_key_data_get(top, "__selection_manager");
27 if (!sel_man)
28 {
29 sel_man = efl_add(EFL_SELECTION_MANAGER_CLASS, top);
30 efl_key_data_set(top, "__selection_manager", sel_man);
31 }
32 return sel_man;
33}
34
35EOLIAN static void
36_efl_ui_dnd_drag_start(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, Eina_Slice data,
37 Efl_Selection_Action action, void *icon_func_data, Efl_Dnd_Drag_Icon_Create icon_func, Eina_Free_Cb icon_func_free_cb,
38 unsigned int seat)
39{
40 ERR("In");
41 Eo *sel_man = _selection_manager_get(obj);
42 efl_selection_manager_drag_start(sel_man, obj, format, data, action,
43 icon_func_data, icon_func, icon_func_free_cb,
44 seat);
45}
46
47EOLIAN static void
48_efl_ui_dnd_drag_cancel(Eo *obj, void *pd EINA_UNUSED, unsigned int seat)
49{
50 ERR("In");
51 Eo *sel_man = _selection_manager_get(obj);
52 efl_selection_manager_drag_cancel(sel_man, obj, seat);
53}
54
55EOLIAN static void
56_efl_ui_dnd_drag_action_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Action action, unsigned int seat)
57{
58 ERR("In");
59 Eo *sel_man = _selection_manager_get(obj);
60 efl_selection_manager_drag_action_set(sel_man, obj, action, seat);
61}
62
63
64EOLIAN static void
65_efl_ui_dnd_drop_target_add(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, unsigned int seat)
66{
67 ERR("In");
68
69 Eo *sel_man = _selection_manager_get(obj);
70 efl_selection_manager_drop_target_add(sel_man, obj, format, seat);
71}
72
73EOLIAN static void
74_efl_ui_dnd_drop_target_del(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, unsigned int seat)
75{
76 ERR("In");
77 Eo *sel_man = _selection_manager_get(obj);
78 efl_selection_manager_drop_target_del(sel_man, obj, format, seat);
79}
80
81#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 @@
1import efl_ui_dnd_types;
2
3mixin Efl.Ui.Dnd {
4 data: null;
5 methods {
6 drag_start {
7 [[Start a drag and drop process at the drag side.
8 During dragging, there are three events emitted as belows:
9 - EFL_UI_DND_EVENT_DRAG_POS
10 - EFL_UI_DND_EVENT_DRAG_ACCEPT
11 - EFL_UI_DND_EVENT_DRAG_DONE
12 ]]
13 params {
14 @in format: Efl.Selection.Format; [[The data format]]
15 @in data: Eina.Slice; [[The drag data]]
16 @in action: Efl.Selection.Action; [[Action when data is transferred]]
17 @in icon_func: Efl.Dnd.Drag_Icon_Create; [[Function pointer to create icon]]
18 @in seat: uint; [[Specified seat for multiple seats case.]]
19 }
20 }
21 drag_action_set {
22 [[Set the action for the drag]]
23 params {
24 @in action: Efl.Selection.Action; [[Drag action]]
25 @in seat: uint; [[Specified seat for multiple seats case.]]
26 }
27 }
28 drag_cancel {
29 [[Cancel the on-going drag]]
30 params {
31 @in seat: uint; [[Specified seat for multiple seats case.]]
32 }
33 }
34 drop_target_add {
35 [[Make the current object as drop targert.
36 There are four events emitted:
37 - EFL_UI_DND_EVENT_DRAG_ENTER
38 - EFL_UI_DND_EVENT_DRAG_LEAVE
39 - EFL_UI_DND_EVENT_DRAG_POS
40 - EFL_UI_DND_EVENT_DRAG_DROP.]]
41 params {
42 @in format: Efl.Selection.Format; [[Accepted data format]]
43 @in seat: uint; [[Specified seat for multiple seats case.]]
44 }
45 }
46 drop_target_del {
47 [[Delete the dropable status from object]]
48 params {
49 @in format: Efl.Selection.Format; [[Accepted data format]]
50 @in seat: uint; [[Specified seat for multiple seats case.]]
51 }
52 }
53 }
54 events {
55 drag,accept; [[accept drag data]]
56 drag,done; [[drag is done (mouse up)]]
57 drag,enter; [[called when the drag object enters this object]]
58 drag,leave; [[called when the drag object leaves this object]]
59 drag,pos; [[called when the drag object changes drag position]]
60 drag,drop; [[called when the drag object dropped on this object]]
61 }
62}
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 {
17abstract Efl.Ui.Widget (Efl.Canvas.Group, Efl.Access, 17abstract Efl.Ui.Widget (Efl.Canvas.Group, Efl.Access,
18 Efl.Access.Component, Efl.Ui.Focus.User, Efl.Part, 18 Efl.Access.Component, Efl.Ui.Focus.User, Efl.Part,
19 Efl.Ui.Focus.Object, Efl.Ui.Base, Efl.Ui.Cursor, 19 Efl.Ui.Focus.Object, Efl.Ui.Base, Efl.Ui.Cursor,
20 Efl.Ui.Translatable, Efl.Selection) 20 Efl.Ui.Translatable, Efl.Selection, Efl.Ui.Dnd)
21{ 21{
22 [[Elementary widget abstract class]] 22 [[Elementary widget abstract class]]
23 legacy_prefix: elm_widget; 23 legacy_prefix: elm_widget;