From c65e82ff717a6abb0474ab13e282a3ed6dafc5f7 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 5 Jan 2005 12:47:10 +0000 Subject: [PATCH] Nicer rubberband drawing, from GtkIconView. 2005-01-05 Marco Pesenti Gritti * shell/ev-view.c: (ev_gdk_color_to_rgb), (draw_rubberband), (expose_bin_window): Nicer rubberband drawing, from GtkIconView. --- ChangeLog | 7 +++++++ shell/ev-view.c | 54 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bf53936..8f4074c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-01-05 Marco Pesenti Gritti + + * shell/ev-view.c: (ev_gdk_color_to_rgb), (draw_rubberband), + (expose_bin_window): + + Nicer rubberband drawing, from GtkIconView. + 2005-01-05 Marco Pesenti Gritti * backend/ev-document.c: (ev_document_save): diff --git a/shell/ev-view.c b/shell/ev-view.c index d8b499b8..8616fea9 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -301,6 +301,51 @@ ev_view_state_changed (GtkWidget *widget, update_window_backgrounds (EV_VIEW (widget)); } +static guint32 +ev_gdk_color_to_rgb (const GdkColor *color) +{ + guint32 result; + result = (0xff0000 | (color->red & 0xff00)); + result <<= 8; + result |= ((color->green & 0xff00) | (color->blue >> 8)); + return result; +} + +static void +draw_rubberband (GtkWidget *widget, GdkWindow *window, const GdkRectangle *rect) +{ + GdkGC *gc; + GdkPixbuf *pixbuf; + GdkColor *fill_color_gdk; + guint fill_color; + + fill_color_gdk = gdk_color_copy (>K_WIDGET (widget)->style->base[GTK_STATE_SELECTED]); + fill_color = ev_gdk_color_to_rgb (fill_color_gdk) << 8 | 0x40; + + pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, + rect->width, rect->height); + gdk_pixbuf_fill (pixbuf, fill_color); + + gdk_draw_pixbuf (window, NULL, pixbuf, + 0, 0, + rect->x,rect->y, + rect->width, rect->height, + GDK_RGB_DITHER_NONE, + 0, 0); + + g_object_unref (pixbuf); + + gc = gdk_gc_new (window); + gdk_gc_set_rgb_fg_color (gc, fill_color_gdk); + gdk_draw_rectangle (window, gc, FALSE, + rect->x, rect->y, + rect->width - 1, + rect->height - 1); + g_object_unref (gc); + + gdk_color_free (fill_color_gdk); +} + static void expose_bin_window (GtkWidget *widget, GdkEventExpose *event) @@ -330,13 +375,8 @@ expose_bin_window (GtkWidget *widget, results[i].highlight_area.height); #endif if (results[i].page_num == current_page) - gdk_draw_rectangle (view->bin_window, - widget->style->base_gc[GTK_STATE_SELECTED], - FALSE, - results[i].highlight_area.x, - results[i].highlight_area.y, - results[i].highlight_area.width, - results[i].highlight_area.height); + draw_rubberband (widget, view->bin_window, + &results[i].highlight_area); ++i; } } -- 2.43.5