[cairo-commit] goocanvas/src goocanvasitem.c, 1.8,
1.9 goocanvasitem.h, 1.6, 1.7 goocanvasitemview.c, 1.9,
1.10 goocanvasview.c, 1.22, 1.23
Damon Chaplin
commit at pdx.freedesktop.org
Wed Jul 19 06:52:35 PDT 2006
Committed by: damon
Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv3831/src
Modified Files:
goocanvasitem.c goocanvasitem.h goocanvasitemview.c
goocanvasview.c
Log Message:
2006-07-19 Damon Chaplin <damon at gnome.org>
* src/goocanvasview.c (goo_canvas_view_scroll): handle scroll events
ourselves, in case we aren't placed directly in a scrolled window.
* src/goocanvasitem.c (goo_canvas_item_get_transform): if the item
doesn't support this method just return NULL.
Index: goocanvasitem.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- goocanvasitem.c 19 Jul 2006 13:38:13 -0000 1.8
+++ goocanvasitem.c 19 Jul 2006 13:52:33 -0000 1.9
@@ -487,7 +487,9 @@
cairo_matrix_t*
goo_canvas_item_get_transform (GooCanvasItem *item)
{
- return GOO_CANVAS_ITEM_GET_IFACE (item)->get_transform (item);
+ GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
+
+ return iface->get_transform ? iface->get_transform (item) : NULL;
}
Index: goocanvasitem.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- goocanvasitem.h 16 Apr 2006 10:39:51 -0000 1.6
+++ goocanvasitem.h 19 Jul 2006 13:52:33 -0000 1.7
@@ -107,7 +107,7 @@
/* Virtual methods that all canvas items must implement. */
GooCanvasItem* (* get_parent) (GooCanvasItem *item);
void (* set_parent) (GooCanvasItem *item,
- GooCanvasItem* parent);
+ GooCanvasItem *parent);
cairo_matrix_t* (* get_transform) (GooCanvasItem *item);
void (* set_transform) (GooCanvasItem *item,
Index: goocanvasitemview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemview.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- goocanvasitemview.c 24 Apr 2006 13:53:42 -0000 1.9
+++ goocanvasitemview.c 19 Jul 2006 13:52:33 -0000 1.10
@@ -379,6 +379,7 @@
{
GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
+ /* Container items must implement get_n_children and normal items don't. */
return iface->get_n_children ? TRUE : FALSE;
}
@@ -397,6 +398,7 @@
{
GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
+ /* If the item doesn't implement get_n_children it has no children. */
return iface->get_n_children ? iface->get_n_children (view) : 0;
}
@@ -406,7 +408,8 @@
* @view: a #GooCanvasItemView.
* @child_num: the index of the child within the view, counting from 0.
*
- * Returns the child view at the given index.
+ * Returns the child view at the given index, or %NULL if the item has no
+ * children or the index is out of range.
*
* Returns: the child at the given index.
**/
@@ -416,6 +419,7 @@
{
GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
+ /* If the item doesn't implement get_child we assume it has no children. */
return iface->get_child ? iface->get_child (view, child_num) : NULL;
}
@@ -542,7 +546,7 @@
* @y: the y coordinate of the point.
* @cr: a cairo contect.
* @is_pointer_event: %TRUE if the "pointer-events" properties of items should
- * be used to determine if they should checked.
+ * be used to determine which parts of the item are tested.
* @parent_is_visible: %TRUE if the parent item view is visible (which
* implies that all ancestors are also visible).
*
@@ -585,7 +589,8 @@
{
GooCanvasItemViewIface *iface = GOO_CANVAS_ITEM_VIEW_GET_IFACE (view);
- return iface->is_visible (view);
+ /* If the item doesn't implement this method assume it is visible. */
+ return iface->is_visible ? iface->is_visible (view) : TRUE;
}
Index: goocanvasview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasview.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- goocanvasview.c 27 May 2006 19:31:44 -0000 1.22
+++ goocanvasview.c 19 Jul 2006 13:52:33 -0000 1.23
@@ -170,6 +170,8 @@
GdkEventButton *event);
static gboolean goo_canvas_view_motion (GtkWidget *widget,
GdkEventMotion *event);
+static gboolean goo_canvas_view_scroll (GtkWidget *widget,
+ GdkEventScroll *event);
static gboolean goo_canvas_view_focus (GtkWidget *widget,
GtkDirectionType direction);
static gboolean goo_canvas_view_key_press (GtkWidget *widget,
@@ -225,6 +227,7 @@
widget_class->button_press_event = goo_canvas_view_button_press;
widget_class->button_release_event = goo_canvas_view_button_release;
widget_class->motion_notify_event = goo_canvas_view_motion;
+ widget_class->scroll_event = goo_canvas_view_scroll;
widget_class->focus = goo_canvas_view_focus;
widget_class->key_press_event = goo_canvas_view_key_press;
widget_class->key_release_event = goo_canvas_view_key_release;
@@ -1812,6 +1815,33 @@
}
+static gint
+goo_canvas_view_scroll (GtkWidget *widget,
+ GdkEventScroll *event)
+{
+ GooCanvasView *view = GOO_CANVAS_VIEW (widget);
+ GtkAdjustment *adj;
+ gdouble delta, new_value;
+
+ if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_DOWN)
+ adj = view->vadjustment;
+ else
+ adj = view->hadjustment;
+
+ delta = pow (adj->page_size, 2.0 / 3.0);
+
+ if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT)
+ delta = - delta;
+
+ new_value = CLAMP (adj->value + delta, adj->lower,
+ adj->upper - adj->page_size);
+
+ gtk_adjustment_set_value (adj, new_value);
+
+ return TRUE;
+}
+
+
static gboolean
goo_canvas_view_focus_in (GtkWidget *widget,
GdkEventFocus *event)
More information about the cairo-commit
mailing list