Commit 6b1b6916 authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler
Browse files

reviewed by: Gene Z. Ragan <gzr@eazel.com>

2001-02-22  Pavel Cisler  <pavel@eazel.com>

	reviewed by: Gene Z. Ragan <gzr@eazel.com>

	Fix 5540 Dragging a group of files in zoomed icon view has
		 strange effect
	Fix 6461 Dropped icons in manual layout land at the wrong
		 coordinates at high zoom levels
	Fix 6845 Dropping multiple icons from list view to icon view
		 piles them on top of each other

	* libnautilus-extensions/nautilus-icon-dnd.c:
	(create_selection_shadow),
	(icon_get_data_binder):
	Send outline rectangles for dragged icons off to a drag in a 100%
	zoom level scale.
	Scale outline rectangles in drag shadows using the scaling factor
	for the target view.

	* libnautilus-extensions/nautilus-list.h:
	* libnautilus-extensions/nautilus-list.c:
	(nautilus_list_get_cell_rectangle),
	(draw_cell), (nautilus_list_clear_from_row),
	(nautilus_list_set_drag_prelight_row),
	Make the call public, change the callers to pass NautilusList.

	* libnautilus-extensions/nautilus-list.c:
	(nautilus_list_each_selected_row):
	Add the row index parameter to the iteratee.

	* libnautilus-extensions/nautilus-list.c:
	(nautilus_list_get_initial_drag_offset):
	Add a way to get the intial mouse drag offset.

	* src/file-manager/fm-list-view.c: (row_get_data_binder),
	(each_icon_get_data_binder):
	Calculate outline rectangles for icons and pass them to the
	drag&drop machinery.

	* libnautilus-extensions/nautilus-list.c:
	(nautilus_list_dnd_initialize):
	Tweaks.

	* libnautilus-extensions/nautilus-art-extensions.h:
	* libnautilus-extensions/nautilus-art-extensions.c:
	(nautilus_art_irect_offset_by), (nautilus_art_irect_offset_to),
	(nautilus_art_irect_scale_by), (nautilus_art_irect_inset),
	(nautilus_art_drect_offset_by), (nautilus_art_drect_offset_to),
	(nautilus_art_irect_offset_by_point),
	(nautilus_art_irect_offset_to_point),
	(nautilus_art_drect_scale_by), (nautilus_art_drect_inset):
	Add a few convenience calls.
parent c76d8068
2001-02-22 Pavel Cisler <pavel@eazel.com>
reviewed by: Gene Z. Ragan <gzr@eazel.com>
Fix 5540 Dragging a group of files in zoomed icon view has
strange effect
Fix 6461 Dropped icons in manual layout land at the wrong
coordinates at high zoom levels
Fix 6845 Dropping multiple icons from list view to icon view
piles them on top of each other
* libnautilus-extensions/nautilus-icon-dnd.c:
(create_selection_shadow),
(icon_get_data_binder):
Send outline rectangles for dragged icons off to a drag in a 100%
zoom level scale.
Scale outline rectangles in drag shadows using the scaling factor
for the target view.
* libnautilus-extensions/nautilus-list.h:
* libnautilus-extensions/nautilus-list.c:
(nautilus_list_get_cell_rectangle),
(draw_cell), (nautilus_list_clear_from_row),
(nautilus_list_set_drag_prelight_row),
Make the call public, change the callers to pass NautilusList.
* libnautilus-extensions/nautilus-list.c:
(nautilus_list_each_selected_row):
Add the row index parameter to the iteratee.
* libnautilus-extensions/nautilus-list.c:
(nautilus_list_get_initial_drag_offset):
Add a way to get the intial mouse drag offset.
* src/file-manager/fm-list-view.c: (row_get_data_binder),
(each_icon_get_data_binder):
Calculate outline rectangles for icons and pass them to the
drag&drop machinery.
* libnautilus-extensions/nautilus-list.c:
(nautilus_list_dnd_initialize):
Tweaks.
* libnautilus-extensions/nautilus-art-extensions.h:
* libnautilus-extensions/nautilus-art-extensions.c:
(nautilus_art_irect_offset_by), (nautilus_art_irect_offset_to),
(nautilus_art_irect_scale_by), (nautilus_art_irect_inset),
(nautilus_art_drect_offset_by), (nautilus_art_drect_offset_to),
(nautilus_art_irect_offset_by_point),
(nautilus_art_irect_offset_to_point),
(nautilus_art_drect_scale_by), (nautilus_art_drect_inset):
Add a few convenience calls.
2001-02-22 Eskil Heyn Olsen <eskil@eazel.com>
reviewed by: Robey Pointer <robey@eazel.com>
......
......@@ -253,6 +253,118 @@ nautilus_art_irect_assign_dimensions (int x,
return rectangle;
}
ArtIRect
nautilus_art_irect_offset_by (ArtIRect rectangle, int x, int y)
{
rectangle.x0 += x;
rectangle.x1 += x;
rectangle.y0 += y;
rectangle.y1 += y;
return rectangle;
}
ArtIRect
nautilus_art_irect_offset_to (ArtIRect rectangle, int x, int y)
{
rectangle.x1 = rectangle.x1 - rectangle.x0 + x;
rectangle.x0 = x;
rectangle.y1 = rectangle.y1 - rectangle.y0 + y;
rectangle.y0 = y;
return rectangle;
}
ArtIRect
nautilus_art_irect_scale_by (ArtIRect rectangle, double scale)
{
rectangle.x0 *= scale;
rectangle.x1 *= scale;
rectangle.y0 *= scale;
rectangle.y1 *= scale;
return rectangle;
}
ArtIRect
nautilus_art_irect_inset (ArtIRect rectangle, int horizontal_inset, int vertical_inset)
{
rectangle.x0 += horizontal_inset;
rectangle.x1 -= horizontal_inset;
rectangle.y0 += vertical_inset;
rectangle.y1 -= vertical_inset;
return rectangle;
}
ArtDRect
nautilus_art_drect_offset_by (ArtDRect rectangle, double x, double y)
{
rectangle.x0 += x;
rectangle.x1 += x;
rectangle.y0 += y;
rectangle.y1 += y;
return rectangle;
}
ArtDRect
nautilus_art_drect_offset_to (ArtDRect rectangle, double x, double y)
{
rectangle.x1 = rectangle.x1 - rectangle.x0 + x;
rectangle.x0 = x;
rectangle.y1 = rectangle.y1 - rectangle.y0 + y;
rectangle.y0 = y;
return rectangle;
}
ArtIRect
nautilus_art_irect_offset_by_point (ArtIRect rectangle, NautilusArtIPoint point)
{
rectangle.x0 += point.x;
rectangle.x1 += point.x;
rectangle.y0 += point.y;
rectangle.y1 += point.y;
return rectangle;
}
ArtIRect
nautilus_art_irect_offset_to_point (ArtIRect rectangle, NautilusArtIPoint point)
{
rectangle.x1 = rectangle.x1 - rectangle.x0 + point.x;
rectangle.x0 = point.x;
rectangle.y1 = rectangle.y1 - rectangle.y0 + point.y;
rectangle.y0 = point.y;
return rectangle;
}
ArtDRect
nautilus_art_drect_scale_by (ArtDRect rectangle, double scale)
{
rectangle.x0 *= scale;
rectangle.x1 *= scale;
rectangle.y0 *= scale;
rectangle.y1 *= scale;
return rectangle;
}
ArtDRect
nautilus_art_drect_inset (ArtDRect rectangle, double horizontal_inset, double vertical_inset)
{
rectangle.x0 += horizontal_inset;
rectangle.x1 -= horizontal_inset;
rectangle.y0 += vertical_inset;
rectangle.y1 -= vertical_inset;
return rectangle;
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
void
......
......@@ -77,6 +77,34 @@ ArtIRect nautilus_art_irect_assign_dimensions (int x,
int y,
const NautilusDimensions *dimensions);
ArtIRect nautilus_art_irect_offset_by (ArtIRect rect,
int x,
int y);
ArtIRect nautilus_art_irect_offset_to (ArtIRect rect,
int x,
int y);
ArtIRect nautilus_art_irect_scale_by (ArtIRect rect,
double scale);
ArtIRect nautilus_art_irect_inset (ArtIRect rect,
int horizontal_inset,
int vertical_inset);
ArtDRect nautilus_art_drect_offset_by (ArtDRect rect,
double x,
double y);
ArtDRect nautilus_art_drect_offset_to (ArtDRect rect,
double x,
double y);
ArtDRect nautilus_art_drect_scale_by (ArtDRect rect,
double scale);
ArtDRect nautilus_art_drect_inset (ArtDRect rect,
double horizontal_inset,
double vertical_inset);
ArtIRect nautilus_art_irect_offset_by_point (ArtIRect rect,
NautilusArtIPoint point);
ArtIRect nautilus_art_irect_offset_to_point (ArtIRect rect,
NautilusArtIPoint point);
END_GNOME_DECLS
#endif /* NAUTILUS_ART_EXTENSIONS_H */
......@@ -118,7 +118,6 @@ create_selection_shadow (NautilusIconContainer *container,
int max_x, max_y;
int min_x, min_y;
GList *p;
double pixels_per_unit;
if (list == NULL) {
return NULL;
......@@ -151,7 +150,6 @@ create_selection_shadow (NautilusIconContainer *container,
gnome_canvas_group_get_type (),
NULL));
pixels_per_unit = canvas->pixels_per_unit;
for (p = list; p != NULL; p = p->next) {
DragSelectionItem *item;
int x1, y1, x2, y2;
......@@ -171,10 +169,10 @@ create_selection_shadow (NautilusIconContainer *container,
gnome_canvas_item_new
(group,
gnome_canvas_rect_get_type (),
"x1", (double) x1 / pixels_per_unit,
"y1", (double) y1 / pixels_per_unit,
"x2", (double) x2 / pixels_per_unit,
"y2", (double) y2 / pixels_per_unit,
"x1", (double) x1,
"y1", (double) y1,
"x2", (double) x2,
"y2", (double) y2,
"outline_color", "black",
"outline_stipple", stipple,
"width_pixels", 1,
......@@ -239,10 +237,17 @@ icon_get_data_binder (NautilusIcon *icon, gpointer data)
return TRUE;
}
window_rect = nautilus_art_irect_offset_by (window_rect,
- container->details->dnd_info->drag_info.start_x,
- container->details->dnd_info->drag_info.start_y);
window_rect = nautilus_art_irect_scale_by (window_rect,
1 / GNOME_CANVAS (container)->pixels_per_unit);
/* pass the uri, mouse-relative x/y and icon width/height */
context->iteratee (uri,
(int) (window_rect.x0 - container->details->dnd_info->drag_info.start_x),
(int) (window_rect.y0 - container->details->dnd_info->drag_info.start_y),
(int) window_rect.x0,
(int) window_rect.y0,
window_rect.x1 - window_rect.x0,
window_rect.y1 - window_rect.y0,
context->iteratee_data);
......
......@@ -555,22 +555,22 @@ nautilus_list_dnd_initialize (NautilusList *list)
gtk_signal_connect (GTK_OBJECT (list),
"drag_end",
GTK_SIGNAL_FUNC(nautilus_list_drag_end),
GTK_SIGNAL_FUNC (nautilus_list_drag_end),
list);
gtk_signal_connect (GTK_OBJECT (list),
"drag_leave",
GTK_SIGNAL_FUNC(nautilus_list_drag_leave),
GTK_SIGNAL_FUNC (nautilus_list_drag_leave),
list);
gtk_signal_connect (GTK_OBJECT (list),
"drag_motion",
GTK_SIGNAL_FUNC(nautilus_list_drag_motion),
GTK_SIGNAL_FUNC (nautilus_list_drag_motion),
list);
gtk_signal_connect (GTK_OBJECT (list),
"drag_drop",
GTK_SIGNAL_FUNC(nautilus_list_drag_drop),
GTK_SIGNAL_FUNC (nautilus_list_drag_drop),
list);
gtk_signal_connect (GTK_OBJECT (list),
......@@ -587,8 +587,6 @@ nautilus_list_dnd_initialize (NautilusList *list)
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK
| GDK_ACTION_ASK);
}
/* Standard object initialization function */
......@@ -2210,9 +2208,14 @@ last_column_index (NautilusCList *clist)
return result;
}
static void
get_cell_rectangle (NautilusCList *clist, int row_index, int column_index, GdkRectangle *result)
void
nautilus_list_get_cell_rectangle (NautilusList *list, int row_index, int column_index, GdkRectangle *result)
{
NautilusCList *clist;
g_return_if_fail (NAUTILUS_IS_LIST (list));
clist = NAUTILUS_CLIST (list);
result->x = clist->column[column_index].area.x + clist->hoffset;
result->y = ROW_TOP_YPIXEL (clist, row_index);
result->width = clist->column[column_index].area.width;
......@@ -2260,7 +2263,7 @@ draw_cell (NautilusCList *clist, GdkRectangle *area, int row_index, int column_i
get_cell_style (NAUTILUS_LIST(clist), row, row->state, row_index,
column_index, &style, &fg_gc, &bg_gc, &bg_rgb);
get_cell_rectangle (clist, row_index, column_index, &cell_rectangle);
nautilus_list_get_cell_rectangle (NAUTILUS_LIST (clist), row_index, column_index, &cell_rectangle);
get_cell_greater_rectangle (&cell_rectangle, &erase_rectangle,
column_index == last_column_index (clist));
......@@ -2602,7 +2605,7 @@ nautilus_list_clear_from_row (NautilusList *list, int row_index,
}
/* calculate the rectangle for the selected column */
get_cell_rectangle (clist, 0, selected_column_index (list), &tmp);
nautilus_list_get_cell_rectangle (list, 0, selected_column_index (list), &tmp);
get_cell_greater_rectangle (&tmp, &tmp,
selected_column_index (list) == last_column_index (clist));
tmp.y = clip_area.y;
......@@ -3630,15 +3633,16 @@ nautilus_list_each_selected_row (NautilusList *list, NautilusEachRowFunction fun
{
NautilusCListRow *row;
GList *p;
int row_index;
g_assert (NAUTILUS_IS_LIST (list));
for (p = NAUTILUS_CLIST (list)->row_list; p != NULL; p = p->next) {
for (p = NAUTILUS_CLIST (list)->row_list, row_index = 0; p != NULL; p = p->next, row_index++) {
row = p->data;
if (row->state != GTK_STATE_SELECTED)
continue;
if (!function(row, data))
if (!function(row, row_index, data))
return;
}
}
......@@ -3742,16 +3746,23 @@ nautilus_list_set_drag_prelight_row (NautilusList *list, int y)
/* Redraw old cell */
if (last_row != NULL) {
row_index = g_list_index (clist->row_list, last_row);
get_cell_rectangle (clist, row_index, 0, &rect);
nautilus_list_get_cell_rectangle (list, row_index, 0, &rect);
gtk_widget_draw (GTK_WIDGET (list), &rect);
}
/* Draw new cell */
if (list->details->drag_prelight_row != NULL) {
row_index = g_list_index (clist->row_list, list->details->drag_prelight_row);
get_cell_rectangle (clist, row_index, 0, &rect);
nautilus_list_get_cell_rectangle (list, row_index, 0, &rect);
gtk_widget_draw (GTK_WIDGET (list), &rect);
}
}
}
void
nautilus_list_get_initial_drag_offset (NautilusList *list, int *x, int *y)
{
*x = list->details->dnd_press_x;// + NAUTILUS_CLIST (list)->hoffset;
*y = list->details->dnd_press_y;// + NAUTILUS_CLIST (list)->voffset;
}
......@@ -136,51 +136,59 @@ struct NautilusListClass {
};
typedef gboolean (* NautilusEachRowFunction) (NautilusCListRow *, gpointer);
GtkType nautilus_list_get_type (void);
GtkWidget * nautilus_list_new_with_titles (int columns,
const char * const *titles);
GList * nautilus_list_get_selection (NautilusList *list);
void nautilus_list_set_selection (NautilusList *list,
GList *selection);
void nautilus_list_reveal_row (NautilusList *list,
int row);
gboolean nautilus_list_is_row_selected (NautilusList *list,
int row);
void nautilus_list_set_pixbuf_list (NautilusList *list,
gint row,
gint column,
GList *pixbufs);
void nautilus_list_set_pixbuf (NautilusList *list,
int row_index,
int column_index,
GdkPixbuf *pixbuf);
GdkPixbuf *nautilus_list_get_pixbuf (NautilusList *list,
int row_index,
int column_index);
void nautilus_list_mark_cell_as_link (NautilusList *list,
gint row,
gint column);
void nautilus_list_set_single_click_mode (NautilusList *list,
gboolean single_click_mode);
void nautilus_list_select_row (NautilusList *list,
int row);
NautilusCListRow *nautilus_list_row_at (NautilusList *list,
int y);
int nautilus_list_get_first_selected_row (NautilusList *list);
int nautilus_list_get_last_selected_row (NautilusList *list);
void nautilus_list_each_selected_row (NautilusList *list,
NautilusEachRowFunction function,
gpointer data);
gboolean nautilus_list_rejects_dropped_icons (NautilusList *list);
void nautilus_list_set_rejects_dropped_icons (NautilusList *list,
gboolean new_value);
void nautilus_list_set_drag_prelight_row (NautilusList *list,
int y);
void nautilus_list_set_anti_aliased_mode (NautilusList *list,
gboolean anti_aliased_mode);
typedef gboolean (* NautilusEachRowFunction) (NautilusCListRow *, int, gpointer);
GtkType nautilus_list_get_type (void);
GtkWidget * nautilus_list_new_with_titles (int columns,
const char * const *titles);
GList * nautilus_list_get_selection (NautilusList *list);
void nautilus_list_set_selection (NautilusList *list,
GList *selection);
void nautilus_list_reveal_row (NautilusList *list,
int row);
gboolean nautilus_list_is_row_selected (NautilusList *list,
int row);
void nautilus_list_get_cell_rectangle (NautilusList *clist,
int row_index,
int column_index,
GdkRectangle *result);
void nautilus_list_set_pixbuf_list (NautilusList *list,
gint row,
gint column,
GList *pixbufs);
void nautilus_list_set_pixbuf (NautilusList *list,
int row_index,
int column_index,
GdkPixbuf *pixbuf);
GdkPixbuf *nautilus_list_get_pixbuf (NautilusList *list,
int row_index,
int column_index);
void nautilus_list_mark_cell_as_link (NautilusList *list,
gint row,
gint column);
void nautilus_list_set_single_click_mode (NautilusList *list,
gboolean single_click_mode);
void nautilus_list_select_row (NautilusList *list,
int row);
NautilusCListRow *nautilus_list_row_at (NautilusList *list,
int y);
int nautilus_list_get_first_selected_row (NautilusList *list);
int nautilus_list_get_last_selected_row (NautilusList *list);
void nautilus_list_each_selected_row (NautilusList *list,
NautilusEachRowFunction function,
gpointer data);
gboolean nautilus_list_rejects_dropped_icons (NautilusList *list);
void nautilus_list_set_rejects_dropped_icons (NautilusList *list,
gboolean new_value);
void nautilus_list_set_drag_prelight_row (NautilusList *list,
int y);
void nautilus_list_get_initial_drag_offset (NautilusList *list,
int *x,
int *y);
void nautilus_list_set_anti_aliased_mode (NautilusList *list,
gboolean anti_aliased_mode);
#endif /* NAUTILUS_LIST_H */
......
......@@ -253,6 +253,118 @@ nautilus_art_irect_assign_dimensions (int x,
return rectangle;
}
ArtIRect
nautilus_art_irect_offset_by (ArtIRect rectangle, int x, int y)
{
rectangle.x0 += x;
rectangle.x1 += x;
rectangle.y0 += y;
rectangle.y1 += y;
return rectangle;
}
ArtIRect
nautilus_art_irect_offset_to (ArtIRect rectangle, int x, int y)
{
rectangle.x1 = rectangle.x1 - rectangle.x0 + x;
rectangle.x0 = x;
rectangle.y1 = rectangle.y1 - rectangle.y0 + y;
rectangle.y0 = y;
return rectangle;
}
ArtIRect
nautilus_art_irect_scale_by (ArtIRect rectangle, double scale)
{
rectangle.x0 *= scale;
rectangle.x1 *= scale;
rectangle.y0 *= scale;
rectangle.y1 *= scale;
return rectangle;
}
ArtIRect
nautilus_art_irect_inset (ArtIRect rectangle, int horizontal_inset, int vertical_inset)
{
rectangle.x0 += horizontal_inset;
rectangle.x1 -= horizontal_inset;
rectangle.y0 += vertical_inset;
rectangle.y1 -= vertical_inset;
return rectangle;
}
ArtDRect
nautilus_art_drect_offset_by (ArtDRect rectangle, double x, double y)
{
rectangle.x0 += x;
rectangle.x1 += x;
rectangle.y0 += y;
rectangle.y1 += y;
return rectangle;
}
ArtDRect
nautilus_art_drect_offset_to (ArtDRect rectangle, double x, double y)
{
rectangle.x1 = rectangle.x1 - rectangle.x0 + x;
rectangle.x0 = x;
rectangle.y1 = rectangle.y1 - rectangle.y0 + y;
rectangle.y0 = y;
return rectangle;
}
ArtIRect
nautilus_art_irect_offset_by_point (ArtIRect rectangle, NautilusArtIPoint point)
{
rectangle.x0 += point.x;
rectangle.x1 += point.x;
rectangle.y0 += point.y;
rectangle.y1 += point.y;
return rectangle;
}
ArtIRect
nautilus_art_irect_offset_to_point (ArtIRect rectangle, NautilusArtIPoint point)
{
rectangle.x1 = rectangle.x1 - rectangle.x0 + point.x;
rectangle.x0 = point.x;
rectangle.y1 = rectangle.y1 - rectangle.y0 + point.y;
rectangle.y0 = point.y;
return rectangle;
}
ArtDRect
nautilus_art_drect_scale_by (ArtDRect rectangle, double scale)
{
rectangle.x0 *= scale;
rectangle.x1 *= scale;
rectangle.y0 *= scale;
rectangle.y1 *= scale;
return rectangle;
}
ArtDRect
nautilus_art_drect_inset (ArtDRect rectangle, double horizontal_inset, double vertical_inset)
{
rectangle.x0 += horizontal_inset;
rectangle.x1 -= horizontal_inset;
rectangle.y0 += vertical_inset;
rectangle.y1 -= vertical_inset;
return rectangle;
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
void
......
......@@ -77,6 +77,34 @@ ArtIRect nautilus_art_irect_assign_dimensions (int x,
int y,