[f-spot: 35/41] anchoring the zoom, step1



commit 63879c67173bf16a74b4960de0e3eaff9ba5f92f
Author: Stephane Delcroix <stephane delcroix org>
Date:   Thu Jun 11 22:15:25 2009 +0200

    anchoring the zoom, step1
    
    there's one bu g left here, but it's time to crash

 src/Widgets/ImageView.cs |   61 ++++++++++++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 23 deletions(-)
---
diff --git a/src/Widgets/ImageView.cs b/src/Widgets/ImageView.cs
index 271c4fc..cb18550 100644
--- a/src/Widgets/ImageView.cs
+++ b/src/Widgets/ImageView.cs
@@ -150,6 +150,28 @@ namespace FSpot.Widgets
 			return win;
 		}
 
+		List<LayoutChild> children;
+		public void Put (Gtk.Widget widget, int x, int y)
+		{
+			children.Add (new LayoutChild (widget, x, y));
+			if (IsRealized)
+				widget.ParentWindow = GdkWindow;
+			widget.Parent = this;
+		}
+
+		public void Move (Gtk.Widget widget, int x, int y)
+		{
+			LayoutChild child = GetChild (widget);
+			if (child == null)
+				return;
+
+			child.X = x;
+			child.Y = y;
+			if (Visible && widget.Visible)
+				QueueResize ();
+		}
+
+
 		public event EventHandler ZoomChanged;
 		public event EventHandler SelectionChanged;
 #endregion
@@ -410,8 +432,24 @@ Console.WriteLine ("DoZoom {0} {1} {2} {3}", zoom, use_anchor, x, y);
 				zoom = MIN_ZOOM;
 
 			this.zoom = zoom;
+			
+			if (!use_anchor) {
+				x = (int)Allocation.Width / 2;
+				y = (int)Allocation.Height / 2;
+			}
+
+			double x_anchor = (double)(XOffset + x) / (double)scaled_width;
+			double y_anchor = (double)(YOffset + y) / (double)scaled_height;
 			ComputeScaledSize ();
 
+			Console.WriteLine ("offset {0} {1}", XOffset, YOffset);
+			Console.WriteLine ("anchor {0} {1}", x_anchor, y_anchor);
+			AdjustmentsChanged -= ScrollToAdjustments;
+			Hadjustment.Value = XOffset = (int)(x_anchor * scaled_width - x); 
+			Vadjustment.Value = YOffset = (int)(y_anchor * scaled_height - y); 
+			AdjustmentsChanged += ScrollToAdjustments;
+			Console.WriteLine ("offset {0} {1}", XOffset, YOffset);
+
 			EventHandler eh = ZoomChanged;
 			if (eh != null)
 				eh (this, EventArgs.Empty);
@@ -519,8 +557,6 @@ Console.WriteLine ("PaintRectangle {0}", area);
 			else if (y > Vadjustment.Upper - Vadjustment.PageSize) 
 				y = (int)(Vadjustment.Upper - Vadjustment.PageSize);
 
-			Console.WriteLine ("ScrollTo {0} {1}", x, y);
-			
 			int xof = x - XOffset;
 			int yof = y - YOffset;
 			XOffset = x;
@@ -563,15 +599,6 @@ Console.WriteLine ("PaintRectangle {0}", area);
 			}
 		}
 
-		List<LayoutChild> children;
-		public void Put (Gtk.Widget widget, int x, int y)
-		{
-			children.Add (new LayoutChild (widget, x, y));
-			if (IsRealized)
-				widget.ParentWindow = GdkWindow;
-			widget.Parent = this;
-		}
-
 		LayoutChild GetChild (Gtk.Widget widget)
 		{
 			foreach (var child in children)
@@ -579,18 +606,6 @@ Console.WriteLine ("PaintRectangle {0}", area);
 					return child;
 			return null;
 		}
-	
-		public void Move (Gtk.Widget widget, int x, int y)
-		{
-			LayoutChild child = GetChild (widget);
-			if (child == null)
-				return;
-
-			child.X = x;
-			child.Y = y;
-			if (Visible && widget.Visible)
-				QueueResize ();
-		}
 #endregion
 	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]