diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2001-01-26 04:34:55 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-01-26 04:34:55 +0800 |
commit | cc505b2c6790296cca752a3b7b1931f48390440f (patch) | |
tree | 1b2fb7dcf378ee6b682af23a6738e7c178ee5cd6 /widgets/misc | |
parent | c46245d4b576b4e8c9a076e7ceb99e5edee0bdd3 (diff) | |
download | gsoc2013-evolution-cc505b2c6790296cca752a3b7b1931f48390440f.tar gsoc2013-evolution-cc505b2c6790296cca752a3b7b1931f48390440f.tar.gz gsoc2013-evolution-cc505b2c6790296cca752a3b7b1931f48390440f.tar.bz2 gsoc2013-evolution-cc505b2c6790296cca752a3b7b1931f48390440f.tar.lz gsoc2013-evolution-cc505b2c6790296cca752a3b7b1931f48390440f.tar.xz gsoc2013-evolution-cc505b2c6790296cca752a3b7b1931f48390440f.tar.zst gsoc2013-evolution-cc505b2c6790296cca752a3b7b1931f48390440f.zip |
Made this function put some space around the area shown.
2001-01-25 Christopher James Lahey <clahey@helixcode.com>
* gal/widgets/e-canvas-utils.c (e_canvas_item_show_area): Made
this function put some space around the area shown.
svn path=/trunk/; revision=7820
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/e-canvas-utils.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/widgets/misc/e-canvas-utils.c b/widgets/misc/e-canvas-utils.c index ac61545b5f..13267b3ac4 100644 --- a/widgets/misc/e-canvas-utils.c +++ b/widgets/misc/e-canvas-utils.c @@ -35,6 +35,34 @@ e_canvas_item_move_absolute (GnomeCanvasItem *item, double dx, double dy) gnome_canvas_item_affine_absolute (item, translate); } +static double +compute_offset(double top, double bottom, double page_top, double page_bottom, double min, double max) +{ + double size = bottom - top; + double offset = 0; + + if (top <= page_top && bottom >= page_bottom) + return CLAMP(0, min - top, max - top); + + if (bottom > page_bottom) + offset = (bottom - page_bottom); + if (top < page_top + offset) + offset = (top - page_top); + + if (top <= page_top + offset && bottom >= page_bottom + offset) + return CLAMP(offset, min - top, max - top); + + if (top < page_top + offset + size * 1.5) + offset = top - (page_top + size * 1.5); + if (bottom > page_bottom + offset - size * 1.5) + offset = bottom - (page_bottom - size * 1.5); + if (top < page_top + offset + size * 1.5) + offset = top - ((page_top + page_bottom - (bottom - top)) / 2); + + return CLAMP(offset, min - top, max - top); +} + + void e_canvas_item_show_area (GnomeCanvasItem *item, double x1, double y1, double x2, double y2) { @@ -48,20 +76,12 @@ e_canvas_item_show_area (GnomeCanvasItem *item, double x1, double y1, double x2, gnome_canvas_item_i2w(item, &x2, &y2); h = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - v = gtk_layout_get_vadjustment(GTK_LAYOUT(item->canvas)); - - if (x2 > h->value + h->page_size) - dx = (x2 - (h->value + h->page_size)); - if (y2 > v->value + v->page_size) - dy = (y2 - (v->value + v->page_size)); - - if (x1 < h->value + dx) - dx = (x1 - h->value); - if (y1 < v->value + dy) - dy = (y1 - v->value); - + dx = compute_offset(x1, x2, h->value, h->value + h->page_size, 0, h->upper - h->page_size); if (dx) gtk_adjustment_set_value(h, h->value + dx); + + v = gtk_layout_get_vadjustment(GTK_LAYOUT(item->canvas)); + dy = compute_offset(y1, y2, v->value, v->value + v->page_size, 0, v->upper - v->page_size); if (dy) gtk_adjustment_set_value(v, v->value + dy); } |