[gegl] Updated gegl-paint code to reflect new property names on the path op.



commit ff6fa983a1a7745d61286d8598f14e914627329c
Author: �yvind Kolås <pippin gimp org>
Date:   Fri Nov 13 03:06:23 2009 +0000

    Updated gegl-paint code to reflect new property names on the path op.
    
    Also set the buffer format to RGBA float, as a temporary workaround
    to avoid over eager in place compositing.

 examples/gegl-paint.c     |   16 +++++++++-------
 examples/util/gegl-view.c |   14 +++++++-------
 2 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/examples/gegl-paint.c b/examples/gegl-paint.c
index 843c3f8..d6741d5 100644
--- a/examples/gegl-paint.c
+++ b/examples/gegl-paint.c
@@ -51,10 +51,10 @@ static gboolean paint_press (GtkWidget      *widget,
       over       = gegl_node_new_child (gegl, "operation", "gegl:over", NULL);
       stroke     = gegl_node_new_child (gegl, "operation", "gegl:path",
                                         "d", vector,
+                                        "fill-opacity", 0.0,
                                         "stroke", gegl_color_new (COLOR),
-                                        "fill", gegl_color_new ("none"),
                                         "stroke-width", LINEWIDTH,
-                                        "hardness", HARDNESS,
+                                        "stroke-hardness", HARDNESS,
                                         NULL);
       gegl_node_link_many (top, over, out, NULL);
       gegl_node_connect_to (stroke, "output", over, "aux");
@@ -143,9 +143,14 @@ main (gint    argc,
       GeglRectangle rect = {0, 0, 512, 512};
       gpointer buf;
 
-      buffer = gegl_buffer_new (&rect, babl_format("RaGaBaA float"));
+      /* XXX: the format should be RaGaBaA float, it is nonpremultiplied
+       * right now, slowing things down a bit, but it circumvents overeager
+       * in place processing code.
+       */
+      buffer = gegl_buffer_new (&rect, babl_format("RGBA float"));
       buf    = gegl_buffer_linear_open (buffer, NULL, NULL, babl_format ("Y' u8"));
-      memset (buf, 255, 512 * 512); /* FIXME: we need a babl_buffer_paint () */
+      /* it would be useful to have a programmatic way of doing this */
+      memset (buf, 255, 512 * 512);
       gegl_buffer_linear_close (buffer, buf);
     }
   else
@@ -170,10 +175,8 @@ main (gint    argc,
                     (GCallback) paint_press, NULL);
   g_signal_connect (GTK_OBJECT (view), "button-release-event",
                     (GCallback) paint_release, NULL);
-
   gtk_widget_add_events (view, GDK_BUTTON_RELEASE_MASK);
 
-
   gtk_container_add (GTK_CONTAINER (window), view);
   gtk_widget_set_size_request (view, 512, 512);
 
@@ -181,7 +184,6 @@ main (gint    argc,
                     G_CALLBACK (gtk_main_quit), window);
   gtk_widget_show_all (window);
 
-
   gtk_main ();
   g_object_unref (gegl);
   gegl_buffer_destroy (buffer);
diff --git a/examples/util/gegl-view.c b/examples/util/gegl-view.c
index 21f356d..b965033 100644
--- a/examples/util/gegl-view.c
+++ b/examples/util/gegl-view.c
@@ -327,8 +327,6 @@ button_press_event (GtkWidget      *widget,
   gint      x    = event->x;
   gint      y    = event->y;
 
-  return FALSE;
-
   priv->screen_x = x;
   priv->screen_y = y;
 
@@ -385,7 +383,7 @@ motion_notify_event (GtkWidget      *widget,
       priv->x -= diff_x;
       priv->y -= diff_y;
 
-      gdk_window_scroll (widget->window, diff_x, diff_y);
+      gdk_window_scroll (gtk_widget_get_window (widget), diff_x, diff_y);
 
       g_object_notify (G_OBJECT (view), "x");
       g_object_notify (G_OBJECT (view), "y");
@@ -463,8 +461,8 @@ expose_event (GtkWidget      *widget,
                       GEGL_AUTO_ROWSTRIDE,
                       GEGL_BLIT_CACHE|(priv->block?0:GEGL_BLIT_DIRTY));
 
-      gdk_draw_rgb_image (widget->window,
-                          widget->style->black_gc,
+      gdk_draw_rgb_image (gtk_widget_get_window (widget),
+                          gtk_widget_get_style (widget)->black_gc,
                           rectangles[i].x, rectangles[i].y,
                           rectangles[i].width, rectangles[i].height,
                           GDK_RGB_DITHER_NONE,
@@ -499,11 +497,13 @@ gegl_view_repaint (GeglView *view)
   GtkWidget       *widget = GTK_WIDGET (view);
   GeglViewPrivate *priv   = GEGL_VIEW_GET_PRIVATE (view);
   GeglRectangle    roi;
+  GtkAllocation    allocation;
 
   roi.x = priv->x / priv->scale;
   roi.y = priv->y / priv->scale;
-  roi.width = ceil(widget->allocation.width / priv->scale+1);
-  roi.height = ceil(widget->allocation.height / priv->scale+1);
+  gtk_widget_get_allocation (widget, &allocation);
+  roi.width = ceil(allocation.width / priv->scale+1);
+  roi.height = ceil(allocation.height / priv->scale+1);
 
   if (priv->monitor_id == 0)
     {



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