# HG changeset patch # User ladanyi # Date 1131131235 0 # Node ID b44281e4cca7602eca00b70fc4c382e5f6548137 # Parent 0c34609f83cdbaf39d15aa47fdfcc3ed405ca539 improved zooming diff -r 0c34609f83cd -r b44281e4cca7 graph_displayer_canvas-event.cc --- a/graph_displayer_canvas-event.cc Wed Nov 02 12:44:50 2005 +0000 +++ b/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 0c34609f83cd -r b44281e4cca7 graph_displayer_canvas-zoom.cc --- a/graph_displayer_canvas-zoom.cc Wed Nov 02 12:44:50 2005 +0000 +++ b/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 0c34609f83cd -r b44281e4cca7 main_win.cc --- a/main_win.cc Wed Nov 02 12:44:50 2005 +0000 +++ b/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()); - /* - " " - " " - */ - try { @@ -150,6 +145,7 @@ " " " " " " + " " " " " " " " @@ -164,6 +160,7 @@ " " " " " " + " " " " " " " " @@ -197,6 +194,7 @@ } Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow()); + pScrolledWindow->set_shadow_type(Gtk::SHADOW_IN); pScrolledWindow->add(gd_canvas); vbox.pack_start(*pScrolledWindow);