[Lemon-commits] [lemon_svn] ladanyi: r2309 - hugo/trunk/gui

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:51:42 CET 2006


Author: ladanyi
Date: Fri Nov  4 20:07:15 2005
New Revision: 2309

Modified:
   hugo/trunk/gui/graph_displayer_canvas-event.cc
   hugo/trunk/gui/graph_displayer_canvas-zoom.cc
   hugo/trunk/gui/main_win.cc

Log:
improved zooming

Modified: hugo/trunk/gui/graph_displayer_canvas-event.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas-event.cc	(original)
+++ hugo/trunk/gui/graph_displayer_canvas-event.cc	Fri Nov  4 20:07:15 2005
@@ -308,7 +308,6 @@
       target_item=NULL;
       active_item=NULL;
       active_node=INVALID;
-
       break;
     default:
       break;

Modified: hugo/trunk/gui/graph_displayer_canvas-zoom.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas-zoom.cc	(original)
+++ hugo/trunk/gui/graph_displayer_canvas-zoom.cc	Fri Nov  4 20:07:15 2005
@@ -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);
 }

Modified: hugo/trunk/gui/main_win.cc
==============================================================================
--- hugo/trunk/gui/main_win.cc	(original)
+++ hugo/trunk/gui/main_win.cc	Fri Nov  4 20:07:15 2005
@@ -127,11 +127,6 @@
   uim->insert_action_group(ag);
   add_accel_group(uim->get_accel_group());
 
-  /*
-      "      <menuitem action='ViewZoomFit' />"
-      "    <toolitem action='ViewZoomFit' />"
-   */
-
   try
   {
 
@@ -150,6 +145,7 @@
       "      <menuitem action='ViewZoomIn' />"
       "      <menuitem action='ViewZoomOut' />"
       "      <menuitem action='ViewZoom100' />"
+      "      <menuitem action='ViewZoomFit' />"
       "    </menu>"
       "    <menu action='ShowMenu'>"
       "      <menuitem action='ShowMaps'/>"
@@ -164,6 +160,7 @@
       "    <toolitem action='ViewZoomIn' />"
       "    <toolitem action='ViewZoomOut' />"
       "    <toolitem action='ViewZoom100' />"
+      "    <toolitem action='ViewZoomFit' />"
       "    <separator />"
       "    <toolitem action='MoveItem' />"
       "    <toolitem action='CreateNode' />"
@@ -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);
 



More information about the Lemon-commits mailing list