[PATCH] updates to canvas fixes



Hackers,

The last patch I sent out that contained a fix for stroking the
outlines of rectangle canvas items had a bug in it.  This patch
superseces the previous one.

This should finally fix all issues regarding the outlines of rectangle
canvas items.  The patch is against gnome-libs 1.2.11.

Rusty
-- 
Rusty Conover 
Systems Programmer
Zoot Enterprises Inc, www.zootweb.com

Only in .: .libs
diff -u ../../gnome-libs-1.2.11/libgnomeui/ChangeLog ./ChangeLog
--- ../../gnome-libs-1.2.11/libgnomeui/ChangeLog	Sat Feb  3 18:42:08 2001
+++ ./ChangeLog	Sat Feb  3 18:39:50 2001
@@ -1,3 +1,22 @@
+2001-02-03    <rconover zootweb com>
+
+	* gnome-canvas-line.c (gnome_canvas_line_set_arg): Added fix for
+	when the color of a line changes the SVP's of the arrowheads also
+	change color.  They didn't change color before.
+
+	* gnome-canvas-rect-allipse.c (gnome_canvas_rect_update): Added
+	fix for proper stroking of rectangle's outlines.  The previous
+	implementation was broken when the canvas's pixels_per_unit !=
+	1.0.
+
+	* gnome-canvas.c: Added ability to make the canvas sensitive to
+	widget state_changed events so if a canvas is placed in a widget
+	which has a PRELIGHT state the canvas background will be updated
+	to reflect the current background color of the widget in the
+	theme.
+	(gnome_canvas_set_state_change_sensitivity): New API call.
+		
+
 2001-01-22  Miguel de Icaza  <miguel ximian com>
 
 	* gnome-dialog.c (gnome_dialog_set_default): Do not grab focus.
Only in .: ChangeLog~
Only in .: Makefile
Only in .: animator_demo
Only in .: animator_demo.o
Only in .: dock_demo
Only in .: dock_demo.o
Only in .: gnome-about.lo
Only in .: gnome-about.o
Only in .: gnome-animator.lo
Only in .: gnome-animator.o
Only in .: gnome-app-helper.lo
Only in .: gnome-app-helper.o
Only in .: gnome-app-util.lo
Only in .: gnome-app-util.o
Only in .: gnome-app.lo
Only in .: gnome-app.o
Only in .: gnome-appbar.lo
Only in .: gnome-appbar.o
Only in .: gnome-calculator.lo
Only in .: gnome-calculator.o
Only in .: gnome-canvas-image.lo
Only in .: gnome-canvas-image.o
diff -u ../../gnome-libs-1.2.11/libgnomeui/gnome-canvas-line.c ./gnome-canvas-line.c
--- ../../gnome-libs-1.2.11/libgnomeui/gnome-canvas-line.c	Sat Feb  3 18:42:07 2001
+++ ./gnome-canvas-line.c	Sat Feb  3 18:32:38 2001
@@ -771,6 +771,14 @@
 		if (!item->canvas->aa)
 			set_line_gc_foreground (line);
 
+
+		if(line->first_svp) {
+			gnome_canvas_item_request_redraw_svp(item, line->first_svp);
+		}
+		if(line->last_svp) {
+			gnome_canvas_item_request_redraw_svp(item, line->last_svp);
+		}
+
 		gnome_canvas_item_request_redraw_svp (item, line->fill_svp);
 	}
 }
Only in .: gnome-canvas-line.c~
Only in .: gnome-canvas-line.lo
Only in .: gnome-canvas-line.o
Only in .: gnome-canvas-load.lo
Only in .: gnome-canvas-load.o
Only in .: gnome-canvas-polygon.lo
Only in .: gnome-canvas-polygon.o
diff -u ../../gnome-libs-1.2.11/libgnomeui/gnome-canvas-rect-ellipse.c ./gnome-canvas-rect-ellipse.c
--- ../../gnome-libs-1.2.11/libgnomeui/gnome-canvas-rect-ellipse.c	Sat Feb  3 18:42:08 2001
+++ ./gnome-canvas-rect-ellipse.c	Sun Feb  4 18:01:48 2001
@@ -860,6 +860,7 @@
 	GnomeCanvasRE *re;
 	ArtVpath vpath[11];
 	ArtVpath *vpath2;
+	ArtSVP *stroke_svp;
 	double x0, y0, x1, y1;
 	double dx, dy;
 	double halfwidth;
@@ -916,7 +917,55 @@
 		} else
 			gnome_canvas_item_update_svp (item, &re->fill_svp, NULL);
 
+
 		if (re->outline_set) {
+			/* The previous implementation here someone
+			 * decided it would be better to do the
+			 * stroking by hand, but it * dosen't work
+			 * right when the canvas is zoomed, so * I'm
+			 * letting libart do the stroking properly */
+
+			 /* If the item is filled, the vpath will already be built,
+			    so whats the point in rebuilding it?  If its not already
+			    built then lets build it. */
+                       
+			if(!re->fill_set) {
+				vpath[0].code = ART_MOVETO;
+				vpath[0].x = x0;
+				vpath[0].y = y0;
+				vpath[1].code = ART_LINETO;
+				vpath[1].x = x0;
+				vpath[1].y = y1;
+				vpath[2].code = ART_LINETO;
+				vpath[2].x = x1;
+				vpath[2].y = y1;
+				vpath[3].code = ART_LINETO;
+				vpath[3].x = x1;
+				vpath[3].y = y0;
+				vpath[4].code = ART_LINETO;
+				vpath[4].x = x0;
+				vpath[4].y = y0;
+				vpath[5].code = ART_END;
+				vpath[5].x = 0;
+				vpath[5].y = 0;
+			}
+
+			vpath2 = art_vpath_affine_transform(vpath, affine);
+			
+			stroke_svp = art_svp_vpath_stroke (vpath2,
+                                                           ART_PATH_STROKE_JOIN_MITER,
+                                                           ART_PATH_STROKE_CAP_BUTT,
+                                                           (re->width_pixels) ? re->width : (re->width * item->canvas->pixels_per_unit),
+                                                           4,
+                                                           0.25);
+                        
+                        gnome_canvas_item_update_svp_clip (item, &re->outline_svp, stroke_svp, clip_path);
+                        art_free (vpath2);
+			
+			
+
+
+#if 0
 			/* We do the stroking by hand because it's simple enough
 			   and could save time. */
 
@@ -981,6 +1030,7 @@
 
 			gnome_canvas_item_update_svp_clip (item, &re->outline_svp, art_svp_from_vpath (vpath2), clip_path);
 			art_free (vpath2);
+#endif
 		} else
 			gnome_canvas_item_update_svp (item, &re->outline_svp, NULL);
 	} else {
Only in .: gnome-canvas-rect-ellipse.c~
Only in .: gnome-canvas-rect-ellipse.lo
Only in .: gnome-canvas-rect-ellipse.o
Only in .: gnome-canvas-text.lo
Only in .: gnome-canvas-text.o
Only in .: gnome-canvas-util.lo
Only in .: gnome-canvas-util.o
Only in .: gnome-canvas-widget.lo
Only in .: gnome-canvas-widget.o
diff -u ../../gnome-libs-1.2.11/libgnomeui/gnome-canvas.c ./gnome-canvas.c
--- ../../gnome-libs-1.2.11/libgnomeui/gnome-canvas.c	Sat Feb  3 18:42:07 2001
+++ ./gnome-canvas.c	Sat Feb  3 18:33:50 2001
@@ -2203,6 +2203,9 @@
 					 GdkEventFocus    *event);
 static gint gnome_canvas_focus_out      (GtkWidget        *widget,
 					 GdkEventFocus    *event);
+static void gnome_canvas_state_changed  (GtkWidget        *widget,
+					 GtkStateType     previous_state);
+
 
 static GtkLayoutClass *canvas_parent_class;
 
@@ -2272,6 +2275,7 @@
 	widget_class->leave_notify_event = gnome_canvas_crossing;
 	widget_class->focus_in_event = gnome_canvas_focus_in;
 	widget_class->focus_out_event = gnome_canvas_focus_out;
+	widget_class->state_changed = gnome_canvas_state_changed;
 }
 
 /* Callback used when the root item of a canvas is destroyed.  The user should
@@ -2300,6 +2304,8 @@
 	canvas->pick_event.crossing.x = 0;
 	canvas->pick_event.crossing.y = 0;
 
+	canvas->state_change_sensitive = 0;
+
 	canvas->dither = GDK_RGB_DITHER_NORMAL;
 
 	gtk_layout_set_hadjustment (GTK_LAYOUT (canvas), NULL);
@@ -3248,7 +3254,13 @@
 				buf.rect.y0 = draw_y1;
 				buf.rect.x1 = draw_x2;
 				buf.rect.y1 = draw_y2;
-				color = &widget->style->bg[GTK_STATE_NORMAL];
+
+				if(canvas->state_change_sensitive) {
+					color = &widget->style->bg[widget->state];
+				} else {
+					color = &widget->style->bg[GTK_STATE_NORMAL];
+				}
+								
 				buf.bg_color = (((color->red & 0xff00) << 8)
 						| (color->green & 0xff00)
 						| (color->blue >> 8));
@@ -3292,8 +3304,15 @@
 				pixmap = gdk_pixmap_new (canvas->layout.bin_window, width, height,
 							 gtk_widget_get_visual (widget)->depth);
 
-				gdk_gc_set_foreground (canvas->pixmap_gc,
-						       &widget->style->bg[GTK_STATE_NORMAL]);
+    				
+				if(canvas->state_change_sensitive) {
+					gdk_gc_set_foreground (canvas->pixmap_gc,
+							       &widget->style->bg[widget->state]);
+				} else {
+					gdk_gc_set_foreground(canvas->pixmap_gc,
+                                                              &widget->style->bg[GTK_STATE_NORMAL]);
+				}
+
 				gdk_draw_rectangle (pixmap,
 						    canvas->pixmap_gc,
 						    TRUE,
@@ -4179,4 +4198,33 @@
 	g_return_val_if_fail (GNOME_IS_CANVAS (canvas), GDK_RGB_DITHER_NONE);
 
 	return canvas->dither;
+}
+
+static void 
+gnome_canvas_state_changed(GtkWidget *widget, GtkStateType previous_state) {
+        GnomeCanvas *canvas = GNOME_CANVAS(widget);
+        GnomeCanvasGroup *root_group;
+        if(GTK_WIDGET_CLASS(canvas_parent_class)->state_changed) {
+		(GTK_WIDGET_CLASS(canvas_parent_class)->state_changed)(widget, previous_state);		
+	}
+	if(canvas->state_change_sensitive) {
+		root_group = gnome_canvas_root(canvas);
+		/* force a canvas refresh */
+		gnome_canvas_item_hide(GNOME_CANVAS_ITEM(root_group));
+		gnome_canvas_item_show(GNOME_CANVAS_ITEM(root_group));
+	}                       
+}
+
+
+/**
+ * gnome_canvas_set_state_change_sensitive:
+ * @canvas: A canvas.
+ * @sensitivity: boolean indicating if this canvas should be sensitive to state changes, by forcing a repaint
+ * 
+ * Sets the sensitivity of the canvas widget to state changes, by forcing a full repaint.
+ **/
+void gnome_canvas_set_state_change_sensitivity (GnomeCanvas *canvas, gboolean sensitive) {
+	g_return_if_fail (canvas != NULL);
+	g_return_if_fail (GNOME_IS_CANVAS (canvas));	
+	canvas->state_change_sensitive = sensitive;
 }
Only in .: gnome-canvas.c~
diff -u ../../gnome-libs-1.2.11/libgnomeui/gnome-canvas.h ./gnome-canvas.h
--- ../../gnome-libs-1.2.11/libgnomeui/gnome-canvas.h	Sat Feb  3 18:42:08 2001
+++ ./gnome-canvas.h	Sat Feb  3 18:32:30 2001
@@ -486,6 +486,10 @@
 
 	/* dither mode for aa drawing */
 	unsigned int dither : 2;
+
+	/* Whether the canvas should be sensitive to state changes,
+	   and if state changes force a rerender */
+	unsigned int state_change_sensitive : 1;
 };
 
 struct _GnomeCanvasClass {
@@ -607,6 +611,12 @@
  * Only applicable to antialiased canvases - ignored by non-antialiased canvases.
  */
 GdkRgbDither gnome_canvas_get_dither (GnomeCanvas *canvas);
+
+/* Sets the sensitivity of the canvas item to a widget state change, this will
+ * allow proper background colors to be used in themes that have prelight elements.
+ */
+void gnome_canvas_set_state_change_sensitivity (GnomeCanvas *canvas, gboolean sensitive);
+
 
 END_GNOME_DECLS
 
Only in .: gnome-canvas.h~
Only in .: gnome-canvas.lo
Only in .: gnome-canvas.o
Only in .: gnome-client.lo
Only in .: gnome-client.o
Only in .: gnome-color-picker.lo
Only in .: gnome-color-picker.o
Only in .: gnome-dateedit.lo
Only in .: gnome-dateedit.o
Only in .: gnome-dentry-edit.lo
Only in .: gnome-dentry-edit.o
Only in .: gnome-dialog-util.lo
Only in .: gnome-dialog-util.o
Only in .: gnome-dialog.lo
Only in .: gnome-dialog.o
Only in .: gnome-dns.lo
Only in .: gnome-dns.o
Only in .: gnome-dock-band.lo
Only in .: gnome-dock-band.o
Only in .: gnome-dock-item.lo
Only in .: gnome-dock-item.o
Only in .: gnome-dock-layout.lo
Only in .: gnome-dock-layout.o
Only in .: gnome-dock.lo
Only in .: gnome-dock.o
Only in .: gnome-druid-page-finish.lo
Only in .: gnome-druid-page-finish.o
Only in .: gnome-druid-page-standard.lo
Only in .: gnome-druid-page-standard.o
Only in .: gnome-druid-page-start.lo
Only in .: gnome-druid-page-start.o
Only in .: gnome-druid-page.lo
Only in .: gnome-druid-page.o
Only in .: gnome-druid.lo
Only in .: gnome-druid.o
Only in .: gnome-entry.lo
Only in .: gnome-entry.o
Only in .: gnome-file-entry.lo
Only in .: gnome-file-entry.o
Only in .: gnome-font-picker.lo
Only in .: gnome-font-picker.o
Only in .: gnome-font-selector.lo
Only in .: gnome-font-selector.o
Only in .: gnome-geometry.lo
Only in .: gnome-geometry.o
Only in .: gnome-guru.lo
Only in .: gnome-guru.o
Only in .: gnome-href.lo
Only in .: gnome-href.o
Only in .: gnome-ice.lo
Only in .: gnome-ice.o
Only in .: gnome-icon-entry.lo
Only in .: gnome-icon-entry.o
Only in .: gnome-icon-item.lo
Only in .: gnome-icon-item.o
Only in .: gnome-icon-list.lo
Only in .: gnome-icon-list.o
Only in .: gnome-icon-sel.lo
Only in .: gnome-icon-sel.o
Only in .: gnome-icon-text.lo
Only in .: gnome-icon-text.o
Only in .: gnome-init.lo
Only in .: gnome-init.o
Only in .: gnome-less.lo
Only in .: gnome-less.o
Only in .: gnome-mdi-child.lo
Only in .: gnome-mdi-child.o
Only in .: gnome-mdi-generic-child.lo
Only in .: gnome-mdi-generic-child.o
Only in .: gnome-mdi-session.lo
Only in .: gnome-mdi-session.o
Only in .: gnome-mdi.lo
Only in .: gnome-mdi.o
Only in .: gnome-messagebox.lo
Only in .: gnome-messagebox.o
Only in .: gnome-number-entry.lo
Only in .: gnome-number-entry.o
Only in .: gnome-paper-selector.lo
Only in .: gnome-paper-selector.o
Only in .: gnome-pixmap-entry.lo
Only in .: gnome-pixmap-entry.o
Only in .: gnome-pixmap.lo
Only in .: gnome-pixmap.o
Only in .: gnome-popup-help.lo
Only in .: gnome-popup-help.o
Only in .: gnome-popup-menu.lo
Only in .: gnome-popup-menu.o
Only in .: gnome-preferences.lo
Only in .: gnome-preferences.o
Only in .: gnome-procbar.lo
Only in .: gnome-procbar.o
Only in .: gnome-properties.lo
Only in .: gnome-properties.o
Only in .: gnome-property-entries.lo
Only in .: gnome-property-entries.o
Only in .: gnome-propertybox.lo
Only in .: gnome-propertybox.o
Only in .: gnome-scores.lo
Only in .: gnome-scores.o
Only in .: gnome-spell.lo
Only in .: gnome-spell.o
Only in .: gnome-startup.lo
Only in .: gnome-startup.o
Only in .: gnome-stock.lo
Only in .: gnome-stock.o
Only in .: gnome-window-icon.lo
Only in .: gnome-window-icon.o
Only in .: gnome-window.lo
Only in .: gnome-window.o
Only in .: gnome-winhints.lo
Only in .: gnome-winhints.o
Only in .: gnome_segv
Only in .: gnome_segv.o
Only in .: gnometypes.lo
Only in .: gnometypes.o
Only in .: gtk-clock.lo
Only in .: gtk-clock.o
Only in .: gtk-ted.lo
Only in .: gtk-ted.o
Only in .: gtkcauldron.lo
Only in .: gtkcauldron.o
Only in .: gtkdial.lo
Only in .: gtkdial.o
Only in .: gtkpixmapmenuitem.lo
Only in .: gtkpixmapmenuitem.o
Only in .: libgnomeui.la
Common subdirectories: ../../gnome-libs-1.2.11/libgnomeui/pixmaps and ./pixmaps
Only in .: stock_demo
Only in .: stock_demo.o
Only in .: ted_demo
Only in .: ted_demo.o
Only in .: winhints_demo
Only in .: winhints_demo.o


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