forked from enlightenment/enlightenment
* dnd operations now only affect the currently focused view
SVN revision: 6003
This commit is contained in:
parent
09bd909ccb
commit
622a5ccaf2
288
src/icons.c
288
src/icons.c
|
@ -172,135 +172,26 @@ e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
}
|
||||
|
||||
static void
|
||||
e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
||||
_paint_selected_icons_onto_drag_window(E_View *v, Imlib_Image im, int wx, int wy)
|
||||
{
|
||||
E_Icon *ic;
|
||||
Ecore_Event *ev;
|
||||
Ecore_Event_Mouse_Move *e;
|
||||
Evas_List l;
|
||||
D_ENTER;
|
||||
|
||||
ev = e_view_get_current_event();
|
||||
|
||||
if (!ev)
|
||||
D_RETURN;
|
||||
e = ev->event;
|
||||
ic = _data;
|
||||
|
||||
if (!ic->state.clicked)
|
||||
if (!v || !im || v->select.count <= 0)
|
||||
D_RETURN;
|
||||
|
||||
if (!ic->view->drag.started)
|
||||
{
|
||||
int dx, dy;
|
||||
|
||||
dx = ic->view->select.down.x - _x;
|
||||
dy = ic->view->select.down.y - _y;
|
||||
if (dx < 0) dx = -dx;
|
||||
if (dy < 0) dy = -dy;
|
||||
if ((dx > 3) || (dy > 3))
|
||||
{
|
||||
Pixmap pmap, mask;
|
||||
Evas_List l;
|
||||
int x, y, xx, yy, rw, rh, downx, downy, wx, wy, ww, wh;
|
||||
|
||||
/* find extents of icons to be dragged */
|
||||
x = 999999999;
|
||||
y = 999999999;
|
||||
xx = -999999999;
|
||||
yy = -999999999;
|
||||
for (l = VM->views; l; l = l->next)
|
||||
{
|
||||
E_View *v;
|
||||
Evas_List ll;
|
||||
|
||||
v = l->data;
|
||||
D("sel count %i\n", v->select.count);
|
||||
if (v->select.count > 0)
|
||||
{
|
||||
for (ll = v->icons; ll; ll = ll->next)
|
||||
{
|
||||
E_Icon *ic;
|
||||
|
||||
ic = ll->data;
|
||||
if (ic->state.selected)
|
||||
{
|
||||
int ix, iy, iw, ih;
|
||||
|
||||
ix = ic->view->scroll.x + ic->geom.x + v->location.x;
|
||||
iy = ic->view->scroll.y + ic->geom.y + v->location.y;
|
||||
iw = ic->geom.w;
|
||||
ih = ic->geom.h;
|
||||
if (ix < x) x = ix;
|
||||
if (iy < y) y = iy;
|
||||
if ((ix + iw) > xx) xx = ix + iw;
|
||||
if ((iy + ih) > yy) yy = iy + ih;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ecore_window_get_geometry(0, NULL, NULL, &rw, &rh);
|
||||
downx = ic->view->select.down.x + ic->view->location.x;
|
||||
downy = ic->view->select.down.y + ic->view->location.y;
|
||||
|
||||
wx = x;
|
||||
ww = xx - x;
|
||||
if (wx < - (rw - downx))
|
||||
{
|
||||
wx = - (rw - downx);
|
||||
ww -= (wx - x);
|
||||
}
|
||||
if ((wx + ww) > (rw + downx))
|
||||
ww = (rw + downx) - wx;
|
||||
wy = y;
|
||||
wh = yy - y;
|
||||
if (wy < - (rh - downy))
|
||||
{
|
||||
wy = - (rh - downy);
|
||||
wh -= (wy - y);
|
||||
}
|
||||
if ((wy + wh) > (rh + downy))
|
||||
wh = (rh + downy) - wy;
|
||||
|
||||
|
||||
ic->view->drag.x = wx + ic->view->location.x;
|
||||
ic->view->drag.y = wy + ic->view->location.y;
|
||||
ic->view->drag.offset.x = downx - ic->view->drag.x;
|
||||
ic->view->drag.offset.y = downy - ic->view->drag.y;
|
||||
|
||||
if ((ww < 1) || (wh < 1)) D_RETURN;
|
||||
ic->view->drag.win = ecore_window_override_new(0, wx, wy, ww, wh);
|
||||
pmap = ecore_pixmap_new(ic->view->drag.win, ww, wh, 0);
|
||||
mask = ecore_pixmap_new(ic->view->drag.win, ww, wh, 1);
|
||||
{
|
||||
Imlib_Image im;
|
||||
|
||||
im = imlib_create_image(ww, wh);
|
||||
imlib_context_set_image(im);
|
||||
imlib_image_set_has_alpha(1);
|
||||
imlib_context_set_blend(1);
|
||||
imlib_image_clear();
|
||||
imlib_context_set_color_modifier(NULL);
|
||||
imlib_context_set_cliprect(0, 0, 0, 0);
|
||||
imlib_context_set_angle(0);
|
||||
|
||||
for (l = VM->views; l; l = l->next)
|
||||
{
|
||||
E_View *v;
|
||||
Evas_List ll;
|
||||
|
||||
v = l->data;
|
||||
if (v->select.count > 0)
|
||||
{
|
||||
for (ll = v->icons; ll; ll = ll->next) {
|
||||
E_Icon *ic;
|
||||
|
||||
ic = ll->data;
|
||||
if (ic->state.selected)
|
||||
/* paint all selected icons onto the invisible drag window */
|
||||
for (l = v->icons; l; l = l->next)
|
||||
{
|
||||
double ix, iy;
|
||||
int icx, icy;
|
||||
Imlib_Image im2;
|
||||
char icon[PATH_MAX];
|
||||
E_Icon *ic;
|
||||
|
||||
ic = l->data;
|
||||
if (!ic->state.selected)
|
||||
continue;
|
||||
|
||||
evas_get_geometry(ic->view->evas,
|
||||
ic->obj.icon,
|
||||
|
@ -345,9 +236,100 @@ e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
D("eek cant load\n");
|
||||
}
|
||||
}
|
||||
D_RETURN;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
_start_drag(E_View *v, int _x, int _y)
|
||||
{
|
||||
Pixmap pmap, mask;
|
||||
Evas_List l;
|
||||
int x, y, xx, yy, rw, rh, downx, downy, wx, wy, ww, wh;
|
||||
int dx, dy;
|
||||
|
||||
if (!v) D_RETURN;
|
||||
|
||||
dx = abs(v->select.down.x - _x);
|
||||
dy = abs(v->select.down.y - _y);
|
||||
/* drag treshold */
|
||||
if ((dx < 3) && (dy < 3))
|
||||
D_RETURN;
|
||||
|
||||
/* find extents of icons to be dragged */
|
||||
x = y = xx = yy = 999999999;
|
||||
|
||||
D("sel count %i\n", v->select.count);
|
||||
if (v->select.count > 0)
|
||||
{
|
||||
for (l = v->icons; l; l = l->next)
|
||||
{
|
||||
E_Icon *ic;
|
||||
|
||||
ic = l->data;
|
||||
if (ic->state.selected)
|
||||
{
|
||||
int ix, iy, iw, ih;
|
||||
|
||||
ix = ic->view->scroll.x + ic->geom.x + v->location.x;
|
||||
iy = ic->view->scroll.y + ic->geom.y + v->location.y;
|
||||
iw = ic->geom.w;
|
||||
ih = ic->geom.h;
|
||||
if (ix < x) x = ix;
|
||||
if (iy < y) y = iy;
|
||||
if ((ix + iw) > xx) xx = ix + iw;
|
||||
if ((iy + ih) > yy) yy = iy + ih;
|
||||
}
|
||||
}
|
||||
}
|
||||
ecore_window_get_geometry(0, NULL, NULL, &rw, &rh);
|
||||
downx = v->select.down.x + v->location.x;
|
||||
downy = v->select.down.y + v->location.y;
|
||||
|
||||
wx = x;
|
||||
ww = xx - x;
|
||||
if (wx < - (rw - downx))
|
||||
{
|
||||
wx = - (rw - downx);
|
||||
ww -= (wx - x);
|
||||
}
|
||||
if ((wx + ww) > (rw + downx))
|
||||
ww = (rw + downx) - wx;
|
||||
wy = y;
|
||||
wh = yy - y;
|
||||
if (wy < - (rh - downy))
|
||||
{
|
||||
wy = - (rh - downy);
|
||||
wh -= (wy - y);
|
||||
}
|
||||
if ((wy + wh) > (rh + downy))
|
||||
wh = (rh + downy) - wy;
|
||||
|
||||
v->drag.x = wx + v->location.x;
|
||||
v->drag.y = wy + v->location.y;
|
||||
v->drag.offset.x = downx - v->drag.x;
|
||||
v->drag.offset.y = downy - v->drag.y;
|
||||
|
||||
if ((ww < 1) || (wh < 1)) D_RETURN;
|
||||
|
||||
v->drag.win = ecore_window_override_new(0, wx, wy, ww, wh);
|
||||
pmap = ecore_pixmap_new(v->drag.win, ww, wh, 0);
|
||||
mask = ecore_pixmap_new(v->drag.win, ww, wh, 1);
|
||||
{
|
||||
Imlib_Image im;
|
||||
|
||||
im = imlib_create_image(ww, wh);
|
||||
imlib_context_set_image(im);
|
||||
imlib_image_set_has_alpha(1);
|
||||
imlib_context_set_blend(1);
|
||||
imlib_image_clear();
|
||||
imlib_context_set_color_modifier(NULL);
|
||||
imlib_context_set_cliprect(0, 0, 0, 0);
|
||||
imlib_context_set_angle(0);
|
||||
|
||||
_paint_selected_icons_onto_drag_window(v, im, wx, wy);
|
||||
|
||||
imlib_context_set_image(im);
|
||||
if (ww * wh < (200 * 200)) imlib_context_set_dither_mask(1);
|
||||
else imlib_context_set_dither_mask(0);
|
||||
|
@ -359,25 +341,46 @@ e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
imlib_render_image_on_drawable(0, 0);
|
||||
imlib_free_image();
|
||||
}
|
||||
ecore_window_set_background_pixmap(ic->view->drag.win, pmap);
|
||||
ecore_window_set_shape_mask(ic->view->drag.win, mask);
|
||||
ecore_window_ignore(ic->view->drag.win);
|
||||
ecore_window_raise(ic->view->drag.win);
|
||||
ecore_window_show(ic->view->drag.win);
|
||||
ecore_window_set_background_pixmap(v->drag.win, pmap);
|
||||
ecore_window_set_shape_mask(v->drag.win, mask);
|
||||
ecore_window_ignore(v->drag.win);
|
||||
ecore_window_raise(v->drag.win);
|
||||
ecore_window_show(v->drag.win);
|
||||
ecore_pixmap_free(pmap);
|
||||
ecore_pixmap_free(mask);
|
||||
|
||||
/* Initiate dnd */
|
||||
ecore_dnd_set_mode_copy();
|
||||
ecore_dnd_set_data(ic->view->win.base);
|
||||
ecore_dnd_set_data(v->win.base);
|
||||
|
||||
ecore_dnd_own_selection(ic->view->win.base);
|
||||
ecore_dnd_own_selection(v->win.base);
|
||||
|
||||
ic->view->drag.started = 1;
|
||||
}
|
||||
v->drag.started = 1;
|
||||
}
|
||||
|
||||
if (ic->view->drag.started)
|
||||
static void
|
||||
e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
||||
{
|
||||
E_Icon *ic;
|
||||
Ecore_Event *ev;
|
||||
Ecore_Event_Mouse_Move *e;
|
||||
D_ENTER;
|
||||
|
||||
ev = e_view_get_current_event();
|
||||
if (!ev)
|
||||
D_RETURN;
|
||||
|
||||
e = ev->event;
|
||||
ic = _data;
|
||||
|
||||
if (!ic->state.clicked)
|
||||
D_RETURN;
|
||||
|
||||
if (!ic->view->drag.started)
|
||||
{
|
||||
_start_drag(ic->view, _x, _y);
|
||||
}
|
||||
else if (ic->view->drag.started)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
|
@ -829,21 +832,7 @@ e_icon_invert_selection(E_Icon *ic)
|
|||
void
|
||||
e_icon_select(E_Icon *ic)
|
||||
{
|
||||
Evas_List l;
|
||||
D_ENTER;
|
||||
if (ic->view->select.lock)
|
||||
D_RETURN;
|
||||
if (ic->view->select.count == 0)
|
||||
{
|
||||
/* lock all other views of our dir */
|
||||
for (l= ic->view->model->views;l;l=l->next)
|
||||
{
|
||||
E_View *v = (E_View *) l->data;
|
||||
v->select.lock = 1;
|
||||
}
|
||||
/* unlock ourselves */
|
||||
ic->view->select.lock = 0;
|
||||
}
|
||||
|
||||
if (!ic->state.selected)
|
||||
{
|
||||
|
@ -858,10 +847,7 @@ e_icon_select(E_Icon *ic)
|
|||
void
|
||||
e_icon_deselect(E_Icon *ic)
|
||||
{
|
||||
Evas_List l;
|
||||
D_ENTER;
|
||||
if (ic->view->select.lock)
|
||||
D_RETURN;
|
||||
|
||||
if (ic->state.selected)
|
||||
{
|
||||
|
@ -869,16 +855,6 @@ e_icon_deselect(E_Icon *ic)
|
|||
ic->view->select.count--;
|
||||
e_icon_update_state(ic);
|
||||
}
|
||||
if (ic->view->select.count == 0)
|
||||
{
|
||||
/* we have just unselected the last icon. Unlock all
|
||||
* other views of our model. */
|
||||
for (l= ic->view->model->views;l;l=l->next)
|
||||
{
|
||||
E_View *v = (E_View *) l->data;
|
||||
v->select.lock = 0;
|
||||
}
|
||||
}
|
||||
D_RETURN;
|
||||
}
|
||||
|
||||
|
|
29
src/view.c
29
src/view.c
|
@ -320,7 +320,7 @@ e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
if (!(ev->mods & (multi_select_mod | range_select_mod)))
|
||||
{
|
||||
v->select.last_count = v->select.count;
|
||||
e_view_deselect_all();
|
||||
e_view_deselect_all(v);
|
||||
}
|
||||
|
||||
if (_b == 1)
|
||||
|
@ -533,18 +533,11 @@ e_bg_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
|
||||
|
||||
void
|
||||
e_view_deselect_all(void)
|
||||
{
|
||||
Evas_List ll;
|
||||
|
||||
D_ENTER;
|
||||
|
||||
for (ll = VM->views; ll; ll = ll->next)
|
||||
e_view_deselect_all(E_View *v)
|
||||
{
|
||||
Evas_List l;
|
||||
E_View *v;
|
||||
|
||||
v = ll->data;
|
||||
D_ENTER;
|
||||
for (l = v->icons; l; l = l->next)
|
||||
{
|
||||
E_Icon *ic;
|
||||
|
@ -552,25 +545,16 @@ e_view_deselect_all(void)
|
|||
ic = l->data;
|
||||
e_icon_deselect(ic);
|
||||
}
|
||||
}
|
||||
|
||||
D_RETURN;
|
||||
}
|
||||
|
||||
void
|
||||
e_view_deselect_all_except(E_Icon *not_ic)
|
||||
{
|
||||
Evas_List ll;
|
||||
Evas_List l;
|
||||
|
||||
D_ENTER;
|
||||
|
||||
for (ll = VM->views; ll; ll = ll->next)
|
||||
{
|
||||
Evas_List l;
|
||||
E_View *v;
|
||||
|
||||
v = ll->data;
|
||||
for (l = v->icons; l; l = l->next)
|
||||
for (l = not_ic->view->icons; l; l = l->next)
|
||||
{
|
||||
E_Icon *ic;
|
||||
|
||||
|
@ -578,8 +562,6 @@ e_view_deselect_all_except(E_Icon *not_ic)
|
|||
if (ic != not_ic)
|
||||
e_icon_deselect(ic);
|
||||
}
|
||||
}
|
||||
|
||||
D_RETURN;
|
||||
}
|
||||
|
||||
|
@ -1653,7 +1635,6 @@ e_view_new(void)
|
|||
v->options.back_pixmap = 0;
|
||||
#endif
|
||||
#endif
|
||||
v->select.lock = 0;
|
||||
v->select.config.grad_size.l = 8;
|
||||
v->select.config.grad_size.r = 8;
|
||||
v->select.config.grad_size.t = 8;
|
||||
|
|
|
@ -94,9 +94,6 @@ struct _E_View
|
|||
} spacing;
|
||||
struct {
|
||||
int on;
|
||||
/* we set this in all other views of our view_model
|
||||
* when the first icon in a view is selected. */
|
||||
int lock;
|
||||
/* The number of selected icons. */
|
||||
int count;
|
||||
/* The number of icons we selected the last time.
|
||||
|
@ -107,6 +104,7 @@ struct _E_View
|
|||
struct {
|
||||
int x, y;
|
||||
} down;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
int r, g, b, a;
|
||||
|
@ -131,6 +129,7 @@ struct _E_View
|
|||
Evas_Object grad_b;
|
||||
} obj;
|
||||
} select;
|
||||
|
||||
struct {
|
||||
int started;
|
||||
Window win;
|
||||
|
@ -190,7 +189,7 @@ struct _E_View
|
|||
void e_view_init(void);
|
||||
|
||||
void e_view_selection_update(E_View *v);
|
||||
void e_view_deselect_all(void);
|
||||
void e_view_deselect_all(E_View *v);
|
||||
void e_view_deselect_all_except(E_Icon *not_ic);
|
||||
Ecore_Event *e_view_get_current_event(void);
|
||||
int e_view_filter_file(E_View *v, char *file);
|
||||
|
|
Loading…
Reference in New Issue