How to survive the Gnome Canvas API changes

This is fairly sketchy at the moment...

For users

The main change is the addition of affine transforms. This has several consequences:

The Gnome canvas has three different coordinate systems. It is vitally important to use the appropriate one. The relationships between these are affine transforms. It would be a good idea to learn this if you don't know it. The PostScript reference manual is one way to start. Know of a good url that explains affine transforms? Let me know.

The three coordinate systems are: world, canvas, and item-relative. Each item has its own item-relative coordinate system relative to its parent. The "parent" of the root group is the canvas coordinate system. The world coordinate system is scaled by canvas->pixels_per_unit relative to the canvas coordinate system (there is also a zoom_offset in there, but that's deprecated).

The bounds of an image are always represented in canvas coordinates.

For custom items

The affine transforms have fairly far-reaching impact. In general, the code should be aware of the affine transform, ideally simply using the transform given in the ::update () method.

Two other major changes: the ::update () method is now expected to set the bounds information, and items have to request their own repaint. The easiest way to do this is to invoke gnome_canvas_update_bbox (this is in gnome-canvas-util) from inside your ::update () method.

Almost all argument setting cases should request an update on the item.

Please see How to write antialiased canvas items for more info on doing aa renderers for your items. This document only deals with how to convert xlib renderers to the new api.

levien.com Gnome home