]> O.S.I.I.S - jp/crow.git/commitdiff
crowIde wip, docker wip, stack remove child debug
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 4 Mar 2018 10:28:09 +0000 (11:28 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 4 Mar 2018 10:28:09 +0000 (11:28 +0100)
23 files changed:
Crow.csproj
Default.style
Templates/DockWindow.template
Tests/Interfaces/Experimental/testDock.crow
Tests/Interfaces/Experimental/testStack.crow [new file with mode: 0644]
Tests/Tests.csproj
src/CompilerServices/CompilerServices.cs
src/GraphicObjects/ColorPicker.cs
src/GraphicObjects/DockStack.cs [new file with mode: 0644]
src/GraphicObjects/DockWindow.cs
src/GraphicObjects/Docker.cs
src/GraphicObjects/Expandable.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/TemplatedGroup.cs
src/GraphicObjects/Wrapper.cs
src/IMLAttributes.cs [new file with mode: 0644]
src/Instantiator.cs
src/Interface.cs
src/Measure.cs
src/StyleReader.cs

index 91b16e313ca1513089c58a586ccdc151b8650555..7a0ffadaee265d9c44fb44cab2edd6653725e62b 100644 (file)
     <Compile Include="src\GraphicObjects\Docker.cs" />
     <Compile Include="src\GraphicObjects\DockWindow.cs" />
     <Compile Include="src\ParsingException.cs" />
+    <Compile Include="src\IMLAttributes.cs" />
+    <Compile Include="src\GraphicObjects\DockStack.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
index c5e42347c95ddb33da07867a8aac3bdf2912bb2f..3c260b5c746f55c7aa7c44d5672b6d0b7b0f4b62 100644 (file)
@@ -58,12 +58,6 @@ MenuItem {
        MouseLeave = "{Foreground=LightGray;Background=Transparent;}";
        SelectionBackground = "Transparent";
 }
-Docker {
-       AllowDrop = "true";
-}
-DockWindow {
-       AllowDrag = "true";
-}
 MessageBox {
        Background = "0.1,0.1,0.2,0.7";
        Width = "Fit";
@@ -79,7 +73,8 @@ Slider {
 }
 Splitter {
        Focusable = "true";
-       Background = "DimGray";
+       Margin = "1";
+       Background = "White";
 }
 Spinner {
        Foreground = "DimGray";
@@ -114,10 +109,20 @@ ToolWindow {
        Width = "150";
        Height = "150";
 }
-DocksView {
+Docker {
+       AllowDrop = "false";
+       Margin="0";
+       Focusable="true";
+}
+DockStack {
+       Margin="1";
        AllowDrop = "true";
+       Focusable="true";
+       DragEnter="{Background=DarkBlue}";
+       DragLeave="{Background=Jet}";
+       EndDrag="{Background=Jet}";
 }
-DockingView {
+DockWindow {
        Focusable = "true";
        AllowDrag = "true";
 }
index 0a3b4e019e55f01986f1e6aa8bcf66822ca174e5..192c6f0966c7831c44c74476bffde4e118dba0cc 100755 (executable)
@@ -1,24 +1,22 @@
 <?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}"
+<GraphicObject Background="{./Background}"/>
+<!--<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}"
                                Background="{./Background}"
                                MouseEnter="./onBorderMouseEnter"
                                MouseLeave="./onBorderMouseLeave">
        <VerticalStack Spacing="0">
-<!--           <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{./WidthPolicy}" Height="Fit"
-                               Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">-->
-                       <HorizontalStack Background="vgradient|0:0.5,0.6,0.5,0.5|1:0.2,0.3,0.3,0.7"
-                                       Name="hs" Margin="2" Spacing="0" Height="Fit">
-                               <GraphicObject Width="5"/>
-                               <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
-                               <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Center" Text="{./Caption}" />
-                               <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
-                                       MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
-                                       <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Images.Icons.exit2.svg"
-                                                MouseClick="./butQuitPress"/>
-                               </Border>
-                               <GraphicObject Width="5"/>
-                       </HorizontalStack>
-<!--           </Border>-->
+               <HorizontalStack Background="vgradient|0:0.5,0.6,0.5,0.5|1:0.2,0.3,0.3,0.7"
+                               Name="hs" Margin="2" Spacing="0" Height="Fit">
+                       <GraphicObject Width="5"/>
+                       <Image Margin="1" Width="12" Height="12" Path="{./Icon}"/>
+                       <Label Width="Stretched" Foreground="White" Margin="1" TextAlignment="Center" Text="{./Caption}" />
+                       <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent"  Height="12" Width="12"
+                               MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
+                               <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Images.Icons.exit2.svg"
+                                        MouseClick="./butQuitPress"/>
+                       </Border>
+                       <GraphicObject Width="5"/>
+               </HorizontalStack>
                <Container Name="Content" MinimumSize="50,50" Background="0.5,0.5,0.5,0.5"/>
        </VerticalStack>
-</Border>
+</Border>-->
index 8a9df9c5a00613283c4109e8c0a17c5c4ee2a036..71301686b7522c7caa36a382d5f2bf0e9b7cb623 100644 (file)
@@ -1,19 +1,26 @@
 <?xml version="1.0"?>
-<!--<Docker Background="Jet" Margin = "0" Focusable="true" >
-       <DockWindow Focusable="true" Caption="View 1" Width="100" Height="100"><GraphicObject Background="Green"/></DockWindow>
-       <DockWindow Focusable="true" Caption="View 2" Resizable = "true" Width="100" Height="100"><GraphicObject Background="Blue"/></DockWindow>
-       <DockWindow Focusable="true" Caption="View 3" Resizable = "true" Width="100" Height="100"><GraphicObject Background="Yellow"/></DockWindow>
-       <DockWindow Focusable="true" Caption="View 4" Resizable = "true" Width="100" Height="100"><GraphicObject Background="Black"/></DockWindow>
-</Docker>-->
+<Docker >
+       <DockWindow Left="100" Top="100" Width="150" Height="150" Background="DarkRed"/>
+       <DockWindow Left="200" Top="200" Width="150" Height="150" Background="DarkGreen"/>
+       <DockWindow Left="300" Top="300" Width="150" Height="150" Background="Blue"/>
+       <DockWindow Left="400" Top="400" Width="150" Height="150" Background="DarkYellow"/>
+       <DockWindow Left="500" Top="500" Width="150" Height="150" Background="Yellow"/>
+</Docker>
 <!--<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>
        <Window Top="300" Left="300" Focusable="true" Caption="View 3" Resizable = "true" Width="300" Height="300"><GraphicObject Focusable="true" Background="Yellow" MouseEnter="{Background=Gray}" MouseLeave="{Background=Yellow}"/></Window>
        <Window Top="400" Left="400" Focusable="true" Caption="View 4" Resizable = "true" Width="300" Height="300"><GraphicObject Focusable="true" Background="Black" MouseEnter="{Background=Gray}" MouseLeave="{Background=Black}"/></Window>
 </Group>-->
-<Docker Background="Jet" Margin = "0" Focusable="true" >
-       <DockWindow Top="100" Left="100" Focusable="true" Caption="View 1" Width="300" Height="300"><GraphicObject Background="Green" Focusable="true" MouseEnter="{Background=Gray}" MouseLeave="{Background=Green}"/></DockWindow>
+<!--<Docker >
+       <DockWindow Resizable = "true" Top="100" Left="100" Caption="View 1" Width="300" Height="300">
+               <VerticalStack Background="DarkGreen" Focusable="true">
+                       <Label Text="{../../Left}" Background="Black" Width="Stretched"/>
+                       <Label Text="{../../Top}" Background="Black"/>
+                       <Label Text="{../../LogicalParent}" Background="Black"/>
+               </VerticalStack>
+       </DockWindow>
        <DockWindow 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}"/></DockWindow>
        <DockWindow Top="300" Left="300" Focusable="true" Caption="View 3" Resizable = "true" Width="300" Height="300"><GraphicObject Focusable="true" Background="Yellow" MouseEnter="{Background=Gray}" MouseLeave="{Background=Yellow}"/></DockWindow>
        <DockWindow Top="400" Left="400" Focusable="true" Caption="View 4" Resizable = "true" Width="300" Height="300"><GraphicObject Focusable="true" Background="Black" MouseEnter="{Background=Gray}" MouseLeave="{Background=Black}"/></DockWindow>
-</Docker>
\ No newline at end of file
+</Docker>-->
\ No newline at end of file
diff --git a/Tests/Interfaces/Experimental/testStack.crow b/Tests/Interfaces/Experimental/testStack.crow
new file mode 100644 (file)
index 0000000..054c3f5
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<Window Width="600" Height="500">
+<VerticalStack Margin="20" Background="Jet" Spacing="10">
+       <GraphicObject Height="100" Width="500" Background="Green"/>
+       <Splitter/>
+       <HorizontalStack>
+               <GraphicObject Height="Stretched" Width="100" Background="Red"/>
+               <Splitter/>
+               <GraphicObject Height="Stretched" Width="100" Background="DarkRed"/>
+       </HorizontalStack>
+       <Splitter/>
+       <GraphicObject Height="100" Width="500" Background="Green"/>
+</VerticalStack>
+</Window>
+<!--<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>
+       <Window Top="300" Left="300" Focusable="true" Caption="View 3" Resizable = "true" Width="300" Height="300"><GraphicObject Focusable="true" Background="Yellow" MouseEnter="{Background=Gray}" MouseLeave="{Background=Yellow}"/></Window>
+       <Window Top="400" Left="400" Focusable="true" Caption="View 4" Resizable = "true" Width="300" Height="300"><GraphicObject Focusable="true" Background="Black" MouseEnter="{Background=Gray}" MouseLeave="{Background=Black}"/></Window>
+</Group>-->
+<!--<Docker >
+       <DockWindow Resizable = "true" Top="100" Left="100" Caption="View 1" Width="300" Height="300">
+               <VerticalStack Background="DarkGreen" Focusable="true">
+                       <Label Text="{../../Left}" Background="Black" Width="Stretched"/>
+                       <Label Text="{../../Top}" Background="Black"/>
+                       <Label Text="{../../LogicalParent}" Background="Black"/>
+               </VerticalStack>
+       </DockWindow>
+       <DockWindow 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}"/></DockWindow>
+       <DockWindow Top="300" Left="300" Focusable="true" Caption="View 3" Resizable = "true" Width="300" Height="300"><GraphicObject Focusable="true" Background="Yellow" MouseEnter="{Background=Gray}" MouseLeave="{Background=Yellow}"/></DockWindow>
+       <DockWindow Top="400" Left="400" Focusable="true" Caption="View 4" Resizable = "true" Width="300" Height="300"><GraphicObject Focusable="true" Background="Black" MouseEnter="{Background=Gray}" MouseLeave="{Background=Black}"/></DockWindow>
+</Docker>-->
\ No newline at end of file
index 677eec33cdda71d77b29d8b331242cc21e16c02d..30fe50c3e5077b5cb42ac3985e2800f156884cad 100644 (file)
     <None Include="Interfaces\Experimental\testDock.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\Experimental\testStack.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index 955a0d69c773b7cafbd7aba12a96b2b471bcf36e..12a020ffa73c9d1f8b24a96a67764768f7f0678e 100644 (file)
@@ -97,6 +97,11 @@ namespace Crow.IML
                
                internal static MethodInfo miCreateExpDel = typeof(ItemTemplate).GetMethod ("CreateExpandDelegate");
                internal static FieldInfo fiFetchMethodName = typeof(ItemTemplate).GetField("fetchMethodName", BindingFlags.Instance | BindingFlags.NonPublic);
+
+               #if DESIGN_MODE
+               internal static MethodInfo miDicStrStrAdd = typeof(Dictionary<string, string>).GetMethod ("set_Item", new Type[] { typeof(string), typeof(string) });
+               #endif
+
                #region tree handling methods
                internal static FieldInfo fiChild = typeof(PrivateContainer).GetField ("child", BindingFlags.Instance | BindingFlags.NonPublic);
                internal static MethodInfo miSetChild = typeof (Container).GetMethod ("SetChild");
index 3a5ec23f4769eea17fd4d7ae46e2b0726a07c0ad..ee0d31daaadba10b89c199de0fa7bd13886535b3 100644 (file)
@@ -165,7 +165,11 @@ namespace Crow
                                NotifyValueChanged ("SelectedColorName", n);
                        else
                                NotifyValueChanged ("SelectedColorName", "-");
-                       NotifyValueChanged ("HexColor", ((int)R).ToString ("X2") + ((int)G).ToString ("X2") + ((int)B).ToString ("X2") + ((int)A).ToString ("X2"));
+                       NotifyValueChanged ("HexColor",
+                               ((int)Math.Round(R)).ToString ("X2") +
+                               ((int)Math.Round(G)).ToString ("X2") +
+                               ((int)Math.Round(B)).ToString ("X2") +
+                               ((int)Math.Round(A)).ToString ("X2"));
                }
                void notifyRGBAHasChanged(){
                        NotifyValueChanged ("R", R);
diff --git a/src/GraphicObjects/DockStack.cs b/src/GraphicObjects/DockStack.cs
new file mode 100644 (file)
index 0000000..29ebe0e
--- /dev/null
@@ -0,0 +1,299 @@
+//
+// DockStack.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Crow.IML;
+
+namespace Crow
+{
+       public class DockStack : GenericStack
+       {
+               internal static Instantiator instStack, instSplit, instSpacer;
+
+               int dockingDiv = 5;
+
+               GraphicObject subStack = null;
+               public GraphicObject SubStack {
+                       get { return subStack;}
+                       set{ subStack=value; }
+               }
+
+               public DockStack ()     {}
+               public DockStack (Interface iface) : base (iface) {}
+
+               public override bool PointIsIn (ref Point m)
+               {                       
+                       if (!base.PointIsIn(ref m))
+                               return false;
+
+                       Group p = Parent as Group;
+                       if (p != null) {
+                               lock (p.Children) {
+                                       for (int i = p.Children.Count - 1; i >= 0; i--) {
+                                               if (p.Children [i] == this)
+                                                       break;
+                                               if (p.Children [i].IsDragged)
+                                                       continue;
+                                               if (p.Children [i].Slot.ContainsOrIsEqual (m)) {                                                
+                                                       return false;
+                                               }
+                                       }
+                               }
+                       }
+                       return Slot.ContainsOrIsEqual(m);
+               }
+//             protected override void onDragEnter (object sender, DragDropEventArgs e)
+//             {
+//                     base.onDragEnter (sender, e);
+//                     showDock = true;
+//             }
+//             protected override void onDragLeave (object sender, DragDropEventArgs e)
+//             {
+//                     base.onDragLeave (sender, e);
+//                     showDock = false;
+//             }
+               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)) {
+                                               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;
+
+                               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
+                                       dw.DockingPosition = Alignment.Center;
+
+                               if (curDockPos != dw.DockingPosition)
+                                       RegisterForGraphicUpdate ();
+                       }
+                       base.onMouseMove (sender, e);
+               }
+               static Orientation GetOrientation (Alignment a){
+                       return (a==Alignment.Left) ||(a==Alignment.Right) ? Orientation.Horizontal : Orientation.Vertical;
+               }
+               protected override void onDraw (Cairo.Context gr)
+               {
+                       gr.Save ();
+
+                       Rectangle rBack = new Rectangle (Slot.Size);
+
+                       Background.SetAsSource (gr, rBack);
+                       CairoHelpers.CairoRectangle (gr, rBack, CornerRadius);
+                       gr.Fill ();
+
+                       if (ClipToClientRect) {
+                               //clip to client zone
+                               CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+                               gr.Clip ();
+                       }
+
+                       childrenRWLock.EnterReadLock ();
+
+                       foreach (GraphicObject g in Children)
+                               g.Paint (ref gr);                       
+
+                       childrenRWLock.ExitReadLock ();
+
+
+                       if (!IsDropTarget) {
+                               gr.Restore ();
+                               return;
+                       }
+
+                       DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;
+                       if (!dw.IsDocked) {
+                               
+                               Rectangle r;
+
+                               if (GetOrientation (dw.DockingPosition) == Orientation || SubStack == null)
+                                       r = ClientRectangle;
+                               else
+                                       r = SubStack.ClientRectangle + SubStack.Slot.Position + ClientRectangle.TopLeft;
+                               
+                               switch (dw.DockingPosition) {
+                               case Alignment.Top:
+                                       gr.Rectangle (r.Left, r.Top, r.Width, r.Height / dockingDiv);
+                                       break;
+                               case Alignment.Bottom:
+                                       gr.Rectangle (r.Left, r.Bottom - r.Height / dockingDiv, r.Width, r.Height / dockingDiv);
+                                       break;
+                               case Alignment.Left:
+                                       gr.Rectangle (r.Left, r.Top, r.Width / dockingDiv, r.Height);
+                                       break;
+                               case Alignment.Right:
+                                       gr.Rectangle (r.Right - r.Width / dockingDiv, r.Top, r.Width / dockingDiv, r.Height);
+                                       break;
+                               }
+                               gr.LineWidth = 1;
+                               gr.SetSourceRGBA (0.4, 0.4, 0.9, 0.4);
+                               gr.FillPreserve ();
+                               gr.SetSourceRGBA (0.9, 0.9, 1.0, 0.8);
+                               gr.Stroke ();
+                       }
+                       gr.Restore ();  
+               }
+               public void Undock (DockWindow dw){
+                       RemoveChild(dw);
+
+                       if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top)                                
+                               RemoveChild (0);
+                        else
+                               RemoveChild (Children.Count - 1);
+
+                       if (Children.Count > 1)
+                               return;
+                       DockStack dsp = Parent as DockStack;
+                       if (dsp == null) {
+                               SubStack = null;
+                               RemoveChild (0);
+                               return;
+                       }
+                       GraphicObject g = Children [0];
+                       RemoveChild (g);
+                       int i = dsp.Children.IndexOf (this);
+                       dsp.RemoveChild (this);
+                       dsp.AddChild (g);
+                       dsp.SubStack = g;
+//                     if (SubStack is DockStack) {
+//
+//                     } else {
+//                             int i = p.Children.IndexOf (this);
+//                             p.RemoveChild (this);
+//                             if (p is DockStack) {
+//                                     DockStack dsp = p as DockStack;
+//                                     dsp.SubStack = instSpacer.CreateInstance ();
+//                                     dsp.AddChild (dsp.SubStack);
+//                             }
+//                     }
+
+               }
+               public void Dock(DockWindow dw){
+                       checkInstantiators();
+
+                       Splitter splitter = instSplit.CreateInstance<Splitter> ();
+                       Rectangle r = ClientRectangle;
+
+                       int vTreshold = r.Height / dockingDiv;
+                       int hTreshold = r.Width / dockingDiv;
+
+                       DockStack activeStack = this;
+
+                       if (SubStack == null) {
+                               activeStack = this;
+                               SubStack = instSpacer.CreateInstance ();
+                       }else if (GetOrientation (dw.DockingPosition) != Orientation) {
+                               int i = Children.IndexOf (SubStack);
+                               RemoveChild (SubStack);
+                               activeStack = instStack.CreateInstance<DockStack> ();
+                               activeStack.SubStack = instSpacer.CreateInstance ();
+                               SubStack = activeStack;
+                               InsertChild(i, activeStack);                             
+                       }
+
+                       switch (dw.DockingPosition) {
+                       case Alignment.Top:                                             
+                               dw.Height = vTreshold;
+                               dw.Width = Measure.Stretched;
+                               if (activeStack.Children.Count == 0) {
+                                       activeStack.Orientation = Orientation.Vertical;
+                                       activeStack.AddChild (dw);
+                                       activeStack.AddChild (splitter);
+                                       activeStack.AddChild (activeStack.SubStack);
+                               } else {
+                                       activeStack.InsertChild (0, dw);
+                                       activeStack.InsertChild (0, splitter);
+                               }
+                               break;
+                       case Alignment.Bottom:
+                               dw.Height = vTreshold;
+                               dw.Width = Measure.Stretched;
+                               if (activeStack.Children.Count == 0) {
+                                       activeStack.Orientation = Orientation.Vertical;
+                                       activeStack.AddChild (activeStack.SubStack);
+                                       activeStack.AddChild (splitter);
+                                       activeStack.AddChild (dw);
+                               } else {
+                                       activeStack.AddChild (splitter);
+                                       activeStack.AddChild (dw);
+                               }
+                               break;
+                       case Alignment.Left:
+                               dw.Width = hTreshold;
+                               dw.Height = Measure.Stretched;
+                               if (activeStack.Children.Count == 0) {
+                                       activeStack.Orientation = Orientation.Horizontal;
+                                       activeStack.AddChild (dw);
+                                       activeStack.AddChild (splitter);
+                                       activeStack.AddChild (activeStack.SubStack);
+                               } else {
+                                       activeStack.InsertChild (0, dw);
+                                       activeStack.InsertChild (0, splitter);
+                               }
+                               break;
+                       case Alignment.Right:
+                               dw.Width = hTreshold;
+                               dw.Height = Measure.Stretched;
+                               if (activeStack.Children.Count == 0) {
+                                       activeStack.Orientation = Orientation.Horizontal;
+                                       activeStack.AddChild (activeStack.SubStack);
+                                       activeStack.AddChild (splitter);
+                                       activeStack.AddChild (dw);
+                               } else {
+                                       activeStack.AddChild (splitter);
+                                       activeStack.AddChild (dw);
+                               }
+                               break;
+                       }
+               }
+
+               void checkInstantiators () {
+                       if (instStack != null)
+                               return;
+                       instStack = IFace.CreateITorFromIMLFragment (@"<DockStack/>");
+                       instSplit = IFace.CreateITorFromIMLFragment (@"<Splitter/>");
+                       instSpacer = IFace.CreateITorFromIMLFragment (@"<GraphicObject Background='Jet' IsEnabled='false'/>");
+               }
+
+       }
+}
+
index b68a308566469affefdea19cf07e5704bb320f89..4c71c92d3c901ed6462793fbd0de3d58ccba4fec 100644 (file)
@@ -35,6 +35,7 @@ namespace Crow
                }
                #endregion
 
+               int undockThreshold = 10;
                bool isDocked = false;
                Alignment docking = Alignment.Center;
 
@@ -43,6 +44,8 @@ namespace Crow
                Rectangle savedSlot;    //last undocked slot recalled when view is undocked
                bool wasResizable;
 
+               public Docker RootDock { get { return LogicalParent as Docker; }}
+
                public bool IsDocked {
                        get { return isDocked; }
                        set {
@@ -61,12 +64,7 @@ namespace Crow
                                NotifyValueChanged ("DockingPosition", DockingPosition);
                        }
                }
-               protected override void onDrop (object sender, DragDropEventArgs e)
-               {
-                       base.onDrop (sender, e);
-                       Docker dv = Parent as Docker;
-                       dv.Dock (this);
-               }
+
                public override bool PointIsIn (ref Point m)
                {                       
                        if (!base.PointIsIn(ref m))
@@ -78,6 +76,8 @@ namespace Crow
                                        for (int i = p.Children.Count - 1; i >= 0; i--) {
                                                if (p.Children [i] == this)
                                                        break;
+                                               if (p.Children [i].IsDragged)
+                                                       continue;
                                                if (p.Children [i].Slot.ContainsOrIsEqual (m)) {                                                
                                                        return false;
                                                }
@@ -113,130 +113,75 @@ namespace Crow
 //                     }
 //             }
 //
-//             public override void onMouseMove (object sender, MouseMoveEventArgs e)
-//             {
-//                     lastMousePos = e.Position;
-//
-//                     if (this.HasFocus && e.Mouse.IsButtonDown (MouseButton.Left) && IsDocked) {
-//                             Docker dv = Parent as Docker;
-//                             if (docking == Alignment.Left) {
-//                                     if (lastMousePos.X - undockingMousePosOrig.X > dv.DockingThreshold)
-//                                             undock ();
-//                             } else if (docking == Alignment.Right) {
-//                                     if (undockingMousePosOrig.X - lastMousePos.X > dv.DockingThreshold)
-//                                             undock ();
-//                             } else if (docking == Alignment.Top) {
-//                                     if (lastMousePos.Y - undockingMousePosOrig.Y > dv.DockingThreshold)
-//                                             undock ();
-//                             } else if (docking == Alignment.Bottom) {
-//                                     if (undockingMousePosOrig.Y - lastMousePos.Y > dv.DockingThreshold)
-//                                             undock ();
-//                             }
-//                             return;
-//                     }
-//
-//                     base.onMouseMove (sender, e);
-//             }
-//             public override void onMouseDown (object sender, MouseButtonEventArgs e)
-//             {
-//                     base.onMouseDown (sender, e);
-//
-//                     if (this.HasFocus && IsDocked && e.Button == MouseButton.Left)
-//                             undockingMousePosOrig = lastMousePos;
-//             }
+               public override void onMouseMove (object sender, MouseMoveEventArgs e)
+               {
+                       lastMousePos = e.Position;
 
-//             protected override void onBorderMouseEnter (object sender, MouseMoveEventArgs e)
-//             {
-//                     base.onBorderMouseEnter (sender, e);
-//
-//                     if (isDocked) {
-//                             switch (docking) {
-//                             case Alignment.Top:
-//                                     if (this.currentDirection != Window.Direction.S)
-//                                             onBorderMouseLeave (this, null);
-//                                     break;
-//                             case Alignment.Left:
-//                                     if (this.currentDirection != Window.Direction.E)
-//                                             onBorderMouseLeave (this, null);
-//                                     break;
-//                             case Alignment.TopLeft:
-//                                     break;
-//                             case Alignment.Right:
-//                                     if (this.currentDirection != Window.Direction.W)
-//                                             onBorderMouseLeave (this, null);
-//                                     break;
-//                             case Alignment.TopRight:
-//                                     break;
-//                             case Alignment.Bottom:
-//                                     if (this.currentDirection != Window.Direction.N)
-//                                             onBorderMouseLeave (this, null);                                        
-//                                     break;
-//                             case Alignment.BottomLeft:
-//                                     break;
-//                             case Alignment.BottomRight:
-//                                     break;
-//                             case Alignment.Center:
-//                                     break;
-//                             default:
-//                                     break;
-//                             }
-//                     }
-//             }
+                       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 ();
+                       }
 
-               void undock () {
-                       this.Left = savedSlot.Left;
-                       this.Top = savedSlot.Top;
-                       this.Width = savedSlot.Width;
-                       this.Height = savedSlot.Height;
+                       base.onMouseMove (sender, e);
+               }
+               public override void onMouseDown (object sender, MouseButtonEventArgs e)
+               {
+                       base.onMouseDown (sender, e);
+
+                       if (this.HasFocus && IsDocked && e.Button == MouseButton.Left)
+                               undockingMousePosOrig = e.Position;
+               }
+               public bool CheckUndock (Point mousePos) {
+                       if (Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold ||
+                           Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold)
+                               return false;
+                       Undock ();
+                       return true;
+               }
+
+               protected override void onStartDrag (object sender, DragDropEventArgs e)
+               {
+                       base.onStartDrag (sender, e);
+
+                       undockingMousePosOrig = IFace.Mouse.Position;
+               }
+               protected override void onDrop (object sender, DragDropEventArgs e)
+               {
+                       if (!isDocked && DockingPosition != Alignment.Center)
+                               dock (e.DropTarget as DockStack);
+                       base.onDrop (sender, e);
+               }
+               public void Undock () {
+                       lock (IFace.UpdateMutex) {
+                               DockStack ds = Parent as DockStack;
+                               ds.Undock (this);
+
+                               RootDock.AddChild (this);
 
-                       IsDocked = false;
-                       Resizable = wasResizable;
+                               this.Left = savedSlot.Left;
+                               this.Top = savedSlot.Top;
+                               this.Width = savedSlot.Width;
+                               this.Height = savedSlot.Height;
+
+                               IsDocked = false;
+                               Resizable = wasResizable;
+                       }
                }
-               void dock (Alignment align){
-                       IsDocked = true;
-                       docking = align;
-                       undockingMousePosOrig = lastMousePos;
-                       savedSlot = this.LastPaintedSlot;
-                       wasResizable = Resizable;
-                       Resizable = false;
-
-                       this.Left = this.Top = 0;
-
-                       switch (align) {
-                       case Alignment.Top:
-                               this.HorizontalAlignment = HorizontalAlignment.Left;
-                               this.VerticalAlignment = VerticalAlignment.Top;
-                               this.Width = Measure.Stretched;
-                               break;
-                       case Alignment.Left:
-                               this.HorizontalAlignment = HorizontalAlignment.Left;
-                               this.VerticalAlignment = VerticalAlignment.Top;
-                               this.Height = Measure.Stretched;
-                               break;
-                       case Alignment.TopLeft:
-                               break;
-                       case Alignment.Right:
-                               this.HorizontalAlignment = HorizontalAlignment.Right;
-                               this.VerticalAlignment = VerticalAlignment.Top;
-                               this.Height = Measure.Stretched;
-                               break;
-                       case Alignment.TopRight:
-                               break;
-                       case Alignment.Bottom:
-                               this.HorizontalAlignment = HorizontalAlignment.Left;
-                               this.VerticalAlignment = VerticalAlignment.Bottom;
-                               this.Width = Measure.Stretched;
-                               break;
-                       case Alignment.BottomLeft:
-                               break;
-                       case Alignment.BottomRight:
-                               break;
-                       case Alignment.Center:
-                               break;
-                       default:
-                               break;
+               void dock (DockStack target){                   
+                       lock (IFace.UpdateMutex) {
+                               IsDocked = true;
+                               undockingMousePosOrig = lastMousePos;
+                               savedSlot = this.LastPaintedSlot;
+                               wasResizable = Resizable;
+                               Resizable = false;
+                               LastSlots = LastPaintedSlot = Slot = default(Rectangle);
+                               Left = Top = 0;
+
+                               RootDock.RemoveChild (this);
+
+                               target.Dock (this);
                        }
-                       
                }
        }
 }
index bb816dd9e4c850cf160852e3986329d3fb7a7d43..dfd386aac328dcc3ab98b5f6b41de001585181af 100644 (file)
@@ -27,45 +27,32 @@ using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using Crow.IML;
+using System.Collections.Generic;
+using System.Diagnostics;
 
 namespace Crow
 {
        public class Docker : Group
-       {
-               static Instantiator instStack, instSplit, instSpacer;
+       {               
                #region CTOR
                static Docker () {
                }
                public Docker () : base ()
                {
-                       instStack = IFace.CreateITorFromIMLFragment (@"<GenericStack Background='Blue' AllowDrop='true' DragEnter='onStackDragEnter'/>");
-                       instSplit = IFace.CreateITorFromIMLFragment (@"<Splitter/>");
-                       instSpacer = IFace.CreateITorFromIMLFragment (@"<GraphicObject Background='Red' IsEnabled='false'/>");
                }
                #endregion
 
-               GenericStack rootStack = null;
+               //GenericStack rootStack = null;
+               DockStack stack = null;
+               int dockingThreshold;
+
+               List<DockWindow> windows = new List<DockWindow>();
 
                public override void AddChild (GraphicObject g)
-               {
-                       DockWindow dw = g as DockWindow;
-                       if (dw == null)
-                               throw new Exception ("Docker accept only DockWindow as child");
-                       
+               {                               
                        base.AddChild (g);
-
-                       dw.LogicalParent = this;
+                       g.LogicalParent = this;
                }
-               public override void RemoveChild (GraphicObject child)
-               {
-                       child.LogicalParent = null;
-
-
-                       base.RemoveChild (child);
-               }
-
-               GenericStack mainStack = null;
-               int dockingThreshold;
 
                [XmlAttributeAttribute][DefaultValue(10)]
                public virtual int DockingThreshold {
@@ -79,57 +66,39 @@ namespace Crow
                        }
                }
 
-               bool showDockingTarget = false;
-               Alignment dockingDirection = Alignment.Center;
-               int dockingDiv = 5;
+               //bool showDockingTarget = false;
+               //Alignment dockingDirection = Alignment.Center;
+               //int dockingDiv = 8;
+               //bool showDock = false;
 
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {                       
                        if (IFace.DragAndDropOperation?.DragSource as DockWindow != null) {
-                               DockWindow dw = IFace.DragAndDropOperation?.DragSource as DockWindow;
-                               if (IFace.DragAndDropOperation.DragSource.Parent == this && !dw.IsDocked)
+                               DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;
+                               if (!dw.IsDocked)
                                        dw.MoveAndResize (e.XDelta, e.YDelta);
-
-                               Rectangle r = ClientRectangle;
-                               int vTreshold = r.Height / dockingDiv;
-                               int hTreshold = r.Width / dockingDiv;
-
-
-                               bool showDock = true;
-
-                               if (dw.Slot.Left < hTreshold)
-                                       dockingDirection = Alignment.Left;
-                               else if (dw.Slot.Right > r.Right - hTreshold)
-                                       dockingDirection = Alignment.Right;
-                               else if (dw.Slot.Top < vTreshold)
-                                       dockingDirection = Alignment.Top;
-                               else if (dw.Slot.Bottom > r.Bottom - vTreshold)
-                                       dockingDirection = Alignment.Bottom;
-                               else {
-                                       dockingDirection = Alignment.Center;
-                                       showDock = false;
+                               if (stack == null) {                            
+                                       stack = new DockStack (IFace);
+                                       InsertChild (0, stack);
+                                       stack.LogicalParent = this;
                                }
-
-                               showDockingTarget = showDock;
-
-                               RegisterForGraphicUpdate ();
-
-                               //System.Diagnostics.Debug.WriteLine ("Dock: {0}", dockingDirection);
-                       } else
-                               showDockingTarget = false;
-
+                       }
                        base.onMouseMove (sender, e);
                }
+               /*
                protected override void onDragEnter (object sender, DragDropEventArgs e)
                {
                        base.onDragEnter (sender, e);
+                       showDock = true;
+                       Console.WriteLine ("showdock=" + showDock);
                }
-               void onStackDragEnter (object sender, DragDropEventArgs e)
+               protected override void onDragLeave (object sender, DragDropEventArgs e)
                {
-                       base.onDragEnter (sender, e);
-
-                       mainStack = sender as GenericStack;
+                       base.onDragLeave (sender, e);
+                       showDock = false;
+                       Console.WriteLine ("showdock=" + showDock);
                }
+
                protected override void onDraw (Cairo.Context gr)
                {
                        gr.Save ();
@@ -149,8 +118,8 @@ namespace Crow
                        childrenRWLock.EnterReadLock ();
 
                        foreach (GraphicObject g in Children) {
-                               if (IFace.DragAndDropOperation?.DragSource == g)
-                                       continue;
+//                             if (IFace.DragAndDropOperation?.DragSource == g)
+//                                     continue;
                                g.Paint (ref gr);
                        }
 
@@ -158,10 +127,10 @@ namespace Crow
 
                        if (showDockingTarget) {
                                Rectangle r;
-                               if (mainStack == null)
+                               if (stack == null)
                                        r = ClientRectangle;
                                else
-                                       r = mainStack.ClientRectangle;
+                                       r = stack.ClientRectangle;
                                
                                switch (dockingDirection) {
                                case Alignment.Top:
@@ -184,73 +153,83 @@ namespace Crow
                                gr.Stroke ();
                        }
 
-                       if (IFace.DragAndDropOperation != null)
-                               IFace.DragAndDropOperation.DragSource.Paint (ref gr);
-
-
                        gr.Restore ();  
                }
+*/
 
+               /*
                public void Dock(DockWindow dw){
+                       checkInstantiators();
+
                        if (dockingDirection == Alignment.Center)
                                return;
+                       
                        lock (IFace.UpdateMutex) {
 
                                Splitter splitter = instSplit.CreateInstance<Splitter> ();
+                               Rectangle r = ClientRectangle;
 
-                               dw.Resizable = false;
-                               dw.Left = dw.Top = 0;
-                               this.RemoveChild (dw);
-
-                               Rectangle r;
-                               if (mainStack == null) {
-                                       mainStack = instStack.CreateInstance<GenericStack> ();
-                                       this.AddChild (mainStack);
-                                       this.putWidgetOnBottom (mainStack);
-                                       r = ClientRectangle;
-                               } else
-                                       r = mainStack.ClientRectangle;                          
+                               if (stack == null) {
+                                       stack = instStack.CreateInstance<GenericStack> ();
+                                       this.AddChild (stack);
+                                       this.putWidgetOnBottom (stack);
+                               } 
                                 
                                int vTreshold = r.Height / dockingDiv;
                                int hTreshold = r.Width / dockingDiv;
 
                                switch (dockingDirection) {
                                case Alignment.Top:                                             
-                                       dw.Width = Measure.Stretched;
-                                       mainStack.Orientation = Orientation.Vertical;
-                                       mainStack.AddChild (dw);
-                                       mainStack.AddChild (splitter);
-                                       //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface));
+                                       dw.Height = vTreshold;
+                                       stack.Orientation = Orientation.Vertical;
+                                       if (stack.Children.Count == 0) {
+                                               stack.AddChild (dw);
+                                               stack.AddChild (splitter);
+                                               stack.AddChild (instSpacer.CreateInstance ());
+                                       } else {
+                                               stack.AddChild (splitter);
+                                               stack.AddChild (dw);
+                                       }
                                        break;
                                case Alignment.Bottom:
-                                       dw.Width = Measure.Stretched;
-                                       mainStack.Orientation = Orientation.Vertical;
-                                       //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface));
-                                       mainStack.AddChild (splitter);
-                                       mainStack.AddChild (dw);
+                                       dw.Height = vTreshold;
+                                       stack.Orientation = Orientation.Vertical;
+                                       if (stack.Children.Count == 0) {
+                                               stack.AddChild (instSpacer.CreateInstance ());
+                                               stack.AddChild (splitter);
+                                               stack.AddChild (dw);
+                                       } else {
+                                               stack.InsertChild (0, dw);
+                                               stack.InsertChild (0, splitter);
+                                       }
                                        break;
                                case Alignment.Left:
-                                       dw.Height = Measure.Stretched;
-                                       mainStack.Orientation = Orientation.Horizontal;
-                                       mainStack.AddChild (dw);
-                                       mainStack.AddChild (splitter);
-                                       //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface));
+                                       dw.Width = hTreshold;
+                                       stack.Orientation = Orientation.Horizontal;
+                                       if (stack.Children.Count == 0) {
+                                               stack.AddChild (dw);
+                                               stack.AddChild (splitter);
+                                               stack.AddChild (instSpacer.CreateInstance ());
+                                       } else {
+                                               stack.AddChild (splitter);
+                                               stack.AddChild (dw);
+                                       }
                                        break;
                                case Alignment.Right:
-                                       dw.Height = Measure.Stretched;
-                                       mainStack.Orientation = Orientation.Horizontal;
-                                       //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface));
-                                       mainStack.AddChild (splitter);
-                                       mainStack.AddChild (dw);
+                                       dw.Width = hTreshold;
+                                       stack.Orientation = Orientation.Horizontal;
+                                       if (stack.Children.Count == 0) {
+                                               stack.AddChild (instSpacer.CreateInstance ());
+                                               stack.AddChild (splitter);
+                                               stack.AddChild (dw);
+                                       } else {
+                                               stack.InsertChild (0, dw);
+                                               stack.InsertChild (0, splitter);
+                                       }
                                        break;
                                }
-
                        }
-               }
-               protected override void onDrop (object sender, DragDropEventArgs e)
-               {
-                       base.onDrop (sender, e);
-               }
+               }*/
        }
 }
 
index aff804f8e16b9e54f1b1782e9fd4942a34c4de11..83d919566a4069b9a41f25b06a4717a90b4e36ac 100644 (file)
@@ -77,7 +77,7 @@ namespace Crow
                                NotifyValueChanged ("Image", image);
                        }
                }
-               [XmlAttributeAttribute][DefaultValue(false)]
+               [DefaultValue(false)]
         public bool IsExpanded
         {
                        get { return _isExpanded; }
index 3d6884e157c36fb1f3a3a3196c5e5783dbf769a4..2df681e480e53cc67ebe936b11f602611efbeb82 100644 (file)
@@ -136,6 +136,46 @@ namespace Crow
                        return base.UpdateLayout(layoutType);
         }
 
+               void adjustStretchedGo (LayoutingType lt){
+                       if (stretchedGO == null)
+                               return;
+                       if (lt == LayoutingType.Width) {
+                               int newW = Math.Max (
+                                                  this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1),
+                                                  stretchedGO.MinimumSize.Width);
+                               if (stretchedGO.MaximumSize.Width > 0)
+                                       newW = Math.Min (newW, stretchedGO.MaximumSize.Width);
+                               if (newW != stretchedGO.Slot.Width) {                                                   
+                                       stretchedGO.Slot.Width = newW;
+                                       stretchedGO.IsDirty = true;
+                                       #if DEBUG_LAYOUTING
+                               Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
+                                       #endif
+                                       stretchedGO.LayoutChanged -= OnChildLayoutChanges;
+                                       stretchedGO.OnLayoutChanges (LayoutingType.Width);
+                                       stretchedGO.LayoutChanged += OnChildLayoutChanges;
+                                       stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
+                               }
+                       } else {
+                               int newH = Math.Max (
+                                       this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
+                                       stretchedGO.MinimumSize.Height);
+                               if (stretchedGO.MaximumSize.Height > 0)
+                                       newH = Math.Min (newH, stretchedGO.MaximumSize.Height);
+                               if (newH != stretchedGO.Slot.Height) {
+                                       stretchedGO.Slot.Height = newH;
+                                       stretchedGO.IsDirty = true;
+                                       #if DEBUG_LAYOUTING
+                                       Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString());
+                                       #endif
+                                       stretchedGO.LayoutChanged -= OnChildLayoutChanges;
+                                       stretchedGO.OnLayoutChanges (LayoutingType.Height);
+                                       stretchedGO.LayoutChanged += OnChildLayoutChanges;
+                                       stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
+                               }                               
+                       }
+               }
+
                public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
                {
                        GraphicObject go = sender as GraphicObject;
@@ -154,24 +194,7 @@ namespace Crow
                                        } else
                                                contentSize.Width += go.Slot.Width - go.LastSlots.Width;
 
-                                       if (stretchedGO != null) {
-                                               int newW = Math.Max (
-                                                                  this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1),
-                                                                  stretchedGO.MinimumSize.Width);
-                                               if (stretchedGO.MaximumSize.Width > 0)
-                                                       newW = Math.Min (newW, stretchedGO.MaximumSize.Width);
-                                               if (newW != stretchedGO.Slot.Width) {                                                   
-                                                       stretchedGO.Slot.Width = newW;
-                                                       stretchedGO.IsDirty = true;
-#if DEBUG_LAYOUTING
-                                       Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
-#endif
-                                                       stretchedGO.LayoutChanged -= OnChildLayoutChanges;
-                                                       stretchedGO.OnLayoutChanges (LayoutingType.Width);
-                                                       stretchedGO.LayoutChanged += OnChildLayoutChanges;
-                                                       stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
-                                               }
-                                       }
+                                       adjustStretchedGo (LayoutingType.Width);                                        
                                        
                                        if (Width == Measure.Fit)
                                                this.RegisterForLayouting (LayoutingType.Width);
@@ -193,24 +216,7 @@ namespace Crow
                                        } else
                                                contentSize.Height += go.Slot.Height - go.LastSlots.Height;
                                        
-                                       if (stretchedGO != null) {
-                                               int newH = Math.Max (
-                                                       this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
-                                                       stretchedGO.MinimumSize.Height);
-                                               if (stretchedGO.MaximumSize.Height > 0)
-                                                       newH = Math.Min (newH, stretchedGO.MaximumSize.Height);
-                                               if (newH != stretchedGO.Slot.Height) {
-                                                       stretchedGO.Slot.Height = newH;
-                                                       stretchedGO.IsDirty = true;
-#if DEBUG_LAYOUTING
-                                       Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString());
-#endif
-                                                       stretchedGO.LayoutChanged -= OnChildLayoutChanges;
-                                                       stretchedGO.OnLayoutChanges (LayoutingType.Height);
-                                                       stretchedGO.LayoutChanged += OnChildLayoutChanges;
-                                                       stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
-                                               }
-                                       }
+                                       adjustStretchedGo (LayoutingType.Height);
 
                                        if (Height == Measure.Fit)
                                                this.RegisterForLayouting (LayoutingType.Height);
@@ -224,6 +230,23 @@ namespace Crow
                }
                #endregion
 
-    
+       public override void RemoveChild (GraphicObject child)
+               {
+                       base.RemoveChild (child);
+                       if (child == stretchedGO) {
+                               stretchedGO = null;
+                               return;
+                       }
+                       if (Orientation == Orientation.Horizontal) {
+                               contentSize.Width -= child.LastSlots.Width;
+                               adjustStretchedGo (LayoutingType.Width);
+                       } else {
+                               contentSize.Height -= child.LastSlots.Height;
+                               adjustStretchedGo (LayoutingType.Height);
+                       }
+
+
+//                     RegisterForLayouting (LayoutingType.ArrangeChildren);
+               }
        }
 }
index adb29e54fb5f71ec618f72eac090e62a29e1102e..db49832e80206cbd8aa4f328604a30a76e3bde5d 100644 (file)
@@ -52,24 +52,37 @@ namespace Crow
                internal ReaderWriterLockSlim parentRWLock = new ReaderWriterLockSlim();
 
                #if DESIGN_MODE
-               static MethodInfo miDesignAddDefLoc = typeof(GraphicObject).GetMethod("design_add_default_location",
+               static MethodInfo miDesignAddDefLoc = typeof(GraphicObject).GetMethod("design_add_style_location",
                        BindingFlags.Instance | BindingFlags.NonPublic);
-               public volatile bool HasChanged = false;
+               static MethodInfo miDesignAddValLoc = typeof(GraphicObject).GetMethod("design_add_iml_location",
+                       BindingFlags.Instance | BindingFlags.NonPublic);
+               
+               public volatile bool design_HasChanged = false;
                public string design_id;
                public int design_line;
                public int design_column;
                public string design_imlPath;
-               public Dictionary<string,string> design_members = new Dictionary<string, string>();
-               public Dictionary<string,FileLocation> design_defaults = new Dictionary<string, FileLocation>();
-               internal void design_add_default_location (string memberName, string path, int line, int col) {
-                       if (design_defaults.ContainsKey(memberName)){
+               public bool design_isTGItem = false;//true if this is a templated item's root
+               public Dictionary<string,string> design_iml_values = new Dictionary<string, string>();
+               public Dictionary<string,string> design_style_values = new Dictionary<string, string>();
+               //public Dictionary<string,FileLocation> design_iml_locations = new Dictionary<string, FileLocation>();
+               public Dictionary<string,FileLocation> design_style_locations = new Dictionary<string, FileLocation>();
+
+               internal void design_add_style_location (string memberName, string path, int line, int col) {
+                       if (design_style_locations.ContainsKey(memberName)){
                                Console.WriteLine ("default value localtion already set for {0}{1}.{2}", this.GetType().Name, this.design_id, memberName);
                                return;
                        }
-                       design_defaults.Add(memberName, new FileLocation(path,line,col));
+                       design_style_locations.Add(memberName, new FileLocation(path,line,col));
                }
-               public bool design_isTGItem = false;
-
+//             internal void design_add_iml_location (string memberName, string path, int line, int col) {
+//                     if (design_iml_locations.ContainsKey(memberName)){
+//                             Console.WriteLine ("IML value localtion already set for {0}{1}.{2}", this.GetType().Name, this.design_id, memberName);
+//                             return;
+//                     }
+//                     design_iml_locations.Add(memberName, new FileLocation(path,line,col));
+//             }
+                       
                public virtual bool FindByDesignID(string designID, out GraphicObject go){
                        go = null;
                        if (this.design_id == designID){
@@ -94,7 +107,7 @@ namespace Crow
                                        getIML (doc, (XmlNode)doc);
                                        doc.WriteTo (xtw);
                                }
-                               this.HasChanged = false;
+                               this.design_HasChanged = false;
                                return sw.ToString ();
                        }
                }
@@ -105,7 +118,7 @@ namespace Crow
                        
                        XmlElement xe = doc.CreateElement(this.GetType().Name);
 
-                       foreach (KeyValuePair<string,string> kv in design_members) {
+                       foreach (KeyValuePair<string,string> kv in design_iml_values) {
                                XmlAttribute xa = doc.CreateAttribute (kv.Key);
                                xa.Value = kv.Value;
                                xe.Attributes.Append (xa);
@@ -257,6 +270,7 @@ namespace Crow
                bool focusable = false;
                bool hasFocus = false;
                bool isActive = false;
+               bool isHover = false;
                bool mouseRepeat;
                protected bool isVisible = true;
                bool isEnabled = true;
@@ -307,6 +321,9 @@ namespace Crow
                internal Size contentSize;
                #endregion
 
+               public void ResetSlots () {
+                       LastSlots = LastPaintedSlot = Slot = default(Rectangle);
+               }
                #region ILayoutable
                [XmlIgnore]public LayoutingType RegisteredLayoutings { get { return registeredLayoutings; } set { registeredLayoutings = value; } }
                //TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject
@@ -364,6 +381,14 @@ namespace Crow
                }
                public virtual Rectangle getSlot () { return Slot;}
                #endregion
+               public Point ScreenPointToLocal(Point p){
+                       Point pt = p - ScreenCoordinates(Slot).TopLeft - ClientRectangle.TopLeft;
+                       if (pt.X < 0)
+                               pt.X = 0;
+                       if (pt.Y < 0)
+                               pt.Y = 0;
+                       return pt;
+               }
 
                #region EVENT HANDLERS
                /// <summary>Occurs when mouse wheel is rolled in this object. It bubbles to the root</summary>
@@ -392,7 +417,11 @@ namespace Crow
                public event EventHandler Focused;
                /// <summary>Occurs when this object loose focus</summary>
                public event EventHandler Unfocused;
-               /// <summary>Occurs when the enabled state this object is set to true</summary>
+               /// <summary>Occurs when mouse is over</summary>
+               public event EventHandler Hover;
+               /// <summary>Occurs when this control is no longer the Hover one</summary>
+               public event EventHandler UnHover;
+               /// <summary>Occurs when this object loose focus</summary>
                public event EventHandler Enabled;
                /// <summary>Occurs when the enabled state this object is set to false</summary>
                public event EventHandler Disabled;
@@ -413,7 +442,7 @@ namespace Crow
 
                #region public properties
                /// <summary>Random value placeholder</summary>
-               [XmlAttributeAttribute]
+               [DesignCategory ("Divers")]
                public object Tag {
                        get { return tag; }
                        set {
@@ -427,7 +456,7 @@ namespace Crow
                /// If enabled, resulting bitmap of graphic object is cached
                /// speeding up rendering of complex object. Default is enabled.
                /// </summary>
-               [XmlAttributeAttribute][DefaultValue(true)]
+               [DesignCategory ("Behavior")][DefaultValue(true)]
                public virtual bool CacheEnabled {
                        get { return cacheEnabled; }
                        set {
@@ -440,7 +469,7 @@ namespace Crow
                /// <summary>
                /// If true, rendering of GraphicObject is clipped inside client rectangle
                /// </summary>
-               [XmlAttributeAttribute][DefaultValue(true)]
+               [DesignCategory ("Appearance")][DefaultValue(true)]
                public virtual bool ClipToClientRect {
                        get { return clipToClientRect; }
                        set {
@@ -461,7 +490,7 @@ namespace Crow
                /// and by template controls to find special element in their template implementation such
                /// as a container or a group to put children in.
                /// </summary>
-               [XmlAttributeAttribute][DefaultValue(null)]
+               [DesignCategory ("Divers")][DefaultValue(null)]
                public virtual string Name {
                        get {
                                #if DEBUG
@@ -481,7 +510,7 @@ namespace Crow
                /// Vertical alignment inside parent, disabled if height is stretched
                /// or top coordinate is not null
                /// </summary>
-               [XmlAttributeAttribute  ()][DefaultValue(VerticalAlignment.Center)]
+               [DesignCategory ("Layout")][DefaultValue(VerticalAlignment.Center)]
                public virtual VerticalAlignment VerticalAlignment {
                        get { return verticalAlignment; }
                        set {
@@ -497,7 +526,7 @@ namespace Crow
                /// Horizontal alignment inside parent, disabled if width is stretched
                /// or left coordinate is not null
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue(HorizontalAlignment.Center)]
+               [DesignCategory ("Layout")][DefaultValue(HorizontalAlignment.Center)]
                public virtual HorizontalAlignment HorizontalAlignment {
                        get { return horizontalAlignment; }
                        set {
@@ -511,7 +540,7 @@ namespace Crow
                /// <summary>
                /// x position inside parent
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue(0)]
+               [DesignCategory ("Layout")][DefaultValue(0)]
                public virtual int Left {
                        get { return left; }
                        set {
@@ -525,7 +554,7 @@ namespace Crow
                /// <summary>
                /// y position inside parent
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue(0)]
+               [DesignCategory ("Layout")][DefaultValue(0)]
                public virtual int Top {
                        get { return top; }
                        set {
@@ -539,7 +568,7 @@ namespace Crow
                /// <summary>
                /// Helper property used to set width and height to fit in one call
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue(false)]
+               [DesignCategory ("Layout")][DefaultValue(false)]
                public virtual bool Fit {
                        get { return Width == Measure.Fit && Height == Measure.Fit ? true : false; }
                        set {
@@ -553,7 +582,7 @@ namespace Crow
                /// Width of this control, by default inherited from parent. May have special values
                /// such as Stretched or Fit. It may be proportionnal or absolute.
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue("Inherit")]
+               [DesignCategory ("Layout")][DefaultValue("Inherit")]
                public virtual Measure Width {
                        get {
                                return width.Units == Unit.Inherit ?
@@ -593,7 +622,7 @@ namespace Crow
                /// Height of this control, by default inherited from parent. May have special values
                /// such as Stretched or Fit. It may be proportionnal or absolute.
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue("Inherit")]
+               [DesignCategory ("Layout")][DefaultValue("Inherit")]
                public virtual Measure Height {
                        get {
                                return height.Units == Unit.Inherit ?
@@ -641,7 +670,7 @@ namespace Crow
                /// Indicate that this object may received focus or not, if not focusable all the descendants are 
                /// affected.
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue(false)]
+               [DesignCategory ("Behaviour")][DefaultValue(false)]
                public virtual bool Focusable {
                        get { return focusable; }
                        set {
@@ -683,9 +712,28 @@ namespace Crow
                        }
                }
                /// <summary>
+               /// true if this control has the pointer hover
+               /// </summary>
+               [XmlIgnore]public virtual bool IsHover {
+                       get { return isHover; }
+                       set {
+                               if (value == isHover)
+                                       return;
+
+                               isHover = value;
+
+                               if (isHover)
+                                       onHover (this, null);
+                               else
+                                       onUnHover (this, null);
+
+                               NotifyValueChanged ("IsHover", isHover);
+                       }
+               }
+               /// <summary>
                /// true if holding mouse button down should trigger multiple click events
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue(false)]
+               [DesignCategory ("Behaviour")][DefaultValue(false)]
                public virtual bool MouseRepeat {
                        get { return mouseRepeat; }
                        set {
@@ -699,7 +747,7 @@ namespace Crow
                /// <summary>
                /// background fill of the control, maybe solid color, gradient, image, or svg
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue("Transparent")]
+               [DesignCategory ("Appearance")][DefaultValue("Transparent")]
                public virtual Fill Background {
                        get { return background; }
                        set {
@@ -720,7 +768,7 @@ namespace Crow
                /// <summary>
                /// Foreground fill of the control, usage may be different among derived controls
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue("White")]
+               [DesignCategory ("Appearance")][DefaultValue("White")]
                public virtual Fill Foreground {
                        get { return foreground; }
                        set {
@@ -734,7 +782,7 @@ namespace Crow
                /// <summary>
                /// Font being used in many controls, it is defined in the base GraphicObject class.
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue("sans,10")]
+               [DesignCategory ("Appearance")][DefaultValue("sans,10")]
                public virtual Font Font {
                        get { return font; }
                        set {
@@ -748,7 +796,7 @@ namespace Crow
                /// <summary>
                /// to get rounded corners
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue(0.0)]
+               [DesignCategory ("Appearance")][DefaultValue(0.0)]
                public virtual double CornerRadius {
                        get { return cornerRadius; }
                        set {
@@ -763,7 +811,7 @@ namespace Crow
                /// This is a single integer for the 4 direction, a gap between the control and it's container,
                /// by default it is filled with the background.
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue(0)]
+               [DesignCategory ("Layout")][DefaultValue(0)]
                public virtual int Margin {
                        get { return margin; }
                        set {
@@ -777,7 +825,7 @@ namespace Crow
                /// <summary>
                /// set the visible state of the control, invisible controls does reserve space in the layouting system.
                /// </summary>
-               [XmlAttributeAttribute][DefaultValue(true)]
+               [DesignCategory ("Appearance")][DefaultValue(true)]
                public virtual bool Visible {
                        get { return isVisible; }
                        set {
@@ -798,7 +846,7 @@ namespace Crow
                /// get or set the enabled state, disabling a control will affect focuability and
                /// also it's rendering which will be grayed
                /// </summary>
-               [XmlAttributeAttribute][DefaultValue(true)]
+               [DesignCategory ("Behaviour")][DefaultValue(true)]
                public virtual bool IsEnabled {
                        get { return isEnabled; }
                        set {
@@ -819,7 +867,7 @@ namespace Crow
                /// <summary>
                /// Minimal width and  height for this control
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue("1,1")]
+               [DesignCategory ("Layout")][DefaultValue("1,1")]
                public virtual Size MinimumSize {
                        get { return minimumSize; }
                        set {
@@ -835,7 +883,7 @@ namespace Crow
                /// <summary>
                /// Maximum width and  height for this control, unlimited if null.
                /// </summary>
-               [XmlAttributeAttribute()][DefaultValue("0,0")]
+               [DesignCategory ("Layout")][DefaultValue("0,0")]
                public virtual Size MaximumSize {
                        get { return maximumSize; }
                        set {
@@ -852,7 +900,7 @@ namespace Crow
                /// Seek first logical tree upward if logicalParent is set, or seek graphic tree for
                /// a not null dataSource that will be active for all descendants having dataSource=null
                /// </summary>
-               [XmlAttributeAttribute]
+               [DesignCategory ("Data")]
                public virtual object DataSource {
                        set {
                                if (DataSource == value)
@@ -893,7 +941,7 @@ namespace Crow
                /// <summary>
                /// Style key to use for this control
                /// </summary>
-               [XmlAttributeAttribute]
+               [DesignCategory ("Appearance")]
                public virtual string Style {
                        get { return style; }
                        set {
@@ -905,7 +953,7 @@ namespace Crow
                                NotifyValueChanged ("Style", style);
                        }
                }
-               [XmlAttributeAttribute]
+               [DesignCategory ("Divers")]
                public virtual string Tooltip {
                        get { return tooltip; }
                        set {
@@ -915,7 +963,7 @@ namespace Crow
                                NotifyValueChanged("Tooltip", tooltip);
                        }
                }
-               [XmlAttributeAttribute]
+               [DesignCategory ("Divers")]
                public IList<Command> ContextCommands {
                        get { return contextCommands; }
                        set {
@@ -1040,7 +1088,9 @@ namespace Crow
                                                name = pi.Name;
                                        else
                                                name = xaa.AttributeName;
-                               }
+                               }else
+                                       name = pi.Name;
+                               
                                int styleIndex = -1;
                                if (styling.Count > 0){
                                        for (int i = 0; i < styling.Count; i++) {
@@ -1057,13 +1107,21 @@ namespace Crow
                                                defaultValue = styling[styleIndex] [name];
 
                                        #if DESIGN_MODE
-                                       FileLocation fl = styling[styleIndex].Locations[name];
-                                       il.Emit (OpCodes.Ldloc_0);
-                                       il.Emit (OpCodes.Ldstr, name);
-                                       il.Emit (OpCodes.Ldstr, fl.FilePath);
-                                       il.Emit (OpCodes.Ldc_I4, fl.Line);
-                                       il.Emit (OpCodes.Ldc_I4, fl.Column);
-                                       il.Emit (OpCodes.Call, miDesignAddDefLoc);
+                                       if (defaultValue != null){
+                                               FileLocation fl = styling[styleIndex].Locations[name];
+                                               il.Emit (OpCodes.Ldloc_0);
+                                               il.Emit (OpCodes.Ldstr, name);
+                                               il.Emit (OpCodes.Ldstr, fl.FilePath);
+                                               il.Emit (OpCodes.Ldc_I4, fl.Line);
+                                               il.Emit (OpCodes.Ldc_I4, fl.Column);
+                                               il.Emit (OpCodes.Call, miDesignAddDefLoc);
+
+                                               il.Emit (OpCodes.Ldloc_0);
+                                               il.Emit (OpCodes.Ldfld, typeof(GraphicObject).GetField("design_style_values"));
+                                               il.Emit (OpCodes.Ldstr, name);
+                                               il.Emit (OpCodes.Ldstr, defaultValue.ToString());
+                                               il.Emit (OpCodes.Call, CompilerServices.miDicStrStrAdd);
+                                       }
                                        #endif
 
                                }else {
@@ -1122,7 +1180,7 @@ namespace Crow
                }
 
                #region Drag&Drop
-               [XmlAttributeAttribute][DefaultValue(false)]
+               [DesignCategory ("DragAndDrop")][DefaultValue(false)]
                public virtual bool AllowDrag {
                        get { return allowDrag; }
                        set {
@@ -1132,7 +1190,7 @@ namespace Crow
                                NotifyValueChanged ("AllowDrag", allowDrag);
                        }
                }
-               [XmlAttributeAttribute][DefaultValue(false)]
+               [DesignCategory ("DragAndDrop")][DefaultValue(false)]
                public virtual bool AllowDrop {
                        get { return allowDrop; }
                        set {
@@ -1193,8 +1251,12 @@ namespace Crow
                protected virtual void onDrop (object sender, DragDropEventArgs e){                     
                        IsDragged = false;
                        Drop.Raise (this, e);
+                       //e.DropTarget.onDragLeave (this, e);//raise drag leave in target
                        Debug.WriteLine(this.ToString() + " : DROP => " + e.ToString());
                }
+               public bool IsDropTarget {
+                       get { return IFace.DragAndDropOperation?.DropTarget == this; }
+               }
 
                #endregion
 
@@ -1314,8 +1376,8 @@ namespace Crow
                public virtual void OnLayoutChanges(LayoutingType  layoutType)
                {
                        #if DEBUG_LAYOUTING
-                       CurrentInterface.currentLQI.Slot = LastSlots;
-                       CurrentInterface.currentLQI.NewSlot = Slot;
+                       IFace.currentLQI.Slot = LastSlots;
+                       IFace.currentLQI.NewSlot = Slot;
                        Debug.WriteLine ("\t\t{0} => {1}",LastSlots,Slot);
                        #endif
 
@@ -1717,26 +1779,38 @@ namespace Crow
                        #if DEBUG_FOCUS
                        Debug.WriteLine("MouseEnter => " + this.ToString());
                        #endif
-
+                       MouseEnter.Raise (this, e);
+               }
+               public virtual void onMouseLeave(object sender, MouseMoveEventArgs e)
+               {
+                       #if DEBUG_FOCUS
+                       Debug.WriteLine("MouseLeave => " + this.ToString());
+                       #endif
+                       MouseLeave.Raise (this, e);
+               }
+               public virtual void onHover(object sender, EventArgs e)
+               {
+                       #if DEBUG_FOCUS
+                       Debug.WriteLine("MouseHover => " + this.ToString());
+                       #endif
                        if (IFace.DragAndDropOperation != null) {
                                if (this.AllowDrop) {
                                        if (IFace.DragAndDropOperation.DragSource != this && IFace.DragAndDropOperation.DropTarget != this)
                                                onDragEnter (this, IFace.DragAndDropOperation);                                 
                                }
                        }
-
-                       MouseEnter.Raise (this, e);
+                       Hover.Raise (this, e);
                }
-               public virtual void onMouseLeave(object sender, MouseMoveEventArgs e)
+               public virtual void onUnHover(object sender, EventArgs e)
                {
                        #if DEBUG_FOCUS
-                       Debug.WriteLine("MouseLeave => " + this.ToString());
+                       Debug.WriteLine("MouseUnHover => " + this.ToString());
                        #endif
                        if (IFace.DragAndDropOperation != null) {
                                if (IFace.DragAndDropOperation.DropTarget == this)
                                        onDragLeave (this, IFace.DragAndDropOperation);
                        }
-                       MouseLeave.Raise (this, e);
+                       UnHover.Raise (this, e);
                }
                #endregion
 
index 0eb1ece239d6215158b38cc6ef9ea5979b7ae7e1..11bf16fba09057e59a7be57d8a4f0f5c78acc1c2 100644 (file)
@@ -114,6 +114,8 @@ namespace Crow
                        childrenRWLock.EnterWriteLock ();
 
                        Children.Remove(child);
+                       child.Parent = null;
+                       //child.ResetSlots ();
 
                        childrenRWLock.ExitWriteLock ();
 
@@ -142,6 +144,9 @@ namespace Crow
                        g.LayoutChanged += OnChildLayoutChanges;
                        g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
                }
+               public virtual void RemoveChild (int idx) {
+                       RemoveChild (children[idx]);
+               }
                public virtual void DeleteChild (int idx) {
                        DeleteChild (children[idx]);
                }
@@ -263,7 +268,7 @@ namespace Crow
                        switch (layoutType) {
                        case LayoutingType.Width:
                                foreach (GraphicObject c in Children) {
-                                       if (c.Width.Units == Unit.Percent)
+                                       if (c.Width.IsRelativeToParent)
                                                c.RegisterForLayouting (LayoutingType.Width);
                                        else
                                                c.RegisterForLayouting (LayoutingType.X);
@@ -271,7 +276,7 @@ namespace Crow
                                break;
                        case LayoutingType.Height:
                                foreach (GraphicObject c in Children) {
-                                       if (c.Height.Units == Unit.Percent)
+                                       if (c.Height.IsRelativeToParent)
                                                c.RegisterForLayouting (LayoutingType.Height);
                                        else
                                                c.RegisterForLayouting (LayoutingType.Y);
@@ -294,9 +299,9 @@ namespace Crow
 
                        childrenRWLock.EnterReadLock ();
 
-                               foreach (GraphicObject g in Children) {
-                                       g.Paint (ref gr);
-                               }
+                       foreach (GraphicObject g in Children) {
+                               g.Paint (ref gr);
+                       }
 
                        childrenRWLock.ExitReadLock ();
                        gr.Restore ();
index 81017a7e6bb440558af61a5610e75f3711daa40f..b0719ef088e903fdb7ea6c75fc383df097a75a8c 100644 (file)
@@ -108,11 +108,11 @@ namespace Crow
                                //force sizing to fit if sizing on children and child has stretched size
                                switch (layoutType) {
                                case LayoutingType.Width:
-                                       if (Width == Measure.Fit && child.Width.Units == Unit.Percent)
+                                       if (Width == Measure.Fit && child.Width.IsRelativeToParent)
                                                child.Width = Measure.Fit;
                                        break;
                                case LayoutingType.Height:
-                                       if (Height == Measure.Fit && child.Height.Units == Unit.Percent)
+                                       if (Height == Measure.Fit && child.Height.IsRelativeToParent)
                                                child.Height = Measure.Fit;
                                        break;
                                }
@@ -129,14 +129,14 @@ namespace Crow
                        LayoutingType ltChild = LayoutingType.None;
 
                        if (layoutType == LayoutingType.Width) {
-                               if (child.Width.Units == Unit.Percent) {
+                               if (child.Width.IsRelativeToParent) {
                                        ltChild |= LayoutingType.Width;
                                        if (child.Width.Value < 100 && child.Left == 0)
                                                ltChild |= LayoutingType.X;
                                } else if (child.Left == 0)
                                        ltChild |= LayoutingType.X;
                        } else if (layoutType == LayoutingType.Height) {
-                               if (child.Height.Units == Unit.Percent) {
+                               if (child.Height.IsRelativeToParent) {
                                        ltChild |= LayoutingType.Height;
                                        if (child.Height.Value < 100 && child.Top == 0)
                                                ltChild |= LayoutingType.Y;
index 42ffa51cd27ed804b622dd4f28a849ba0d5d4b69..f7c937638bb2c2e4ea6259625d6d41e6c0bdaa98 100644 (file)
@@ -457,8 +457,9 @@ namespace Crow
                        }
 
                        if (iTemp.Expand != null && g is Expandable) {
-                               (g as Expandable).Expand += iTemp.Expand;
-                               (g as Expandable).GetIsExpandable = iTemp.HasSubItems;
+                               Expandable e = g as Expandable;
+                               e.Expand += iTemp.Expand;
+                               e.GetIsExpandable = iTemp.HasSubItems;
                        }
 
                        g.DataSource = o;
index 3f5dfdf0ce2c93be57088ff81f841a5f9735add0..a7f5f73b8965d50d46285605c37206ddb6c65beb 100644 (file)
@@ -104,7 +104,7 @@ namespace Crow
                                this.RegisterForLayouting (LayoutingType.Width);
                                break;
                        case LayoutingType.Height:
-                               if (Orientation == Orientation.Vertical && go.Height.Units == Unit.Percent) {
+                               if (Orientation == Orientation.Vertical && go.Height.IsRelativeToParent) {
                                        go.Height = Measure.Fit;
                                        return;
                                }
@@ -137,7 +137,7 @@ namespace Crow
                                        foreach (GraphicObject c in Children) {
                                                if (!c.Visible)
                                                        continue;
-                                               if (c.Height.Units == Unit.Percent &&
+                                               if (c.Height.IsRelativeToParent &&
                                                    c.RegisteredLayoutings.HasFlag (LayoutingType.Height)) {
                                                        childrenRWLock.ExitReadLock();
                                                        return -1;
@@ -172,7 +172,7 @@ namespace Crow
                                foreach (GraphicObject c in Children) {
                                        if (!c.Visible)
                                                continue;
-                                       if (c.Width.Units == Unit.Percent &&
+                                       if (c.Width.IsRelativeToParent &&
                                            c.RegisteredLayoutings.HasFlag (LayoutingType.Width)) {
                                                childrenRWLock.ExitReadLock();
                                                return -1;
@@ -217,13 +217,13 @@ namespace Crow
                public override void OnLayoutChanges (LayoutingType layoutType)
                {
                        #if DEBUG_LAYOUTING
-                       CurrentInterface.currentLQI.Slot = LastSlots;
-                       CurrentInterface.currentLQI.Slot = Slot;
+                       IFace.currentLQI.Slot = LastSlots;
+                       IFace.currentLQI.Slot = Slot;
                        #endif
                        switch (layoutType) {
                        case LayoutingType.Width:
                                foreach (GraphicObject c in Children) {
-                                       if (c.Width.Units == Unit.Percent)
+                                       if (c.Width.IsRelativeToParent)
                                                c.RegisterForLayouting (LayoutingType.Width);
                                }
                                if (Height == Measure.Fit)
@@ -232,7 +232,7 @@ namespace Crow
                                break;
                        case LayoutingType.Height:
                                foreach (GraphicObject c in Children) {
-                                       if (c.Height.Units == Unit.Percent)
+                                       if (c.Height.IsRelativeToParent)
                                                c.RegisterForLayouting (LayoutingType.Height);
                                }
                                if (Width == Measure.Fit)
diff --git a/src/IMLAttributes.cs b/src/IMLAttributes.cs
new file mode 100644 (file)
index 0000000..40ba5f9
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// IMLAttributes.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace Crow
+{
+       public class DesignCategory : Attribute
+       {
+               public string Name { get; set; }
+
+               public DesignCategory (string name)
+               {
+                       Name = name;
+               }
+       }
+}
+
index 5c6711f5f0e1bff56958f772701ebe88e3d3b8ce..49d4f5334c37beb2b8f0d1910484abf4b2575d6e 100644 (file)
@@ -388,6 +388,21 @@ namespace Crow.IML
                                }
                        }
                }
+
+               #if DESIGN_MODE
+               void emitSetDesignAttribute (IMLContext ctx, string name, string value){
+                       //store member value in iml
+                       ctx.il.Emit (OpCodes.Ldloc_0);
+                       ctx.il.Emit (OpCodes.Ldfld, typeof(GraphicObject).GetField("design_iml_values"));
+                       ctx.il.Emit (OpCodes.Ldstr, name);
+                       if (string.IsNullOrEmpty (value))
+                               ctx.il.Emit (OpCodes.Ldnull);
+                       else
+                               ctx.il.Emit (OpCodes.Ldstr, value);
+                       ctx.il.Emit (OpCodes.Call, CompilerServices.miDicStrStrAdd);
+               }
+               #endif
+
                /// <summary>
                /// process styling, attributes and children loading.
                /// </summary>
@@ -419,8 +434,12 @@ namespace Crow.IML
                                //first check for Style attribute then trigger default value loading
                                if (reader.HasAttributes) {
                                        string style = reader.GetAttribute ("Style");
-                                       if (!string.IsNullOrEmpty (style))
+                                       if (!string.IsNullOrEmpty (style)){
                                                CompilerServices.EmitSetValue (ctx.il, CompilerServices.piStyle, style);
+                                               #if DESIGN_MODE
+                                               emitSetDesignAttribute (ctx, "Style", style);
+                                               #endif
+                                       }
                                }
                                ctx.il.Emit (OpCodes.Ldloc_0);
                                ctx.il.Emit (OpCodes.Callvirt, CompilerServices.miLoadDefaultVals);
@@ -434,19 +453,9 @@ namespace Crow.IML
                                                        continue;
 
                                                #if DESIGN_MODE
-                                               //store member value in iml
-                                               ctx.il.Emit (OpCodes.Ldloc_0);
-                                               ctx.il.Emit (OpCodes.Ldfld, typeof(GraphicObject).GetField("design_members"));
-                                               ctx.il.Emit (OpCodes.Ldstr, reader.Name);
-                                               if (string.IsNullOrEmpty (reader.Value))
-                                                       ctx.il.Emit (OpCodes.Ldnull);
-                                               else
-                                                       ctx.il.Emit (OpCodes.Ldstr, reader.Value);
-                                               ctx.il.Emit (OpCodes.Call, 
-                                                       typeof(Dictionary<string, string>).GetMethod ("set_Item", new Type[] { typeof(string), typeof(string) }));
+                                               emitSetDesignAttribute (ctx, reader.Name, reader.Value);
                                                #endif
 
-
                                                MemberInfo mi = ctx.CurrentNodeType.GetMember (reader.Name).FirstOrDefault ();
                                                if (mi == null)
                                                        throw new Exception ("Member '" + reader.Name + "' not found in " + ctx.CurrentNodeType.Name);
index cdfd24d7a1034a48d2bbf93d51b1efc791662df6..4b7807319c0d1ef1b43f856a927a123d0ec7160c 100644 (file)
@@ -459,13 +459,22 @@ namespace Crow
                        set {
                                if (_hoverWidget == value)
                                        return;
+
+                               if (_hoverWidget != null)
+                                       _hoverWidget.IsHover = false;
+
                                _hoverWidget = value;
-                               #if DEBUG_FOCUS
+
                                if (_hoverWidget != null)
-                               Debug.WriteLine("Hover => " + _hoverWidget.ToString());
-                               else
-                               Debug.WriteLine("Hover => null");
-                               #endif
+                               {
+                                       _hoverWidget.IsHover = true;
+                                       #if DEBUG_FOCUS
+                                       Debug.WriteLine("Hover => " + _activeWidget.ToString());
+                                       }else
+                                       Debug.WriteLine("Hover => null");
+                                       #else
+                               }
+                                       #endif
                        }
                }
                /// <summary>Widget has the keyboard or mouse focus</summary>
index c88038c6f33e6a2b81928dfeba6aa494c24c2f4e..0374f5d9d6ebb3c05f86339b45d0a5c6c9543df8 100644 (file)
@@ -69,6 +69,7 @@ namespace Crow
                /// </summary>
                public bool IsFixed { get { return Units == Unit.Pixel; }}
                public bool IsFit { get { return Value == -1 && Units == Unit.Percent; }}
+               public bool IsRelativeToParent { get { return Value >= 0 && Units == Unit.Percent; }}
                #region Operators
                public static implicit operator int(Measure m){
                        return m.Value;
index c597abb9cb459185b5f1d4693e5999ab0d31c77d..e8a3ca136398088c628cfde6dfebdf69e7c1242e 100644 (file)
@@ -162,7 +162,7 @@ namespace Crow
                                                #if DESIGN_MODE
                                                styling [tc].Locations[currentProperty] = new FileLocation(resId, line,column);
                                                #endif
-                                               System.Diagnostics.Debug.WriteLine ("Style: {3} : {0}.{1} = {2}", tc, currentProperty, token, resId);
+                                               //System.Diagnostics.Debug.WriteLine ("Style: {3} : {0}.{1} = {2}", tc, currentProperty, token, resId);
                                        }
                                        token = "";
                                        curState = States.members;