[gimp] plug-ins: port filter-pack drawing to cairo



commit e0ad0f478e83758056cb3b78500bf4f3eee9c7f6
Author: Michael Natterer <mitch gimp org>
Date:   Wed Sep 8 14:36:29 2010 +0200

    plug-ins: port filter-pack drawing to cairo

 plug-ins/common/filter-pack.c |   52 +++++++++++++++++++++-------------------
 1 files changed, 27 insertions(+), 25 deletions(-)
---
diff --git a/plug-ins/common/filter-pack.c b/plug-ins/common/filter-pack.c
index 15564df..4a8e7d0 100644
--- a/plug-ins/common/filter-pack.c
+++ b/plug-ins/common/filter-pack.c
@@ -1451,46 +1451,48 @@ slider_erase (GdkWindow *window,
 }
 
 static void
-draw_slider (GdkWindow *window,
-             GdkGC     *border_gc,
-             GdkGC     *fill_gc,
-             gint       xpos)
+draw_slider (cairo_t  *cr,
+             GdkColor *border_color,
+             GdkColor *fill_color,
+             gint      xpos)
 {
-  gint i;
-
-  for (i = 0; i < RANGE_HEIGHT; i++)
-    gdk_draw_line (window, fill_gc, MARGIN + xpos-i/2, i, MARGIN + xpos+i/2,i);
+  cairo_move_to (cr, MARGIN + xpos, 0);
+  cairo_line_to (cr, MARGIN + xpos - (RANGE_HEIGHT - 1) / 2, RANGE_HEIGHT - 1);
+  cairo_line_to (cr, MARGIN + xpos + (RANGE_HEIGHT - 1) / 2, RANGE_HEIGHT - 1);
+  cairo_line_to (cr, MARGIN + xpos, 0);
 
-  gdk_draw_line (window, border_gc, MARGIN + xpos, 0,
-                 MARGIN + xpos - (RANGE_HEIGHT - 1) / 2, RANGE_HEIGHT - 1);
+  gdk_cairo_set_source_color (cr, fill_color);
+  cairo_fill_preserve (cr);
 
-  gdk_draw_line (window, border_gc, MARGIN + xpos, 0,
-                 MARGIN + xpos + (RANGE_HEIGHT - 1) / 2, RANGE_HEIGHT - 1);
-
-  gdk_draw_line (window, border_gc, MARGIN + xpos- (RANGE_HEIGHT - 1)/2,
-                 RANGE_HEIGHT-1, MARGIN + xpos + (RANGE_HEIGHT-1)/2,
-                 RANGE_HEIGHT - 1);
+  gdk_cairo_set_source_color (cr, border_color);
+  cairo_stroke (cr);
 }
 
 static void
 draw_it (GtkWidget *widget)
 {
   GtkStyle *style = gtk_widget_get_style (AW.aliasing_graph);
+  cairo_t  *cr    = gdk_cairo_create (gtk_widget_get_window (AW.aliasing_graph));
+
+  cairo_translate (cr, 0.5, 0.5);
+  cairo_set_line_width (cr, 1.0);
 
-  draw_slider (gtk_widget_get_window (AW.aliasing_graph),
-               style->black_gc,
-               style->dark_gc[GTK_STATE_NORMAL],
+  draw_slider (cr,
+               &style->black,
+               &style->dark[GTK_STATE_NORMAL],
                fpvals.cutoff[SHADOWS]);
 
-  draw_slider (gtk_widget_get_window (AW.aliasing_graph),
-               style->black_gc,
-               style->dark_gc[GTK_STATE_NORMAL],
+  draw_slider (cr,
+               &style->black,
+               &style->dark[GTK_STATE_NORMAL],
                fpvals.cutoff[MIDTONES]);
 
-  draw_slider (gtk_widget_get_window (AW.aliasing_graph),
-               style->black_gc,
-               style->dark_gc[GTK_STATE_SELECTED],
+  draw_slider (cr,
+               &style->black,
+               &style->dark[GTK_STATE_SELECTED],
                fpvals.offset);
+
+  cairo_destroy (cr);
 }
 
 static gboolean



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