Enlightenment CVS committal Author : lordchaos Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_iconbox.c ewl_iconbox.h Log Message: Fixes to selection box code. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- ewl_iconbox.c 12 Jul 2005 03:47:17 -0000 1.4 +++ ewl_iconbox.c 14 Jul 2005 08:01:48 -0000 1.5 @@ -211,6 +211,9 @@ ewl_widget_layer_set(EWL_WIDGET(ib->select_floater), 1000); ewl_widget_color_set(EWL_WIDGET(ib->select), 128, 50, 70, 128); ib->drag_box = 0; + + /*Set the dx/dy drag start points to 'null' values*/ + ib->dx = -1; ib->dy = -1; /* -------------------------------- */ ewl_widget_show(ib->select); @@ -255,7 +258,6 @@ 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(EWL_WIDGET(ib), EWL_CALLBACK_CONFIGURE, configure, NULL); - /*ewl_container_callback_nointercept(EWL_CONTAINER(ib->ewl_iconbox_pane_inner), EWL_CALLBACK_MOUSE_DOWN);*/ @@ -372,15 +374,38 @@ /*Handle selection box*/ if (ib->drag_box) { - int sbx, sby; - sbx = ewl_object_current_x_get(EWL_OBJECT(ib->select_floater)); - sby = ewl_object_current_y_get(EWL_OBJECT(ib->select_floater)); - - if (ev->x-sbx-3 > 0 && ev->y-sby-3 >0) { - ewl_object_custom_size_set(EWL_OBJECT(ib->select), ev->x-sbx-3, ev->y-sby-3); - ewl_object_custom_size_set(EWL_OBJECT(ib->select_floater), ev->x-sbx-3, ev->y-sby-3); + + + + if (ib->dx == -1) { + /* Assume this is the drag start point */ + ib->dx = ewl_object_current_x_get(EWL_OBJECT(ib->select_floater)); + ib->dy = ewl_object_current_y_get(EWL_OBJECT(ib->select_floater)); + } + + int lx,ly,hx,hy; + + /*Work out where to start/end..*/ + if (ib->dx < ev->x) { + lx = ib->dx; hx = ev->x; + } else { + lx = ev->x; hx = ib->dx; + } + + if (ib->dy < ev->y) { + ly = ib->dy ; hy = ev->y; + } else { + ly = ev->y; hy = ib->dy; } + + ewl_floater_position_set(EWL_FLOATER(ib->select_floater), (lx - ibx) + abs(px-ibx) , (ly+1 - iby) + abs(py-iby)); + + if (hx-lx >0 && hy-ly > 0) { + ewl_object_custom_size_set(EWL_OBJECT(ib->select), (hx-lx), (hy-ly)); + ewl_object_custom_size_set(EWL_OBJECT(ib->select_floater), hx-lx, hy-ly); + } + /*Now check which icons we have to select in this range...*/ { Ewl_IconBox_Icon* list_item; @@ -398,7 +423,7 @@ ix = ewl_object_current_x_get(EWL_OBJECT(list_item)); iy = ewl_object_current_y_get(EWL_OBJECT(list_item)); - if (ix >= sbx && iy >= sby && ix <= (sbx+w) && iy <= (sby+h) ) { + if (ix >= lx && iy >= ly && ix <= hx && iy <= hy ) { ewl_iconbox_icon_select(EWL_ICONBOX_ICON(list_item),0); } else { ewl_iconbox_icon_deselect(EWL_ICONBOX_ICON(list_item)); @@ -463,7 +488,7 @@ /*printf ("Start select at %d:%d\n", ev->x, ev->y);*/ ewl_object_custom_size_set(EWL_OBJECT(ib->select), 1, 1); - + /* Put the floater at the position we started at */ ewl_floater_position_set(EWL_FLOATER(ib->select_floater), ev->x-ibx + abs(px-ibx), ev->y-iby + abs(py-iby)); @@ -508,6 +533,8 @@ /*printf("Stopped select: %d:%d\n", ev->x, ev->y);*/ ewl_widget_hide(EWL_WIDGET(ib->select_floater)); ib->drag_box = 0; + ib->dx = -1; + ib->dy = -1; } } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- ewl_iconbox.h 12 Jul 2005 03:47:17 -0000 1.2 +++ ewl_iconbox.h 14 Jul 2005 08:01:49 -0000 1.3 @@ -70,7 +70,8 @@ Ewl_IconBox_Icon* drag_icon; Ewl_IconBox_Icon* edit_icon; - int xdown, ydown; + int xdown, ydown; /* Last icon button down x/y, for edge resistence */ + int dx, dy; /* Drag start x/y */ /* Objects for label editing..*/ Ewl_Widget* entry; @@ -80,7 +81,7 @@ /*Objects for selection */ Ewl_Widget* select; Ewl_Widget* select_floater; - int drag_box; + int drag_box; /* Are we dragging? */ /* Editable flag */ @@ -99,6 +100,7 @@ void ewl_iconbox_editable_set(Ewl_IconBox *ib, int edit); void ewl_iconbox_icon_arrange(Ewl_IconBox* ib); void ewl_iconbox_deselect_all(Ewl_IconBox* ib); +Ewl_IconBox_Icon* ewl_iconbox_icon_add(Ewl_IconBox* iconbox, char* name, char* icon_file); /* Internal callbacks */ @@ -106,7 +108,6 @@ void ewl_iconbox_expansion_cb(Ewl_Widget *w, void *ev_data, void *user_data); /* Internal functions */ -Ewl_IconBox_Icon* ewl_iconbox_icon_add(Ewl_IconBox* iconbox, char* name, char* icon_file); void ewl_iconbox_icon_select(Ewl_IconBox_Icon* ib, int loc); void ewl_iconbox_icon_deselect(Ewl_IconBox_Icon *ib); void ewl_iconbox_label_edit_key_down(Ewl_Widget *w, void *ev_data, void* user_data); ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs