]> O.S.I.I.S - jp/crow.git/commitdiff
iface.POLLING_INTERVAL in the run loop, block comments for styling
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 13 Sep 2021 12:50:43 +0000 (12:50 +0000)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 13 Sep 2021 12:50:43 +0000 (12:50 +0000)
Crow/src/Fill/BmpPicture.cs
Crow/src/IML/IMLContext.cs
Crow/src/Interface.cs
Crow/src/Widgets/ComboBox.cs
Crow/src/Widgets/TemplatedControl.cs
Crow/src/styling/StyleReader.cs

index 8b72b8b3dfeaa90556e30f8fa74fbb95da7ac97b..6bf9add52aba856510dcc597ff7ea42302cb0c37 100644 (file)
@@ -40,7 +40,7 @@ namespace Crow
                        }
                        using (Stream stream = iFace.GetStreamFromPath (Path)) {
                                load (stream);
-                               //loadBitmap (new System.Drawing.Bitmap (stream));      
+                               //loadBitmap (new System.Drawing.Bitmap (stream));
                                iFace.sharedPictures[Path] = new sharedPicture (image, Dimensions);
                        }
                }
index 5d66a5e0ac327e1604a14afa23522227cc125108..a69f7b2d5f8d24398f5dec27264afd5fc1e59f3f 100644 (file)
@@ -49,10 +49,10 @@ namespace Crow.IML
                        il.Emit (OpCodes.Nop);
                        //set local GraphicObject to root object
                        ConstructorInfo ci = rootType.GetConstructor (
-                                       BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, 
+                                       BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
                                        null, Type.EmptyTypes, null);
                        if (ci == null)
-                               throw new Exception ("No default parameterless constructor found in " + rootType.Name);                 
+                               throw new Exception ("No default parameterless constructor found in " + rootType.Name);
                        il.Emit (OpCodes.Newobj, ci);
                        il.Emit (OpCodes.Stloc_0);
                        CompilerServices.emitSetCurInterface (il);
@@ -125,7 +125,7 @@ namespace Crow.IML
                }
                /// <summary>
                /// Stores all the names found in current iml for binding resolution if any of them
-               /// are targeting named widget 
+               /// are targeting named widget
                /// </summary>
                public void StoreCurrentName(string name){
                        if (!Names.ContainsKey(name))
@@ -136,7 +136,7 @@ namespace Crow.IML
                        foreach (BindingDefinition bd in UnresolvedTargets) {
                                if (bd.HasUnresolvedTargetName) {
                                        try {
-                                               ResolveName (bd);       
+                                               ResolveName (bd);
                                        } catch (Exception ex) {
                                                System.Diagnostics.Debug.WriteLine (ex.ToString ());
                                                continue;
index b8e52a5634d368e37e1424c25b06841542fe0b30..b46bf018d3468a331bc916ef660d6673fb1930d1 100644 (file)
@@ -478,8 +478,10 @@ namespace Crow
                public virtual void UpdateFrame () {
 #if VKVG
                        Update ();
-#endif
                        Thread.Sleep (UPDATE_INTERVAL);
+#else
+                       Thread.Sleep (POLLING_INTERVAL);
+#endif
                }
 
                public virtual void Quit () => Glfw3.SetWindowShouldClose (hWin, 1);
@@ -548,6 +550,11 @@ namespace Crow
                const int INIT_QUEUE_CAPACITY = 512;
                /// <summary>Time interval in milisecond between Updates of the interface</summary>
                public static int UPDATE_INTERVAL = 5;
+               /// <summary>
+               /// Time interval in milisecond between Glfw polling for devices. Wait is done in
+               /// the 'UpdateFrame' method in the 'Run' cycle and may be overriden.
+               /// </summary>
+               public static int POLLING_INTERVAL = 1;
                /// <summary>Crow configuration root path</summary>
                public static string CROW_CONFIG_ROOT;
                /// <summary>If true, mouse focus is given when mouse is over control</summary>
@@ -857,7 +864,7 @@ namespace Crow
                /// </summary>
                internal Dictionary<string, sharedPicture> sharedPictures = new Dictionary<string, sharedPicture> ();
 
-               static bool tryGetResource (Assembly a, string resId, out Stream stream) {
+               static bool tryFindResource (Assembly a, string resId, out Stream stream) {
                        stream = null;
                        if (a == null)
                                return false;
@@ -871,17 +878,17 @@ namespace Crow
                        if (path.StartsWith ("#", StringComparison.Ordinal)) {
                                Stream stream = null;
                                string resId = path.Substring (1);
-                               if (tryGetResource (Assembly.GetEntryAssembly (), resId, out stream))
+                               if (tryFindResource (Assembly.GetEntryAssembly (), resId, out stream))
                                        return stream;
                                string[] assemblyNames = resId.Split ('.');
                                if (AppDomain.CurrentDomain.GetAssemblies ().FirstOrDefault (aa => aa.GetName ().Name == assemblyNames[0]).TryGetResource (resId, out stream))
                                        return stream;
                                if (assemblyNames.Length > 3)
-                                       if (tryGetResource (AppDomain.CurrentDomain.GetAssemblies ()
+                                       if (tryFindResource (AppDomain.CurrentDomain.GetAssemblies ()
                                                .FirstOrDefault (aa => aa.GetName ().Name == $"{assemblyNames[0]}.{assemblyNames[1]}"), resId, out stream))
                                                return stream;
                                foreach (Assembly ca in crowAssemblies)
-                                       if (tryGetResource (ca, resId, out stream))
+                                       if (tryFindResource (ca, resId, out stream))
                                                return stream;
                                throw new Exception ("Resource not found: " + path);
                        }
index 22672645c4f79cc1f50a23473513c0d53ae74cf0..22103ac32ecb51feb88c8267ccbec703d87e970a 100644 (file)
@@ -28,7 +28,7 @@ namespace Crow
                        base.OnLayoutChanges (layoutType);
 
                        if (layoutType == LayoutingType.Width)
-                               MinimumPopupSize = new Size (this.Slot.Width, minimumPopupSize.Height);                 
+                               MinimumPopupSize = new Size (this.Slot.Width, minimumPopupSize.Height);
                }
        }
 }
index 909c4bb81e7298800a9d5849773a8dd4e20e12bb..c1e20eaea7bb5ace034cf98e7bb5ac5f2c8d7c61 100644 (file)
@@ -116,6 +116,9 @@ namespace Crow
                /// It must be an embedded ressource with ID = fullTypeName.template
                /// Entry assembly is search first, then the one where the type is defined
                /// </summary>
+               /// <Remark>
+               /// Setting the default template path in style will provide an interned string for itor search.
+               /// </Remark>
                /// <param name="template">Optional template instance</param>
                protected virtual void loadTemplate(Widget template = null)
                {
@@ -124,8 +127,8 @@ namespace Crow
 
                        if (template == null) {
                                try {
-                                       string defTmpId = $"#{this.GetType ().FullName}.template";
-                                       this.SetChild (IFace.GetInstantiator (defTmpId).CreateInstance());
+                                       string defaultTemplatePath = $"#{this.GetType().FullName}.template";
+                                       this.SetChild (IFace.GetInstantiator (defaultTemplatePath).CreateInstance());
                                } catch (Exception ex) {
                                        throw new Exception ($"Default template loading error for '{this.GetType ().FullName}'", ex);
                                }
index 2df90a22e09c3e171a9819bed5f0efbfaf231389..23e3047c71001cfa677adcee907aeb78af764cec 100644 (file)
@@ -89,9 +89,18 @@ namespace Crow
                                switch (Peek ()) {
                                case '/':
                                        ReadChar ();
-                                       if (PeekChar () != '/')
-                                               throw new ParserException (line, column, "Unexpected char '/'", resId);
-                                       ReadLine ();
+                                       if (PeekChar () == '/')
+                                               ReadLine ();
+                                       else if (PeekChar () == '*'){
+                                               while (!EndOfStream) {
+                                                       char c = ReadChar ();
+                                                       if (c == '*' && PeekChar () == '/') {
+                                                               ReadChar();
+                                                               break;
+                                                       }
+                                               }
+                                       }else
+                                               throw new ParserException (line, column, $"Unexpected char '{PeekChar ()}'", resId);
                                        break;
                                case ',':
                                        ReadChar ();