summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-12-23 16:27:46 +0200
committerYakov Goldberg <yakov.g@samsung.com>2014-12-23 18:27:28 +0200
commit049fbcc94c653e5034ab73ca08b4aa0c35134672 (patch)
treec9939d6906f2ae7cc6a0caeeb255a4308e6bf778 /src/bin
parente20a25c69510096e9066ba1f7303b22c769eb691 (diff)
DnD: fix 2
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/egui_gui/dnd.c2
-rw-r--r--src/bin/egui_gui/editor.c130
2 files changed, 108 insertions, 24 deletions
diff --git a/src/bin/egui_gui/dnd.c b/src/bin/egui_gui/dnd.c
index d4386d3..12c8f74 100644
--- a/src/bin/egui_gui/dnd.c
+++ b/src/bin/egui_gui/dnd.c
@@ -44,6 +44,7 @@ typedef struct
44#define DROP_TARGET "__drop_target__" 44#define DROP_TARGET "__drop_target__"
45 45
46static DnD_Info _dnd_info; 46static DnD_Info _dnd_info;
47int aa;
47 48
48/* Determine if dragged object is inside droppable. */ 49/* Determine if dragged object is inside droppable. */
49Eina_Bool 50Eina_Bool
@@ -313,6 +314,7 @@ _drag_start(void *data)
313 314
314 _dnd_info.tm = NULL; 315 _dnd_info.tm = NULL;
315 _dnd_info.drag_info = di; 316 _dnd_info.drag_info = di;
317 _dnd_info.dnd_in_out = 0;
316 elm_drag_start(di->obj, ELM_SEL_FORMAT_TEXT, 318 elm_drag_start(di->obj, ELM_SEL_FORMAT_TEXT,
317 di->data, ELM_XDND_ACTION_COPY, 319 di->data, ELM_XDND_ACTION_COPY,
318 image_create_icon_f, drag_image, 320 image_create_icon_f, drag_image,
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index 44b5e33..de81c5d 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -571,10 +571,14 @@ _mouse_down_main(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_
571 objtree_item_selected_set(wdg); 571 objtree_item_selected_set(wdg);
572} 572}
573 573
574static void
575_drag_obj_del(const Gui_Widget *dragged_wdg, Eo *canvas);
576
574/* Callback, called when eidress mouse button */ 577/* Callback, called when eidress mouse button */
575static void 578static void
576_mouse_up_main(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 579_mouse_up_main(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
577{ 580{
581 Gui_Widget *main_wdg = data;
578 if (!dnd_is_in_drop_target()) 582 if (!dnd_is_in_drop_target())
579 { 583 {
580 /* Check if dragged object is visible. 584 /* Check if dragged object is visible.
@@ -589,9 +593,18 @@ _mouse_up_main(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, vo
589 _wdg_border_draw(NULL, EINA_FALSE, BORDER_DROP_TARGET); 593 _wdg_border_draw(NULL, EINA_FALSE, BORDER_DROP_TARGET);
590 if (!vis) 594 if (!vis)
591 { 595 {
596 DnD_Info *di = wdg_data_get(main_wdg, EDITOR_DND_DATA);
597 Eo *canvas = session_eo_get(session, main_wdg);
598 if (di->eo_cur)
599 {
600 _drag_obj_del(drag_widget, canvas);
601 di->eo_cur = NULL;
602 }
603
592 Gui_Widget *wdg_main = data; 604 Gui_Widget *wdg_main = data;
593 _wdg_parent_win_reload(wdg_main); 605 _wdg_parent_win_reload(wdg_main);
594 _editor_wdg_selected_set(drag_widget); 606 _editor_wdg_selected_set(drag_widget);
607 objtree_item_selected_set(drag_widget);
595 } 608 }
596 } 609 }
597} 610}
@@ -960,7 +973,41 @@ _frame_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj,
960static Eina_Bool 973static Eina_Bool
961_frame_mouse_up(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 974_frame_mouse_up(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
962{ 975{
963 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _frame_mouse_move); 976 const Gui_Widget *wdg = _editor_wdg_selected_get();
977 /* Don't use dnd for dragging window around canvas. */
978 if (IS_WIN(wdg))
979 {
980 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _frame_mouse_move);
981 }
982 else
983 {
984 if (!dnd_is_in_drop_target())
985 {
986 /* Check if dragged object is visible.
987 * If not, means that _drag_start_cb was called, so need to reload main wdg. */
988 Eo *canvas = egui_layout_gui_get()->main_win->canvas_bg;
989 DnD_Info *di = eo_do(canvas, eo_key_data_get(EDITOR_DND_DATA));
990
991
992 const Gui_Widget *drag_widget = dnd_drag_wdg_get();
993 if (!drag_widget) return EO_CALLBACK_CONTINUE;
994 Eina_Bool vis = eo_do(obj, evas_obj_visibility_get());
995
996 drag_stop();
997 _wdg_border_draw(NULL, EINA_FALSE, BORDER_DROP_TARGET);
998 if (!vis)
999 {
1000 if (di->eo_cur)
1001 {
1002 _drag_obj_del(drag_widget, canvas);
1003 di->eo_cur = NULL;
1004 }
1005 _wdg_parent_win_reload(drag_widget);
1006 _editor_wdg_selected_set(drag_widget);
1007 objtree_item_selected_set(drag_widget);
1008 }
1009 }
1010 }
964 return EO_CALLBACK_CONTINUE; 1011 return EO_CALLBACK_CONTINUE;
965} 1012}
966 1013
@@ -1608,6 +1655,22 @@ _drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev)
1608 else 1655 else
1609 { 1656 {
1610 new_wdg = dnd_drag_wdg_get(); 1657 new_wdg = dnd_drag_wdg_get();
1658
1659 if (IS_MAIN(new_wdg))
1660 {
1661 Main_Wdg_Info *wi = wdg_data_get(new_wdg, MAIN_WDG_INFO);
1662 if (wi)
1663 {
1664 Eo *fr = main_wdg_info_frame_get(wi);
1665 Eo *o = session_eo_get(session, new_wdg);
1666 Eo *optional_win = eo_do(o, eo_key_data_get("__editor_win"));
1667 wdg_data_set(new_wdg, MAIN_WDG_INFO, NULL);
1668 eo_do(o, eo_key_data_del("__editor_win"));
1669 eo_del(optional_win);
1670 eo_del(fr);
1671 free(wi);
1672 }
1673 }
1611 } 1674 }
1612 1675
1613 /* Check if new_widget was packed previously: take it's parent and check 1676 /* Check if new_widget was packed previously: take it's parent and check
@@ -1795,13 +1858,45 @@ _drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev)
1795 wdg_data_set(new_wdg, CURSOR_DROP_Y, (void *) (intptr_t) di->pointer_y); 1858 wdg_data_set(new_wdg, CURSOR_DROP_Y, (void *) (intptr_t) di->pointer_y);
1796 } 1859 }
1797 } 1860 }
1861 /* Dragging into win */
1798 else if (wdg && IS_WIN(wdg)) 1862 else if (wdg && IS_WIN(wdg))
1799 { 1863 {
1800 Gui_Memento *memento_next = gui_memento_new(wdg_eid_get(new_wdg), 1864 Gui_Memento *memento_next = gui_memento_new(wdg_eid_get(new_wdg),
1801 MEMENTO_WIDGET_PARENT, 1865 MEMENTO_WIDGET_PARENT,
1802 wdg_parent_id_get(new_wdg), wdg_eid_get(wdg)); 1866 wdg_parent_id_get(new_wdg), wdg_eid_get(wdg));
1867 Gui_Memento *memento_last = memento_next;
1803 gui_memento_append((Gui_Memento *) gui_context_current_memento_get(ctx), memento_next); 1868 gui_memento_append((Gui_Memento *) gui_context_current_memento_get(ctx), memento_next);
1804 wdg_parent_set((Gui_Widget *) new_wdg, wdg_name_get(wdg)); 1869 wdg_parent_set((Gui_Widget *) new_wdg, wdg_name_get(wdg));
1870 if (new_wdg)
1871 {
1872 Gui_Widget_Property *old_prop, *prop;
1873 Gui_Value *val;
1874 old_prop = wdg_prop_get(new_wdg, DB_DEF_EVAS_OBJECT_CLASS, POSITION_SET);
1875 if (!old_prop)
1876 {
1877 Op_Desc *op = db_mro_op_desc_get(wdg_class_name_get(new_wdg), DB_DEF_EVAS_OBJECT_CLASS, POSITION_SET);
1878 prop = prop_create_for_op(op);
1879 }
1880 else
1881 {
1882 prop = prop_copy(old_prop);
1883 }
1884
1885 val = prop_value_nth_get(prop, 0);
1886 gui_value_int_set(val, di->pointer_x);
1887 val = prop_value_nth_get(prop, 1);
1888 gui_value_int_set(val, di->pointer_y);
1889 propview_item_update(prop);
1890
1891 memento_next = gui_memento_new(wdg_eid_get(new_wdg), MEMENTO_PROPERTY, old_prop, prop);
1892 gui_memento_append(memento_last, memento_next);
1893
1894 if (old_prop)
1895 {
1896 wdg_prop_remove((Gui_Widget *) new_wdg, old_prop);
1897 }
1898 wdg_prop_add((Gui_Widget *) new_wdg, prop);
1899 }
1805 } 1900 }
1806 else 1901 else
1807 { 1902 {
@@ -2190,13 +2285,18 @@ _drag_start_cb(const Gui_Widget *wdg, const Eo *_wdg_eo)
2190 wdg_container = wdg_parent; 2285 wdg_container = wdg_parent;
2191 2286
2192 /* Explicitly call enter cb in order to create object, which will be dragged. */ 2287 /* Explicitly call enter cb in order to create object, which will be dragged. */
2193 Evas_Coord x, y; 2288 Evas_Coord x = 0, y = 0;
2194 if (IS_MAIN(wdg)) 2289 if (IS_MAIN(wdg))
2195 { 2290 {
2196 _drop_target_main_wdg_enter(NULL, egui_layout_gui_get()->main_win->canvas_bg); 2291 _drop_target_main_wdg_enter(NULL, egui_layout_gui_get()->main_win->canvas_bg);
2197 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO); 2292 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
2198 Eo *fr = main_wdg_info_frame_get(wi); 2293 if (wi)
2199 eo_do(fr, evas_obj_position_get(&x, &y)); 2294 {
2295 Eo *fr = main_wdg_info_frame_get(wi);
2296 eo_do(fr, evas_obj_position_get(&x, &y));
2297 eo_do(fr, evas_obj_visibility_set(EINA_FALSE));
2298 }
2299 _drop_target_pos(NULL, egui_layout_gui_get()->main_win->canvas_bg, x, y, ELM_XDND_ACTION_UNKNOWN);
2200 } 2300 }
2201 else 2301 else
2202 { 2302 {
@@ -2220,24 +2320,6 @@ _drag_start_cb(const Gui_Widget *wdg, const Eo *_wdg_eo)
2220 _drop_target_enter(wdg_container, NULL); 2320 _drop_target_enter(wdg_container, NULL);
2221 _drop_target_pos(wdg_container, NULL, x, y, ELM_XDND_ACTION_UNKNOWN); 2321 _drop_target_pos(wdg_container, NULL, x, y, ELM_XDND_ACTION_UNKNOWN);
2222 } 2322 }
2223 /* Case for main object. */
2224 else if (!wdg_parent)
2225 {
2226 _drop_target_pos(NULL, egui_layout_gui_get()->main_win->canvas_bg, x, y, ELM_XDND_ACTION_UNKNOWN);
2227
2228 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
2229 wdg_data_set(wdg, MAIN_WDG_INFO, NULL);
2230 if (wi)
2231 {
2232 Eo *fr = main_wdg_info_frame_get(wi);
2233 Eo *o = session_eo_get(session, wdg);
2234 Eo *optional_win = eo_do(o, eo_key_data_get("__editor_win"));
2235 //eo_do(fr, evas_obj_visibility_set(EINA_FALSE));
2236 eo_del(optional_win);
2237 eo_del(fr);
2238 free(wi);
2239 }
2240 }
2241} 2323}
2242 2324
2243static Eina_Bool 2325static Eina_Bool
@@ -2648,10 +2730,10 @@ _editor_undo(const Gui_Context *ctx)
2648 Eo *fr = main_wdg_info_frame_get(wi); 2730 Eo *fr = main_wdg_info_frame_get(wi);
2649 Eo *o = session_eo_get(session, wdg); 2731 Eo *o = session_eo_get(session, wdg);
2650 Eo *optional_win = eo_do(o, eo_key_data_get("__editor_win")); 2732 Eo *optional_win = eo_do(o, eo_key_data_get("__editor_win"));
2651 //eo_do(fr, evas_obj_visibility_set(EINA_FALSE));
2652 eo_del(optional_win); 2733 eo_del(optional_win);
2653 eo_del(fr); 2734 eo_del(fr);
2654 free(wi); 2735 free(wi);
2736 session_wdg_existence_set(session, wdg, EINA_FALSE);
2655 } 2737 }
2656 } 2738 }
2657 Eid *old_parent_id = (Eid *) gui_memento_old_pointer_get(memento); 2739 Eid *old_parent_id = (Eid *) gui_memento_old_pointer_get(memento);
@@ -2849,10 +2931,10 @@ _editor_redo(const Gui_Context *ctx)
2849 Eo *fr = main_wdg_info_frame_get(wi); 2931 Eo *fr = main_wdg_info_frame_get(wi);
2850 Eo *o = session_eo_get(session, wdg); 2932 Eo *o = session_eo_get(session, wdg);
2851 Eo *optional_win = eo_do(o, eo_key_data_get("__editor_win")); 2933 Eo *optional_win = eo_do(o, eo_key_data_get("__editor_win"));
2852 //eo_do(fr, evas_obj_visibility_set(EINA_FALSE));
2853 eo_del(optional_win); 2934 eo_del(optional_win);
2854 eo_del(fr); 2935 eo_del(fr);
2855 free(wi); 2936 free(wi);
2937 session_wdg_existence_set(session, wdg, EINA_FALSE);
2856 } 2938 }
2857 } 2939 }
2858 Eid *new_parent_id = (Eid *) gui_memento_new_pointer_get(memento); 2940 Eid *new_parent_id = (Eid *) gui_memento_new_pointer_get(memento);