]> O.S.I.I.S - jp/crow.git/commitdiff
search default template with Interface.GetStreamFromPath, add LoadStyle public method...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 4 Jun 2020 21:16:35 +0000 (23:16 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 4 Jun 2020 21:16:35 +0000 (23:16 +0200)
Crow/src/IML/Instantiator.cs
Crow/src/Interface.cs
Crow/src/Widgets/TemplatedControl.cs
Crow/src/Widgets/Widget.cs
Crow/src/styling/StyleReader.cs
Samples/BasicTests/BasicTests.cs
Samples/common/ui/Interfaces/Divers/templateInStyle.crow [new file with mode: 0644]

index 9668a8c270ea9ea035cee642742a58223383f233..c1a11f039f6f9f2d541f805bbd3e4894952a0865 100644 (file)
@@ -298,6 +298,7 @@ namespace Crow.IML {
                                bool inlineTemplate = false;
 
                                reader.Read ();
+
                                string templatePath = reader.GetAttribute ("Template");
                                string itemTemplatePath = reader.GetAttribute ("ItemTemplate");
 
index 9757e76ee0a189416525de337b6457e2af0ac0ed..77360f3eae4b3a7477d6366327e24597e6b59883 100644 (file)
@@ -152,7 +152,6 @@ namespace Crow
                        Glfw3.SetCharCallback (hWin, HandleCharDelegate);
                        Glfw3.SetWindowSizeCallback (hWin, HandleWindowSizeDelegate);
 
-                       //Glfw3.SetWindowTitle (hWin, "FPS: " + fps.ToString ());
                        switch (Environment.OSVersion.Platform) {
                        case PlatformID.MacOSX:
                                break;
@@ -208,6 +207,9 @@ namespace Crow
 
                #endregion
 
+               public string WindowTitle {
+                       set => Glfw3.SetWindowTitle (hWin, value);
+               }
 
                public bool Running {
                        get => !Glfw3.WindowShouldClose (hWin);
@@ -482,9 +484,18 @@ namespace Crow
                                .GetManifestResourceNames ()
                                .Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) {
                                using (StyleReader sr = new StyleReader (assembly.GetManifestResourceStream (s))) 
-                                       sr.Parse (this.StylingConstants, this.Styling, s);                              
+                                       sr.Parse (StylingConstants, Styling, s);                                
                        }
                }
+               public void LoadStyle (string stylePath) {
+                       using (Stream s = new FileStream (stylePath, FileMode.Open))
+                               LoadStyle (s, stylePath);
+
+               }
+               public void LoadStyle (Stream stream, string resId) {
+                       using (StyleReader sr = new StyleReader (stream))
+                               sr.Parse (StylingConstants, Styling, resId);
+               }
                #endregion
 
 
index 614bc1ac09c2ac565366c7c5dcb852430c13aaab..ae2967d0d282ee447317f810a2c073fb0c27a98c 100644 (file)
@@ -118,9 +118,7 @@ namespace Crow
 
                                if (!IFace.DefaultTemplates.ContainsKey (mdTok)) {
                                        string defTmpId = this.GetType ().FullName + ".template";
-                                       Stream s = Assembly.GetEntryAssembly ()?.GetManifestResourceStream (defTmpId);
-                                       if (s == null)
-                                               s = Assembly.GetAssembly (this.GetType ()).GetManifestResourceStream (defTmpId);
+                                       Stream s = Interface.GetStreamFromPath ("#" + defTmpId);
                                        if (s == null)
                                                throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName));
                                        IFace.DefaultTemplates [mdTok] = new IML.Instantiator (IFace, s, defTmpId);
index de079e1500d1ca16dd6519a3bddd488b44c9c093..96f4ce7b8437ea74cef760399af210fbf9f771ea 100644 (file)
@@ -1708,8 +1708,8 @@ namespace Crow
                        else if (LastPaintedSlot.Width != Slot.Width || LastPaintedSlot.Height != Slot.Height)
                                bmp.SetSize (Slot.Width, Slot.Height);*/
                        bmp?.Dispose ();
-                       //bmp = IFace.surf.CreateSimilar (Content.ColorAlpha, Slot.Width, Slot.Height);
-                       bmp = new ImageSurface(Format.Argb32, Slot.Width, Slot.Height);
+                       bmp = IFace.surf.CreateSimilar (Content.ColorAlpha, Slot.Width, Slot.Height);
+                       //bmp = new ImageSurface(Format.Argb32, Slot.Width, Slot.Height);
 
                        using (Context gr = new Context (bmp)) {
                                gr.Antialias = Interface.Antialias;
index 96b79b9e10b32203bf1f7b1bdcc0f20fc4cd6275..84839890a5826234d16eb83addcd2106ef037ead 100644 (file)
@@ -66,7 +66,7 @@ namespace Crow
                        line = 1;
                        curState = States.classNames;
 
-                       string styleKey = resId.Substring (0, resId.Length - 6);
+                       //string styleKey = resId.Substring (0, resId.Length - 6);
                        string token = "";
                        List<string> targetsClasses = new List<string> ();
                        string currentProperty = "";
index e32b608011e2187875f59be2103773949cdd0f6b..13c0758ce26aa14973ecff9b544ee738121ad7e3 100644 (file)
@@ -37,7 +37,8 @@ namespace tests
                        //testFiles = new string [] { @"Interfaces/TemplatedGroup/3.crow" };
                        //testFiles = new string [] { @"Interfaces/Divers/testShape.crow" };
                        //testFiles = new string [] { @"Interfaces/TemplatedControl/testEnumSelector.crow" };
-                       testFiles = new string [] { @"Interfaces/Divers/all.crow" };
+                       //testFiles = new string [] { @"Interfaces/Divers/all.crow" };
+                       testFiles = new string [] { @"Interfaces/Divers/templateInStyle.crow" };
                        //testFiles = new string [] { @"Interfaces/Divers/colorPicker2.crow" };
                        testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray ();
                        testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray ();
diff --git a/Samples/common/ui/Interfaces/Divers/templateInStyle.crow b/Samples/common/ui/Interfaces/Divers/templateInStyle.crow
new file mode 100644 (file)
index 0000000..159aa10
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CheckBox Style="CheckBox2" />
\ No newline at end of file