[cairo-commit] goocanvas/src goocanvasview.c,1.15,1.16
Damon Chaplin
commit at pdx.freedesktop.org
Sun Apr 23 04:32:11 PDT 2006
Committed by: damon
Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv3936/src
Modified Files:
goocanvasview.c
Log Message:
2006-04-23 Damon Chaplin <damon at gnome.org>
* src/goocanvasview.c (goo_canvas_view_focus): scroll to show the new
focused item if necessary.
Index: goocanvasview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- goocanvasview.c 22 Apr 2006 19:17:28 -0000 1.15
+++ goocanvasview.c 23 Apr 2006 11:32:08 -0000 1.16
@@ -915,6 +915,37 @@
}
+/* This makes sure the given item view is displayed, scrolling if necessary. */
+static void
+goo_canvas_view_scroll_to_item_view (GooCanvasView *view,
+ GooCanvasItemView *item_view)
+{
+ GooCanvasBounds *bounds;
+ gdouble hvalue, vvalue;
+
+ bounds = goo_canvas_item_view_get_bounds (item_view);
+
+ goo_canvas_view_convert_to_pixels (view, &bounds->x1, &bounds->y1);
+ goo_canvas_view_convert_to_pixels (view, &bounds->x2, &bounds->y2);
+
+ view->freeze_count++;
+
+ /* Remember the current adjustment values. */
+ hvalue = hadjustment->value;
+ vvalue = vadjustment->value;
+
+ /* Update the adjustments so the item view is displayed. */
+ gtk_adjustment_clamp_page (view->hadjustment, bounds->x1, bounds->x2);
+ gtk_adjustment_clamp_page (view->vadjustment, bounds->y1, bounds->y2);
+
+ view->freeze_count--;
+
+ /* If the adjustments have changed we need to scroll. */
+ if (hvalue != hadjustment->value || vvalue != vadjustment->value)
+ goo_canvas_view_adjustment_value_changed (NULL, view);
+}
+
+
/**
* goo_canvas_view_set_scale:
* @view: a #GooCanvasView.
@@ -2362,7 +2393,6 @@
GooCanvasItemView *item_view,
GooCanvasViewFocusData *data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (item_view);
GooCanvasItemView *child_view;
gboolean can_focus = FALSE, is_best;
gint n_children, i;
@@ -2467,6 +2497,7 @@
if (data.best_item_view)
{
goo_canvas_view_grab_focus (view, data.best_item_view);
+ goo_canvas_view_scroll_to_item_view (view, data.best_item_view);
return TRUE;
}
More information about the cairo-commit
mailing list