# HG changeset patch
# User ladanyi
# Date 1131131235 0
# Node ID a70cee06ae9ca01ceac27ee4be8237de4a49f5e8
# Parent 5214b33f954d05ef8f45e53c695e7555974bb5fa
improved zooming
diff -r 5214b33f954d -r a70cee06ae9c gui/graph_displayer_canvas-event.cc
--- a/gui/graph_displayer_canvas-event.cc Fri Nov 04 17:44:13 2005 +0000
+++ b/gui/graph_displayer_canvas-event.cc Fri Nov 04 19:07:15 2005 +0000
@@ -308,7 +308,6 @@
target_item=NULL;
active_item=NULL;
active_node=INVALID;
-
break;
default:
break;
diff -r 5214b33f954d -r a70cee06ae9c gui/graph_displayer_canvas-zoom.cc
--- a/gui/graph_displayer_canvas-zoom.cc Fri Nov 04 17:44:13 2005 +0000
+++ b/gui/graph_displayer_canvas-zoom.cc Fri Nov 04 19:07:15 2005 +0000
@@ -16,34 +16,36 @@
void GraphDisplayerCanvas::zoomFit()
{
+ updateScrollRegion();
+
// get the height and width of the canvas
Gtk::Allocation a = get_allocation();
int aw = a.get_width();
int ah = a.get_height();
- // add some space
- aw -= 5; if (aw < 0) aw = 0;
- ah -= 5; if (ah < 0) ah = 0;
// get the bounding box of the graph
- double wx1, wy1, wx2, wy2;
- Gnome::Canvas::Item* pCanvasItem = root();
- pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
+ update_now();
+ double x1, y1, x2, y2;
+ root()->get_bounds(x1, y1, x2, y2);
// fit the graph to the window
- double ppu1 = (double) aw / fabs(wx2 - wx1);
- double ppu2 = (double) ah / fabs(wy2 - wy1);
+ double ppu1 = (double) aw / fabs(x2 - x1);
+ double ppu2 = (double) ah / fabs(y2 - y1);
set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
}
void GraphDisplayerCanvas::zoom100()
{
+ updateScrollRegion();
set_pixels_per_unit(1.0);
}
void GraphDisplayerCanvas::updateScrollRegion()
{
- double wx1, wy1, wx2, wy2;
- Gnome::Canvas::Item* pCanvasItem = root();
- pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
- set_scroll_region(wx1, wy1, wx2, wy2);
+ // get_bounds() yields something sane only when no updates are pending
+ // and it returns a sufficient, not an exact bounding box
+ update_now();
+ double x1, y1, x2, y2;
+ root()->get_bounds(x1, y1, x2, y2);
+ set_scroll_region(x1, y1, x2, y2);
}
diff -r 5214b33f954d -r a70cee06ae9c gui/main_win.cc
--- a/gui/main_win.cc Fri Nov 04 17:44:13 2005 +0000
+++ b/gui/main_win.cc Fri Nov 04 19:07:15 2005 +0000
@@ -127,11 +127,6 @@
uim->insert_action_group(ag);
add_accel_group(uim->get_accel_group());
- /*
- " "
- "