[gegl-edit] Added icons for unbounded nodes and empty nodes



commit 8ccb0613c6b74deb61961f2bc29d9351c1fa87ed
Author: Isaac Wagner <isaacbw src gnome org>
Date:   Thu Aug 9 18:05:18 2012 -0400

    Added icons for unbounded nodes and empty nodes

 gegl-edit/Makefile.am        |    4 ++-
 gegl-edit/data/empty.png     |  Bin 0 -> 341 bytes
 gegl-edit/data/unbounded.png |  Bin 0 -> 336 bytes
 gegl-edit/gegl-edit.c        |   44 +++++++++++++++++++++++++++++++----------
 gegl-edit/gresource.xml      |    2 +
 5 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/gegl-edit/Makefile.am b/gegl-edit/Makefile.am
index f9565f1..2fc55b5 100644
--- a/gegl-edit/Makefile.am
+++ b/gegl-edit/Makefile.am
@@ -6,7 +6,9 @@ UI_FILES = \
 	contextmenu.ui \
 	contextmenu_canvas.ui \
 	data/in.png \
-	data/out.png 
+	data/out.png \
+	data/unbounded.png \
+	data/empty.png
 
 BUILT_SOURCES = \
 	resources.c \
diff --git a/gegl-edit/data/empty.png b/gegl-edit/data/empty.png
new file mode 100644
index 0000000..07f7d0b
Binary files /dev/null and b/gegl-edit/data/empty.png differ
diff --git a/gegl-edit/data/unbounded.png b/gegl-edit/data/unbounded.png
new file mode 100644
index 0000000..262b7fc
Binary files /dev/null and b/gegl-edit/data/unbounded.png differ
diff --git a/gegl-edit/gegl-edit.c b/gegl-edit/gegl-edit.c
index 130b43d..98cb45d 100644
--- a/gegl-edit/gegl-edit.c
+++ b/gegl-edit/gegl-edit.c
@@ -21,6 +21,8 @@ typedef struct
   const gchar *filename;
   cairo_surface_t *in;
   cairo_surface_t *out;
+  cairo_surface_t *empty;
+  cairo_surface_t *unbounded;
 } CallbackData;
 
 static const gchar* query_proxy(GeglGtkPropertyView *view, GeglNode *node, const gchar *property, CallbackData* data);
@@ -116,6 +118,16 @@ main (gint	  argc,
   closure.bytes = in_bytes;
   closure.offset = 0;
   data->out = cairo_image_surface_create_from_png_stream( (cairo_read_func_t) cairo_read_bytes, &closure);
+
+  in_bytes = g_resource_lookup_data(resource, "/gegl-edit/data/empty.png", 0, NULL);
+  closure.bytes = in_bytes;
+  closure.offset = 0;
+  data->empty = cairo_image_surface_create_from_png_stream( (cairo_read_func_t) cairo_read_bytes, &closure);
+
+  in_bytes = g_resource_lookup_data(resource, "/gegl-edit/data/unbounded.png", 0, NULL);
+  closure.bytes = in_bytes;
+  closure.offset = 0;
+  data->unbounded = cairo_image_surface_create_from_png_stream( (cairo_read_func_t) cairo_read_bytes, &closure);
   //done loading images
 
   g_signal_connect(props, "property-changed", G_CALLBACK(property_changed), view);
@@ -170,14 +182,13 @@ main (gint	  argc,
 }
 
 ////////GraphGtk callbacks////////
-static void post_render(GraphGtkNode *node, cairo_t *cr, CallbackData *data)
+static void post_render(GraphGtkNode *view_node, cairo_t *cr, CallbackData *data)
 {
   GeglNode *gegl = g_queue_peek_head(data->graph_stack);
   GList *input_proxies = NULL;
   GList *output_proxies = NULL;
 
 
-  //Note: gegl:nop has two pads but both lead to the same proxy. This is the only case in which is_input and is_output would both be true
   GSList *pads;
   gboolean is_input = FALSE;
   gboolean is_output = FALSE;
@@ -186,33 +197,44 @@ static void post_render(GraphGtkNode *node, cairo_t *cr, CallbackData *data)
       if(gegl_pad_is_input(pads->data))
 	{
 	  GeglNode *proxy = gegl_node_get_input_proxy(gegl, gegl_pad_get_name(pads->data));
-	  if(node->user_data == proxy)
+	  if(view_node->user_data == proxy)
 	    is_input = TRUE;
 	}
       else if(gegl_pad_is_output(pads->data))
 	{
 	  GeglNode *proxy = gegl_node_get_output_proxy(gegl, gegl_pad_get_name(pads->data));
-	  if(node->user_data == proxy)
+	  if(view_node->user_data == proxy)
 	    is_output = TRUE;
 	}
     }
 
-  if (is_output && is_input)
+  gint offset = 0;
+  if (is_input)
     {
-      cairo_set_source_surface(cr, data->out, node->x+node->offset_x+cairo_image_surface_get_width(data->in), node->y+node->offset_y+node->height-cairo_image_surface_get_height(data->out));
+      cairo_set_source_surface(cr, data->in, offset+view_node->x+view_node->offset_x, view_node->y+view_node->offset_y+view_node->height-cairo_image_surface_get_height(data->in));
       cairo_paint(cr);
-      cairo_set_source_surface(cr, data->in, node->x+node->offset_x, node->y+node->offset_y+node->height-cairo_image_surface_get_height(data->in));
+      offset += cairo_image_surface_get_width(data->in);
+    }
+  if (is_output)
+    {
+      cairo_set_source_surface(cr, data->out, offset+view_node->x+view_node->offset_x, view_node->y+view_node->offset_y+view_node->height-cairo_image_surface_get_height(data->out));
       cairo_paint(cr);
+      offset += cairo_image_surface_get_width(data->out);
     }
-  else if (is_output)
+  
+  GeglNode *node = view_node->user_data;
+  const GeglRectangle roi = gegl_node_get_bounding_box(node);
+  if(gegl_rectangle_is_infinite_plane(&roi))
     {
-      cairo_set_source_surface(cr, data->out, node->x+node->offset_x, node->y+node->offset_y+node->height-cairo_image_surface_get_height(data->out));
+      cairo_set_source_surface(cr, data->unbounded, offset+view_node->x+view_node->offset_x, view_node->y+view_node->offset_y+view_node->height-cairo_image_surface_get_height(data->unbounded));
       cairo_paint(cr);
+      offset += cairo_image_surface_get_width(data->unbounded);
     }
-  else if (is_input)
+  if(roi.width == 0 || roi.height == 0)
     {
-      cairo_set_source_surface(cr, data->in, node->x+node->offset_x, node->y+node->offset_y+node->height-cairo_image_surface_get_height(data->in));
+      cairo_set_source_surface(cr, data->empty, offset+view_node->x+view_node->offset_x, view_node->y+view_node->offset_y+view_node->height-cairo_image_surface_get_height(data->empty));
       cairo_paint(cr);
+      offset += cairo_image_surface_get_width(data->empty);
     }
 }
 
diff --git a/gegl-edit/gresource.xml b/gegl-edit/gresource.xml
index 8204035..2b4a691 100644
--- a/gegl-edit/gresource.xml
+++ b/gegl-edit/gresource.xml
@@ -6,5 +6,7 @@
     <file preprocess="xml-stripblanks">contextmenu_canvas.ui</file>
     <file>data/in.png</file>
     <file>data/out.png</file>
+    <file>data/empty.png</file>
+    <file>data/unbounded.png</file>
   </gresource>
 </gresources>



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