]> O.S.I.I.S - jp/crow.git/commitdiff
Height and Width of GO major change for stacking, docker improvement and simplification
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 7 Mar 2018 14:06:30 +0000 (15:06 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 7 Mar 2018 14:06:30 +0000 (15:06 +0100)
Tests/Interfaces/Experimental/testDock.crow
Tests/Interfaces/TemplatedContainer/testTabView2.crow
src/ExtensionsMethods.cs
src/GraphicObjects/DockStack.cs
src/GraphicObjects/DockWindow.cs
src/GraphicObjects/Docker.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TabView.cs

index 3f1aaa3d41d372c38f5ad928c3a8b52324103af4..742c1e07c4e31a3832e78888e32f6bc7f9d588d5 100644 (file)
@@ -1,14 +1,18 @@
 <?xml version="1.0"?>
-<Docker Background="Onyx">
-       <DockWindow Left="100" Top="100" Width="150" Height="150" Background="DarkRed" />
-       <DockWindow Left="150" Top="150" Width="150" Height="150" Background="DarkGreen"/>
-       <DockWindow Left="200" Top="200" Width="150" Height="150" Background="Blue"/>
-       <DockWindow Left="250" Top="250" Width="150" Height="150" Background="DarkYellow"/>
-       <DockWindow Left="300" Top="300" Width="150" Height="150" Background="Yellow"/>
-       <DockWindow Left="350" Top="350" Width="150" Height="150" Background="BrownWeb"/>
-       <DockWindow Left="400" Top="400" Width="150" Height="150" Background="Teal"/>
-       <DockWindow Left="450" Top="450" Width="150" Height="150" Background="Maize"/>
-</Docker>
+<VerticalStack>
+       <Docker>
+               <DockStack Background="Onyx"/>
+               <DockWindow Width="150" Height="150" Background="DarkRed" />
+               <DockWindow Width="150" Height="150" Background="DarkGreen"/>
+               <DockWindow Width="150" Height="150" Background="Blue"/>
+               <DockWindow Width="150" Height="150" Background="DarkYellow"/>
+               <DockWindow Width="150" Height="150" Background="Yellow"/>
+               <DockWindow Width="150" Height="150" Background="BrownWeb"/>
+       </Docker>
+<!---          <DockWindow Left="400" Top="400" Width="150" Height="150" Background="Teal"/>
+               <DockWindow Left="450" Top="450" Width="150" Height="150" Background="Maize"/>-->
+       
+</VerticalStack>
 <!--<Group Background="Jet" Margin = "0" Focusable="true" >
        <Window Top="100" Left="100" Focusable="true" Caption="View 1" Width="300" Height="300"><GraphicObject Background="Green" Focusable="true" MouseEnter="{Background=Gray}" MouseLeave="{Background=Green}"/></Window>
        <Window Top="200" Left="200" Focusable="true" Caption="View 2" Resizable = "true" Width="300" Height="300"><GraphicObject Focusable="true" Background="Blue" MouseEnter="{Background=Gray}" MouseLeave="{Background=Blue}"/></Window>
index 7d9275c9791eedf79b06a283922a708839068353..7e32078a70ceba188e82a1ecd1125c426237eb77 100644 (file)
@@ -31,7 +31,7 @@
                <Button Background="vgradient|0:DimGray|1:Black" HorizontalAlignment="Right"
                        Caption="Add new tab" Width="Fit" Height="30" MouseDown="onAddTabButClick"/>    
        </VerticalStack>
-<!--   <VerticalStack Width="40%">     
+       <VerticalStack Width="40%">     
                <HorizontalStack Height="Fit">
                        <Label Text="Selected Tab:"/>
                        <Label Text="{../../tabview2.SelectedTab}"/>
@@ -61,5 +61,5 @@
                </TabView>
                <Button Background="vgradient|0:DimGray|1:Black" HorizontalAlignment="Right"
                        Caption="Add new tab" Width="Fit" Height="30" MouseDown="onAddTabButClick2"/>   
-       </VerticalStack>-->
+       </VerticalStack>
 </HorizontalStack>
index dfb90f0ea3808b4ee2e7cdbbe754d180f502d908..d74488743e617abda11acbd17345ca990f4d366d 100644 (file)
@@ -109,6 +109,27 @@ namespace Crow
                public static Orientation GetOrientation(this Alignment a){
                        return (a==Alignment.Left) ||(a==Alignment.Right) ? Orientation.Horizontal : Orientation.Vertical;
                }
+               public static Alignment GetOpposite(this Alignment a){
+                       switch (a) {
+                       case Alignment.Left:
+                               return Alignment.Right;
+                       case Alignment.Right:
+                               return Alignment.Left;
+                       case Alignment.Top:
+                               return Alignment.Bottom;
+                       case Alignment.Bottom:
+                               return Alignment.Top;
+                       case Alignment.TopLeft:
+                               return Alignment.BottomRight;
+                       case Alignment.TopRight:
+                               return Alignment.BottomLeft;
+                       case Alignment.BottomLeft:
+                               return Alignment.TopRight;
+                       case Alignment.BottomRight:
+                               return Alignment.TopLeft;                       
+                       }
+                       return Alignment.Center;
+               }
                public static void Raise(this EventHandler handler, object sender, EventArgs e)
                {
                        if(handler != null)
index c06be42a58bbce86111667208138ee67dfea340d..bfd3ac9a325f29891ba804a3090918ebcd433c5b 100644 (file)
@@ -29,17 +29,9 @@ using Crow.IML;
 namespace Crow
 {
        public class DockStack : GenericStack
-       {               
-               int dockingDiv = 6;
-               GraphicObject subStack = null;
-
+       {
                Docker rootDock { get { return LogicalParent as Docker; }}
 
-               public GraphicObject SubStack {
-                       get { return subStack;}
-                       set{ subStack=value; }
-               }
-
                #region CTor
                public DockStack ()     {}
                public DockStack (Interface iface) : base (iface) {}
@@ -77,40 +69,93 @@ namespace Crow
                        }
                        return Slot.ContainsOrIsEqual(m);
                }
+
+//             public override void OnLayoutChanges (LayoutingType layoutType)
+//             {
+//                     base.OnLayoutChanges (layoutType);
+//
+//                     if ((layoutType & LayoutingType.Sizing) > 0)
+//                             computeRects();                 
+//             }
+
+               Rectangle rIn = default(Rectangle);
+               double dockThresh = 0.2;
+               GraphicObject focusedChild;
+               internal GraphicObject stretchedChild;
+
+               void getFocusedChild (Point lm) {
+                       Rectangle cb = ClientRectangle;
+
+                       childrenRWLock.EnterReadLock ();
+                       foreach (GraphicObject c in Children) {
+                               Rectangle bounds = c.Slot + cb.Position;
+                               if (!bounds.ContainsOrIsEqual (lm))
+                                       continue;
+                               rIn = bounds;
+                               focusedChild = c;
+                               break;
+                       }
+                       childrenRWLock.ExitReadLock ();                 
+               }
+
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
                        if (IsDropTarget) {                             
                                DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;
                                if (dw.IsDocked) {
-                                       if (!dw.CheckUndock (e.Position)) {
+                                       //if (!dw.CheckUndock (e.Position)) {
                                                base.onMouseMove (sender, e);
                                                return;
-                                       }                                               
+                                       //}                                             
                                }
-                               Point lm = ScreenPointToLocal (e.Position);
-
-                               Rectangle r = ClientRectangle;
-                               int vTreshold = r.Height / dockingDiv;
-                               int hTreshold = r.Width / dockingDiv;
 
                                Alignment curDockPos = dw.DockingPosition;
+                               dw.DockingPosition = Alignment.Undefined;
+
+                               Rectangle cb = ClientRectangle;
+                               Point lm = ScreenPointToLocal (e.Position);
 
-                               if (lm.X < hTreshold)
-                                       dw.DockingPosition = Alignment.Left;
-                               else if (lm.X > r.Right - hTreshold)
-                                       dw.DockingPosition = Alignment.Right;
-                               else if (lm.Y < vTreshold)
-                                       dw.DockingPosition = Alignment.Top;
-                               else if (lm.Y > r.Bottom - vTreshold)
-                                       dw.DockingPosition = Alignment.Bottom;
-                               else if (this.Children.Contains (rootDock.CenterDockedObj) && !(rootDock.CenterDockedObj is DockWindow)) {
-                                       r.Inflate (-r.Width / 3, -r.Height / 3);
-                                       if (r.ContainsOrIsEqual (lm))
+                               if (Children.Count == 0) {
+                                       Rectangle r = cb;
+                                       r.Inflate (r.Width / -5, r.Height / -5);
+                                       if (r.ContainsOrIsEqual(lm))
                                                dw.DockingPosition = Alignment.Center;
-                                       else
-                                               dw.DockingPosition = Alignment.Undefined;
-                               } else
-                                       dw.DockingPosition = Alignment.Undefined;
+                               } else {
+                                       rIn = cb;
+
+                                       if (Orientation == Orientation.Horizontal || Children.Count == 1) {
+                                               if (lm.Y > cb.Top + cb.Height / 3 && lm.Y < cb.Bottom - cb.Height / 3) {
+                                                       if (lm.X < cb.Left + cb.Width / 3)
+                                                               dw.DockingPosition = Alignment.Left;
+                                                       else if (lm.X > cb.Right - cb.Width / 3)
+                                                               dw.DockingPosition = Alignment.Right;                                                   
+                                               } else {
+                                                       getFocusedChild (lm);
+                                                       if (focusedChild != null) {
+                                                               if (lm.Y < rIn.Top + rIn.Height / 3)
+                                                                       dw.DockingPosition = Alignment.Top;
+                                                               else if (lm.Y > rIn.Bottom - rIn.Height / 3)
+                                                                       dw.DockingPosition = Alignment.Bottom;                                                                          
+                                                       }
+                                               }
+                                       }
+                                       if (Orientation == Orientation.Vertical || Children.Count == 1) {
+                                               if (lm.X > cb.Left + cb.Width / 3 && lm.X < cb.Right - cb.Width / 3) {
+                                                       if (lm.Y < cb.Top + cb.Height / 3)
+                                                               dw.DockingPosition = Alignment.Top;
+                                                       else if (lm.Y > cb.Bottom - cb.Height / 3)
+                                                               dw.DockingPosition = Alignment.Bottom;                                                  
+                                               } else {
+                                                       getFocusedChild (lm);
+                                                       if (focusedChild != null) {
+                                                               if (lm.X < rIn.Left + rIn.Width / 3)
+                                                                       dw.DockingPosition = Alignment.Left;
+                                                               else if (lm.X > rIn.Right - rIn.Width / 3)
+                                                                       dw.DockingPosition = Alignment.Right;                                                                           
+                                                       }
+                                               }
+                                       }
+                               }
 
                                if (curDockPos != dw.DockingPosition)
                                        RegisterForGraphicUpdate ();
@@ -160,32 +205,28 @@ namespace Crow
 
                        DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;
                        if (!dw.IsDocked) {
-                               
-                               Rectangle r;
-
-                               if ((dw.DockingPosition.GetOrientation () == Orientation || SubStack == null)&&dw.DockingPosition != Alignment.Center) {
-                                       r = ClientRectangle;
-                                       Console.WriteLine ("Same rect substack=" + SubStack);
-                               }else {
-                                       r = subStack.ClientRectangle + subStack.Slot.Position + ClientRectangle.TopLeft;
-                                       Console.WriteLine ("sub rect");
-                               }
-                               
+                               Rectangle cb = ClientRectangle;
+                               double minDim = Math.Min (cb.Width, cb.Height);
+
+                               Rectangle r = rIn;
+                               if (Children.Count <= 1 || dw.DockingPosition.GetOrientation()==Orientation )
+                                       r = cb;
+
                                switch (dw.DockingPosition) {
                                case Alignment.Top:
-                                       gr.Rectangle (r.Left, r.Top, r.Width, r.Height / dockingDiv);
+                                       gr.Rectangle (r.Left, r.Top, r.Width, r.Height * dockThresh);
                                        break;
                                case Alignment.Bottom:
-                                       gr.Rectangle (r.Left, r.Bottom - r.Height / dockingDiv, r.Width, r.Height / dockingDiv);
+                                       gr.Rectangle (r.Left, r.Bottom - r.Height * dockThresh, r.Width, r.Height * dockThresh);
                                        break;
                                case Alignment.Left:
-                                       gr.Rectangle (r.Left, r.Top, r.Width / dockingDiv, r.Height);
+                                       gr.Rectangle (r.Left, r.Top, r.Width * dockThresh, r.Height);
                                        break;
                                case Alignment.Right:
-                                       gr.Rectangle (r.Right - r.Width / dockingDiv, r.Top, r.Width / dockingDiv, r.Height);
+                                       gr.Rectangle (r.Right - r.Width * dockThresh, r.Top, r.Width * dockThresh, r.Height);
                                        break;
                                case Alignment.Center:
-                                       r.Inflate (-Math.Min (r.Width, r.Height) / dockingDiv);
+                                       r.Inflate ((int)Math.Ceiling (Math.Min (r.Width, r.Height) * -0.05));
                                        gr.Rectangle (r);
                                        break;
                                }
@@ -197,77 +238,37 @@ namespace Crow
                        }
                        gr.Restore ();  
                }
-
-               public void Undock (DockWindow dw){
-                       int idx = Children.IndexOf(dw);
-
-                       RemoveChild(dw);
-
-                       if (rootDock.CenterDockedObj == dw) {                           
-                               rootDock.CenterDockedObj = new GraphicObject (IFace) { IsEnabled = false };
-                               InsertChild (idx, rootDock.CenterDockedObj);
-                               SubStack = rootDock.CenterDockedObj;
-                       }else if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top)                          
-                               RemoveChild (idx);
-                       else
-                               RemoveChild (idx - 1);
-
-                       if (Children.Count > 1)
-                               return;
-
-                       DockStack dsp = Parent as DockStack;
-                       if (dsp == null)
-                               return;
-
-                       RemoveChild (0);
-                       idx = dsp.Children.IndexOf (this);
-                       dsp.RemoveChild (this);
-                       dsp.InsertChild (idx, SubStack);
-                       dsp.SubStack = SubStack;
-                       return;
-               }
-               public void Dock(DockWindow dw){                        
-                       Rectangle r = ClientRectangle;
-
-                       int vTreshold = r.Height / dockingDiv;
-                       int hTreshold = r.Width / dockingDiv;
-
+                       
+               public void Dock(DockWindow dw){
                        DockStack activeStack = this;
-                       Console.WriteLine ("******* Dockingtack {0}", this.Name);
+
                        if (Children.Count == 1) {
-                               activeStack = this;
                                Orientation = dw.DockingPosition.GetOrientation ();
-                       }else if (dw.DockingPosition.GetOrientation() != Orientation) {                         
-                               activeStack = new DockStack (IFace);
-                               int ci = Children.IndexOf (rootDock.CenterDockedObj);
-                               if (ci  <0 ){
-                                       DockStack dsp = Parent as DockStack;
-                                       if (dsp != null) {
-                                               int idx = dsp.Children.IndexOf (this);
-                                               dsp.RemoveChild (this);
-                                               dsp.SubStack = activeStack;
-                                               dsp.InsertChild (idx, activeStack);
-                                               activeStack.SubStack = this;
-                                               activeStack.AddChild (this);
-                                       } else {
-                                               Docker dk = Parent as Docker;
-                                               dk.RemoveChild (this);
-                                               dk.InsertChild (0, activeStack);
-                                               dk.SubStack = activeStack;
-                                               activeStack.AddChild (this);
-                                               activeStack.SubStack = this;
-                                       }
-                               }else{
-                                       int i = Children.IndexOf (SubStack);
-                                       RemoveChild (SubStack);
-                                       activeStack.SubStack = SubStack;
-                                       SubStack = activeStack;
-                                       InsertChild(i, activeStack);
-                                       activeStack.AddChild (activeStack.SubStack);
+                               if (Children [0] is DockWindow) {
+                                       (Children [0] as DockWindow).DockingPosition = dw.DockingPosition.GetOpposite ();
                                }
+                       } else if (Children.Count > 0 && dw.DockingPosition.GetOrientation () != Orientation) {
+                               activeStack = new DockStack (IFace);
                                activeStack.Orientation = dw.DockingPosition.GetOrientation ();
+                               activeStack.Width = focusedChild.Width;
+                               activeStack.Height = focusedChild.Height;
+                               int idx = Children.IndexOf (focusedChild);
+                               RemoveChild (focusedChild);
+                               focusedChild.Height = Measure.Stretched;
+                               focusedChild.Width = Measure.Stretched;
+                               InsertChild (idx, activeStack);
+                               activeStack.AddChild (focusedChild);
+                               activeStack.stretchedChild = focusedChild;
+                               if (focusedChild is DockWindow)
+                                       (focusedChild as DockWindow).DockingPosition = dw.DockingPosition.GetOpposite ();
+                               focusedChild = null;
                        }
-                       Console.WriteLine ("Docking {0} in {1}", dw.Name, activeStack.Name);
+
+                       Rectangle r = ClientRectangle;
+                       int vTreshold = (int)(r.Height * dockThresh);
+                       int hTreshold = (int)(r.Width * dockThresh);
+
+                       Console.WriteLine ("Docking {0} as {2} in {1}", dw.Name, activeStack.Name, dw.DockingPosition);
                        switch (dw.DockingPosition) {
                        case Alignment.Top:                                             
                                dw.Height = vTreshold;
@@ -294,15 +295,63 @@ namespace Crow
                                activeStack.AddChild (dw);
                                break;
                        case Alignment.Center:
-                               dw.Width = dw.Height = Measure.Stretched;                                
-                               int i = activeStack.Children.IndexOf (rootDock.CenterDockedObj);
-                               activeStack.DeleteChild (i);
-                               activeStack.InsertChild (i, dw);
-                               activeStack.SubStack = dw;
-                               rootDock.CenterDockedObj= dw;
+                               dw.Width = dw.Height = Measure.Stretched;
+                               AddChild (dw);
+                               stretchedChild = dw;
                                break;
                        }
                }
+               public void Undock (DockWindow dw){
+                       int idx = Children.IndexOf(dw);
+
+                       RemoveChild(dw);
+
+                       if (Children.Count == 0)
+                               return;
+
+                       if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top) {                              
+                               RemoveChild (idx);
+                               if (stretchedChild == dw) {
+                                       stretchedChild = Children [idx];
+                                       stretchedChild.Width = stretchedChild.Height = Measure.Stretched;
+                               }
+                       } else {
+                               RemoveChild (idx - 1);
+                               if (stretchedChild == dw) {
+                                       stretchedChild = Children [idx-2];
+                                       stretchedChild.Width = stretchedChild.Height = Measure.Stretched;
+                               }
+                       }
+
+                       if (Children.Count == 1) {
+                               DockStack dsp = Parent as DockStack;
+                               if (dsp == null) {
+                                       Children [0].Width = Children [0].Height = Measure.Stretched;
+                                       return;
+                               }                               
+                               //remove level and move remaining obj to level above
+                               GraphicObject g = Children [0];
+                               RemoveChild (g);
+                               idx = dsp.Children.IndexOf (this);
+                               dsp.RemoveChild (this);
+                               dsp.InsertChild (idx, g);
+                               g.Width = this.Width;
+                               g.Height = this.Height;
+                               if (dsp.stretchedChild == this)
+                                       dsp.stretchedChild = g;
+                               dsp.checkAlignments ();
+                       } else
+                               checkAlignments ();
+               }
+
+               internal void checkAlignments () {
+                       DockWindow dw = Children[0] as DockWindow;
+                       if (dw != null)
+                               dw.DockingPosition = (Orientation == Orientation.Horizontal ? Alignment.Left : Alignment.Top);
+                       dw = Children[Children.Count - 1] as DockWindow;
+                       if (dw != null)
+                               dw.DockingPosition = (Orientation == Orientation.Horizontal ? Alignment.Right : Alignment.Bottom);
+               }
        }
 }
 
index f333f6c4bc36dab742441fd34d311471689fc57c..34290a2e613a0a2b0dbfb7eb07936ba25941b914 100644 (file)
@@ -39,7 +39,6 @@ namespace Crow
                bool isDocked = false;
                Alignment docking = Alignment.Undefined;
 
-               Point lastMousePos;     //last known mouse pos in this control
                Point undockingMousePosOrig; //mouse pos when docking was donne, use for undocking on mouse move
                Rectangle savedSlot;    //last undocked slot recalled when view is undocked
                bool wasResizable;
@@ -89,13 +88,14 @@ namespace Crow
 
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
-                       lastMousePos = e.Position;
+//                     if (this.HasFocus && e.Mouse.IsButtonDown (MouseButton.Left) && IsDocked) {
+//                             if (Math.Abs (e.Position.X - undockingMousePosOrig.X) > 10 ||
+//                                 Math.Abs (e.Position.X - undockingMousePosOrig.X) > 10)
+//                                     Undock ();
+//                     }
 
-                       if (this.HasFocus && e.Mouse.IsButtonDown (MouseButton.Left) && IsDocked) {
-                               if (Math.Abs (e.Position.X - undockingMousePosOrig.X) > 10 ||
-                                   Math.Abs (e.Position.X - undockingMousePosOrig.X) > 10)
-                                       Undock ();
-                       }
+                       if (this.HasFocus && e.Mouse.IsButtonDown (MouseButton.Left) && IsDocked)
+                               CheckUndock (e.Position);
 
                        base.onMouseMove (sender, e);
                }
@@ -107,6 +107,8 @@ namespace Crow
                                undockingMousePosOrig = e.Position;
                }
                public bool CheckUndock (Point mousePos) {
+                       if (DockingPosition == Alignment.Center)
+                               return false;
                        if (Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold ||
                            Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold)
                                return false;
@@ -143,10 +145,8 @@ namespace Crow
                                Resizable = wasResizable;
                        }
                }
+
                void dock (DockStack target){
-                       if (RootDock.CenterDockedObj is DockWindow && DockingPosition == Alignment.Center)
-                               return;
-                       
                        lock (IFace.UpdateMutex) {
                                IsDocked = true;
                                //undockingMousePosOrig = lastMousePos;
@@ -156,17 +156,23 @@ namespace Crow
                                LastSlots = LastPaintedSlot = Slot = default(Rectangle);
                                Left = Top = 0;
 
-                               RootDock.RemoveChild (this);
+                               Group g = Parent as Group;
+                               g.RemoveChild (this);
 
                                target.Dock (this);
                        }
                }
+
                protected override void close ()
                {
                        if (isDocked)
                                Undock ();
                        base.close ();
                }
+
+               public string ExportWinConfigs () {                     
+                       return string.Format ("{0};{1};{2}", this.Name, DockingPosition, savedSlot);
+               }
        }
 }
 
index 6c55e34eae9645a7e42d3010d2c83f610789cbc1..1aa4fa3777778b61c8cd0f3318e0aa0b294e3724 100644 (file)
@@ -44,8 +44,6 @@ namespace Crow
 
                int dockingThreshold;
 
-               public DockStack SubStack = null;
-               public GraphicObject CenterDockedObj = null;
 
                [XmlAttributeAttribute][DefaultValue(10)]
                public virtual int DockingThreshold {
@@ -58,42 +56,29 @@ namespace Crow
                        }
                }
 
-               protected override void onInitialized (object sender, EventArgs e)
-               {
-                       base.onInitialized (sender, e);
-                       CenterDockedObj = new GraphicObject (IFace) { IsEnabled = false };
-               }
-
                public override void AddChild (GraphicObject g)
                {                               
                        base.AddChild (g);
                        g.LogicalParent = this;
                }
-               public override void RemoveChild (GraphicObject child)
-               {
-//                     lock (IFace.UpdateMutex) {
-//                             RegisterClip (ScreenCoordinates (LastPaintedSlot));
-//                     }
-                       base.RemoveChild (child);
-               }
 
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {                       
                        if (IFace.DragAndDropOperation?.DragSource as DockWindow != null) {
                                DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;
-                               if (!dw.IsDocked)
-                                       dw.MoveAndResize (e.XDelta, e.YDelta);
-                               if (SubStack == null) {
-                                       DockStack ds = new DockStack (IFace);
-                                       SubStack = ds;
-                                       InsertChild (0, SubStack);
-                                       ds.LogicalParent = this;
-                                       ds.AddChild (CenterDockedObj);
-                                       ds.SubStack = CenterDockedObj;
+                               if (!dw.IsDocked) {
+                                       Rectangle r = dw.ScreenCoordinates (dw.Slot);
+                                       Point p = ScreenPointToLocal (e.Position);
+                                       dw.Left = p.X - r.Width / 2;
+                                       dw.Top = p.Y - r.Height / 2;
                                }
                        }
                        base.onMouseMove (sender, e);
                }
+
+               public string ExportWinConfigs () {
+                       return "";      
+               }
        }
 }
 
index f23b0bba09881f7870b4f3d0bf1f31e516ae3337..587f86dc5a4afd9e6b91cbb32d266fb03a21843d 100644 (file)
@@ -230,7 +230,7 @@ namespace Crow
                {
                        base.RemoveChild (child);
                        if (child == stretchedGO) {
-                               stretchedGO.LastSlots = default(Rectangle);
+                               //stretchedGO.LastSlots = default(Rectangle);
                                stretchedGO = null;
                                RegisterForLayouting (LayoutingType.Sizing);
                                return;
index 1e35f5b8e8e48c18fae52fdf02dfef9ed2b132b3..911ea7bd0150d7951a67f632bd291c2d8e483a60 100644 (file)
@@ -604,23 +604,24 @@ namespace Crow
                                        if (value < MinimumSize.Width || (value > MaximumSize.Width && MaximumSize.Width > 0))
                                                return;
                                }
-                               Measure lastWP = WidthPolicy;
+                               Measure old = width;
                                width = value;
                                NotifyValueChanged ("Width", width);
-                               if (WidthPolicy != lastWP) {
-                                       NotifyValueChanged ("WidthPolicy", WidthPolicy);
+                               if (width == Measure.Stretched || old == Measure.Stretched) {
+                                       //NotifyValueChanged ("WidthPolicy", width.Policy);
                                        //contentSize in Stacks are only update on childLayoutChange, and the single stretched
                                        //child of the stack is not counted in contentSize, so when changing size policy of a child
                                        //we should adapt contentSize
                                        //TODO:check case when child become stretched, and another stretched item already exists.
-                                       if (parent is GenericStack) {//TODO:check if I should test Group instead
-                                               if ((parent as GenericStack).Orientation == Orientation.Horizontal) {
-                                                       if (lastWP == Measure.Fit)
-                                                               (parent as GenericStack).contentSize.Width -= this.LastSlots.Width;
+                                       GenericStack gs = Parent as GenericStack;
+                                       if (gs != null){ //TODO:check if I should test Group instead
+                                               if (gs.Orientation == Orientation.Horizontal) {
+                                                       if (width == Measure.Stretched)
+                                                               gs.contentSize.Width -= this.LastSlots.Width;
                                                        else
-                                                               (parent as GenericStack).contentSize.Width += this.LastSlots.Width;
+                                                               gs.contentSize.Width += this.LastSlots.Width;
                                                }
-                                       }
+                                       }                                                       
                                }
 
                                this.RegisterForLayouting (LayoutingType.Width);
@@ -644,17 +645,18 @@ namespace Crow
                                        if (value < MinimumSize.Height || (value > MaximumSize.Height && MaximumSize.Height > 0))
                                                return;
                                }
-                               Measure lastHP = HeightPolicy;
+                               Measure old = height;
                                height = value;
                                NotifyValueChanged ("Height", height);
-                               if (HeightPolicy != lastHP) {
-                                       NotifyValueChanged ("HeightPolicy", HeightPolicy);
-                                       if (parent is GenericStack) {
-                                               if ((parent as GenericStack).Orientation == Orientation.Vertical) {
-                                                       if (lastHP == Measure.Fit)
-                                                               (parent as GenericStack).contentSize.Height -= this.LastSlots.Height;
+                               if (height == Measure.Stretched || old == Measure.Stretched) {
+                                       //NotifyValueChanged ("HeightPolicy", HeightPolicy);
+                                       GenericStack gs = Parent as GenericStack;
+                                       if (gs != null){ //TODO:check if I should test Group instead
+                                               if (gs.Orientation == Orientation.Vertical) {
+                                                       if (height == Measure.Stretched)
+                                                               gs.contentSize.Height -= this.LastSlots.Height;
                                                        else
-                                                               (parent as GenericStack).contentSize.Height += this.LastSlots.Height;
+                                                               gs.contentSize.Height += this.LastSlots.Height;
                                                }
                                        }
                                }
@@ -663,13 +665,13 @@ namespace Crow
                        }
                }
                /// <summary>
-               /// Used for binding on dimensions, this property will never hold fixed size, but instead only
+               /// Was Used for binding on dimensions, this property will never hold fixed size, but instead only
                /// Fit or Stretched, **with inherited state implementation, it is not longer used in binding**
                /// </summary>
                [XmlIgnore]public virtual Measure WidthPolicy { get {
                                return Width.IsFit ? Measure.Fit : Measure.Stretched; } }
                /// <summary>
-               /// Used for binding on dimensions, this property will never hold fixed size, but instead only
+               /// Was Used for binding on dimensions, this property will never hold fixed size, but instead only
                /// Fit or Stretched, **with inherited state implementation, it is not longer used in binding**
                /// </summary>
                [XmlIgnore]public virtual Measure HeightPolicy { get {
index b2814393e91a4ae95232f99e8112fd481951a18a..584c180e53838ee8f2bfb9e07a79604750b5fc59 100644 (file)
@@ -227,7 +227,6 @@ namespace Crow
                        tv.AddChild (this);
                }
                #region Mouse Handling
-               public bool HoldCursor = false;
                public override bool PointIsIn (ref Point m)
                {
                        if (!base.PointIsIn (ref m))
@@ -238,15 +237,9 @@ namespace Crow
                        else
                                return this.isSelected;
                }
-               public override void onMouseDown (object sender, MouseButtonEventArgs e)
-               {
-                       base.onMouseDown (sender, e);
-                       HoldCursor = true;
-               }
                public override void onMouseUp (object sender, MouseButtonEventArgs e)
                {
                        base.onMouseUp (sender, e);
-                       HoldCursor = false;
                        tview.UpdateLayout (LayoutingType.ArrangeChildren);
                }
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
@@ -256,7 +249,7 @@ namespace Crow
                        if (Parent == null)
                                return;
                        
-                       if (!(HasFocus && HoldCursor))
+                       if (!IsDragged)
                                return;
 
                        TabView tv = Parent as TabView;
index 49d8729d4a1f0f6dd7a8be3ed02dfb315180b86b..304e820d8065224048978e9f422a58ed6cfea4a4 100644 (file)
@@ -215,7 +215,7 @@ namespace Crow
                                else
                                        adjustedTab = -1;
 
-                               Console.WriteLine ("tabspace: {0} tw:{1}", tabSpace, tabWidth);
+                               //Console.WriteLine ("tabspace: {0} tw:{1}", tabSpace, tabWidth);
 
                                childrenRWLock.EnterReadLock();
                                TabItem[] tabItms = Children.Cast<TabItem>().OrderBy (t=>t.ViewIndex).ToArray();
@@ -227,7 +227,7 @@ namespace Crow
                                                continue;
                                        tabItms [i].NotifyValueChanged ("TabHeight", tabHeight);
                                        tabItms [i].NotifyValueChanged ("TabWidth", TabWidth);
-                                       if (!tabItms [i].HoldCursor) {
+                                       if (!tabItms [i].IsDragged) {
                                                tabItms [i].TabOffset = curOffset;
                                                //Console.WriteLine ("offset: {0}=>{1}", tabItms [i].Name, tabItms [i].TabOffset);
                                        }