From 3e93e1e290952df1c9ed86ffea8835e2f12679a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Mon, 13 Sep 2021 12:50:43 +0000 Subject: [PATCH] iface.POLLING_INTERVAL in the run loop, block comments for styling --- Crow/src/Fill/BmpPicture.cs | 2 +- Crow/src/IML/IMLContext.cs | 8 ++++---- Crow/src/Interface.cs | 17 ++++++++++++----- Crow/src/Widgets/ComboBox.cs | 2 +- Crow/src/Widgets/TemplatedControl.cs | 7 +++++-- Crow/src/styling/StyleReader.cs | 15 ++++++++++++--- 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/Crow/src/Fill/BmpPicture.cs b/Crow/src/Fill/BmpPicture.cs index 8b72b8b3..6bf9add5 100644 --- a/Crow/src/Fill/BmpPicture.cs +++ b/Crow/src/Fill/BmpPicture.cs @@ -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); } } diff --git a/Crow/src/IML/IMLContext.cs b/Crow/src/IML/IMLContext.cs index 5d66a5e0..a69f7b2d 100644 --- a/Crow/src/IML/IMLContext.cs +++ b/Crow/src/IML/IMLContext.cs @@ -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 } /// /// Stores all the names found in current iml for binding resolution if any of them - /// are targeting named widget + /// are targeting named widget /// 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; diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index b8e52a56..b46bf018 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -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; /// Time interval in milisecond between Updates of the interface public static int UPDATE_INTERVAL = 5; + /// + /// Time interval in milisecond between Glfw polling for devices. Wait is done in + /// the 'UpdateFrame' method in the 'Run' cycle and may be overriden. + /// + public static int POLLING_INTERVAL = 1; /// Crow configuration root path public static string CROW_CONFIG_ROOT; /// If true, mouse focus is given when mouse is over control @@ -857,7 +864,7 @@ namespace Crow /// internal Dictionary sharedPictures = new Dictionary (); - 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); } diff --git a/Crow/src/Widgets/ComboBox.cs b/Crow/src/Widgets/ComboBox.cs index 22672645..22103ac3 100644 --- a/Crow/src/Widgets/ComboBox.cs +++ b/Crow/src/Widgets/ComboBox.cs @@ -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); } } } diff --git a/Crow/src/Widgets/TemplatedControl.cs b/Crow/src/Widgets/TemplatedControl.cs index 909c4bb8..c1e20eae 100644 --- a/Crow/src/Widgets/TemplatedControl.cs +++ b/Crow/src/Widgets/TemplatedControl.cs @@ -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 /// + /// + /// Setting the default template path in style will provide an interned string for itor search. + /// /// Optional template instance 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); } diff --git a/Crow/src/styling/StyleReader.cs b/Crow/src/styling/StyleReader.cs index 2df90a22..23e3047c 100644 --- a/Crow/src/styling/StyleReader.cs +++ b/Crow/src/styling/StyleReader.cs @@ -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 (); -- 2.47.3