Logo Search packages:      
Sourcecode: inkscape version File versions

void sp_canvas_scroll_to ( SPCanvas canvas,
double  cx,
double  cy,
unsigned int  clear,
bool  is_scrolling 

Scrolls canvas to specific position (cx and cy are measured in screen pixels)

Definition at line 2159 of file sp-canvas.cpp.

Referenced by SPDesktop::scroll_world(), and SPDesktop::set_display_area().

    g_return_if_fail (canvas != NULL);
    g_return_if_fail (SP_IS_CANVAS (canvas));

    int ix = (int) round(cx); // ix and iy are the new canvas coordinates (integer screen pixels)
    int iy = (int) round(cy); // cx might be negative, so (int)(cx + 0.5) will not do!
    int dx = ix - canvas->x0; // dx and dy specify the displacement (scroll) of the
    int dy = iy - canvas->y0; // canvas w.r.t its previous position

    canvas->dx0 = cx; // here the 'd' stands for double, not delta!
    canvas->dy0 = cy;
    canvas->x0 = ix;
    canvas->y0 = iy;

    sp_canvas_resize_tiles (canvas, canvas->x0, canvas->y0, canvas->x0+canvas->widget.allocation.width, canvas->y0+canvas->widget.allocation.height);

    if (!clear) {
        // scrolling without zoom; redraw only the newly exposed areas
        if ((dx != 0) || (dy != 0)) {
            canvas->is_scrolling = is_scrolling;
            if (GTK_WIDGET_REALIZED (canvas)) {
                gdk_window_scroll (SP_CANVAS_WINDOW (canvas), -dx, -dy);
    } else {
        // scrolling as part of zoom; do nothing here - the next do_update will perform full redraw

Generated by  Doxygen 1.6.0   Back to index