[Monodevelop-patches-list] r1767 - trunk/MonoDevelop/src/Libraries/Gdl

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Tue Jun 15 12:54:31 EDT 2004


Author: jzwart
Date: 2004-06-15 12:54:31 -0400 (Tue, 15 Jun 2004)
New Revision: 1767

Modified:
   trunk/MonoDevelop/src/Libraries/Gdl/Dock.cs
   trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs
   trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs
   trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs
Log:
Fix the size of the xor'ed rectangle when dragging items outside a dock.


Modified: trunk/MonoDevelop/src/Libraries/Gdl/Dock.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/Dock.cs	2004-06-15 12:48:47 UTC (rev 1766)
+++ trunk/MonoDevelop/src/Libraries/Gdl/Dock.cs	2004-06-15 16:54:31 UTC (rev 1767)
@@ -13,8 +13,8 @@
 		private bool floating;
 		private Widget window;
 		private bool autoTitle;
-		private int float_x;
-		private int float_y;
+		private int floatX;
+		private int floatY;
 		private int width = -1;
 		private int height = -1;
 		private Gdk.GC xorGC;
@@ -26,45 +26,62 @@
 		{
 		}
 
-		public Dock (Dock original, bool _float) : this (original, _float, 0, 0, -1, -1)
+		public Dock (Dock original, bool floating)
+			: this (original, floating, 0, 0, -1, -1)
 		{
 		}
 
-		public Dock (Dock original, bool _float, int x, int y, int _width, int _height)
+		public Dock (Dock original, bool floating, int x, int y, int width, int height)
 		{
-			float_x = x;
-			float_y = y;
-			width = _width;
-			height = _height;
+			floatX = x;
+			floatY = y;
+			this.width = width;
+			this.height = height;
+			this.floating = floating;
+			
 			SetFlag (WidgetFlags.NoWindow);
-			if (original != null) {
+			if (original != null)
 				Bind (original.Master);
-			}
-			this.floating = _float;
+
+			/* create a master for the dock if none was provided */
 			if (Master == null) {
 				DockObjectFlags &= ~(DockObjectFlags.Automatic);
 				Bind (new DockMaster ());
 			}
+
 			if (floating) {
+				/* create floating window for this dock */
 				window = new Window (WindowType.Toplevel);
-				((Gtk.Window)window).WindowPosition = WindowPosition.Mouse;
-				((Gtk.Window)window).SetDefaultSize (width, height);
-				((Gtk.Window)window).TypeHint = Gdk.WindowTypeHint.Normal;
-				((Gtk.Window)window).Move (float_x, float_y);
-				window.ConfigureEvent += new ConfigureEventHandler (floatingConfigure);
+				Window wnd = window as Window;
+
+				/* set position and default size */
+				wnd.WindowPosition = WindowPosition.Mouse;
+				wnd.SetDefaultSize (width, height);
+				wnd.TypeHint = Gdk.WindowTypeHint.Normal;
+				
+				/* metacity ignores this */
+				wnd.Move (floatX, floatY);
+
+				/* connect to the configure event so we can track down window geometry */
+				wnd.ConfigureEvent += new ConfigureEventHandler (OnFloatingConfigure);
+				
+				/* set the title */
 				SetWindowTitle ();
-				//TODO: connect to long name notify
+
+				/* set transient for the first dock if that is a non-floating dock */
 				DockObject controller = Master.Controller;
 				if (controller != null && controller is Dock) {
 					if (!((Dock)controller).Floating) {
-						if (controller.Toplevel != null && controller.Toplevel is Gtk.Window) {
-							((Gtk.Window)window).TransientFor = (Gtk.Window)controller.Toplevel;
+						if (controller.Toplevel != null && controller.Toplevel is Window) {
+							wnd.TransientFor = (Window)controller.Toplevel;
 						}
 					}
 				}
-				((Gtk.Window)window).Add (this);
-				((Gtk.Window)window).DeleteEvent += new DeleteEventHandler (floatingDelete);
+				
+				wnd.Add (this);
+				wnd.DeleteEvent += new DeleteEventHandler (OnFloatingDelete);
 			}
+
 			DockObjectFlags |= DockObjectFlags.Attached;
 		}
 		
@@ -79,10 +96,10 @@
 		
 		public int FloatX {
 			get {
-				return float_x;
+				return floatX;
 			}
 			set {
-				float_x = value;
+				floatX = value;
 				if (floating && window != null && window is Window)
 					((Window)window).Resize (width, height);
 			}
@@ -90,10 +107,10 @@
 		
 		public int FloatY {
 			get {
-				return float_y;
+				return floatY;
 			}
 			set {
-				float_y = value;
+				floatY = value;
 				if (floating && window != null && window is Window)
 					((Window)window).Resize (width, height);
 			}
@@ -233,7 +250,7 @@
 			}
 		}
 
-		/*protected override void OnDestroyed ()
+		protected override void OnDestroyed ()
 		{
 			if (window != null) {
 				window.Destroy ();
@@ -243,7 +260,7 @@
 			if (xorGC != null)
 				xorGC = null;
 			base.OnDestroyed ();
-		}*/
+		}
 		
 		protected override void OnAdded (Widget widget)
 		{
@@ -363,8 +380,6 @@
 				return;
 
 			if (position == DockPlacement.Floating) {
-				Console.WriteLine ("Adding a floating dockitem");
-				DockItem item = requestor as DockItem;
 				int x = 0, y = 0, width = -1, height = -1;
 				if (data != null && data is Gdk.Rectangle) {
 					Gdk.Rectangle rect = (Gdk.Rectangle)data;
@@ -373,7 +388,8 @@
 					width = rect.Width;
 					height = rect.Height;
 				}
-				AddFloatingItem (item, x, y, width, height);
+				
+				AddFloatingItem ((DockItem)requestor, x, y, width, height);
 			} else if (root != null) {
 				/* This is somewhat a special case since we know
 				   which item to pass the request on because we only
@@ -409,8 +425,7 @@
 		public override bool OnReorder (DockObject requestor, DockPlacement position, object data)
 		{
 			if (Floating && position == DockPlacement.Floating && root == requestor) {
-				if (window != null && window is Window &&
-				    data != null && data is Gdk.Rectangle) {
+				if (window != null && data != null && data is Gdk.Rectangle) {
 					Gdk.Rectangle rect = (Gdk.Rectangle)data;
 					((Window)window).Move (rect.X, rect.Y);
 					return true;
@@ -451,10 +466,8 @@
 		
 		public void AddFloatingItem (DockItem item, int x, int y, int width, int height)
 		{
-			if (this.Master == null) {
-				Console.WriteLine ("something is seriously fucked here");
-			}
-			Gdl.Dock dock = new Dock (this, true, x, y, width, height);
+			Dock dock = new Dock (this, true, x, y, width, height);
+			
 			if (Visible) {
 				dock.Show ();
 				if (IsMapped)
@@ -492,7 +505,7 @@
 		public static Dock GetTopLevel (DockObject obj)
 		{
 			DockObject parent = obj;
-			while (parent != null && !(parent is Gdl.Dock))
+			while (parent != null && !(parent is Dock))
 				parent = parent.ParentObject;
 
 			return parent != null ? (Dock)parent : null;
@@ -551,19 +564,23 @@
 		}
 
 		[GLib.ConnectBefore]
-		private void floatingConfigure (object o, ConfigureEventArgs e)
+		private void OnFloatingConfigure (object o, ConfigureEventArgs e)
 		{
-			float_x = e.Event.X;
-			float_y = e.Event.Y;
+			floatX = e.Event.X;
+			floatY = e.Event.Y;
 			width = e.Event.Width;
 			height = e.Event.Height;
+
 			e.RetVal = false;
 		}
 
-		private void floatingDelete (object o, DeleteEventArgs e)
+		private void OnFloatingDelete (object o, DeleteEventArgs e)
 		{
 			if (root != null)
+				/* this will call reduce on ourselves, hiding
+				   the window if appropiate */
 				((DockItem)root).HideItem ();
+
 			e.RetVal = true;
 		}
 	}

Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs	2004-06-15 12:48:47 UTC (rev 1766)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs	2004-06-15 16:54:31 UTC (rev 1767)
@@ -204,6 +204,15 @@
 			}
 		}
 		
+		public Requisition PreferredSize {
+			get {
+				Requisition req = new Requisition ();
+				req.Width = Math.Max (preferredWidth, Allocation.Width);
+				req.Height = Math.Max (preferredHeight, Allocation.Height);
+				return req;
+			}
+		}
+		
 		public bool Resize {
 			get {
 				return resize;
@@ -575,8 +584,8 @@
 				int divider = -1;
 
 				/* these are for calculating the extra docking parameter */
-				Requisition other = DockItem.PreferredSize ((DockItem)request.Applicant);
-				Requisition my = DockItem.PreferredSize (this);
+				Requisition other = ((DockItem)request.Applicant).PreferredSize;
+				Requisition my = PreferredSize;
 				
 				/* Calculate location in terms of the available space (0-100%). */
 				float rx = (float) relX / alloc.Width;
@@ -913,14 +922,6 @@
 			}
 		}
 
-		public static Requisition PreferredSize (DockItem item)
-		{
-			Requisition req;
-			req.Width = Math.Max (item.preferredWidth, item.Allocation.Width);
-			req.Height = Math.Max (item.preferredHeight, item.Allocation.Height);
-			return req;
-		}
-		
 		private bool EventInGripWindow (Gdk.Event evnt)
 		{
 			if (grip != null && grip.TitleWindow == evnt.Window)

Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs	2004-06-15 12:48:47 UTC (rev 1766)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs	2004-06-15 16:54:31 UTC (rev 1767)
@@ -255,8 +255,6 @@
 		
 		private void OnDragBegin (DockItem item)
 		{
-			Console.WriteLine ("DockMaster.OnDragBegin");
-		
 			/* Set the target to itself so it won't go floating with just a click. */
 			request = new DockRequest ();
 			request.Applicant = item;
@@ -360,8 +358,9 @@
 				
 				myRequest.Target = Dock.GetTopLevel (item);
 				myRequest.Position = DockPlacement.Floating;
-				myRequest.Width = item.PreferredWidth;
-				myRequest.Height = item.PreferredHeight;
+				Requisition preferredSize = item.PreferredSize;
+				myRequest.Width = preferredSize.Width;
+				myRequest.Height = preferredSize.Height;
 				myRequest.X = rootX - item.DragOffX;
 				myRequest.Y = rootY - item.DragOffY;
 			}

Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs	2004-06-15 12:48:47 UTC (rev 1766)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs	2004-06-15 16:54:31 UTC (rev 1767)
@@ -171,8 +171,8 @@
 				mayDock = true;
 
 				/* these are for calculating the extra docking parameter */
-				Requisition other = DockItem.PreferredSize ((DockItem)request.Applicant);
-				Requisition my = DockItem.PreferredSize (this);
+				Requisition other = ((DockItem)request.Applicant).PreferredSize;
+				Requisition my = PreferredSize;
 				
 				/* Set docking indicator rectangle to the Dock size. */
 				request.X = alloc.X + bw;




More information about the Monodevelop-patches-list mailing list