Author: danw
Date: 2005-03-15 11:30:00 -0500 (Tue, 15 Mar 2005)
New Revision: 41838
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/Set.cs
trunk/stetic/libstetic/WidgetSite.cs
trunk/stetic/libstetic/wrapper/Box.cs
trunk/stetic/stetic/Project.cs
Log:
* libstetic/WidgetSite.cs (AddFault, AddHFault, AddVFault): Make
AddHFault and AddVFault take WidgetSites rather than coordinates,
and provide AddFault for fully-generic fault adding. For AddHFault
and AddVFault, make the fault windows fill the entire space
between the two widgets (or from the widget to the edge of its
parent) if the widgets are spread apart.
(OnDragMotion): Center the splitter inside its fault since the
fault may be very large now.
* libstetic/wrapper/Box.cs (Sync): update for that
* stetic/Project.cs (ContentsChanged): fix a crash when dragging a
widget from one position to another within the same container
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2005-03-15 15:49:30 UTC (rev 41837)
+++ trunk/stetic/ChangeLog 2005-03-15 16:30:00 UTC (rev 41838)
@@ -1,3 +1,19 @@
+2005-03-15 Dan Winship <[EMAIL PROTECTED]>
+
+ * libstetic/WidgetSite.cs (AddFault, AddHFault, AddVFault): Make
+ AddHFault and AddVFault take WidgetSites rather than coordinates,
+ and provide AddFault for fully-generic fault adding. For AddHFault
+ and AddVFault, make the fault windows fill the entire space
+ between the two widgets (or from the widget to the edge of its
+ parent) if the widgets are spread apart.
+ (OnDragMotion): Center the splitter inside its fault since the
+ fault may be very large now.
+
+ * libstetic/wrapper/Box.cs (Sync): update for that
+
+ * stetic/Project.cs (ContentsChanged): fix a crash when dragging a
+ widget from one position to another within the same container
+
2005-03-14 Dan Winship <[EMAIL PROTECTED]>
* libstetic/WidgetSite.cs (FindFault): fix another autoexpand
Modified: trunk/stetic/libstetic/Set.cs
===================================================================
--- trunk/stetic/libstetic/Set.cs 2005-03-15 15:49:30 UTC (rev 41837)
+++ trunk/stetic/libstetic/Set.cs 2005-03-15 16:30:00 UTC (rev 41838)
@@ -19,6 +19,11 @@
}
}
+ public void Clear ()
+ {
+ hash.Clear ();
+ }
+
public IEnumerator GetEnumerator ()
{
return this;
Modified: trunk/stetic/libstetic/WidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/WidgetSite.cs 2005-03-15 15:49:30 UTC (rev
41837)
+++ trunk/stetic/libstetic/WidgetSite.cs 2005-03-15 16:30:00 UTC (rev
41838)
@@ -174,46 +174,128 @@
}
Hashtable faults;
+ Set hfaults;
+ const int FaultOverlap = 3;
- void SetupFaults ()
+ public void AddFault (object id, Gtk.Orientation orientation,
Rectangle fault)
{
- if (faults == null) {
- faults = new Hashtable ();
- DND.DragBegin += ShowFaults;
- DND.DragEnd += HideFaults;
- }
- if (Occupancy == SiteOccupancy.Occupied)
- DND.DestSet (this, false);
+ AddFault (id, orientation, fault.X, fault.Y,
fault.Width, fault.Height);
}
- public void AddHFault (object id, int y, int x1, int x2)
+ public void AddFault (object id, Gtk.Orientation orientation,
+ int x, int y, int width, int height)
{
if (!IsRealized)
return;
+
Gdk.Window win = NewWindow (GdkWindow,
Gdk.WindowClass.InputOnly);
- win.MoveResize (x1, y - 2, x2 - x1 , 5);
- if (faults == null || faults.Count == 0)
- SetupFaults ();
+ win.MoveResize (x, y, width, height);
+
+ if (faults == null || faults.Count == 0) {
+ if (faults == null) {
+ faults = new Hashtable ();
+ hfaults = new Set ();
+ DND.DragBegin += ShowFaults;
+ DND.DragEnd += HideFaults;
+ }
+ if (Occupancy == SiteOccupancy.Occupied)
+ DND.DestSet (this, false);
+ }
+
faults[id] = win;
+ hfaults[id] = (orientation ==
Gtk.Orientation.Horizontal);
}
- public void AddVFault (object id, int x, int y1, int y2)
+ public void AddHFault (object id, WidgetSite above, WidgetSite
below)
{
if (!IsRealized)
return;
- Gdk.Window win = NewWindow (GdkWindow,
Gdk.WindowClass.InputOnly);
- win.MoveResize (x - 2, y1, 5, y2 - y1);
- if (faults == null || faults.Count == 0)
- SetupFaults ();
- faults[id] = win;
+
+ Gdk.Rectangle aboveAlloc, belowAlloc;
+ int x1, y1, x2, y2;
+
+ if (above != null && below != null) {
+ aboveAlloc = above.Allocation;
+ belowAlloc = below.Allocation;
+
+ x1 = Math.Min (aboveAlloc.X, belowAlloc.X);
+ x2 = Math.Max (aboveAlloc.X + aboveAlloc.Width,
belowAlloc.X + belowAlloc.Width);
+ y1 = aboveAlloc.Y + aboveAlloc.Height;
+ y2 = belowAlloc.Y;
+
+ while (y2 - y1 < FaultOverlap * 2) {
+ y1--;
+ y2++;
+ }
+ } else if (above == null) {
+ belowAlloc = below.Allocation;
+
+ x1 = belowAlloc.X;
+ x2 = belowAlloc.X + belowAlloc.Width;
+ y1 = 0;
+ y2 = Math.Max (belowAlloc.Y, FaultOverlap);
+ } else {
+ aboveAlloc = above.Allocation;
+
+ x1 = aboveAlloc.X;
+ x2 = aboveAlloc.X + aboveAlloc.Width;
+ y1 = Math.Min (aboveAlloc.Y +
aboveAlloc.Height, Allocation.Height - FaultOverlap);
+ y2 = Allocation.Height;
+ }
+
+ AddFault (id, Gtk.Orientation.Horizontal, x1, y1, x2 -
x1, y2 - y1);
}
+ public void AddVFault (object id, WidgetSite left, WidgetSite
right)
+ {
+ if (!IsRealized)
+ return;
+
+ Gdk.Rectangle leftAlloc, rightAlloc;
+ int x1, y1, x2, y2;
+
+ if (left != null && right != null) {
+ leftAlloc = left.Allocation;
+ rightAlloc = right.Allocation;
+
+ x1 = leftAlloc.X + leftAlloc.Width;
+ x2 = rightAlloc.X;
+
+ y1 = Math.Min (leftAlloc.Y, rightAlloc.Y);
+ y2 = Math.Max (leftAlloc.Y + leftAlloc.Height,
rightAlloc.Y + rightAlloc.Height);
+
+ while (x2 - x1 < FaultOverlap * 2) {
+ x1--;
+ x2++;
+ }
+ } else if (left == null) {
+ rightAlloc = right.Allocation;
+
+ x1 = 0;
+ x2 = Math.Max (rightAlloc.X, FaultOverlap);
+
+ y1 = rightAlloc.Y;
+ y2 = rightAlloc.Y + rightAlloc.Height;
+ } else {
+ leftAlloc = left.Allocation;
+
+ x1 = Math.Min (leftAlloc.X + leftAlloc.Width,
Allocation.Width - FaultOverlap);
+ x2 = Allocation.Width;
+
+ y1 = leftAlloc.Y;
+ y2 = leftAlloc.Y + leftAlloc.Height;
+ }
+
+ AddFault (id, Gtk.Orientation.Vertical, x1, y1, x2 -
x1, y2 - y1);
+ }
+
public void ClearFaults ()
{
if (faults != null) {
foreach (Gdk.Window win in faults.Values)
win.Destroy ();
faults.Clear ();
+ hfaults.Clear ();
}
if (Occupancy == SiteOccupancy.Occupied)
DND.DestUnset (this);
@@ -281,7 +363,13 @@
splitter = NewWindow (GdkWindow,
Gdk.WindowClass.InputOutput);
matchWin.GetGeometry (out wx, out wy, out
width, out height, out depth);
- splitter.MoveResize (wx, wy, width, height);
+ if (hfaults[dragFault]) {
+ splitter.MoveResize (wx, wy + height /
2 - FaultOverlap,
+ width, 2 *
FaultOverlap);
+ } else {
+ splitter.MoveResize (wx + width / 2 -
FaultOverlap, wy,
+ 2 * FaultOverlap,
height);
+ }
splitter.ShowUnraised ();
GdkWindow.Lower ();
} else if (dragFault == null)
Modified: trunk/stetic/libstetic/wrapper/Box.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Box.cs 2005-03-15 15:49:30 UTC (rev
41837)
+++ trunk/stetic/libstetic/wrapper/Box.cs 2005-03-15 16:30:00 UTC (rev
41838)
@@ -59,29 +59,24 @@
sorted[bc.Position] = childsite;
}
- Gdk.Rectangle alloc = box.Allocation;
-
if (this is HBox) {
if (sorted[0] != null)
- site.AddVFault (0, 0, 0, alloc.Height);
+ site.AddVFault (0, null, sorted[0]);
if (sorted[sorted.Length - 1] != null)
- site.AddVFault (sorted.Length,
alloc.Width, 0, alloc.Height);
+ site.AddVFault (sorted.Length,
sorted[sorted.Length - 1], null);
} else {
if (sorted[0] != null)
- site.AddHFault (0, 0, 0, alloc.Width);
+ site.AddHFault (0, null, sorted[0]);
if (sorted[sorted.Length - 1] != null)
- site.AddHFault (sorted.Length,
alloc.Height, 0, alloc.Width);
+ site.AddHFault (sorted.Length,
sorted[sorted.Length - 1], null);
}
for (int i = 1; i < sorted.Length; i++) {
if (sorted[i - 1] != null && sorted[i] != null)
{
- Gdk.Rectangle alloc1 = sorted[i -
1].Allocation;
- Gdk.Rectangle alloc2 =
sorted[i].Allocation;
-
if (this is HBox)
- site.AddVFault (i, (alloc1.X +
alloc1.Width + alloc2.X) / 2, 0, alloc.Height);
+ site.AddVFault (i, sorted[i -
1], sorted[i]);
else
- site.AddHFault (i, (alloc1.Y +
alloc1.Height + alloc2.Y) / 2, 0, alloc.Width);
+ site.AddHFault (i, sorted[i -
1], sorted[i]);
}
}
}
Modified: trunk/stetic/stetic/Project.cs
===================================================================
--- trunk/stetic/stetic/Project.cs 2005-03-15 15:49:30 UTC (rev 41837)
+++ trunk/stetic/stetic/Project.cs 2005-03-15 16:30:00 UTC (rev 41838)
@@ -99,7 +99,7 @@
ArrayList children = new ArrayList ();
foreach (WidgetSite site in cwrap.Sites) {
- if (site.Occupied)
+ if (site.Contents != null)
children.Add (site.Contents);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches