[gthumb] fixed painting of the grid view when selecting with the mouse



commit d9fd3e83be31f16d8cfaca6fae7aca686a9cb426
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Jan 30 19:01:46 2012 +0100

    fixed painting of the grid view when selecting with the mouse
    
    repaint all the items above the selection

 gthumb/gth-grid-view.c |   38 ++++++--------------------------------
 1 files changed, 6 insertions(+), 32 deletions(-)
---
diff --git a/gthumb/gth-grid-view.c b/gthumb/gth-grid-view.c
index 8eda5de..f5c6b76 100644
--- a/gthumb/gth-grid-view.c
+++ b/gthumb/gth-grid-view.c
@@ -50,7 +50,6 @@
 #define SCROLL_DELAY               30
 #define LAYOUT_DELAY               20
 #define MAX_DELTA_FOR_SCROLLING    1024.0
-#define RUBBERBAND_BORDER          2
 
 
 static void gth_grid_view_gth_file_selection_interface_init (GthFileSelectionInterface *iface);
@@ -1269,7 +1268,6 @@ _gth_grid_view_item_draw_thumbnail (GthGridViewItem *item,
 		cairo_fill (cr);
 	}
 
-	gdk_rgba_parse (&background_color, "#edeceb");
 	gtk_style_context_get_background_color (style_context, item_state, &background_color);
 	_gdk_rgba_darker (&background_color, &lighter_color);
 	_gdk_rgba_darker (&lighter_color, &darker_color);
@@ -1420,10 +1418,7 @@ _gth_grid_view_item_draw_thumbnail (GthGridViewItem *item,
 	cairo_fill (cr);
 
 	if (item_state & GTK_STATE_FLAG_SELECTED) {
-		GdkRGBA color;
-
-		gtk_style_context_get_background_color (style_context, item_state, &color);
-		cairo_set_source_rgba (cr, color.red, color.green, color.blue, 0.33);
+		cairo_set_source_rgba (cr, background_color.red, background_color.green, background_color.blue, 0.33);
 		cairo_rectangle (cr,
 				 frame_rect.x,
 				 frame_rect.y,
@@ -1598,7 +1593,6 @@ gth_grid_view_draw (GtkWidget *widget,
 
 	cairo_save (cr);
 	gtk_cairo_transform_to_window (cr, widget, self->priv->bin_window);
-	cairo_set_line_width (cr, 1.0);
 
 	for (i = first_visible, scan = g_list_nth (self->priv->items, first_visible);
 	     (i <= last_visible) && scan;
@@ -2778,7 +2772,6 @@ _gth_grid_view_update_mouse_selection (GthGridView *self,
 	cairo_region_t        *invalid_region;
 	int                    x1, y1, x2, y2;
 	GtkAllocation          allocation;
-	cairo_region_t        *common_region;
 	gboolean               additive;
 	gboolean               invert;
 	int                    min_y, max_y;
@@ -2825,27 +2818,6 @@ _gth_grid_view_update_mouse_selection (GthGridView *self,
 	invalid_region = cairo_region_create_rectangle (&old_selection_area);
 	cairo_region_union_rectangle (invalid_region, &self->priv->selection_area);
 
-	common_region = cairo_region_create_rectangle (&old_selection_area);
-	cairo_region_intersect_rectangle (common_region, &self->priv->selection_area);
-
-	if (! cairo_region_is_empty (common_region)) {
-		cairo_rectangle_int_t common_region_extents;
-
-		/* invalidate the border as well */
-		cairo_region_get_extents (common_region, &common_region_extents);
-		common_region_extents.x += RUBBERBAND_BORDER;
-		common_region_extents.y += RUBBERBAND_BORDER;
-		common_region_extents.width -= RUBBERBAND_BORDER * 2;
-		common_region_extents.height -= RUBBERBAND_BORDER * 2;
-
-		cairo_region_subtract_rectangle (invalid_region, &common_region_extents);
-	}
-
-	gdk_window_invalidate_region (self->priv->bin_window, invalid_region, FALSE);
-
-	cairo_region_destroy (common_region);
-	cairo_region_destroy (invalid_region);
-
 	/* select or unselect images as appropriate */
 
 	additive = self->priv->sel_state & GDK_SHIFT_MASK;
@@ -2865,8 +2837,6 @@ _gth_grid_view_update_mouse_selection (GthGridView *self,
 	if (end != NULL)
 		end = end->next;
 
-	gdk_window_freeze_updates (self->priv->bin_window);
-
 	x1 = self->priv->selection_area.x;
 	y1 = self->priv->selection_area.y;
 	x2 = x1 + self->priv->selection_area.width;
@@ -2893,9 +2863,13 @@ _gth_grid_view_update_mouse_selection (GthGridView *self,
 		}
 		else if (selection_changed)
 			_gth_grid_view_set_item_selected (self, (item->tmp_state & GTK_STATE_FLAG_SELECTED), i);
+
+		if (gdk_rectangle_intersect (&self->priv->selection_area, &item->area, NULL))
+			cairo_region_union_rectangle (invalid_region, &item->area);
 	}
 
-	gdk_window_thaw_updates (self->priv->bin_window);
+	gdk_window_invalidate_region (self->priv->bin_window, invalid_region, FALSE);
+	cairo_region_destroy (invalid_region);
 
 	_gth_grid_view_emit_selection_changed (self);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]