Zooming and Scrolling

An overview on zooming and scrolling in the CCC

Scrolling
Zooming

This chapter describes the zoom and scroll mechanisms that are implemented in the CCC.

In my first attempts on implementing zoom and scroll I often ran into the problem that certain kinds of actions (e.g. a special combination of scroll, zoom, scroll, zoom) lead into unwanted aspects. This was the result of not splitting zoom and scrolling. When I zoomed, I was modifying the scroll properties, which should not happen as I know now. As long as no operation affects the other we cannot run into these side effects. So here's how zoom and scroll are implemented in libccc.

Scrolling

For scrolling we use the GtkAdjustment class to specify everything we need. The GtkAdjustment has got these values of interest: lower, upper, page-size, value. The value is the position of the adjustment, which is between lower and (upper - page-size). So we can easily use it as an offset like this: lower is the minimum axis coordinate of the root item; upper is the maximum axis coordinate of the root item; page-size is the number of visible canvas points on the widget (widget-dimension / zoom); value is the current scroll offset.