]> O.S.I.I.S - jp/crow.git/commitdiff
File dialog derived from Window, not functional
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 22 Oct 2016 12:04:54 +0000 (14:04 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 22 Oct 2016 12:04:54 +0000 (14:04 +0200)
modifié :         Default.style
modifié :         Templates/FileDialog.template
nouveau fichier : Tests/Interfaces/Unsorted/testFileDialog.crow
supprimé :        Tests/Interfaces/Unsorted/testFileDialog.goml
modifié :         Tests/Tests.csproj
modifié :         src/GraphicObjects/FileDialog.cs
divers
modifié :         src/GraphicObjects/HueSelector.cs
modifié :         src/LayoutingQueueItem.cs

Default.style
Templates/FileDialog.template
Tests/Interfaces/Unsorted/testFileDialog.crow [new file with mode: 0644]
Tests/Interfaces/Unsorted/testFileDialog.goml [deleted file]
Tests/Tests.csproj
src/GraphicObjects/FileDialog.cs
src/GraphicObjects/HueSelector.cs
src/LayoutingQueueItem.cs

index 9376a37f0790b62f9c9fa6e7f7f799c5ed645407..553be982c176f70cb6932429b03e42cc3d62f440 100644 (file)
@@ -63,6 +63,12 @@ Window {
        Width = 150;
        Height = 150;
 }
+FileDialog {
+       Focusable = true;
+       MinimumSize=50,50;
+       Width = 500;
+       Height = 300;
+}
 Border {
        Foreground = Gray;
 }
index c8a10c8d7462ecbca6486e33abe0fc27991d90c8..905fee44a54cc35fe187a3a50342565207860678 100644 (file)
@@ -1,24 +1,73 @@
 <?xml version="1.0"?>
-<Window Caption="OpenFile" Height="300" Width="500">
-       <VerticalStack Margin="5">
-               <TextBox Margin="1" Width="0" Height="-1" Text="{CurrentPath}"/>
-               <HorizontalStack >
-                       <ListBox Data="{Directories}" Width="-1" Height="0"
-                               Background="0.5,0.5,0.5,0.5"
-                               SelectedItemChanged="OnSelectedItemChanged"
-                               Template="#Crow.Templates.ScrollingListBox.goml" 
-                               ItemTemplate="#Crow.Templates.tmpDirItem.goml" >
-                       </ListBox>
-                       <ListBox Data="{Files}" Width="0" Height="0"
-                               Background="0.5,0.5,0.5,0.5"
-                               SelectedItemChanged="onFileListItemChanged"
-                               Template="#Crow.Templates.ScrollingListBox.goml" 
-                               ItemTemplate="#Crow.Templates.imgItemTemplate.goml">
-                       </ListBox>
-               </HorizontalStack>
-               <HorizontalStack Fit="true" HorizontalAlignment="Right">
-                       <Button Caption="Ok" MouseClick="onFileSelect"/>
-                       <Button Caption="Cancel"/>
+<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}"
+                               Background="{./Background}"
+                               MouseEnter="./onBorderMouseEnter"
+                               MouseLeave="./onBorderMouseLeave">
+       <VerticalStack Spacing="0">
+               <HorizontalStack Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9"
+                               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="{./Title}" />
+                       <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="Onyx">
+                       <VerticalStack Margin="5">
+                               <TextBox Text="{²./CurrentDirectory}"/>
+                               <HorizontalStack>
+                                       <DirectoryView Name="dv" CurrentDirectory="{²./CurrentDirectory}" SelectedItemChanged="./Tv_SelectedItemChanged"
+                                               Width="50%" Margin="1" ShowFiles="false">
+                                               <Template>
+                                                       <TreeView IsRoot="true" Name="treeView" Data="{./FileSystemEntries}"
+                                                                       SelectedItemChanged="./onSelectedItemChanged">
+                                                               <ItemTemplate DataType="System.IO.FileInfo">
+                                                                       <HorizontalStack Focusable="true"  Height="Fit" Width="Stretched" Background="{../Background}" >
+                                                                               <Image Margin="2" Width="14" Height="14"
+                                                                                       Path="#Crow.Images.Icons.file.svg"/>
+                                                                               <Label Text="{Name}" Width="Stretched"
+                                                                                       MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+                                                                                       MouseLeave="{Background=Transparent}"/>
+                                                                       </HorizontalStack>
+                                                               </ItemTemplate>
+                                                               <ItemTemplate DataType="System.IO.DirectoryInfo" Data="GetDirectories">
+                                                                       <Expandable Caption="{Name}" >
+                                                                               <Template>
+                                                                                       <VerticalStack>
+                                                                                               <HorizontalStack Spacing="1" Height="Fit"
+                                                                                                               MouseEnter="{Background=hgradient|0:BlueCrayola|1:Transparent}"
+                                                                                                               MouseLeave="{Background=Transparent}">
+                                                                                                       <Image Margin="2" Width="12" Height="12"
+                                                                                                               Path="{./Image}"
+                                                                                                               SvgSub="{./IsExpanded}"/>
+                                                                                                       <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>
+                                                               </ItemTemplate>
+                                                       </TreeView>
+                                               </Template>
+                                       </DirectoryView>
+                               </HorizontalStack>
+                               <HorizontalStack Fit="true" HorizontalAlignment="Right">
+                                       <Button Caption="Ok" MouseClick="onFileSelect"/>
+                                       <Button Caption="Cancel"/>
+                               </HorizontalStack>
+                       </VerticalStack>
+               </Container>
        </VerticalStack>
-</Window>
+</Border>
diff --git a/Tests/Interfaces/Unsorted/testFileDialog.crow b/Tests/Interfaces/Unsorted/testFileDialog.crow
new file mode 100644 (file)
index 0000000..dd59e23
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<FileDialog Title="Open File" />
+
diff --git a/Tests/Interfaces/Unsorted/testFileDialog.goml b/Tests/Interfaces/Unsorted/testFileDialog.goml
deleted file mode 100644 (file)
index 715ff2f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0"?>
-<FileDialog Width="500" Height="300"/>
-
index 82fe60b07c495506ad6a24d33b8402b27e96d99c..ea03ce1a3459b57010f749d1ede118e23661a5a0 100644 (file)
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="packages.config" />
-    <None Include="Interfaces\Unsorted\testFileDialog.goml">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
     <None Include="Interfaces\Unsorted\testTypeViewer.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="Interfaces\Divers\test2WayBinding.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\Unsorted\testFileDialog.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index 16a60a4f0f62c59437b5030b36b821f08bf279ec..543b27cc218d7ddb0edd21172e856ddff4e1d56c 100644 (file)
@@ -29,112 +29,103 @@ using System.Text.RegularExpressions;
 
 namespace Crow
 {
-       public class FileDialog: IValueChange
+       public class FileDialog: Window
        {
-               #region IValueChange implementation
-               public event EventHandler<ValueChangeEventArgs> ValueChanged;
-               public virtual void NotifyValueChanged(string MemberName, object _value)
-               {
-                       ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));                 
-               }
-               #endregion
-
-               Window window;
-               DirectoryInfo currentDir;
-               FileInfo selectedFile;
-               string searchPattern = "*";
+               string searchPattern, curDirectory;
 
                #region CTOR
-               public FileDialog ()
+               public FileDialog () : base()
                {
-                       currentDir = new DirectoryInfo (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
-                       //window = Interface..Load("#Crow.Templates.FileDialog.goml") as Window;
-                       window.DataSource = this;
                }
                #endregion
-
-               public string CurrentPath {
-                       get { return currentDir.FullName; }
+               //[DefaultValue(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))]
+               [XmlAttributeAttribute][DefaultValue("/home")]
+               public virtual string CurrentDirectory {
+                       get { return curDirectory; }
                        set {
-                               currentDir = new DirectoryInfo (value);
-                               NotifyValueChanged ("CurrentPath", CurrentPath);
+                               if (curDirectory == value)
+                                       return;
+                               curDirectory = value; 
+                               NotifyValueChanged ("CurrentDirectory", curDirectory);
+
                        }
-               }
-               public string SearchPattern {
+               } 
+
+               [XmlAttributeAttribute()][DefaultValue("*")]
+               public virtual string SearchPattern {
                        get { return searchPattern; }
                        set {
-                               searchPattern = value;
-                               NotifyValueChanged ("Files", Files);
-                       }
-               }
+                               if (searchPattern == value)
+                                       return;
+                               searchPattern = value; 
+                               NotifyValueChanged ("SearchPattern", searchPattern);
 
-               public DirectoryInfo[] Directories
-               {
-                       get {
-                               //currentDir.GetDirectories
-                               List<DirectoryInfo> tmp = currentDir.GetDirectories ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToList();
-                               if (currentDir.Parent != null)
-                                       tmp.Insert (0, currentDir.Parent);
-                               return tmp.ToArray ();
                        }
-               }
-               public FileInfo[] Files
-               {
-                       get {
-                               string[] exts = searchPattern.Replace("*","").Split ('|');
-                               //return currentDir.GetFiles (searchPattern).Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToArray();
-                               return currentDir.GetFiles().Where(f => exts.Any
-                                       (x => f.Name.EndsWith (x, StringComparison.InvariantCultureIgnoreCase))).ToArray();
-                       }
-               }
-
-               public void Show(){
-                        //.AddWidget(window);
-               }
-
-               void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e)
-               {
-                       currentDir = e.NewValue as DirectoryInfo;
-                       NotifyValueChanged ("CurrentPath", CurrentPath);
-                       NotifyValueChanged ("Directories", Directories);
-                       NotifyValueChanged ("Files", Files);
-
-               }
-               void onFileListItemChanged (object sender, SelectionChangeEventArgs e)
-               {
-                       selectedFile = e.NewValue as FileInfo;
-               }
-               void onFileSelect(object sender, MouseButtonEventArgs e){
-                       //OpenTKGameWindow.currentWindow.DeleteWidget(window);
-               }
-       }
-       public class DirContainer: IValueChange
-       {
-               #region IValueChange implementation
-               public event EventHandler<ValueChangeEventArgs> ValueChanged;
-               public void NotifyValueChanged(string name, object value)
-               {
-                       ValueChanged.Raise (this, new ValueChangeEventArgs (name, value));
-               }
-               #endregion
+               } 
 
-               public DirectoryInfo CurDir;
-               public DirContainer(DirectoryInfo _dir){
-                       CurDir = _dir;
-               }
-               public string Name {
-                       get { return CurDir.Name; }
-               }
-
-               void onDirUp(object sender, MouseButtonEventArgs e)
-               {
-
-               }
-               public void onMouseDown(object sender, MouseButtonEventArgs e)
-               {
-                       Debug.WriteLine (sender.ToString ());
-               }
+//             public DirectoryInfo[] Directories
+//             {
+//                     get {
+//                             //currentDir.GetDirectories
+//                             List<DirectoryInfo> tmp = currentDir.GetDirectories ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToList();
+//                             if (currentDir.Parent != null)
+//                                     tmp.Insert (0, currentDir.Parent);
+//                             return tmp.ToArray ();
+//                     }
+//             }
+//             public FileInfo[] Files
+//             {
+//                     get {
+//                             string[] exts = searchPattern.Replace("*","").Split ('|');
+//                             //return currentDir.GetFiles (searchPattern).Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToArray();
+//                             return currentDir.GetFiles().Where(f => exts.Any
+//                                     (x => f.Name.EndsWith (x, StringComparison.InvariantCultureIgnoreCase))).ToArray();
+//                     }
+//             }
 
+//             void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e)
+//             {
+//                     currentDir = e.NewValue as DirectoryInfo;
+//                     NotifyValueChanged ("CurrentPath", CurrentPath);
+//                     NotifyValueChanged ("Directories", Directories);
+//                     NotifyValueChanged ("Files", Files);
+//
+//             }
+//             void onFileListItemChanged (object sender, SelectionChangeEventArgs e)
+//             {
+//                     selectedFile = e.NewValue as FileInfo;
+//             }
+//             void onFileSelect(object sender, MouseButtonEventArgs e){
+//                     //OpenTKGameWindow.currentWindow.DeleteWidget(window);
+//             }
        }
+//     public class DirContainer: IValueChange
+//     {
+//             #region IValueChange implementation
+//             public event EventHandler<ValueChangeEventArgs> ValueChanged;
+//             public void NotifyValueChanged(string name, object value)
+//             {
+//                     ValueChanged.Raise (this, new ValueChangeEventArgs (name, value));
+//             }
+//             #endregion
+//
+//             public DirectoryInfo CurDir;
+//             public DirContainer(DirectoryInfo _dir){
+//                     CurDir = _dir;
+//             }
+//             public string Name {
+//                     get { return CurDir.Name; }
+//             }
+//
+//             void onDirUp(object sender, MouseButtonEventArgs e)
+//             {
+//
+//             }
+//             public void onMouseDown(object sender, MouseButtonEventArgs e)
+//             {
+//                     Debug.WriteLine (sender.ToString ());
+//             }
+//
+//     }
 }
 
index 7afd6f7ac61a921cf95fe801d552d5aa407c78d8..ec0a6f2ca4f2eb60a26a934652cfcd9c14417a89 100644 (file)
@@ -70,13 +70,13 @@ namespace Crow
 
                        Crow.Gradient grad = new Gradient (gt);
 
-                       grad.Stops.Add (new Gradient.ColorStop (0, new Color (1, 0, 0, 1)));
+                       grad.Stops.Add (new Gradient.ColorStop (0,     new Color (1, 0, 0, 1)));
                        grad.Stops.Add (new Gradient.ColorStop (0.167, new Color (1, 1, 0, 1)));
                        grad.Stops.Add (new Gradient.ColorStop (0.333, new Color (0, 1, 0, 1)));
-                       grad.Stops.Add (new Gradient.ColorStop (0.5, new Color (0, 1, 1, 1)));
+                       grad.Stops.Add (new Gradient.ColorStop (0.5,   new Color (0, 1, 1, 1)));
                        grad.Stops.Add (new Gradient.ColorStop (0.667, new Color (0, 0, 1, 1)));
                        grad.Stops.Add (new Gradient.ColorStop (0.833, new Color (1, 0, 1, 1)));
-                       grad.Stops.Add (new Gradient.ColorStop (1, new Color (1, 0, 0, 1)));
+                       grad.Stops.Add (new Gradient.ColorStop (1,     new Color (1, 0, 0, 1)));
 
                        grad.SetAsSource (gr, r);
                        CairoHelpers.CairoRectangle (gr, r, CornerRadius);
index 3b19efc9866bd30d798569e2d0f6c67687ba93d6..2257ae8eb231e6987f08f13c602f4466018c9da0 100644 (file)
@@ -96,7 +96,9 @@ namespace Crow
                        if (Layoutable.Parent == null) {//TODO:improve this
                                //cancel layouting for object without parent, maybe some were in queue when
                                //removed from a listbox
+                               #if DEBUG_LAYOUTING
                                Debug.WriteLine ("ERROR: processLayouting, no parent for: " + this.ToString ());
+                               #endif
                                return;
                        }
                        #if DEBUG_LAYOUTING