Enlightenment CVS committal Author : sebastid Project : e17 Module : apps/e
Dir : e17/apps/e/src/modules/ibar Modified Files: e_mod_main.c Log Message: Now the ibar DnD should be right. Please? =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/modules/ibar/e_mod_main.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -3 -r1.57 -r1.58 --- e_mod_main.c 8 Jun 2005 13:08:37 -0000 1.57 +++ e_mod_main.c 10 Jun 2005 16:01:00 -0000 1.58 @@ -55,6 +55,7 @@ static IBar_Icon *_ibar_icon_new(IBar_Bar *ibb, E_App *a); static void _ibar_icon_free(IBar_Icon *ic); static IBar_Icon *_ibar_icon_find(IBar_Bar *ibb, E_App *a); +static IBar_Icon *_ibar_icon_pos_find(IBar_Bar *ibb, int x, int y); static void _ibar_icon_reorder_after(IBar_Icon *ic, IBar_Icon *after); static void _ibar_bar_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change); @@ -727,6 +728,35 @@ return NULL; } +static IBar_Icon * +_ibar_icon_pos_find(IBar_Bar *ibb, int x, int y) +{ + IBar_Icon *ic; + double pos, iw; + int w, h; + + x = x - (ibb->x + ibb->bar_inset.l); + y = y - (ibb->y + ibb->bar_inset.t); + w = ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r); + h = ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b); + + if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) || + (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP)) + { + iw = w / (double) e_box_pack_count_get(ibb->box_object); + pos = x / iw; + } + else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) || + (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT)) + { + iw = h / (double) e_box_pack_count_get(ibb->box_object); + pos = y / iw; + } + + ic = evas_list_nth(ibb->icons, pos); + return ic; +} + void _ibar_config_menu_new(IBar *ib) { @@ -1416,9 +1446,7 @@ Evas_Object *o; IBar_Bar *ibb; IBar_Icon *ic; - Evas_Coord x, y, w, h; - double iw; - int pos; + int w, h; ev = event; ibb = data; @@ -1428,24 +1456,10 @@ evas_object_color_set(o, 255, 0, 0, 255); evas_object_resize(o, ibb->ibar->conf->iconsize, ibb->ibar->conf->iconsize); - if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) || - (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP)) - { - iw = w / (double) e_box_pack_count_get(ibb->box_object); - pos = x / iw; - } - else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) || - (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT)) - { - iw = h / (double) e_box_pack_count_get(ibb->box_object); - pos = y / iw; - } - - ic = evas_list_nth(ibb->icons, pos); + ic = _ibar_icon_pos_find(ibb, ev->x, ev->y); e_box_freeze(ibb->box_object); evas_object_show(ibb->drag_object); - e_box_unpack(ibb->drag_object); if (ic) { /* Add new eapp before this icon */ @@ -1476,32 +1490,12 @@ E_Event_Dnd_Move *ev; IBar_Bar *ibb; IBar_Icon *ic; - Evas_Coord x, y, w, h; - double iw; - int pos; + int w, h; ev = event; ibb = data; - x = ev->x - (ibb->x + ibb->bar_inset.l); - y = ev->y - (ibb->y + ibb->bar_inset.t); - w = ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r); - h = ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b); - - if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) || - (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP)) - { - iw = w / (double) e_box_pack_count_get(ibb->box_object); - pos = x / iw; - } - else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) || - (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT)) - { - iw = h / (double) e_box_pack_count_get(ibb->box_object); - pos = y / iw; - } - - ic = evas_list_nth(ibb->icons, pos); + ic = _ibar_icon_pos_find(ibb, ev->x, ev->y); e_box_freeze(ibb->box_object); evas_object_show(ibb->drag_object); @@ -1554,14 +1548,14 @@ E_App *app; IBar_Bar *ibb; IBar_Icon *ic; - Evas_Coord x, y, w, h; - double iw; - int pos; ev = event; ibb = data; app = ev->data; + /* add dropped element */ + ic = _ibar_icon_pos_find(ibb, ev->x, ev->y); + /* remove drag marker */ e_box_freeze(ibb->box_object); e_box_unpack(ibb->drag_object); @@ -1570,26 +1564,6 @@ _ibar_bar_frame_resize(ibb); - /* add dropped element */ - x = ev->x - (ibb->x + ibb->bar_inset.l); - y = ev->y - (ibb->y + ibb->bar_inset.t); - w = ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r); - h = ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b); - - if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) || - (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP)) - { - iw = w / (double) evas_list_count(ibb->icons); - pos = x / iw; - } - else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) || - (e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT)) - { - iw = h / (double) evas_list_count(ibb->icons); - pos = y / iw; - } - - ic = evas_list_nth(ibb->icons, pos); if (ic) { /* Add new eapp before this icon */ ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput a projector? How fast can you ride your desk chair down the office luge track? If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs