Enlightenment CVS committal Author : lordchaos Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_embed.c ewl_embed.h ewl_enums.h ewl_events.c ewl_iconbox.c ewl_iconbox.h ewl_window.c ewl_window.h Log Message: * EWL Drag-and-drop, step 1. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_embed.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ewl_embed.c 13 Nov 2005 23:01:14 -0000 1.21 +++ ewl_embed.c 20 Nov 2005 03:03:34 -0000 1.22 @@ -678,6 +678,54 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } + +/** + * @param embed: the embed where the DND position event is to occur + * @param x: the x coordinate of the mouse move + * @param y: the y coordinate of the mouse move + * @return Returns no value. + * @brief Sends the event for a DND position into an embed. + */ +void +ewl_embed_dnd_position_feed(Ewl_Embed *embed, int x, int y) +{ + Ewl_Widget *widget = NULL; + Ewl_Event_Mouse_Move ev; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("embed", embed); + DCHECK_TYPE("embed", embed, "embed"); + + ev.x = x; + ev.y = y; + + ewl_embed_active_set(embed, TRUE); + + widget = ewl_container_child_at_recursive_get(EWL_CONTAINER(embed), x, y); + + if (widget) { + Ewl_Widget* parent = widget; + + printf("Found widget %p\n", widget); + + /*Pass the event up the chain*/ + while (parent) { + ewl_callback_call_with_event_data(parent, + EWL_CALLBACK_DND_POSITION, &ev); + + parent = parent->parent; + } + + ewl_callback_call_with_event_data(widget, + EWL_CALLBACK_DND_POSITION, &ev); + } else { + DWARNING("Could not find widget for dnd position event"); + } + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + + /** * @param embed: the embed where the mouse event is to occur * @param x: the x coordinate of the mouse out =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_embed.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- ewl_embed.h 1 Nov 2005 05:54:50 -0000 1.7 +++ ewl_embed.h 20 Nov 2005 03:03:34 -0000 1.8 @@ -93,6 +93,9 @@ int y, unsigned int modifiers); void ewl_embed_mouse_move_feed(Ewl_Embed *embed, int x, int y, unsigned int modifiers); + +void ewl_embed_dnd_position_feed(Ewl_Embed *embed, int x, int y); + void ewl_embed_mouse_out_feed(Ewl_Embed *embed, int x, int y, unsigned int modifiers); void ewl_embed_mouse_wheel_feed(Ewl_Embed *embed, int x, int y, =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_enums.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- ewl_enums.h 4 Nov 2005 00:53:22 -0000 1.22 +++ ewl_enums.h 20 Nov 2005 03:03:34 -0000 1.23 @@ -45,6 +45,11 @@ EWL_CALLBACK_WIDGET_ENABLE, /**< Widget has been re-enabled */ EWL_CALLBACK_WIDGET_DISABLE, /**< Widget no longer takes input */ EWL_CALLBACK_PASTE, /**< Data is ready to be pasted */ + + EWL_CALLBACK_DND_POSITION, /** A DND position event **/ + EWL_CALLBACK_DND_ENTER, /** On enter of a widget **/ + EWL_CALLBACK_DND_LEAVE, /** On exit of a widget **/ + EWL_CALLBACK_MAX /**< Flag to indicate last value */ }; @@ -148,6 +153,8 @@ EWL_FLAG_STATE_SELECTED = 0x10000000, EWL_FLAG_STATE_DND = 0x2000000, EWL_FLAG_STATE_DISABLED = 0x4000000, + + EWL_FLAG_PROPERTY_DND_AWARE = 0x10000000 }; #define EWL_FLAG_FILL_NORMAL (EWL_FLAG_FILL_FILL) =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_events.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- ewl_events.c 23 Oct 2005 23:15:19 -0000 1.8 +++ ewl_events.c 20 Nov 2005 03:03:34 -0000 1.9 @@ -19,6 +19,8 @@ int ewl_ev_x_mouse_move(void *data, int type, void *_ev); int ewl_ev_x_mouse_out(void *data, int type, void *_ev); int ewl_ev_x_paste(void *data, int type, void *_ev); + +int ewl_ev_dnd_position(void *data, int type, void *_ev); #endif #ifdef ENABLE_EWL_FB @@ -62,6 +64,12 @@ ecore_event_handler_add(ECORE_X_EVENT_KEY_UP, ewl_ev_x_key_up, NULL); + + /* Register dispatching functions for DND events */ + + ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION, + ewl_ev_dnd_position, NULL); + /* * Finally, register dispatching functions for mouse events. */ @@ -419,6 +427,7 @@ ev = e; + embed = ewl_embed_evas_window_find((void *)ev->win); if (!embed) DRETURN_INT(TRUE, DLEVEL_STABLE); @@ -499,6 +508,62 @@ DRETURN_INT(TRUE, DLEVEL_STABLE); } +/** + * @param data: user specified data passed to the function + * @param type: the type of event triggering the function call + * @param e: the dnd position information + * @return Returns no value. + * @brief Handles the data for an XDND position event + * + * Tells an XDND source if we can accept DND at this window location + */ +int +ewl_ev_dnd_position(void *data __UNUSED__, int type __UNUSED__, void *e) +{ + Ewl_Window* window; + Ecore_X_Event_Xdnd_Position *ev = e; + int x,y,wx,wy; + Ecore_X_Rectangle rect; + + DENTER_FUNCTION(DLEVEL_STABLE); + + window = ewl_window_window_find((void *)ev->win); + if (window) { + Ewl_Widget* notify; + Ewl_Embed* embed; + + ewl_window_position_get(EWL_WINDOW(window), &wx,&wy); + x = ev->position.x - wx; + y = ev->position.y - wy; + //printf("Received event at window pos (%d:%d), %d:%d\n",CURRENT_X(window), CURRENT_Y(window), x,y); + + + /*Look for the child here*/ + embed = ewl_embed_evas_window_find((void *)ev->win); + if (embed) { + //printf("Found embed, feeding..\n"); + ewl_embed_dnd_position_feed(embed, x, y); + } else { + //printf("Could not find embed for window..\n"); + } + + + + rect.x = 0; + rect.y = 0; + rect.width = 0; + rect.height = 0; + ecore_x_dnd_send_status(1, 0, rect, ECORE_X_DND_ACTION_PRIVATE); + + + } + + DRETURN_INT(TRUE, DLEVEL_STABLE); +} + + + + #endif #ifdef ENABLE_EWL_FB =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.c,v retrieving revision 1.76 retrieving revision 1.77 diff -u -3 -r1.76 -r1.77 --- ewl_iconbox.c 18 Nov 2005 03:35:50 -0000 1.76 +++ ewl_iconbox.c 20 Nov 2005 03:03:34 -0000 1.77 @@ -27,9 +27,6 @@ } - -/*Ecore_List *ewl_iconbox_icon_list;*/ - /** * @return Returns NULL on failure, a new Ewl_IconBox on success * @brief Creates a new Ewl_IconBox @@ -53,6 +50,11 @@ DRETURN_PTR(EWL_WIDGET(ib), DLEVEL_STABLE); } + +/** + * @return Returns a new Ewl_IconBox_Icon, NULL on failure + * + */ Ewl_Widget *ewl_iconbox_icon_new() { Ewl_IconBox_Icon* icon; @@ -74,6 +76,7 @@ } + void ewl_iconbox_inner_pane_calculate(Ewl_IconBox* ib) { @@ -100,6 +103,11 @@ } +/** + * @param icon: The Ewl_IconBox_Icon to initialize + * @return Returns a positive value on success + * + */ int ewl_iconbox_icon_init(Ewl_IconBox_Icon* icon) { Ewl_Widget *w; @@ -133,7 +141,12 @@ } - +/** + * @param ib: The length of text to delete + * @return Returns a positive value on success + * + * Initialize an iconbox + */ int ewl_iconbox_init(Ewl_IconBox* ib) { Ewl_Widget *w; @@ -203,9 +216,6 @@ ewl_callback_append(ib->ewl_iconbox_context_menu_item, EWL_CALLBACK_MOUSE_DOWN, ewl_iconbox_expansion_cb, ib); ewl_widget_show(ib->ewl_iconbox_context_menu_item); - /*ib->ewl_iconbox_context_menu_item = ewl_separator_new(); - ewl_container_child_append(EWL_CONTAINER(ib->ewl_iconbox_context_menu), ib->ewl_iconbox_context_menu_item); - ewl_widget_show(ib->ewl_iconbox_context_menu_item);*/ ewl_widget_show(ib->ewl_iconbox_view_menu); /* Add the menu floater to the pane inner */ @@ -260,7 +270,7 @@ ewl_container_child_append(EWL_CONTAINER(ib->select_floater), ib->select); ewl_container_child_append(EWL_CONTAINER(ib->ewl_iconbox_pane_inner), ib->select_floater); - ewl_object_custom_size_set(EWL_OBJECT(ib->select), 80, 40); + ewl_object_custom_size_set(EWL_OBJECT(ib->select), 0, 0); ewl_widget_layer_set(EWL_WIDGET(ib->select_floater), 1); ewl_widget_color_set(EWL_WIDGET(ib->select), 255, 255, 25, 50); ib->drag_box = 0; @@ -318,6 +328,7 @@ ewl_callback_append(ib->ewl_iconbox_pane_inner, EWL_CALLBACK_MOUSE_MOVE, ewl_iconbox_mouse_move_cb, ib); ewl_callback_append(ib->ewl_iconbox_pane_inner, EWL_CALLBACK_MOUSE_DOWN, ewl_iconbox_pane_mouse_down_cb, ib); ewl_callback_append(ib->ewl_iconbox_pane_inner, EWL_CALLBACK_MOUSE_UP, ewl_iconbox_mouse_up, ib); + ewl_callback_append(ib->ewl_iconbox_pane_inner, EWL_CALLBACK_DND_POSITION, ewl_iconbox_dnd_position_cb, ib); ewl_callback_append(EWL_WIDGET(ib), EWL_CALLBACK_CONFIGURE, ewl_iconbox_configure_cb, NULL); ewl_callback_append(EWL_WIDGET(ib), EWL_CALLBACK_DESTROY, ewl_iconbox_destroy_cb, NULL); @@ -328,7 +339,14 @@ } - +/** + * @param ib: The IconBox to set the custom icon height for + * @param w: The custom width + * @param h: The custom height + * @return Returns no value + * + * Set a custom image size for all icons in this iconbox + */ void ewl_iconbox_icon_size_custom_set(Ewl_IconBox* ib, int w, int h) { ib->iw = w; ib->ih = h; @@ -336,10 +354,26 @@ +/** + * @param ib: The Ewl_IconBox to add a menu item to + * @param item: The ewl_menu_item to add. + * @return Returns no value + * + * Add a menu item to the iconbox background menu + */ void ewl_iconbox_context_menu_item_add(Ewl_IconBox* ib, Ewl_Widget* item) { ewl_container_child_append(EWL_CONTAINER(ib->ewl_iconbox_context_menu), item); } + +/** + * @param t: The Ewl_Text to delete the text from + * @param length: The length of text to delete + * @return Returns no value + * + * This will delete the specified length of text from the current cursor + * position + */ void ewl_iconbox_icon_menu_item_add(Ewl_IconBox* ib, Ewl_Widget* item) { ewl_object_minimum_size_set(EWL_OBJECT(item), 100,15); ewl_container_child_append(EWL_CONTAINER(ib->icon_menu), item); @@ -820,6 +854,30 @@ /*Callbacks*/ +void ewl_iconbox_dnd_position_cb(Ewl_Widget *item, void *ev_data, void *user_data) { + int ibx,iby,px,py,fw,fh; + Ewl_IconBox* ib = EWL_ICONBOX(user_data); + Ewl_IconBox_Icon* list_item = ib->select_icon; + Ewl_Event_Mouse_Move *ev = ev_data; + + ibx = ewl_object_current_x_get(EWL_OBJECT(ib)); + iby = ewl_object_current_y_get(EWL_OBJECT(ib)); + + px = ewl_object_current_x_get(EWL_OBJECT(ib->ewl_iconbox_pane_inner)); + py = ewl_object_current_y_get(EWL_OBJECT(ib->ewl_iconbox_pane_inner)); + + + fw= ewl_object_preferred_w_get(EWL_OBJECT(list_item->image)); + fh= ewl_object_preferred_h_get(EWL_OBJECT(list_item->image)); + ewl_floater_position_set(EWL_FLOATER(list_item->floater), (ev->x - ibx) + abs(px-ibx) - (fw/2), + (ev->y - iby) + abs(py-iby) - (fh/2)); + + + +} + + + void ewl_iconbox_destroy_cb(Ewl_Widget *w, void *ev_data __UNUSED__, void *user_data __UNUSED__) { Ewl_IconBox* ib = EWL_ICONBOX(w); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- ewl_iconbox.h 13 Nov 2005 07:59:31 -0000 1.22 +++ ewl_iconbox.h 20 Nov 2005 03:03:34 -0000 1.23 @@ -132,6 +132,7 @@ /* Internal callbacks */ +void ewl_iconbox_dnd_position_cb(Ewl_Widget *item, void *ev_data, void *user_data); void ewl_iconbox_arrange_cb(Ewl_Widget *w, void *ev_data, void *user_data); void ewl_iconbox_expansion_cb(Ewl_Widget *w, void *ev_data, void *user_data); void ewl_iconbox_mouse_move_cb(Ewl_Widget *w, void *ev_data, void *user_data); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_window.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ewl_window.c 2 Nov 2005 17:43:14 -0000 1.21 +++ ewl_window.c 20 Nov 2005 03:03:34 -0000 1.22 @@ -591,6 +591,32 @@ DRETURN_INT(override, DLEVEL_STABLE); } + + +/** + * @param win: the window to remove the border + * @return Returns no value. + * @brief Set a window as being DND aware + * + * Inform ecore_x that this window is capable of receiving DND events + */ +void +ewl_window_dnd_aware_set(Ewl_Window *win) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("win", win); + DCHECK_TYPE("win", win, "window"); + + win->flags |= EWL_FLAG_PROPERTY_DND_AWARE; + if (win->window) ecore_x_dnd_aware_set((Ecore_X_Window)win->window,1); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + + + + + void ewl_window_realize_cb(Ewl_Widget *w, void *ev_data __UNUSED__, void *user_data __UNUSED__) @@ -677,6 +703,10 @@ width, height); } window->window = (void *)xwin; + + if (window->flags & EWL_FLAG_PROPERTY_DND_AWARE) { + ecore_x_dnd_aware_set((Ecore_X_Window)window->window,1); + } } #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_window.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_window.h 27 Oct 2005 05:32:54 -0000 1.6 +++ ewl_window.h 20 Nov 2005 03:03:34 -0000 1.7 @@ -72,6 +72,7 @@ int ewl_window_pointer_grab_get(Ewl_Window *win); void ewl_window_override_set(Ewl_Window *win, int override); int ewl_window_override_get(Ewl_Window *win); +void ewl_window_dnd_aware_set(Ewl_Window *win); /* * Internally used callbacks, override at your own risk. ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today Register for a JBoss Training Course. Free Certification Exam for All Training Attendees Through End of 2005. For more info visit: http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs