]> O.S.I.I.S - jp/crow.git/commitdiff
CrowThread;AlwaysOnTop win;GTree explorer;
authorjpbruyere <jp.bruyere@hotmail.com>
Wed, 25 Jan 2017 08:25:14 +0000 (09:25 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Wed, 25 Jan 2017 08:25:14 +0000 (09:25 +0100)
17 files changed:
Crow.csproj
CrowIDE/CrowIDE.csproj
CrowIDE/src/CrowIDE.cs
CrowIDE/src/ImlVisualEditor.cs
CrowIDE/src/MembersView.cs
CrowIDE/ui/GTreeExpITemp.crow
CrowIDE/ui/GTreeExplorer.crow
CrowIDE/ui/MemberView.crow [new file with mode: 0644]
CrowIDE/ui/MembersView.template
CrowIDE/ui/imlEditor.crow
src/CrowThread.cs [new file with mode: 0644]
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Popper.cs
src/GraphicObjects/TemplatedGroup.cs
src/GraphicObjects/TreeView.cs
src/Interface.cs

index 13a0a351d2624fba7418dd6d9316cf542d5f9c8b..25e7f10dc4d5e609580ed87d9f5bc277400c67ce 100644 (file)
     <Compile Include="src\IML\EventBinding.cs" />
     <Compile Include="src\PerformanceMeasure.cs" />
     <Compile Include="src\IML\BindingMember.cs" />
+    <Compile Include="src\CrowThread.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
index 2e747f231382bbb3899a3af392a133d524f804b9..ec173d3de8231608fce9f957d3aa06fb605a73e2 100644 (file)
@@ -82,6 +82,7 @@
     <EmbeddedResource Include="Default.style" />
     <EmbeddedResource Include="ui\GTreeExplorer.crow" />
     <EmbeddedResource Include="ui\GTreeExpITemp.crow" />
+    <EmbeddedResource Include="ui\MemberView.crow" />
   </ItemGroup>
   <ItemGroup>
     <None Include="ui\test.crow">
index 6bb1e7eff6112d272a780fd436ab6160026155f8..afaab3a41ed5160f9597c956e2c0b7c74baee99e 100644 (file)
@@ -43,7 +43,6 @@ namespace CrowIDE
                {
                }
                ImlVisualEditor imlVE;
-               GraphicObject bindingExp, lqisExp;
 
                protected override void OnLoad (EventArgs e)
                {
@@ -63,22 +62,31 @@ namespace CrowIDE
                        if (e.Key == OpenTK.Input.Key.Escape) {
                                Quit (null, null);
                                return;
+                       } else if (e.Key == OpenTK.Input.Key.F4) {
+                               loadWindow ("#CrowIDE.ui.MemberView.crow");
                        } else if (e.Key == OpenTK.Input.Key.F5) {
-                               if (bindingExp != null) {
-                                       CrowInterface.DeleteWidget (bindingExp);
-                               }
-                               bindingExp = CrowInterface.LoadInterface ("#CrowIDE.ui.GTreeExplorer.crow");
-                               bindingExp.DataSource = imlVE;
-                               return;
+                               loadWindow ("#CrowIDE.ui.GTreeExplorer.crow");
                        } else if (e.Key == OpenTK.Input.Key.F6) {
-                               if (lqisExp != null) {
-                                       CrowInterface.DeleteWidget (lqisExp);
-                               }
-                               lqisExp = CrowInterface.LoadInterface ("#CrowIDE.ui.LQIsExplorer.crow");
-                               lqisExp.DataSource = imlVE;
-                               return;
+                               loadWindow ("#CrowIDE.ui.LQIsExplorer.crow");
                        }
                }
+               void loadWindow(string path){
+                       try {
+                               GraphicObject g = CrowInterface.FindByName (path);
+                               if (g != null)
+                                       return;
+                               g = CrowInterface.LoadInterface (path);
+                               g.Name = path;
+                               g.DataSource = imlVE;
+                       } catch (Exception ex) {
+                               System.Diagnostics.Debug.WriteLine (ex.ToString ());
+                       }
+               }
+               void closeWindow (string path){
+                       GraphicObject g = CrowInterface.FindByName (path);
+                       if (g != null)
+                               CrowInterface.DeleteWidget (g);
+               }
                protected void onCommandSave(object sender, MouseButtonEventArgs e){
                        System.Diagnostics.Debug.WriteLine("save");
                }
index 0a89bad85c8aaefd4e0b5d2dbe791de25d21ca81..cab3846d871d2c8bd44ffe5232a3750b1a2f5026 100644 (file)
@@ -45,10 +45,43 @@ namespace CrowIDE
                Interface imlVE;
                Instantiator itor;
                string imlSource;
+               GraphicObject selectedItem;
 
                bool drawGrid;
                int gridSpacing;
 
+               [XmlAttributeAttribute][DefaultValue(true)]
+               public bool DrawGrid {
+                       get { return drawGrid; }
+                       set {
+                               if (drawGrid == value)
+                                       return;
+                               drawGrid = value;
+                               NotifyValueChanged ("DrawGrid", drawGrid);
+                               RegisterForRedraw ();
+                       }
+               }
+               [XmlAttributeAttribute][DefaultValue(10)]
+               public int GridSpacing {
+                       get { return gridSpacing; }
+                       set {
+                               if (gridSpacing == value)
+                                       return;
+                               gridSpacing = value;
+                               NotifyValueChanged ("GridSpacing", gridSpacing);
+                               RegisterForRedraw ();
+                       }
+               }
+               [XmlAttributeAttribute]public GraphicObject SelectedItem {
+                       get { return selectedItem; }
+                       set {
+                               if (selectedItem == value)
+                                       return;
+                               selectedItem = value;
+                               NotifyValueChanged ("SelectedItem", selectedItem);
+                               RegisterForRedraw ();
+                       }
+               }
                [XmlIgnore]public List<LQIList> LQIs {
                        get { return imlVE.LQIs; }
                }
@@ -109,7 +142,9 @@ namespace CrowIDE
                        using (StreamReader sr = new StreamReader (imlPath)) {
                                ImlSource = sr.ReadToEnd ();
                        }
+                       NotifyValueChanged ("GraphicTree", null);
                        NotifyValueChanged ("GraphicTree", GraphicTree);
+                       SelectedItem = null;
                }
                void reload_iTor(Instantiator new_iTot){
                        itor = new_iTot;
@@ -125,31 +160,6 @@ namespace CrowIDE
                        }
                }
 
-               [XmlAttributeAttribute()][DefaultValue(true)]
-               public bool DrawGrid {
-                       get { return drawGrid; }
-                       set {
-                               if (drawGrid == value)
-                                       return;
-                               drawGrid = value;
-                               NotifyValueChanged ("DrawGrid", drawGrid);
-                               RegisterForRedraw ();
-                       }
-               }
-               [XmlAttributeAttribute()][DefaultValue(10)]
-               public int GridSpacing {
-                       get { return gridSpacing; }
-                       set {
-                               if (gridSpacing == value)
-                                       return;
-                               gridSpacing = value;
-                               NotifyValueChanged ("GridSpacing", gridSpacing);
-                               RegisterForRedraw ();
-                       }
-               }
-               [XmlIgnore]public object SelectedItem {
-                       get { return imlVE.HoverWidget; }
-               }
                void interfaceThread()
                {
                        while (true) {
@@ -201,7 +211,7 @@ namespace CrowIDE
                public override void onMouseDown (object sender, MouseButtonEventArgs e)
                {
                        base.onMouseDown (sender, e);
-                       NotifyValueChanged ("SelectedItem", imlVE.HoverWidget);
+                       SelectedItem = imlVE.HoverWidget;
                }
                protected override void onDraw (Cairo.Context gr)
                {
@@ -240,19 +250,25 @@ namespace CrowIDE
                                imlVE.IsDirty = false;
                        }
 
-                       if (imlVE.HoverWidget == null)
-                               return;
-
-                       Rectangle hr = imlVE.HoverWidget.ScreenCoordinates(imlVE.HoverWidget.getSlot ());
+                       Rectangle hr;
+                       if (imlVE.HoverWidget != null) {
+                               hr = imlVE.HoverWidget.ScreenCoordinates (imlVE.HoverWidget.getSlot ());
+//                     gr.SetSourceColor (Color.LightGray);
+//                     gr.DrawCote (new Cairo.PointD (hr.X, hr.Center.Y), new Cairo.PointD (hr.Right, hr.Center.Y));
+//                     gr.DrawCote (new Cairo.PointD (hr.Center.X, hr.Y), new Cairo.PointD (hr.Center.X, hr.Bottom));
+                               //hr.Inflate (2);
+                               gr.SetSourceColor (Color.LightGray);
+                               gr.SetDash (new double[]{ 3.0, 3.0 }, 0.0);
+                               gr.Rectangle (hr, 1.0);
+                       }
 
-                       gr.SetSourceColor (Color.LightGray);
-                       gr.DrawCote (new Cairo.PointD (hr.X, hr.Center.Y), new Cairo.PointD (hr.Right, hr.Center.Y));
-                       gr.DrawCote (new Cairo.PointD (hr.Center.X, hr.Y), new Cairo.PointD (hr.Center.X, hr.Bottom));
-                       hr.Inflate (2);
-                       gr.SetSourceColor (Color.LightGray);
-                       gr.SetDash (new double[]{ 3.0, 3.0 },0.0);
+                       if (SelectedItem == null)
+                               return;
+                       hr = SelectedItem.ScreenCoordinates(SelectedItem.getSlot ());
+                       hr.Inflate (1);
+                       gr.SetSourceColor (Color.Yellow);
+                       gr.SetDash (new double[]{ 5.0, 3.0 },0.0);
                        gr.Rectangle (hr, 1.0);
-
                }
                #endregion
 
@@ -265,10 +281,10 @@ namespace CrowIDE
                        MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY);
                        e.Mouse = imlVE.Mouse;
 
-                       if (imlVE.activeWidget != null) {
+                       if (imlVE.ActiveWidget != null) {
                                //TODO, ensure object is still in the graphic tree
                                //send move evt even if mouse move outside bounds
-                               imlVE.activeWidget.onMouseMove (this, e);
+                               imlVE.ActiveWidget.onMouseMove (this, e);
                                return true;
                        }
 
@@ -332,6 +348,12 @@ namespace CrowIDE
                        }
                        imlVE.HoverWidget = null;
                        return false;
+
+               }
+
+               void GTView_SelectedItemChanged (object sender, SelectionChangeEventArgs e)
+               {
+                       SelectedItem = e.NewValue as GraphicObject;
                }
        }
 }
index 69f182d0a565bc44b2e0a0d19158c694cecbf677..18f1a7096ee06666c5337158ec106db014574e37 100644 (file)
@@ -29,7 +29,7 @@ namespace CrowIDE
 {
        public class PropertyContainer : IValueChange
        {
-                               #region IValueChange implementation
+               #region IValueChange implementation
                public event EventHandler<ValueChangeEventArgs> ValueChanged;
                public virtual void NotifyValueChanged(string MemberName, object _value)
                {
index 6ce59f3c6b12d26ef575b01edb7294000cec0d4c..ba0148303485a33fcc4c77b8385c90c3a25524b9 100644 (file)
@@ -2,9 +2,7 @@
 <Expandable Caption="{Name}" >
        <Template>
                <VerticalStack>
-                       <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand"
-                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
-                                       MouseLeave="{Background=Transparent}">
+                       <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand" Background="{./Background}">
                                <Container Margin="1" Width="10" Height="10" Focusable="true" MouseClick="./onClickForExpand"
                                        MouseEnter="{Background=LightGray}"
                                        MouseLeave="{Background=Transparent}">
@@ -15,7 +13,9 @@
                                </Container>
                                <Image Margin="2" Width="14" Height="14"
                                        Path="#Crow.Images.Icons.folder.svg"/>
-                               <Label Text="{./Caption}"/>
+                               <Label Text="{./Caption}"
+                                               MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+                                               MouseLeave="{Background=Transparent}"/>
                        </HorizontalStack>
                        <Container Name="Content" Visible="false"/>
                </VerticalStack>
index d498a222152aa09b803cd41a5ba69576a82d52dd..0b8ea315777c97c0a14c1408a82e324043572fb6 100644 (file)
@@ -1,18 +1,39 @@
 ï»¿<?xml version="1.0"?>
-<Window Title="Graphic Tree" Width="20%" Height="90%" Background="DimGray" AlwaysOnTop="true">
-       <TreeView IsRoot="true" Name="treeView" Data="{GraphicTree}" Background="Jet">
-               <ItemTemplate>
-                       <Label Text="{Name}" Width="Stretched"
-                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
-                                       MouseLeave="{Background=Transparent}"/>
-               </ItemTemplate>
-               <ItemTemplate DataType="Crow.Group" Data="GetChildren"
-                       Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
-               <ItemTemplate DataType="Crow.Container" Data="GetChildren"
-                       Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
-               <ItemTemplate DataType="Crow.TemplatedContainer" Data="GetChildren"
-                       Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
-               <ItemTemplate DataType="Crow.TemplatedGroup" Data="GetChildren"
-                       Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
-       </TreeView>
+<Window Title="Graphic Tree" Width="20%" Height="70%" AlwaysOnTop="true">
+       <VerticalStack>
+               <Button Caption="Expand All" MouseClick="../treeView.onExpandAll_MouseClick"/>          
+               <TreeView IsRoot="true" Name="treeView" Data="{GraphicTree}"
+                       SelectedItemChanged="GTView_SelectedItemChanged">
+<!--                   <Template>
+                               <HorizontalStack>
+                                       <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"
+                                               Background="{./Background}"
+                                               ScrollY="{../scrollbar1.Value}">
+                                               <VerticalStack
+                                                       Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+                                       </Scroller>
+                                       <ScrollBar
+                                               Name="scrollbar1"
+                                               Value="{../scroller1.ScrollY}"
+                                               Maximum="{../scroller1.MaximumScroll}"
+                                               Width="12" Orientation="Vertical"/>
+                               </HorizontalStack>
+                       </Template>-->
+                       <ItemTemplate>
+                               <HorizontalStack Width="Stretched" Focusable="true">
+                                       <Label Text="{Name}"
+                                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+                                                       MouseLeave="{Background=Transparent}"/>
+                               </HorizontalStack>
+                       </ItemTemplate>
+                       <ItemTemplate DataType="Crow.Group" Data="GetChildren"
+                               Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
+                       <ItemTemplate DataType="Crow.Container" Data="GetChildren"
+                               Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
+                       <ItemTemplate DataType="Crow.TemplatedContainer" Data="GetChildren"
+                               Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
+                       <ItemTemplate DataType="Crow.TemplatedGroup" Data="GetChildren"
+                               Path="#CrowIDE.ui.GTreeExpITemp.crow"/>
+               </TreeView>
+       </VerticalStack>
 </Window>
diff --git a/CrowIDE/ui/MemberView.crow b/CrowIDE/ui/MemberView.crow
new file mode 100644 (file)
index 0000000..6ac493b
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0"?>
+<Window Title="Member View" Width="30%" Height="50%" Background="DimGray" AlwaysOnTop="true">
+       <MembersView Instance="{SelectedItem}" DataTest="Type">
+       <!--                            <Template>
+                       <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"
+                               ValueChanged="./_scroller_ValueChanged">
+                               <VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
+                                       Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+                       </Scroller>
+               </Template>-->
+               <ItemTemplate>
+                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
+                                       MouseEnter="{Background=UnitedNationsBlue}"
+                                       MouseLeave="{Background=Transparent}" >
+                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+                               <TextBox Margin="1" Text="{²Value}" Height="Fit" Width="50%"/>
+                       </HorizontalStack>
+               </ItemTemplate>
+               <ItemTemplate DataType="System.Boolean">
+                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
+                                       MouseEnter="{Background=UnitedNationsBlue}"
+                                       MouseLeave="{Background=Transparent}" >
+                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+                               <CheckBox Background="White" Margin="1" Caption="" IsChecked="{²Value}"/>
+                       </HorizontalStack>
+               </ItemTemplate>
+               <ItemTemplate DataType="System.Enum">
+                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
+                                       MouseEnter="{Background=UnitedNationsBlue}"
+                                       MouseLeave="{Background=Transparent}" >
+                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+                               <ComboBox Margin="1"  Height="Fit" Width="50%" Data="{Choices}"
+                                               SelectedIndex="{²Value}">
+                                       <Template>
+                                               <Popper Name="popper" PopDirection="Bottom">
+                                                       <Template>
+                                                               <Border CornerRadius="0" Foreground="LightGray" Background="White">
+                                                                       <HorizontalStack Margin="0" Spacing="1">
+                                                                               <Label Width="Stretched" MinimumSize="80,10" Margin="1" Foreground="Black" Background="White"
+                                                                                       Text="{../../../../SelectedItem}"/>
+                                                                               <Button Width="12" Height="12" Focusable="false"
+                                                                                       Template="#Crow.Templates.ArrowButTemplate.crow">
+                                                                                       <Image Margin="1"  Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
+                                                                               </Button>
+                                                                       </HorizontalStack>
+                                                               </Border>
+                                                       </Template>
+                                                       <Border Background="White" BorderWidth="1" Margin="1" Foreground="Black"
+                                                               MinimumSize="{../../MinimumPopupSize}" Fit="true">
+                                                               <Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
+                                                                       MaximumSize="0,200"
+                                                                       HorizontalAlignment="Left"
+                                                                       ValueChanged="../../../_scroller_ValueChanged">
+                                                                       <VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
+                                                                               MouseClick="../../../onMouseClick" Focusable="True"
+                                                                               Height="Fit" Name="ItemsContainer" Margin="0"
+                                                                               HorizontalAlignment="Left"
+                                                                               VerticalAlignment="Top"/>
+                                                               </Scroller>
+                                                       </Border>
+                                               </Popper>
+                                       </Template>
+                                       <ItemTemplate>
+                                               <Container Fit="true" Margin="0" Focusable="true"
+                                                               HorizontalAlignment="Left"
+                                                               MouseEnter="{Background=SteelBlue}"
+                                                               MouseLeave="{Background=Transparent}">
+                                                       <Label Text="{}" Foreground="Black"/>
+                                               </Container>
+                                       </ItemTemplate>
+                               </ComboBox>
+                       </HorizontalStack>
+               </ItemTemplate>
+               <ItemTemplate DataType="Crow.Fill">
+                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
+                                       MouseEnter="{Background=UnitedNationsBlue}"
+                                       MouseLeave="{Background=Transparent}" >
+                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
+                               <Popper Background="White" Margin="1" Caption="{Value}">
+                                       <Template>
+                                               <HorizontalStack Spacing="3" Height="Fit" Background="{./Background}">
+                                                       <Border Foreground="Black" Width="16" Height="10" CornerRadius="3"
+                                                               Background="{Value}">
+                                                       </Border>
+                                                       <Label Text="{./Caption}" Foreground="Black"/>
+                                               </HorizontalStack>
+                                       </Template>
+                                       <ColorPicker SelectedColor="{²Value}" Background="Onyx" Margin="5" Fit="True" />
+                               </Popper>
+                       </HorizontalStack>
+               </ItemTemplate>
+
+       </MembersView>
+</Window>
\ No newline at end of file
index 17dda5bdee46b130fe8bef57799c2c2c1712d089..91b7515d207d0e818716325a2b8981be60b97368 100755 (executable)
@@ -1,9 +1,11 @@
 <?xml version="1.0"?>
-<Border BorderWidth="1" Margin="1" MinimumSize="10,10" Height="{./HeightPolicy}" Width="{./WidthPolicy}" >
-       <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"
-               Height="{./HeightPolicy}" Width="{./WidthPolicy}"
-               ValueChanged="./_scroller_ValueChanged">
-               <VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
-                       Height="Fit" Width="{./WidthPolicy}" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
-       </Scroller>
+<Border BorderWidth="5" Margin="1" MinimumSize="10,10">
+       <VerticalStack>
+               <Label Text="{./Instance}"/>
+               <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"         
+                       ValueChanged="./_scroller_ValueChanged">
+                       <VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
+                               Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+               </Scroller>
+       </VerticalStack>
 </Border>
\ No newline at end of file
index ce4911684f5645001f41e4d4af413468acb60151..ad589bcb4651486eb3575a272d17da9ef4186768 100644 (file)
                </Border>
                <HorizontalStack>
                        <DirectoryView Name="dv" CurrentDirectory="./" SelectedItemChanged="Tv_SelectedItemChanged"
-                               Width="20%" Height="100%" Margin="10"/>
+                               Width="20%" Height="100%" Margin="0"/>
                        <Splitter/>
                        <VerticalStack Width="Stretched">
                                <ImlVisualEditor Height="60%" Margin="0" MinimumSize="10,10" Foreground="SkyBlue"
-                                       ImlPath="{../../../dv.SelectedItem}"
+                                       ImlPath="{../../../dv.SelectedItem}" SelectedItem="{²SelectedItem}"
                                        Name="crowContainer" Background="Onyx"/>
                                <Splitter/>
                                <HorizontalStack Margin="10" MinimumSize="10,1">
                                </HorizontalStack>
                        </VerticalStack>
                        <Splitter/>
-                       <MembersView Width="20%" Instance="{../crowContainer.SelectedItem}" DataTest="Type">
-                               <Template>
-                                       <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"
-                                               ValueChanged="./_scroller_ValueChanged">
-                                               <VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
-                                                       Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
-                                       </Scroller>
-                               </Template>
-                               <ItemTemplate>
-                                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
-                                                       MouseEnter="{Background=UnitedNationsBlue}"
-                                                       MouseLeave="{Background=Transparent}" >
-                                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
-                                               <TextBox Margin="1" Text="{²Value}" Height="Fit" Width="50%"/>
-                                       </HorizontalStack>
-                               </ItemTemplate>
-                               <ItemTemplate DataType="System.Boolean">
-                                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
-                                                       MouseEnter="{Background=UnitedNationsBlue}"
-                                                       MouseLeave="{Background=Transparent}" >
-                                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
-                                               <CheckBox Background="White" Margin="1" Caption="" IsChecked="{²Value}"/>
-                                       </HorizontalStack>
-                               </ItemTemplate>
-                               <ItemTemplate DataType="System.Enum">
-                                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
-                                                       MouseEnter="{Background=UnitedNationsBlue}"
-                                                       MouseLeave="{Background=Transparent}" >
-                                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
-                                               <ComboBox Margin="1"  Height="Fit" Width="50%" Data="{Choices}"
-                                                               SelectedIndex="{²Value}">
-                                                       <Template>
-                                                               <Popper Name="popper" PopDirection="Bottom">
-                                                                       <Template>
-                                                                               <Border CornerRadius="0" Foreground="LightGray" Background="White">
-                                                                                       <HorizontalStack Margin="0" Spacing="1">
-                                                                                               <Label Width="Stretched" MinimumSize="80,10" Margin="1" Foreground="Black" Background="White"
-                                                                                                       Text="{../../../../SelectedItem}"/>
-                                                                                               <Button Width="12" Height="12" Focusable="false"
-                                                                                                       Template="#Crow.Templates.ArrowButTemplate.crow">
-                                                                                                       <Image Margin="1"  Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
-                                                                                               </Button>
-                                                                                       </HorizontalStack>
-                                                                               </Border>
-                                                                       </Template>
-                                                                       <Border Background="White" BorderWidth="1" Margin="1" Foreground="Black"
-                                                                               MinimumSize="{../../MinimumPopupSize}" Fit="true">
-                                                                               <Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
-                                                                                       MaximumSize="0,200"
-                                                                                       HorizontalAlignment="Left"
-                                                                                       ValueChanged="../../../_scroller_ValueChanged">
-                                                                                       <VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
-                                                                                               MouseClick="../../../onMouseClick" Focusable="True"
-                                                                                               Height="Fit" Name="ItemsContainer" Margin="0"
-                                                                                               HorizontalAlignment="Left"
-                                                                                               VerticalAlignment="Top"/>
-                                                                               </Scroller>
-                                                                       </Border>
-                                                               </Popper>
-                                                       </Template>
-                                                       <ItemTemplate>
-                                                               <Container Fit="true" Margin="0" Focusable="true"
-                                                                               HorizontalAlignment="Left"
-                                                                               MouseEnter="{Background=SteelBlue}"
-                                                                               MouseLeave="{Background=Transparent}">
-                                                                       <Label Text="{}" Foreground="Black"/>
-                                                               </Container>
-                                                       </ItemTemplate>
-                                               </ComboBox>
-                                       </HorizontalStack>
-                               </ItemTemplate>
-                               <ItemTemplate DataType="Crow.Fill">
-                                       <HorizontalStack Focusable="true"  Height="Fit" Spacing="0"
-                                                       MouseEnter="{Background=UnitedNationsBlue}"
-                                                       MouseLeave="{Background=Transparent}" >
-                                               <Label Margin="1" Text="{Name}" Height="Fit" Width="50%"/>
-                                               <Popper Background="White" Margin="1" Caption="{Value}">
-                                                       <Template>
-                                                               <HorizontalStack Spacing="3" Height="Fit" Background="{./Background}">
-                                                                       <Border Foreground="Black" Width="16" Height="10" CornerRadius="3"
-                                                                               Background="{Value}">
-                                                                       </Border>
-                                                                       <Label Text="{./Caption}" Foreground="Black"/>
-                                                               </HorizontalStack>
-                                                       </Template>
-                                                       <ColorPicker SelectedColor="{²Value}" Background="Onyx" Margin="5" Fit="True" />
-                                               </Popper>
-                                       </HorizontalStack>
-                               </ItemTemplate>
-
-                       </MembersView>
                </HorizontalStack>
        </VerticalStack>
 </Window>
diff --git a/src/CrowThread.cs b/src/CrowThread.cs
new file mode 100644 (file)
index 0000000..dfdeda0
--- /dev/null
@@ -0,0 +1,58 @@
+//
+//  CrowThread.cs
+//
+//  Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+//  Copyright (c) 2017 jp
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Threading;
+
+namespace Crow
+{
+       /// <summary>
+       /// Thread monitored by current interface with Finished event when state==Stopped
+       /// </summary>
+       public class CrowThread {
+               Thread thread;
+               public event EventHandler Finished;
+               public GraphicObject Host;
+               public CrowThread (GraphicObject host, ThreadStart start){
+                       thread = new Thread (start);
+                       thread.IsBackground = true;
+                       Host = host;
+                       lock (Host.CurrentInterface.CrowThreads)
+                               Host.CurrentInterface.CrowThreads.Add (this);
+               }
+               public void CheckState(){
+                       if (thread.ThreadState != ThreadState.Stopped)
+                               return;
+                       Finished.Raise (Host, null);
+                       lock (Host.CurrentInterface.CrowThreads)
+                               Host.CurrentInterface.CrowThreads.Remove (this);
+               }
+               public void Start() { thread.Start();}
+               public void Cancel(){
+                       if (thread.IsAlive){
+                               //cancelLoading = true;
+                               thread.Join ();
+                               //cancelLoading = false;
+                       }
+                       Host.CurrentInterface.CrowThreads.Remove (this);
+               }
+       }
+}
+
index a2d78d88be345453e5bc766c01be9e189732b210..0636c14e457a90773f41c70cccb04292132534a4 100644 (file)
@@ -29,6 +29,7 @@ namespace Crow
                                        return;
                                _spacing = value; 
                                NotifyValueChanged ("Spacing", Spacing);
+                               RegisterForLayouting (LayoutingType.Sizing|LayoutingType.ArrangeChildren);
                        }
         }
         [XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
index 070a221a6abb711fd2cdc1102b62f3f985d4cc2e..1e8bfcf99fd8380253de77d87a9fbfd28823834d 100644 (file)
@@ -507,8 +507,10 @@ namespace Crow
                                isVisible = value;
 
                                //ensure main win doesn't keep hidden childrens ref
-                               if (!isVisible && this.Contains (CurrentInterface.HoverWidget))
-                                       CurrentInterface.HoverWidget = null;
+                               if (CurrentInterface.HoverWidget != null) {
+                                       if (!isVisible && this.Contains (CurrentInterface.HoverWidget))
+                                               CurrentInterface.HoverWidget = null;
+                               }
 
                                if (isVisible)
                                        RegisterForLayouting (LayoutingType.Sizing);
@@ -1200,8 +1202,8 @@ namespace Crow
                                currentInterface.clickTimer.Restart();
                        CurrentInterface.eligibleForDoubleClick = null;
                        
-                       if (CurrentInterface.activeWidget == null)
-                               CurrentInterface.activeWidget = this;
+                       if (CurrentInterface.ActiveWidget == null)
+                               CurrentInterface.ActiveWidget = this;
                        if (this.Focusable && !Interface.FocusOnHover) {
                                BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg;
                                if (be.Focused == null) {
index 3862133710b95208d0994a21ab1eb050ee1b7b42..84088355e767bae43f18e0931c0ee3e4027f3b0d 100644 (file)
@@ -219,16 +219,17 @@ namespace Crow
                        if (Content != null) {
                                Content.Visible = true;
                                if (Content.Parent == null)
-                                       CurrentInterface.AddWidget (Content);
-                               CurrentInterface.PutOnTop (Content);
+                                       CurrentInterface.AddWidget (Content, true);
+                               CurrentInterface.PutOnTop (Content, true);
                                _content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing));
                        }
                        Pop.Raise (this, e);
                }
                public virtual void onUnpop(object sender, EventArgs e)
                {
-                       if (Content != null)
+                       if (Content != null) {
                                Content.Visible = false;
+                       }
                        Unpop.Raise (this, e);
                }
        }
index ee799fd02fc732dfcf87e47d531b7a286943cc46..a1941f06b10c84cb351f98fe0a1fad04b78ce7f3 100644 (file)
@@ -40,6 +40,7 @@ namespace Crow
 
                #region events
                public event EventHandler<SelectionChangeEventArgs> SelectedItemChanged;
+               public event EventHandler Loaded;
                #endregion
 
                IList data;
@@ -47,7 +48,7 @@ namespace Crow
                Color selBackground, selForeground;
 
                int itemPerPage = 50;
-               Thread loadingThread = null;
+               CrowThread loadingThread = null;
                volatile bool cancelLoading = false;
 
                #region Templating
@@ -141,8 +142,8 @@ namespace Crow
                                if (data == null)
                                        return;
 
-                               loadingThread = new Thread (loading);
-                               loadingThread.IsBackground = true;
+                               loadingThread = new CrowThread (this, loading);
+                               loadingThread.Finished += (object sender, EventArgs e) => (sender as TemplatedGroup).Loaded.Raise (sender, e);
                                loadingThread.Start ();
                                //loadPage(1);
 
@@ -310,13 +311,8 @@ namespace Crow
                        }
                }
                void cancelLoadingThread(){
-                       if (loadingThread == null)
-                               return;
-                       if (!loadingThread.IsAlive)
-                               return;
-                       cancelLoading = true;
-                       loadingThread.Join ();
-                       cancelLoading = false;
+                       if (loadingThread != null)
+                               loadingThread.Cancel ();
                }
                void loadPage(int pageNum)
                {
@@ -374,6 +370,8 @@ namespace Crow
                        }
                }
                protected void loadItem(int i, Group page){
+                       if (data [i] == null)//TODO:surely a threading sync problem
+                               return;
                        GraphicObject g = null;
                        ItemTemplate iTemp = null;
                        Type dataType = data [i].GetType ();
index 4fa881b4e0e3c08bc73308f6e724e919776e5faa..d4354b65b97fdf7b323ea7a198904f8163da42c2 100644 (file)
@@ -48,7 +48,6 @@ namespace Crow
                                NotifyValueChanged ("IsRoot", isRoot);
                        }
                }
-
                [XmlIgnore]public override object SelectedItem {
                        get {
                                return selectedItemContainer == null ?
@@ -84,6 +83,32 @@ namespace Crow
                        NotifyValueChanged ("SelectedItem", SelectedItem);
                        raiseSelectedItemChanged ();
                }
+
+               void onExpandAll_MouseClick (object sender, MouseButtonEventArgs e)
+               {
+                       ExpandAll ();
+               }
+
+               public void ExpandAll(){
+                       foreach (Group grp in items.Children) {
+                               foreach (GraphicObject go in grp.Children) {
+                                       Expandable exp = go as Expandable;
+                                       if (exp == null)
+                                               continue;
+                                       TreeView subTV = exp.FindByName ("List") as TreeView;
+                                       if (subTV == null)
+                                               continue;
+                                       EventHandler handler = null;
+                                       handler = delegate(object sender, EventArgs e) {
+                                               TreeView tv = sender as TreeView;
+                                               tv.Loaded -= handler;
+                                               tv.ExpandAll ();
+                                       };
+                                       subTV.Loaded += handler;
+                                       exp.IsExpanded = true;
+                               }
+                       }
+               }
        }
 }
 
index 6b859dbedda4df1e8ce03398407489cfe68d68a6..565e6ab4985635582e6755cb8d4817fc09b7da6e 100644 (file)
@@ -142,6 +142,7 @@ namespace Crow
                public static Dictionary<String, Instantiator> Instantiators = new Dictionary<string, Instantiator>();
                public bool DesignMode = false;
                public int TopWindows = 0;//window always on top count
+               public List<CrowThread> CrowThreads = new List<CrowThread>();//used to monitor thread finished
                #endregion
 
                #region Private Fields
@@ -302,7 +303,7 @@ namespace Crow
 
                /// <summary>Widget is focused and button is down or another perif action is occuring
                /// , it can not lose focus while Active</summary>
-               public GraphicObject activeWidget
+               public GraphicObject ActiveWidget
                {
                        get { return _activeWidget; }
                        set
@@ -394,6 +395,13 @@ namespace Crow
                                        _focusedWidget.onKeyDown (this, lastKeyDownEvt);
                                }
                        }
+                       CrowThread[] tmpThreads;
+                       lock (CrowThreads) {
+                               tmpThreads = new CrowThread[CrowThreads.Count];
+                               Array.Copy (CrowThreads.ToArray (), tmpThreads, CrowThreads.Count);
+                       }
+                       for (int i = 0; i < tmpThreads.Length; i++)
+                               tmpThreads [i].CheckState ();
 
                        if (!Monitor.TryEnter (UpdateMutex))
                                return;
@@ -535,14 +543,15 @@ namespace Crow
 
                #region GraphicTree handling
                /// <summary>Add widget to the Graphic tree of this interface and register it for layouting</summary>
-               public void AddWidget(GraphicObject g)
+               public void AddWidget(GraphicObject g, bool topMost = false)
                {
                        g.Parent = this;
                        int ptr = TopWindows;
                        if (g is Window) {
                                if ((g as Window).AlwaysOnTop)
                                        ptr = 0;
-                       }
+                       } else if (topMost)
+                               ptr = 0;
                        GraphicTree.Insert (ptr, g);
                        g.RegisteredLayoutings = LayoutingType.None;
                        g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
@@ -554,12 +563,18 @@ namespace Crow
                        GraphicTree.Remove (g);
                }
                /// <summary> Put widget on top of other root widgets</summary>
-               public void PutOnTop(GraphicObject g)
+               public void PutOnTop(GraphicObject g, bool topMost = false)
                {
-                       if (GraphicTree.IndexOf(g) > TopWindows)
+                       int ptr = TopWindows;
+                       if (g is Window) {
+                               if ((g as Window).AlwaysOnTop)
+                                       ptr = 0;
+                       } else if (topMost)
+                               ptr = 0;
+                       if (GraphicTree.IndexOf(g) > ptr)
                        {
                                GraphicTree.Remove(g);
-                               GraphicTree.Insert(TopWindows, g);
+                               GraphicTree.Insert(ptr, g);
                                EnqueueForRepaint (g);
                        }
                }
@@ -634,10 +649,10 @@ namespace Crow
                        MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY);
                        e.Mouse = Mouse;
 
-                       if (activeWidget != null) {
+                       if (ActiveWidget != null) {
                                //TODO, ensure object is still in the graphic tree
                                //send move evt even if mouse move outside bounds
-                               activeWidget.onMouseMove (this, e);
+                               ActiveWidget.onMouseMove (this, e);
                                return true;
                        }
 
@@ -717,7 +732,7 @@ namespace Crow
                        }
 
                        _activeWidget.onMouseUp (_activeWidget, e);
-                       activeWidget = null;
+                       ActiveWidget = null;
                        return true;
                }
                public bool ProcessMouseButtonDown(int button)