[cairo-commit] goocanvas/src Makefile.in, 1.1.1.1, NONE demo.c, 1.1.1.1, 1.2 goocanvastextview.c, 1.1.1.1, 1.2 goocanvastextview.h, 1.1.1.1, 1.2 goocanvasview.c, 1.1.1.1, 1.2 goocanvasview.h, 1.1.1.1, 1.2

Damon Chaplin commit at pdx.freedesktop.org
Wed Mar 22 15:49:46 PST 2006


Committed by: damon

Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv11491/src

Modified Files:
	demo.c goocanvastextview.c goocanvastextview.h goocanvasview.c 
	goocanvasview.h 
Removed Files:
	Makefile.in 
Log Message:
2006-03-22  Damon Chaplin  <damon at gnome.org>

	* src/goocanvasview.[hc]: convert to a subclass of GtkContainer rather
	than GtkLayout, since the layout code didn't help much and just added
	to the confusion. (Getting scrolling/zooming to work smoothly  is
	pretty difficult.)

	Added a goo_canvas_view_scroll_to() function to scroll to a desired
	position.
	
	Added an anchor setting to specify where to place the contents of the
	canvas if it is smaller than the allocated widget area. (Like the
	"center_scroll_region" setting in GnomeCanvas but a bit more general.)

	Mapped a temporary window above the canvas when zooming in/out to
	stop X from scrolling the canvas contents before it is redrawn.
	(Idea pinched from FooCanvas.) Though this could possibly cause
	problems with keyboard input in future, in which case I think we should
	drop the fancy window scrolling stuff and just scroll ourselves.

	Added an internal freeze_count like GtkLayout used to have. This is
	used while reconfiguring the scrollbars etc. so we don't scroll more
	than once (e.g. horizontally then vertically).

	Added coordinate conversion functions to convert between device units
	and canvas item units or pixels.

	* src/goocanvastextview.[hc]: create a cairo_font_options_t object in
	the class init function and use it for all created PangoLayouts.
	This ensures that text is layed out the same at any scale, which
	also avoids the problems with items not being redrawn properly
	(since the bounds were slightly wrong). Note that I was using
	cairo_set_font_options(cr) before, but that isn't picked up by Pango
	so didn't work. (Font options seem to be associated with surfaces and
	also with the graphics state which is confusing.)



--- Makefile.in DELETED ---

Index: demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/demo.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- demo.c	15 Dec 2005 15:32:02 -0000	1.1.1.1
+++ demo.c	22 Mar 2006 23:49:44 -0000	1.2
@@ -48,6 +48,99 @@
 
 
 static void
+anchor_nw_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  if (GTK_TOGGLE_BUTTON (button)->active)
+    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_NW);
+}
+
+
+static void
+anchor_n_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  if (GTK_TOGGLE_BUTTON (button)->active)
+    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_N);
+}
+
+
+static void
+anchor_ne_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  if (GTK_TOGGLE_BUTTON (button)->active)
+    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_NE);
+}
+
+
+static void
+anchor_w_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  if (GTK_TOGGLE_BUTTON (button)->active)
+    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_W);
+}
+
+
+static void
+anchor_c_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  if (GTK_TOGGLE_BUTTON (button)->active)
+    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_CENTER);
+}
+
+
+static void
+anchor_e_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  if (GTK_TOGGLE_BUTTON (button)->active)
+    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_E);
+}
+
+
+static void
+anchor_sw_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  if (GTK_TOGGLE_BUTTON (button)->active)
+    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_SW);
+}
+
+
+static void
+anchor_s_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  if (GTK_TOGGLE_BUTTON (button)->active)
+    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_S);
+}
+
+
+static void
+anchor_se_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  if (GTK_TOGGLE_BUTTON (button)->active)
+    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_SE);
+}
+
+
+static void
+scroll_to_50_50_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  goo_canvas_view_scroll_to (canvas_view, 50, 50);
+}
+
+
+static void
+scroll_to_500_500_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  goo_canvas_view_scroll_to (canvas_view, 500, 500);
+}
+
+
+static void
+scroll_to_250_250_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+{
+  goo_canvas_view_scroll_to (canvas_view, 250, 250);
+}
+
+
+static void
 animate_ellipse_clicked (GtkWidget *button, GooCanvasView *canvas_view)
 {
 #if 1
@@ -276,6 +369,7 @@
 	GtkWidget *w;
 	GtkWidget *scrolled_win, *canvas_view;
 	GtkAdjustment *hadj, *vadj, *adj;
+	GSList *group = NULL;
 
 	vbox = gtk_vbox_new (FALSE, 4);
 	gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
@@ -298,7 +392,7 @@
 			  NULL);
 
 	goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas_view),
-				    0, 0, 1000, 1000);
+				    0, 0, 604, 454);
 
 	/* Zoom */
 
@@ -306,11 +400,11 @@
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 
-	adj = GTK_ADJUSTMENT (gtk_adjustment_new (1.00, 0.05, 5.00, 0.05, 0.50, 0.50));
+	adj = GTK_ADJUSTMENT (gtk_adjustment_new (1.00, 0.05, 100.00, 0.05, 0.50, 0.50));
+	w = gtk_spin_button_new (adj, 0.0, 2);
 	g_signal_connect (adj, "value_changed",
 			  (GtkSignalFunc) zoom_changed,
 			  canvas_view);
-	w = gtk_spin_button_new (adj, 0.0, 2);
 	gtk_widget_set_size_request (w, 50, -1);
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
@@ -351,6 +445,117 @@
 			  (GtkSignalFunc) stop_animation_clicked,
 			  canvas_view);
 	
+
+	hbox = gtk_hbox_new (FALSE, 4);
+	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+	gtk_widget_show (hbox);
+
+	/* Scroll to */
+
+	w = gtk_label_new ("Scroll To:");
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+
+	w = gtk_button_new_with_label("50,50");
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "clicked",
+			  (GtkSignalFunc) scroll_to_50_50_clicked,
+			  canvas_view);
+
+	w = gtk_button_new_with_label("250,250");
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "clicked",
+			  (GtkSignalFunc) scroll_to_250_250_clicked,
+			  canvas_view);
+
+	w = gtk_button_new_with_label("500,500");
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "clicked",
+			  (GtkSignalFunc) scroll_to_500_500_clicked,
+			  canvas_view);
+
+	/* Scroll anchor */
+
+	w = gtk_label_new ("Anchor:");
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+
+	w = gtk_radio_button_new_with_label (group, "NW");
+	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "toggled",
+			  (GtkSignalFunc) anchor_nw_toggled,
+			  canvas_view);
+
+	w = gtk_radio_button_new_with_label (group, "N");
+	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "toggled",
+			  (GtkSignalFunc) anchor_n_toggled,
+			  canvas_view);
+
+	w = gtk_radio_button_new_with_label (group, "NE");
+	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "toggled",
+			  (GtkSignalFunc) anchor_ne_toggled,
+			  canvas_view);
+
+	w = gtk_radio_button_new_with_label (group, "W");
+	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "toggled",
+			  (GtkSignalFunc) anchor_w_toggled,
+			  canvas_view);
+
+	w = gtk_radio_button_new_with_label (group, "C");
+	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "toggled",
+			  (GtkSignalFunc) anchor_c_toggled,
+			  canvas_view);
+
+	w = gtk_radio_button_new_with_label (group, "E");
+	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "toggled",
+			  (GtkSignalFunc) anchor_e_toggled,
+			  canvas_view);
+
+	w = gtk_radio_button_new_with_label (group, "SW");
+	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "toggled",
+			  (GtkSignalFunc) anchor_sw_toggled,
+			  canvas_view);
+
+	w = gtk_radio_button_new_with_label (group, "S");
+	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "toggled",
+			  (GtkSignalFunc) anchor_s_toggled,
+			  canvas_view);
+
+	w = gtk_radio_button_new_with_label (group, "SE");
+	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
+	gtk_widget_show (w);
+	g_signal_connect (w, "toggled",
+			  (GtkSignalFunc) anchor_se_toggled,
+			  canvas_view);
+
+	
 	/* Layout the stuff */
 
 	hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 1000, 10, 100, 100));
@@ -392,6 +597,7 @@
 			      "font", "Sans 12",
 			      NULL);
   goo_canvas_item_skew_y (item, 30, x, y);
+  /*goo_canvas_item_rotate (item, 30, x, y);*/
 }
 
 
@@ -538,6 +744,14 @@
 				     "line-width", 1.0,
 				     NULL);
   cairo_pattern_destroy (pattern);
+
+
+#if 0
+ {
+   GooCanvasItem *clone = goo_canvas_clone_new (root, ellipse1);
+   goo_canvas_item_translate (clone, 100, 100);
+ }
+#endif
 }
 
 
@@ -784,6 +998,7 @@
     0, 0, 0, 255,   0, 0, 0, 0,   0, 0, 0, 0,     0, 0, 0, 255
   };
 
+#if 1
   pattern = create_stipple ("blue", stipple_data);
   goo_canvas_text_new (make_anchor (root, 420, 20),
 		       "Anchor NW", 0, 0, -1, GTK_ANCHOR_NW,
@@ -799,6 +1014,7 @@
 		       "alignment", PANGO_ALIGN_CENTER,
 		       "fill_color", "firebrick",
 		       NULL);
+#endif
 
 #if 0
   goo_canvas_text_new (make_anchor (root, 590, 140),
@@ -813,12 +1029,14 @@
 		       NULL);
 #endif
 
+#if 1
   textitem = goo_canvas_text_new (make_anchor (root, 420, 240),
 				  "This is a very long paragraph that will need to be wrapped over several lines so we can see what happens to line-breaking as the view is zoomed in and out.",
 				  0, 0, 180, GTK_ANCHOR_W,
 				  "font", "Sans 12",
 				  "fill_color", "goldenrod",
 				  NULL);
+#endif
 }
 
 
@@ -967,7 +1185,7 @@
 main (int argc, char *argv[])
 {
   GooCanvasModelSimple *canvas_model;
-  GtkWidget *window1, *window2;
+  GtkWidget *window;
 
   gtk_set_locale ();
   gtk_init (&argc, &argv);
@@ -975,8 +1193,10 @@
   canvas_model = create_model ();
 
   /* Create 2 windows to show off multiple views. */
-  window1 = create_window (canvas_model);
-  window2 = create_window (canvas_model);
+  window = create_window (canvas_model);
+#if 1
+  window = create_window (canvas_model);
+#endif
 
   gtk_main ();
   return 0;

Index: goocanvastextview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastextview.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- goocanvastextview.c	15 Dec 2005 15:32:00 -0000	1.1.1.1
+++ goocanvastextview.c	22 Mar 2006 23:49:44 -0000	1.2
@@ -30,6 +30,13 @@
   GObjectClass *gobject_class = (GObjectClass*) klass;
 
   gobject_class->finalize = goo_canvas_text_view_finalize;
+
+  /* Create the font options once and reuse it. */
+  klass->font_options = cairo_font_options_create ();
+  cairo_font_options_set_hint_metrics (klass->font_options,
+				       CAIRO_HINT_METRICS_OFF);
+  cairo_font_options_set_hint_style (klass->font_options,
+				     CAIRO_HINT_STYLE_NONE);
 }
 
 
@@ -69,11 +76,13 @@
 
 
 static PangoLayout*
-goo_canvas_text_create_layout (GooCanvasText   *text,
-			       cairo_t         *cr,
-			       GooCanvasBounds *bounds)
+goo_canvas_text_view_create_layout (GooCanvasTextView *text_view,
+				    cairo_t           *cr,
+				    GooCanvasBounds   *bounds)
 {
+  GooCanvasText *text = text_view->text;
   PangoLayout *layout;
+  PangoContext *context;
   PangoRectangle logical_rect;
   double width, height;
 
@@ -87,20 +96,10 @@
 
   layout = pango_cairo_create_layout (cr);
 
-#if 0
-  /* FIXME: I tried this to see if it fixed the problem with the zoom level
-     affecting the text layout, but it didn't. I think Pango picks up the
-     options from the cairo surface anyway, so this does nothing. */
-  PangoContext *context;
-  cairo_font_options_t *options;
-
-  options = cairo_font_options_create ();
-  cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
-  cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
+  /* Set the font options to ensure the text layout is the same whatever
+     the scale is. */
   context = pango_layout_get_context (layout);
-  pango_cairo_context_set_font_options (context, options);
-  cairo_font_options_destroy (options);
-#endif
+  pango_cairo_context_set_font_options (context, GOO_CANVAS_TEXT_VIEW_GET_CLASS (text_view)->font_options);
 
   if (text->width > 0)
     pango_layout_set_width (layout, (double) text->width * PANGO_SCALE);
@@ -194,17 +193,23 @@
       canvas_view = goo_canvas_item_view_get_canvas_view (text_view->parent_view);
 
       /* Request a redraw of the existing bounds. */
+#if 0
+      g_print ("Text view old bounds: %g, %g  %g x %g\n",
+	       bounds->x1, bounds->y1,
+	       bounds->x2 - bounds->x1, bounds->y2 - bounds->y1);
+#endif
       goo_canvas_view_request_redraw (canvas_view, bounds);
 
       /* Compute the new bounds. */
-      layout = goo_canvas_text_create_layout (text_view->text, cr, bounds);
+      layout = goo_canvas_text_view_create_layout (text_view, cr, bounds);
       g_object_unref (layout);
 
       goo_canvas_item_simple_user_bounds_to_device (simple, cr, bounds);
 
 #if 0
-      g_print ("Text view bounds: %g, %g - %g, %g\n",
-	       bounds->x1, bounds->y1, bounds->x2, bounds->y2);
+      g_print ("Text view new bounds: %g, %g  %g x %g\n",
+	       bounds->x1, bounds->y1,
+	       bounds->x2 - bounds->x1, bounds->y2 - bounds->y1);
 #endif
 
       /* Request a redraw of the new bounds. */
@@ -272,7 +277,7 @@
 
   cairo_device_to_user (cr, &user_x, &user_y);
 
-  layout = goo_canvas_text_create_layout (text_view->text, cr, &bounds);
+  layout = goo_canvas_text_view_create_layout (text_view, cr, &bounds);
 
   /* Convert the coordinates into Pango units. */
   px = (user_x - bounds.x1) * PANGO_SCALE;
@@ -340,7 +345,7 @@
   goo_canvas_item_simple_set_fill_options (simple, cr);
 
   cairo_new_path (cr);
-  layout = goo_canvas_text_create_layout (text, cr, &layout_bounds);
+  layout = goo_canvas_text_view_create_layout (text_view, cr, &layout_bounds);
   cairo_move_to (cr, layout_bounds.x1, layout_bounds.y1);
   pango_cairo_show_layout (cr, layout);
   g_object_unref (layout);
@@ -349,9 +354,7 @@
   cairo_rectangle (cr, layout_bounds.x1, layout_bounds.y1,
 		   layout_bounds.x2 - layout_bounds.x1,
 		   layout_bounds.y2 - layout_bounds.y1);
-  g_print ("Width: %g Height: %g\n",
-	   layout_bounds.x2 - layout_bounds.x1,
-	   layout_bounds.y2 - layout_bounds.y1);
+  cairo_set_line_width (cr, 1.0);
   cairo_stroke (cr);
 #endif
 

Index: goocanvastextview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastextview.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- goocanvastextview.h	15 Dec 2005 15:32:00 -0000	1.1.1.1
+++ goocanvastextview.h	22 Mar 2006 23:49:44 -0000	1.2
@@ -45,6 +45,9 @@
 struct _GooCanvasTextViewClass
 {
   GObjectClass parent_class;
+
+  /* The font options we always use. */
+  cairo_font_options_t *font_options;
 };
 
 

Index: goocanvasview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- goocanvasview.c	15 Dec 2005 15:32:02 -0000	1.1.1.1
+++ goocanvasview.c	22 Mar 2006 23:49:44 -0000	1.2
@@ -2,7 +2,7 @@
  * GooCanvas. Copyright (C) 2005 Damon Chaplin.
  * Released under the GNU LGPL license. See COPYING for details.
  *
- * goocanvasview.c - 
+ * goocanvasview.c - the main canvas widget.
  */
 #include <config.h>
 #include <gtk/gtk.h>
@@ -22,6 +22,15 @@
 
 static void     goo_canvas_view_finalize	(GObject          *object);
[...1145 lines suppressed...]
+    {
+      list = g_list_prepend (list, tmp_view);
+      tmp_view = goo_canvas_item_view_get_parent_view (tmp_view);
+    }
+
+  /* Now step down applying each view's transformation. */
+  for (l = list; l; l = l->next)
+    {
+      item = goo_canvas_item_view_get_item ((GooCanvasItemView*) l->data);
+      item_transform = goo_canvas_item_get_transform (item);
+      if (item_transform)
+	cairo_matrix_multiply (&transform, &transform, item_transform);
+    }
+  g_list_free (list);
+
+  /* Now convert the coordinates. */
+  cairo_matrix_transform_point (&transform, x, y);
+}
+
+

Index: goocanvasview.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- goocanvasview.h	15 Dec 2005 15:32:01 -0000	1.1.1.1
+++ goocanvasview.h	22 Mar 2006 23:49:44 -0000	1.2
@@ -2,7 +2,7 @@
  * GooCanvas. Copyright (C) 2005 Damon Chaplin.
  * Released under the GNU LGPL license. See COPYING for details.
  *
- * goocanvasview.h - 
+ * goocanvasview.h - the main canvas widget.
  */
 #ifndef __GOO_CANVAS_VIEW_H__
 #define __GOO_CANVAS_VIEW_H__
@@ -25,7 +25,7 @@
 
 struct _GooCanvasView
 {
-  GtkLayout parent;
+  GtkContainer container;
 
   /* The model we are viewing. */
   GooCanvasModel *model;
@@ -39,6 +39,10 @@
   /* The scale/zoom factor of the view. */
   gdouble pixels_per_unit;
 
+  /* Where the canvas is anchored (where it is displayed when it is smaller
+     than the entire window). */
+  GtkAnchorType anchor;
+
   /* Idle handler ID, for processing updates. */
   guint idle_id;
 
@@ -68,11 +72,36 @@
   /* The synthesized event used for sending enter-notify and leave-notify
      events to item views. */
   GdkEventCrossing crossing_event;
+
+  /* The main canvas window, which gets scrolled around. */
+  GdkWindow *canvas_window;
+
+  /* The offsets of the canvas within the canvas window, in pixels. These are
+     used when the canvas is smaller than the window size and the anchor is not
+     NORTH_WEST. */
+  gint canvas_x_offset;
+  gint canvas_y_offset;
+
+  /* The adjustments used for scrolling. */
+  GtkAdjustment *hadjustment;
+  GtkAdjustment *vadjustment;
+
+  /* Freezes any movement of the canvas window, until thawed. This is used
+     when we need to set both adjustments and don't want it to scroll twice. */
+  gint freeze_count;
+
+  /* A window temporarily mapped above the canvas to stop X from scrolling
+     the contents unnecessarily (i.e. when we zoom in/out). */
+  GdkWindow *tmp_window;
 };
 
 struct _GooCanvasViewClass
 {
-  GtkLayoutClass parent_class;
+  GtkContainerClass parent_class;
+
+  void  (*set_scroll_adjustments)	   (GooCanvasView     *view,
+					    GtkAdjustment     *hadjustment,
+					    GtkAdjustment     *vadjustment);
 
   /* Virtual methods. */
   GooCanvasItemView* (* create_item_view)  (GooCanvasView     *view,
@@ -86,38 +115,78 @@
 };
 
 
-GType      goo_canvas_view_get_type       (void) G_GNUC_CONST;
-GtkWidget* goo_canvas_view_new            (void);
+GType         goo_canvas_view_get_type       (void) G_GNUC_CONST;
+GtkWidget*    goo_canvas_view_new            (void);
 
-void       goo_canvas_view_set_model	  (GooCanvasView   *view,
-					   GooCanvasModel  *model);
+void          goo_canvas_view_set_model	     (GooCanvasView     *view,
+					      GooCanvasModel    *model);
 
-void       goo_canvas_view_set_scale	  (GooCanvasView   *view,
-					   gdouble          pixels_per_unit);
+void          goo_canvas_view_set_scale	     (GooCanvasView     *view,
+					      gdouble            pixels_per_unit);
 
-void       goo_canvas_view_set_bounds	  (GooCanvasView   *view,
-					   gdouble          left,
-					   gdouble          top,
-					   gdouble          right,
-					   gdouble          bottom);
+void	      goo_canvas_view_set_anchor     (GooCanvasView	*view,
+					      GtkAnchorType      anchor);
+
+void          goo_canvas_view_set_bounds     (GooCanvasView     *view,
+					      gdouble            left,
+					      gdouble            top,
+					      gdouble            right,
+					      gdouble            bottom);
+
+void          goo_canvas_view_scroll_to	     (GooCanvasView     *view,
+					      gdouble            left,
+					      gdouble            top);
 
 GooCanvasItemView* goo_canvas_view_create_item_view (GooCanvasView     *view,
 						     GooCanvasItem     *item,
 						     GooCanvasItemView *parent_view);
 
-void       goo_canvas_view_request_update (GooCanvasView     *view);
-void       goo_canvas_view_request_redraw (GooCanvasView     *view,
-					   GooCanvasBounds   *bounds);
+void          goo_canvas_view_request_update (GooCanvasView     *view);
+void          goo_canvas_view_request_redraw (GooCanvasView     *view,
+					      GooCanvasBounds   *bounds);
 
 
-GdkGrabStatus goo_canvas_view_pointer_grab (GooCanvasView     *canvas_view,
-					    GooCanvasItemView *item_view,
-					    GdkEventMask       event_mask,
-					    GdkCursor         *cursor,
-					    guint32            time);
+void          goo_canvas_view_grab_focus     (GooCanvasView     *canvas_view,
+					      GooCanvasItemView *item_view);
+
+/*
+ * Pointer/keyboard grabbing & ungrabbing.
+ */
+GdkGrabStatus goo_canvas_view_pointer_grab   (GooCanvasView     *canvas_view,
+					      GooCanvasItemView *item_view,
+					      GdkEventMask       event_mask,
+					      GdkCursor         *cursor,
+					      guint32            time);
 void          goo_canvas_view_pointer_ungrab (GooCanvasView     *canvas_view,
 					      GooCanvasItemView *item_view,
 					      guint32            time);
+GdkGrabStatus goo_canvas_view_keyboard_grab  (GooCanvasView     *canvas_view,
+					      GooCanvasItemView *item_view,
+					      gboolean           owner_events,
+					      guint32            time);
+void          goo_canvas_view_keyboard_ungrab (GooCanvasView     *canvas_view,
+					       GooCanvasItemView *item_view,
+					       guint32            time);
+
+
+/*
+ * Coordinate conversion.
+ */
+void   goo_canvas_view_convert_to_pixels       (GooCanvasView     *canvas_view,
+						gdouble           *x,
+						gdouble           *y);
+void   goo_canvas_view_convert_from_pixels     (GooCanvasView     *canvas_view,
+						gdouble           *x,
+						gdouble           *y);
+
+void   goo_canvas_view_convert_to_item_space   (GooCanvasView     *canvas_view,
+						GooCanvasItemView *item_view,
+						gdouble           *x,
+						gdouble           *y);
+void   goo_canvas_view_convert_from_item_space (GooCanvasView     *canvas_view,
+						GooCanvasItemView *item_view,
+						gdouble           *x,
+						gdouble           *y);
 
 
 G_END_DECLS



More information about the cairo-commit mailing list