forked from AuroraMiddleware/gtk
iconview: Simplify rubberband drawing
This commit is contained in:
parent
0d6461714b
commit
ab781bd89b
@ -305,8 +305,7 @@ static void gtk_icon_view_paint_item (GtkIco
|
|||||||
gint y,
|
gint y,
|
||||||
gboolean draw_focus);
|
gboolean draw_focus);
|
||||||
static void gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
|
static void gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
|
||||||
cairo_t *cr,
|
cairo_t *cr);
|
||||||
GdkRectangle *area);
|
|
||||||
static void gtk_icon_view_queue_draw_path (GtkIconView *icon_view,
|
static void gtk_icon_view_queue_draw_path (GtkIconView *icon_view,
|
||||||
GtkTreePath *path);
|
GtkTreePath *path);
|
||||||
static void gtk_icon_view_queue_draw_item (GtkIconView *icon_view,
|
static void gtk_icon_view_queue_draw_item (GtkIconView *icon_view,
|
||||||
@ -1677,18 +1676,7 @@ gtk_icon_view_expose (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (icon_view->priv->doing_rubberband)
|
if (icon_view->priv->doing_rubberband)
|
||||||
{
|
gtk_icon_view_paint_rubberband (icon_view, cr);
|
||||||
cairo_rectangle_int_t rectangle;
|
|
||||||
gint n_rectangles;
|
|
||||||
|
|
||||||
n_rectangles = cairo_region_num_rectangles (expose->region);
|
|
||||||
|
|
||||||
while (n_rectangles--)
|
|
||||||
{
|
|
||||||
cairo_region_get_rectangle (expose->region, n_rectangles, &rectangle);
|
|
||||||
gtk_icon_view_paint_rubberband (icon_view, cr, &rectangle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
|
||||||
@ -3312,21 +3300,18 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
|
gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
|
||||||
cairo_t *cr,
|
cairo_t *cr)
|
||||||
GdkRectangle *area)
|
|
||||||
{
|
{
|
||||||
GdkRectangle rect;
|
GdkRectangle rect;
|
||||||
GdkRectangle rubber_rect;
|
|
||||||
GdkColor *fill_color_gdk;
|
GdkColor *fill_color_gdk;
|
||||||
guchar fill_color_alpha;
|
guchar fill_color_alpha;
|
||||||
|
|
||||||
rubber_rect.x = MIN (icon_view->priv->rubberband_x1, icon_view->priv->rubberband_x2);
|
cairo_save (cr);
|
||||||
rubber_rect.y = MIN (icon_view->priv->rubberband_y1, icon_view->priv->rubberband_y2);
|
|
||||||
rubber_rect.width = ABS (icon_view->priv->rubberband_x1 - icon_view->priv->rubberband_x2) + 1;
|
|
||||||
rubber_rect.height = ABS (icon_view->priv->rubberband_y1 - icon_view->priv->rubberband_y2) + 1;
|
|
||||||
|
|
||||||
if (!gdk_rectangle_intersect (&rubber_rect, area, &rect))
|
rect.x = MIN (icon_view->priv->rubberband_x1, icon_view->priv->rubberband_x2);
|
||||||
return;
|
rect.y = MIN (icon_view->priv->rubberband_y1, icon_view->priv->rubberband_y2);
|
||||||
|
rect.width = ABS (icon_view->priv->rubberband_x1 - icon_view->priv->rubberband_x2) + 1;
|
||||||
|
rect.height = ABS (icon_view->priv->rubberband_y1 - icon_view->priv->rubberband_y2) + 1;
|
||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (icon_view),
|
gtk_widget_style_get (GTK_WIDGET (icon_view),
|
||||||
"selection-box-color", &fill_color_gdk,
|
"selection-box-color", &fill_color_gdk,
|
||||||
@ -3336,29 +3321,21 @@ gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
|
|||||||
if (!fill_color_gdk)
|
if (!fill_color_gdk)
|
||||||
fill_color_gdk = gdk_color_copy (>k_widget_get_style (GTK_WIDGET (icon_view))->base[GTK_STATE_SELECTED]);
|
fill_color_gdk = gdk_color_copy (>k_widget_get_style (GTK_WIDGET (icon_view))->base[GTK_STATE_SELECTED]);
|
||||||
|
|
||||||
cairo_set_source_rgba (cr,
|
gdk_cairo_set_source_color (cr, fill_color_gdk);
|
||||||
fill_color_gdk->red / 65535.,
|
|
||||||
fill_color_gdk->green / 65535.,
|
|
||||||
fill_color_gdk->blue / 65535.,
|
|
||||||
fill_color_alpha / 255.);
|
|
||||||
|
|
||||||
cairo_save (cr);
|
|
||||||
gdk_cairo_rectangle (cr, &rect);
|
gdk_cairo_rectangle (cr, &rect);
|
||||||
cairo_clip (cr);
|
cairo_clip (cr);
|
||||||
cairo_paint (cr);
|
|
||||||
|
|
||||||
/* Draw the border without alpha */
|
cairo_paint_with_alpha (cr, fill_color_alpha / 255.);
|
||||||
cairo_set_source_rgb (cr,
|
|
||||||
fill_color_gdk->red / 65535.,
|
|
||||||
fill_color_gdk->green / 65535.,
|
|
||||||
fill_color_gdk->blue / 65535.);
|
|
||||||
cairo_rectangle (cr,
|
cairo_rectangle (cr,
|
||||||
rubber_rect.x + 0.5, rubber_rect.y + 0.5,
|
rect.x + 0.5, rect.y + 0.5,
|
||||||
rubber_rect.width - 1, rubber_rect.height - 1);
|
rect.width - 1, rect.height - 1);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
cairo_restore (cr);
|
|
||||||
|
|
||||||
gdk_color_free (fill_color_gdk);
|
gdk_color_free (fill_color_gdk);
|
||||||
|
|
||||||
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user