]> O.S.I.I.S - jp/crow.git/commitdiff
unbox value type in emitGetSubData, FileDialog enabled for folder only, minimum size...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 2 Feb 2021 19:18:53 +0000 (20:18 +0100)
committerj-p <jp_bruyere@hotmail.com>
Sat, 6 Feb 2021 19:28:02 +0000 (20:28 +0100)
Crow/Default.style
Crow/Templates/Button.template
Crow/Templates/FileDialog.template
Crow/src/Command.cs
Crow/src/Interface.cs
Crow/src/ItemTemplate.cs
Crow/src/Widgets/FileDialog.cs
Samples/DebugLogAnalyzer/DbgLogViewer.cs
Samples/common/ui/Interfaces/Divers/0.crow

index b99680b1821cdf13de3a76f311662c9fff48789e..db754c1b8d508e03bebe57178fb444a327d814bf 100644 (file)
@@ -67,6 +67,7 @@ Wrapper {
 }
 Button {
        Caption = "Button";
+       MinimumSize = "50,20";
        Width = "Fit";
 }
 Label {
index 14b14a2f80be8828870d772b7b752b72339b5399..c46da8c6b881bfdc4fbd76a69dd72d3c62215561 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<Border Background="{./Background}" MinimumSize="50,20" Name="Content"
+<Border Background="{./Background}" Name="Content"
        Foreground="Transparent" CornerRadius="{../CornerRadius}" BorderWidth="1"
        MouseEnter="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black};{caption.Foreground=White}"
        MouseLeave="{Foreground=Transparent};{caption.Foreground=LightGrey}"
index 5140aae7813b4c4778ee0625ad5c663e350592f2..3967d9d8dc3956cf6c562ebac89fbf138bbeca64 100644 (file)
@@ -22,7 +22,7 @@
                                        <TextBox Style="TxtInFileDialog" Text="{²./CurrentDirectory}"/>
                                </HorizontalStack>
                                <DirectoryView ShowHidden="{²../cbShowHidden.IsChecked}" FileMask="{²../txtFileMask.Text}" ShowFiles="{²../cbShowFiles.IsChecked}" Name="fv" CurrentDirectory="{./CurrentDirectory}" SelectedItemChanged="./onFVSelectedItemChanged"
-                                               Width="100%" Margin="0" MouseDoubleClick="./onFileSelect">
+                                               Width="100%" Margin="0" MouseDoubleClick="./onFileSelectDblClick">
                                        <Template>
                                                <ListBox ItemTemplate="#Crow.FileItems.template" Name="fileView" Data="{./FileSystemEntries}"
                                                        SelectedItemChanged="./onSelectedItemChanged">
index caa8a3b0ea5be5fc24773b8a0e4e324aceba68a6..a068224ebafd0ccdeab0b5cdbafefcb0f1273420 100644 (file)
@@ -59,6 +59,7 @@ namespace Crow {
                #endregion
 
                #region CTOR
+               public Command () {}
                /// <summary>
                /// Initializes a new instance of Command with the action pass as argument.
                /// </summary>
index 12df8553d1fb22fce5baff02f29c7a6aa05278ae..d22c58e9538ec4f4d20919a95464b204747917c8 100644 (file)
@@ -70,25 +70,31 @@ namespace Crow
                        if (!Directory.Exists (CROW_CONFIG_ROOT))
                                Directory.CreateDirectory (CROW_CONFIG_ROOT);
 
-                       //ensure all assemblies are loaded, because IML could contains classes not instanciated in source
-                       foreach (string af in Directory.GetFiles (AppDomain.CurrentDomain.BaseDirectory, "*.dll")) {
-                               try {
-                                       Assembly a =Assembly.LoadFrom (af);
-                                       if (a == Assembly.GetEntryAssembly () || a == Assembly.GetExecutingAssembly ())
-                                               continue;
-                                       if (a.GetCustomAttribute (typeof (CrowAttribute)) != null) 
-                                               crowAssemblies.Add (a);
-                               } catch {
-                                       Debug.WriteLine ("{0} not loaded as assembly.", af);
-                               }
-                       }
-
                        FontRenderingOptions = new FontOptions ();
                        FontRenderingOptions.Antialias = Antialias.Subpixel;
                        FontRenderingOptions.HintMetrics = HintMetrics.On;
                        FontRenderingOptions.HintStyle = HintStyle.Full;
                        FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default;
+
+                       preloadCrowAssemblies ();
                }
+               static void preloadCrowAssemblies () {
+                       //ensure all assemblies are loaded, because IML could contains classes not instanciated in source
+                       Assembly ea = Assembly.GetEntryAssembly ();
+                       System.IO.FileStream[] files = ea.GetFiles ();
+                       foreach (AssemblyName an in ea.GetReferencedAssemblies()) {
+                               try {
+                                       Assembly a = Assembly.ReflectionOnlyLoad (an.Name);
+                                       if (a == Assembly.GetExecutingAssembly ())
+                                                       continue;
+                                       if (a.GetCustomAttribute (typeof (CrowAttribute)) != null)
+                                                       crowAssemblies.Add (a);
+                               } catch {
+
+                               }                                                                                       
+                       }
+               }
+
                public Interface (int width, int height, IntPtr glfwWindowHandle) : this (width, height, false, false)
                {
                        hWin = glfwWindowHandle;
@@ -172,6 +178,30 @@ namespace Crow
                                throw new PlatformNotSupportedException ("Unable to create cairo surface.");
                        }
                }
+               internal Dictionary<string, MethodInfo> knownExtMethods = new Dictionary<string, MethodInfo> ();
+               internal MethodInfo SearchExtMethod (Type t, string methodName) {
+                       string key = t.Name + "." + methodName;
+                       if (knownExtMethods.ContainsKey (key))
+                               return knownExtMethods [key];
+
+                       //System.Diagnostics.Debug.WriteLine ($"*** search extension method: {t};{methodName} => key={key}");
+
+                       MethodInfo mi = null;
+                       if (!CompilerServices.TryGetExtensionMethods (Assembly.GetEntryAssembly (), t, methodName, out mi)) {
+                               if (!CompilerServices.TryGetExtensionMethods (t.Module.Assembly, t, methodName, out mi)) {
+                                       foreach (Assembly a in crowAssemblies) {
+                                               if (CompilerServices.TryGetExtensionMethods (a, t, methodName, out mi))
+                                                       break;
+                                       }
+                                       if (mi == null)
+                                               CompilerServices.TryGetExtensionMethods (Assembly.GetExecutingAssembly (), t, methodName, out mi);//crow Assembly
+                               }
+                       }
+
+                       //add key even if mi is null to prevent searching again and again for propertyless bindings
+                       knownExtMethods.Add (key, mi);
+                       return mi;
+               }
 
                #region events delegates
 
index e16962560fee5269a49a3f2182b938ee5ae8a916..cf182b42c0b1cf5df027959a10c35cab82f11dd8 100644 (file)
@@ -228,9 +228,11 @@ namespace Crow
                }
                //data is on the stack
                void emitGetSubData(ILGenerator il, Type dataType){
+                       if (dataType.IsValueType)
+                               il.Emit (OpCodes.Unbox_Any, dataType);
                        MethodInfo miGetDatas = dataType.GetMethod (fetchMethodName, new Type[] {});
                        if (miGetDatas == null)
-                               miGetDatas = CompilerServices.SearchExtMethod (dataType, fetchMethodName);
+                               miGetDatas = iface.SearchExtMethod (dataType, fetchMethodName);
 
                        if (miGetDatas == null) {//in last resort, search among properties
                                PropertyInfo piDatas = dataType.GetProperty (fetchMethodName);
index 1a7ec842ba2ac83301376ace8bd472548a7c80da..bc6b46c037d4c5c12aa7d742463ce3999ed7dd9e 100644 (file)
@@ -106,19 +106,24 @@ namespace Crow
                                SelectedDirectory = e.NewValue.ToString();
                }
                public void goUpDirClick (object sender, MouseButtonEventArgs e){
-                       string root = Directory.GetDirectoryRoot(CurrentDirectory);                     
-                       DirectoryInfo parentDir = Directory.GetParent (CurrentDirectory);
-                       if (parentDir == null)
+                       string root = Directory.GetDirectoryRoot(CurrentDirectory);
+                       if (CurrentDirectory == root)
                                return;
-                       CurrentDirectory = parentDir.FullName;
+                       CurrentDirectory = Directory.GetParent(CurrentDirectory).FullName;
                }
-               void onFileSelect(object sender, MouseButtonEventArgs e){
-                       if (string.IsNullOrEmpty (SelectedFile))
-                               CurrentDirectory = SelectedDirectory;
-                       else {
-                               OkClicked.Raise (this, null);
-                               IFace.DeleteWidget (this);
+               void onFileSelectDblClick (object sender, MouseButtonEventArgs e) {
+                       CurrentDirectory = SelectedDirectory;
+               }
+
+               void onFileSelect (object sender, MouseButtonEventArgs e){
+                       if (ShowFiles) {
+                               if (string.IsNullOrEmpty (SelectedFile)) {
+                                       CurrentDirectory = SelectedDirectory;
+                                       return;
+                               }                                                                       
                        }
+                       OkClicked.Raise (this, null);
+                       IFace.DeleteWidget (this);
                }
                void onCancel(object sender, MouseButtonEventArgs e){
                        IFace.DeleteWidget (this);
index 0d6bdfa96209432d7f73e5b16ad90c9d693a0ffb..49facb5a5bf99b473a116570a3f6dacf08075154 100644 (file)
@@ -364,9 +364,9 @@ namespace Crow
                        }*/
 
                }
-               public override void Paint (ref Cairo.Context ctx)
+               public override void Paint (Cairo.Context ctx)
                {
-                       base.Paint (ref ctx);
+                       base.Paint (ctx);
 
                        Rectangle r = new Rectangle(mousePos.X, 0, 1, Slot.Height);
                        Rectangle ctxR = ContextCoordinates (r);
index ea52615705139697f65989c10dddc057830c8ec8..adc13fd87aff5f1f923df069434402e0b7546a40 100644 (file)
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Window Caption="Showcase" Height="90%" Width="90%" Background="Jet">
+<?xml version="1.0" encoding="UTF-8"?>
+<Window Caption="Showcase" Height="90%" Width="90%" Background="DarkGrey">
        <HorizontalStack>
                <VerticalStack Width="30%" Margin="5">
                        <GroupBox Caption="Performance" Height="Fit">
                                        </VerticalStack>
                                        <Splitter />
                                        <VerticalStack Width="50%">
-                                               <RadioButton Style="CheckBox2" />
-                                               <RadioButton Style="CheckBox2" />
-                                               <RadioButton Style="CheckBox2" />
-                                               <RadioButton Style="CheckBox2" />
+                                               <RadioButton Style="CheckBox2" Caption="RadioButton"/>
+                                               <RadioButton Style="CheckBox2" Caption="RadioButton"/>
+                                               <RadioButton Style="CheckBox2" Caption="RadioButton"/>
+                                               <RadioButton Style="CheckBox2" Caption="RadioButton"/>
                                        </VerticalStack>
                                </HorizontalStack>
                        </GroupBox>