[Monodevelop-patches-list] r1763 - trunk/MonoDevelop/src/Libraries/Gdl
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Mon Jun 14 13:20:07 EDT 2004
Author: jzwart
Date: 2004-06-14 13:20:06 -0400 (Mon, 14 Jun 2004)
New Revision: 1763
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
trunk/MonoDevelop/src/Libraries/Gdl/DockRequest.cs
Log:
Another step in the direction of a working DND dock.
Modified: trunk/MonoDevelop/src/Libraries/Gdl/Dock.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/Dock.cs 2004-06-14 16:57:01 UTC (rev 1762)
+++ trunk/MonoDevelop/src/Libraries/Gdl/Dock.cs 2004-06-14 17:20:06 UTC (rev 1763)
@@ -308,8 +308,6 @@
int relX = x - alloc.X;
int relY = y - alloc.Y;
- DockRequest myRequest = new DockRequest (request);
-
/* Check if coordinates are in GdlDock widget. */
if (relX > 0 && relX < alloc.Width &&
relY > 0 && relY < alloc.Height) {
@@ -318,57 +316,43 @@
mayDock = true;
/* Set docking indicator rectangle to the Dock size. */
- Gdk.Rectangle reqRect = new Gdk.Rectangle ();
- reqRect.X = alloc.X + bw;
- reqRect.Y = alloc.Y + bw;
- reqRect.Width = alloc.Width - 2 * bw;
- reqRect.Height = alloc.Height - 2 * bw;
- myRequest.Rect = reqRect;
+ request.X = alloc.X + bw;
+ request.Y = alloc.Y + bw;
+ request.Width = alloc.Width - 2 * bw;
+ request.Height = alloc.Height - 2 * bw;
/* If Dock has no root item yet, set the dock
itself as possible target. */
if (root == null) {
- myRequest.Position = DockPlacement.Top;
- myRequest.Target = this;
+ request.Position = DockPlacement.Top;
+ request.Target = this;
} else {
- myRequest.Target = root;
+ request.Target = root;
/* See if it's in the BorderWidth band. */
if (relX < bw) {
- myRequest.Position = DockPlacement.Left;
- reqRect.Width = (int)(reqRect.Width * SplitRatio);
- myRequest.Rect = reqRect;
+ request.Position = DockPlacement.Left;
+ request.Width = (int)(request.Width * SplitRatio);
} else if (relX > alloc.Width - bw) {
- myRequest.Position = DockPlacement.Right;
- reqRect.X += (int)(reqRect.Width * (1 - SplitRatio));
- reqRect.Width = (int)(reqRect.Width * SplitRatio);
- myRequest.Rect = reqRect;
+ request.Position = DockPlacement.Right;
+ request.X += (int)(request.Width * (1 - SplitRatio));
+ request.Width = (int)(request.Width * SplitRatio);
} else if (relY < bw) {
- myRequest.Position = DockPlacement.Top;
- reqRect.Height = (int)(reqRect.Height * SplitRatio);
- myRequest.Rect = reqRect;
+ request.Position = DockPlacement.Top;
+ request.Height = (int)(request.Height * SplitRatio);
} else if (relY > alloc.Height - bw) {
- myRequest.Position = DockPlacement.Bottom;
- reqRect.Y += (int)(reqRect.Height * (1 - SplitRatio));
- reqRect.Height = (int)(reqRect.Height * SplitRatio);
- myRequest.Rect = reqRect;
+ request.Position = DockPlacement.Bottom;
+ request.Y += (int)(request.Height * (1 - SplitRatio));
+ request.Height = (int)(request.Height * SplitRatio);
} else {
/* Otherwise try our children. */
/* give them allocation coordinates
(we are a NoWindow widget) */
- mayDock = root.OnDockRequest (x, y, ref myRequest);
+ mayDock = root.OnDockRequest (x, y, ref request);
}
}
}
- if (mayDock && request != null) {
- request.Applicant = myRequest.Applicant;
- request.Target = myRequest.Target;
- request.Position = myRequest.Position;
- request.Rect = myRequest.Rect;
- request.Extra = myRequest.Extra;
- }
-
return mayDock;
}
Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs 2004-06-14 16:57:01 UTC (rev 1762)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs 2004-06-14 17:20:06 UTC (rev 1763)
@@ -601,35 +601,34 @@
}
/* Reset rectangle coordinates to entire item. */
- Gdk.Rectangle reqRect = new Gdk.Rectangle ();
- reqRect.X = 0;
- reqRect.Y = 0;
- reqRect.Width = alloc.Width;
- reqRect.Height = alloc.Height;
+ request.X = 0;
+ request.Y = 0;
+ request.Width = alloc.Width;
+ request.Height = alloc.Height;
/* Calculate docking indicator rectangle size for new locations.
Only do this when we're not over the item's current location. */
if (request.Applicant != this) {
switch (request.Position) {
case DockPlacement.Top:
- reqRect.Height = (int)(reqRect.Height * SplitRatio);
+ request.Height = (int)(request.Height * SplitRatio);
break;
case DockPlacement.Bottom:
- reqRect.Y += (int)(reqRect.Height * (1 - SplitRatio));
- reqRect.Height = (int)(reqRect.Height * SplitRatio);
+ request.Y += (int)(request.Height * (1 - SplitRatio));
+ request.Height = (int)(request.Height * SplitRatio);
break;
case DockPlacement.Left:
- reqRect.Width = (int)(reqRect.Width * SplitRatio);
+ request.Width = (int)(request.Width * SplitRatio);
break;
case DockPlacement.Right:
- reqRect.X += (int)(reqRect.Width * (1 - SplitRatio));
- reqRect.Width = (int)(reqRect.Width * SplitRatio);
+ request.X += (int)(request.Width * (1 - SplitRatio));
+ request.Width = (int)(request.Width * SplitRatio);
break;
case DockPlacement.Center:
- reqRect.X = (int)(reqRect.Width * SplitRatio / 2);
- reqRect.Y = (int)(reqRect.Height * SplitRatio / 2);
- reqRect.Width = (int)(reqRect.Width * (1 - SplitRatio / 2)) - reqRect.X;
- reqRect.Height = (int)(reqRect.Height * (1 - SplitRatio / 2)) - reqRect.Y;
+ request.X = (int)(request.Width * SplitRatio / 2);
+ request.Y = (int)(request.Height * SplitRatio / 2);
+ request.Width = (int)(request.Width * (1 - SplitRatio / 2)) - request.X;
+ request.Height = (int)(request.Height * (1 - SplitRatio / 2)) - request.Y;
break;
default:
break;
@@ -638,14 +637,13 @@
/* adjust returned coordinates so they are have the same
origin as our window */
- reqRect.X += alloc.X;
- reqRect.Y += alloc.Y;
+ request.X += alloc.X;
+ request.Y += alloc.Y;
/* Set possible target location and return true. */
request.Target = this;
/* fill-in other dock information */
- request.Rect = reqRect;
if (request.Position != DockPlacement.Center && divider >= 0)
request.Extra = divider;
Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs 2004-06-14 16:57:01 UTC (rev 1762)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs 2004-06-14 17:20:06 UTC (rev 1763)
@@ -269,8 +269,6 @@
private void OnDragEnd (DockItem item, bool cancelled)
{
- Console.WriteLine ("DockMaster.OnDragEnd");
-
if (item != request.Applicant) {
Console.WriteLine ("Dragged item is not the same as the one we started with");
return;
@@ -297,7 +295,7 @@
int winX, winY;
int x, y;
bool mayDock = false;
- DockRequest myRequest = request;
+ DockRequest myRequest = new DockRequest (request);
if (item != request.Applicant) {
Console.WriteLine ("Dragged item is not the same as the one we started with");
@@ -331,6 +329,8 @@
if (rootX >= winX && rootX < winX + winW &&
rootY >= winY && rootY < winY + winH)
dock = widget as Dock;
+ } else {
+ Console.WriteLine ("Gdk.Window does not contain the owner in the UserData field");
}
}
@@ -360,20 +360,16 @@
myRequest.Target = Dock.GetTopLevel (item);
myRequest.Position = DockPlacement.Floating;
-
- Gdk.Rectangle rect = new Gdk.Rectangle ();
- rect.Width = item.PreferredWidth;
- rect.Height = item.PreferredHeight;
- rect.X = rootX - item.DragOffX;
- rect.Y = rootY - item.DragOffY;
- myRequest.Rect = rect;
- myRequest.Extra = myRequest.Rect;
+ myRequest.Width = item.PreferredWidth;
+ myRequest.Height = item.PreferredHeight;
+ myRequest.X = rootX - item.DragOffX;
+ myRequest.Y = rootY - item.DragOffY;
}
- if (!(myRequest.Rect.X == request.Rect.X &&
- myRequest.Rect.Y == request.Rect.Y &&
- myRequest.Rect.Width == request.Rect.Width &&
- myRequest.Rect.Height == request.Rect.Height &&
+ if (!(myRequest.X == request.X &&
+ myRequest.Y == request.Y &&
+ myRequest.Width == request.Width &&
+ myRequest.Height == request.Height &&
dock == rectOwner)) {
/* erase the previous rectangle */
@@ -391,16 +387,17 @@
private void XorRect ()
{
- Console.WriteLine ("DockMaster.XorRect");
-
rectDrawn = !rectDrawn;
if (rectOwner != null) {
- rectOwner.XorRect (request.Rect);
+ Gdk.Rectangle rect = new Gdk.Rectangle (request.X,
+ request.Y,
+ request.Width,
+ request.Height);
+ rectOwner.XorRect (rect);
return;
}
- Gdk.Rectangle rect = request.Rect;
Gdk.Window window = Gdk.Global.DefaultRootWindow;
if (rootXorGC == null) {
@@ -419,13 +416,14 @@
rootXorGC.SetDashes (1, new sbyte[] {1, 1}, 2);
- window.DrawRectangle (rootXorGC, false, rect.X, rect.Y,
- rect.Width, rect.Height);
+ window.DrawRectangle (rootXorGC, false, request.X, request.Y,
+ request.Width, request.Height);
rootXorGC.SetDashes (0, new sbyte[] {1, 1}, 2);
- window.DrawRectangle (rootXorGC, false, rect.X + 1, rect.Y + 1,
- rect.Width - 2, rect.Height - 2);
+ window.DrawRectangle (rootXorGC, false, request.X + 1,
+ request.Y + 1, request.Width - 2,
+ request.Height - 2);
}
}
}
Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs 2004-06-14 16:57:01 UTC (rev 1762)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs 2004-06-14 17:20:06 UTC (rev 1763)
@@ -162,8 +162,6 @@
int relX = x - alloc.X;
int relY = y - alloc.Y;
- DockRequest myRequest = new DockRequest (request);
-
/* Location is inside. */
if (relX > 0 && relX < alloc.Width &&
relY > 0 && relY < alloc.Width) {
@@ -177,38 +175,82 @@
Requisition my = DockItem.PreferredSize (this);
/* Set docking indicator rectangle to the Dock size. */
- Gdk.Rectangle reqRect = new Gdk.Rectangle ();
- reqRect.X = alloc.X + bw;
- reqRect.Y = alloc.Y + bw;
- reqRect.Width = alloc.Width - 2 * bw;
- reqRect.Height = alloc.Height - 2 * bw;
- myRequest.Rect = reqRect;
-
- myRequest.Target = this;
+ request.X = alloc.X + bw;
+ request.Y = alloc.Y + bw;
+ request.Width = alloc.Width - 2 * bw;
+ request.Height = alloc.Height - 2 * bw;
+ request.Target = this;
- /* See if it's in the border_width band. */
- /*if (relX < bw) {
- myRequest.Position = DockPlacement.Left;
- myRequest.Rect.Width = myRequest.Rect.Width * SplitRatio;
+ /* See if it's in the BorderWidth band. */
+ if (relX < bw) {
+ request.Position = DockPlacement.Left;
+ request.Width = (int)(request.Width * SplitRatio);
divider = other.Width;
- } else if (relX > alloc->Width - bw) {
- myRequest.Position = DockPlacement.Right;
- myRequest.Rect.X += myRequest.Rect.Width * (1 - SplitRatio);
- myRequest.Rect.Width *= SplitRatio;
+ } else if (relX > alloc.Width - bw) {
+ request.Position = DockPlacement.Right;
+ request.X += (int)(request.Width * (1 - SplitRatio));
+ request.Width = (int)(request.Width * SplitRatio);
divider = Math.Max (0, my.Width - other.Width);
} else if (relY < bw) {
- myRequest.Position = DockPlacement.Top;
- myRequest.Rect.Height *= SplitRatio;
+ request.Position = DockPlacement.Top;
+ request.Height = (int)(request.Height * SplitRatio);
divider = other.Height;
- } else if (relY > alloc->Height - bw) {
- myRequest.Position = DockPlacement.Bottom;
- myRequest.Rect.Y += myRequest.Rect.Height * (1 - SplitRatio);
- myRequest.Rect.Height *= SplitRatio;
+ } else if (relY > alloc.Height - bw) {
+ request.Position = DockPlacement.Bottom;
+ request.Y += (int)(request.Height * (1 - SplitRatio));
+ request.Height = (int)(request.Height * SplitRatio);
divider = Math.Max (0, my.Height - other.Height);
} else { /* Otherwise try our children. */
- //}
+ mayDock = false;
+ DockRequest myRequest = new DockRequest (request);
+ foreach (DockObject item in Children) {
+ if (item.OnDockRequest (relX, relY, ref myRequest)) {
+ mayDock = true;
+ request = myRequest;
+ break;
+ }
+ }
+
+ if (!mayDock) {
+ /* the pointer is on the handle, so snap
+ to top/bottom or left/right */
+ mayDock = true;
+
+ if (Orientation == Orientation.Horizontal) {
+ if (relY < alloc.Height / 2) {
+ request.Position = DockPlacement.Top;
+ request.Height = (int)(request.Height * SplitRatio);
+ divider = other.Height;
+ } else {
+ request.Position = DockPlacement.Bottom;
+ request.Y += (int)(request.Height * (1 - SplitRatio));
+ request.Height = (int)(request.Height * SplitRatio);
+ divider = Math.Max (0, my.Height - other.Height);
+ }
+ } else {
+ if (relX < alloc.Width / 2) {
+ request.Position = DockPlacement.Left;
+ request.Width = (int)(request.Width * SplitRatio);
+ divider = other.Width;
+ } else {
+ request.Position = DockPlacement.Right;
+ request.X += (int)(request.Width * (1 - SplitRatio));
+ request.Width = (int)(request.Width * SplitRatio);
+ divider = Math.Max (0, my.Width - other.Width);
+ }
+ }
+ }
+ }
+
+ if (mayDock) {
+ /* adjust returned coordinates so they are
+ relative to our allocation */
+ request.X += alloc.X;
+ request.Y += alloc.Y;
+ }
}
- return true;
+
+ return mayDock;
}
}
}
Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockRequest.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockRequest.cs 2004-06-14 16:57:01 UTC (rev 1762)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockRequest.cs 2004-06-14 17:20:06 UTC (rev 1763)
@@ -11,20 +11,24 @@
private DockObject applicant;
private DockObject target;
private DockPlacement position;
- private Rectangle rect;
+ private int x, y, width, height;
private object extra;
- public DockRequest (DockRequest copy)
+ public DockRequest ()
{
- this.applicant = copy.Applicant;
- this.target = copy.Target;
- this.position = copy.Position;
- this.rect = copy.Rect;
- this.extra = copy.Extra;
}
- public DockRequest ()
+ public DockRequest (DockRequest copy)
{
+ applicant = copy.Applicant;
+ target = copy.Target;
+ x = copy.X;
+ y = copy.Y;
+ width = copy.Width;
+ height = copy.Height;
+ position = copy.Position;
+
+ extra = copy.Extra;
}
public DockObject Applicant {
@@ -41,15 +45,46 @@
get { return position; }
set { position = value; }
}
+
+ public int X {
+ get {
+ return x;
+ }
+ set {
+ x = value;
+ }
+ }
- public Rectangle Rect {
- get { return rect; }
- set { rect = value; }
+ public int Y {
+ get {
+ return y;
+ }
+ set {
+ y = value;
+ }
}
+ public int Width {
+ get {
+ return width;
+ }
+ set {
+ width = value;
+ }
+ }
+
+ public int Height {
+ get {
+ return height;
+ }
+ set {
+ height = value;
+ }
+ }
+
public object Extra {
get { return extra; }
set { extra = value; }
}
}
-}
\ No newline at end of file
+}
More information about the Monodevelop-patches-list
mailing list