]> O.S.I.I.S - jp/crow.git/commitdiff
dataType for expandable itemTemplate use 'isAssignableFrom'; GraphicTree View
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 24 Jan 2017 11:11:30 +0000 (12:11 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 24 Jan 2017 11:13:15 +0000 (12:13 +0100)
CrowIDE/CrowIDE.csproj
CrowIDE/src/CrowIDE.cs
CrowIDE/src/Extensions.cs
CrowIDE/src/ImlVisualEditor.cs
CrowIDE/ui/GTreeExpITemp.crow [new file with mode: 0644]
CrowIDE/ui/GTreeExplorer.crow [new file with mode: 0644]
CrowIDE/ui/bindingExpITemp.crow [deleted file]
CrowIDE/ui/bindingExplorer.crow [deleted file]
src/GraphicObjects/TemplatedGroup.cs

index b9f16d25736e889476e922a74f440b193caba01b..2e747f231382bbb3899a3af392a133d524f804b9 100644 (file)
@@ -28,8 +28,6 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
-    <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
-    <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>none</DebugType>
@@ -37,8 +35,6 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>0</WarningLevel>
     <ConsolePause>false</ConsolePause>
-    <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
-    <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="cairo-sharp">
       <Package>gtk-sharp-3.0</Package>
     </Reference>
-    <Reference Include="gdk-sharp">
-      <Package>gtk-sharp-2.0</Package>
-    </Reference>
-    <Reference Include="gio-sharp">
-      <Package>gio-sharp-3.0</Package>
-    </Reference>
-    <Reference Include="glib-sharp">
-      <Package>glib-sharp-3.0</Package>
-    </Reference>
     <Reference Include="OpenTK">
       <HintPath>$(SolutionDir)packages\OpenTK.2.0.0\lib\net20\OpenTK.dll</HintPath>
       <Package>opentk</Package>
     <EmbeddedResource Include="ui\MembersView.template">
       <LogicalName>CrowIDE.MembersView.template</LogicalName>
     </EmbeddedResource>
-    <EmbeddedResource Include="ui\bindingExplorer.crow" />
-    <EmbeddedResource Include="ui\bindingExpITemp.crow" />
     <EmbeddedResource Include="ui\LQIsExplorer.crow" />
     <EmbeddedResource Include="Default.style" />
+    <EmbeddedResource Include="ui\GTreeExplorer.crow" />
+    <EmbeddedResource Include="ui\GTreeExpITemp.crow" />
   </ItemGroup>
   <ItemGroup>
     <None Include="ui\test.crow">
index b137ad8d084260df21ee093e977b1407ad23d77e..6bb1e7eff6112d272a780fd436ab6160026155f8 100644 (file)
@@ -67,7 +67,7 @@ namespace CrowIDE
                                if (bindingExp != null) {
                                        CrowInterface.DeleteWidget (bindingExp);
                                }
-                               bindingExp = CrowInterface.LoadInterface ("#CrowIDE.ui.bindingExplorer.crow");
+                               bindingExp = CrowInterface.LoadInterface ("#CrowIDE.ui.GTreeExplorer.crow");
                                bindingExp.DataSource = imlVE;
                                return;
                        } else if (e.Key == OpenTK.Input.Key.F6) {
index e2897e3e4b5766f1ebc21e828b9b975f7cf41015..5e8981dfeb00075417871062775a3e33f1173dea 100644 (file)
@@ -26,10 +26,16 @@ namespace Crow
        public static class Extensions
        {
                public static List<GraphicObject> GetChildren(this GraphicObject go){
-                       if (go is Group)
+                       Type goType = go.GetType();
+                       if (typeof (Group).IsAssignableFrom (goType))
                                return (go as Group).Children;
-                       if (go is Container)
+                       if (typeof(Container).IsAssignableFrom (goType))
                                return new List<GraphicObject>( new GraphicObject[] { (go as Container).Child });
+                       if (typeof(TemplatedContainer).IsAssignableFrom (goType))
+                               return new List<GraphicObject>( new GraphicObject[] { (go as TemplatedContainer).Content });
+                       if (typeof(TemplatedGroup).IsAssignableFrom (goType))
+                               return (go as TemplatedGroup).Items;
+
                        return new List<GraphicObject>();
                }
        }
index e3975cfe40f003425d73f2a55dfc5e66daa4d163..0a89bad85c8aaefd4e0b5d2dbe791de25d21ca81 100644 (file)
@@ -34,6 +34,7 @@ namespace CrowIDE
                public ImlVisualEditor () : base()
                {
                        imlVE = new Interface ();
+                       imlVE.DesignMode = true;
                        Thread t = new Thread (interfaceThread);
                        t.IsBackground = true;
                        t.Start ();
@@ -78,6 +79,9 @@ namespace CrowIDE
                        }
                }
 
+               public List<GraphicObject> GraphicTree {
+                       get { return imlVE.GraphicTree; }
+               }
 
 
                void reloadFromSource(){
@@ -105,6 +109,7 @@ namespace CrowIDE
                        using (StreamReader sr = new StreamReader (imlPath)) {
                                ImlSource = sr.ReadToEnd ();
                        }
+                       NotifyValueChanged ("GraphicTree", GraphicTree);
                }
                void reload_iTor(Instantiator new_iTot){
                        itor = new_iTot;
diff --git a/CrowIDE/ui/GTreeExpITemp.crow b/CrowIDE/ui/GTreeExpITemp.crow
new file mode 100644 (file)
index 0000000..6ce59f3
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<Expandable Caption="{Name}" >
+       <Template>
+               <VerticalStack>
+                       <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand"
+                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+                                       MouseLeave="{Background=Transparent}">
+                               <Container Margin="1" Width="10" Height="10" Focusable="true" MouseClick="./onClickForExpand"
+                                       MouseEnter="{Background=LightGray}"
+                                       MouseLeave="{Background=Transparent}">
+                                       <Image
+                                               Path="{./Image}"
+                                               Visible="{./IsExpandable}"
+                                               SvgSub="{./IsExpanded}"/>
+                               </Container>
+                               <Image Margin="2" Width="14" Height="14"
+                                       Path="#Crow.Images.Icons.folder.svg"/>
+                               <Label Text="{./Caption}"/>
+                       </HorizontalStack>
+                       <Container Name="Content" Visible="false"/>
+               </VerticalStack>
+       </Template>
+       <HorizontalStack Height="Fit">
+               <GraphicObject Width="12" Height="10"/>
+               <TreeView Name="List" Height="Fit"
+                       Template="#Crow.Templates.treeList.crow" />
+       </HorizontalStack>
+</Expandable>
diff --git a/CrowIDE/ui/GTreeExplorer.crow b/CrowIDE/ui/GTreeExplorer.crow
new file mode 100644 (file)
index 0000000..d498a22
--- /dev/null
@@ -0,0 +1,18 @@
+<?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>
diff --git a/CrowIDE/ui/bindingExpITemp.crow b/CrowIDE/ui/bindingExpITemp.crow
deleted file mode 100644 (file)
index 0797371..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0"?>
-<Expandable Caption="{Name}" >
-       <Template>
-               <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
-                       <HorizontalStack Spacing="1" Height="Fit" Width="{./WidthPolicy}"
-                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
-                                       MouseLeave="{Background=Transparent}">
-                               <Image Margin="2" Width="12" Height="12"
-                                       Visible="{./HasContent}"
-                                       Path="{./Image}"
-                                       SvgSub="{./IsExpanded}"/>
-                               <Label Text="{./Caption}" Width="{./WidthPolicy}"/>
-                       </HorizontalStack>
-                       <Container Name="Content" Visible="false"
-                                       Height="{./HeightPolicy}" Width="{./WidthPolicy}"/>
-               </VerticalStack>
-       </Template>
-       <HorizontalStack Height="Fit" Width="{./WidthPolicy}">
-               <GraphicObject Width="12" Height="10"/>
-               <TreeView Name="List" Height="Fit" Width="{./WidthPolicy}"
-                       Template="#Crow.Templates.treeList.crow" />
-       </HorizontalStack>
-</Expandable>
diff --git a/CrowIDE/ui/bindingExplorer.crow b/CrowIDE/ui/bindingExplorer.crow
deleted file mode 100644 (file)
index 13d90be..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0"?>
-<Window Width="50%" Height="50%" Background="DimGray">
-       <TreeView IsRoot="true" Name="treeView" Data="{GraphicTree}">
-               <ItemTemplate DataType="Crow.GraphicObject">
-                       <Label Text="{Name}" Width="Stretched"
-                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
-                                       MouseLeave="{Background=Transparent}"/>
-               </ItemTemplate>
-               <ItemTemplate DataType="Crow.Container" Data="GetChildren"
-                       Path="#CrowIDE.ui.bindingExpITemp.crow"/>
-               <ItemTemplate DataType="Crow.Group" Data="GetChildren"
-                       Path="#CrowIDE.ui.bindingExpITemp.crow"/>
-       </TreeView>
-</Window>
index f636786d76b70aaaf911c13cc7ff24af7a84c259..ee799fd02fc732dfcf87e47d531b7a286943cc46 100644 (file)
@@ -106,11 +106,11 @@ namespace Crow
                public virtual List<GraphicObject> Items{ get { return items.Children; }}
                [XmlAttributeAttribute][DefaultValue(-1)]public int SelectedIndex{
                        get { return _selectedIndex; }
-                       set { 
+                       set {
                                if (value == _selectedIndex)
                                        return;
 
-                               _selectedIndex = value; 
+                               _selectedIndex = value;
 
                                NotifyValueChanged ("SelectedIndex", _selectedIndex);
                                NotifyValueChanged ("SelectedItem", SelectedItem);
@@ -179,7 +179,7 @@ namespace Crow
                protected void raiseSelectedItemChanged(){
                        SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
                }
-                       
+
 
                public virtual void AddItem(GraphicObject g){
                        items.AddChild (g);
@@ -313,7 +313,7 @@ namespace Crow
                        if (loadingThread == null)
                                return;
                        if (!loadingThread.IsAlive)
-                               return;                 
+                               return;
                        cancelLoading = true;
                        loadingThread.Join ();
                        cancelLoading = false;
@@ -341,7 +341,7 @@ namespace Crow
                                page = gs;
 
                        }else
-                               page = Activator.CreateInstance (items.GetType ()) as Group;                    
+                               page = Activator.CreateInstance (items.GetType ()) as Group;
 
                        page.Name = "page" + pageNum;
 
@@ -383,9 +383,20 @@ namespace Crow
                                itempKey = getItempKey (dataType, data [i]);
 
                        if (ItemTemplates.ContainsKey (itempKey))
-                                       iTemp = ItemTemplates [itempKey];
-                       else
-                               iTemp = ItemTemplates ["default"];
+                               iTemp = ItemTemplates [itempKey];
+                       else {
+                               foreach (string it in ItemTemplates.Keys) {
+                                       Type t = Type.GetType (it);
+                                       if (t == null)
+                                               continue;
+                                       if (t.IsAssignableFrom (dataType)) {//TODO:types could be cached
+                                               iTemp = ItemTemplates [it];
+                                               break;
+                                       }
+                               }
+                               if (iTemp == null)
+                                       iTemp = ItemTemplates ["default"];
+                       }
 
                        lock (CurrentInterface.LayoutMutex) {
                                g = iTemp.CreateInstance(CurrentInterface);