]> O.S.I.I.S - jp/crow.git/commitdiff
Correct bug 'Instanciing from code instead of IML'
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 16 Aug 2016 13:23:34 +0000 (15:23 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 16 Aug 2016 13:23:34 +0000 (15:23 +0200)
set currentInterface to default one if null
modifié :         Crow.OpenTK.nuspec
modifié :         src/CompilerServices/CompilerServices.cs
modifié :         src/GraphicObjects/Container.cs
modifié :         src/GraphicObjects/GraphicObject.cs
modifié :         src/GraphicObjects/PrivateContainer.cs
modifié :         src/GraphicObjects/TemplatedControl.cs
modifié :         src/Interface.cs

Crow.OpenTK.nuspec
src/CompilerServices/CompilerServices.cs
src/GraphicObjects/Container.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/TemplatedControl.cs
src/Interface.cs

index e3f20cd60e51e3e2d2a22de3870b3ba8d321d921..1a6221f79395ce951b979aef1c14543b521bd881 100644 (file)
@@ -2,7 +2,7 @@
 <package >
        <metadata>
                <id>Crow.OpenTK</id>
-               <version>0.4.6</version>
+               <version>0.4.8</version>
                <title>C# Rapid Open Widget Toolkit</title>
                <authors>JP Bruyere</authors>
                <owners>Grand Tetras Software</owners>
@@ -22,7 +22,7 @@ Crow.OpenTK is the OpenTK ready version.
 
 For more information, please visit https://jpbruyere.github.io/Crow/.
                </summary>
-               <releaseNotes>pre-alpha release, minimal OpenTK implementation.</releaseNotes>
+               <releaseNotes>alpha release</releaseNotes>
                <copyright>Copyright 2016</copyright>
                <dependencies>
                        <dependency id="OpenTK.Next" version="1.2" />
index 79d3745d896f79cb528e2ef88f1fac1de283f988..7a73574b959d2f76a01990fed510356d7c082832 100644 (file)
@@ -13,8 +13,8 @@ namespace Crow
        public static class CompilerServices
        {
                static MethodInfo miAddBinding = typeof(GraphicObject).GetMethod ("BindMember");
-               static FieldInfo miSetCurIface = typeof(GraphicObject).
-                       GetField ("CurrentInterface", BindingFlags.NonPublic | BindingFlags.Instance);
+               static FieldInfo miSetCurIface = typeof(GraphicObject).GetField ("currentInterface",
+                       BindingFlags.NonPublic | BindingFlags.Instance);
 
                public static void emitSetCurInterface(ILGenerator il){
                        il.Emit (OpCodes.Ldloc_0);
index fb4a7834f80ed229eeb58a1874e9a879a33c3d29..0b6045bb0a690c77e9b8d209b40c5ddbe79c2ee1 100644 (file)
@@ -14,10 +14,6 @@ namespace Crow
                        : base()
                {
                }
-               public Container(Rectangle _bounds)
-                       : base(_bounds)
-               {
-               }
                #endregion
 
                [XmlIgnore]
index bd96b76c3f594c811b8a222cc9a6568dfecf33a3..0cde106a41653d8a4cdec0f0d2ac56701e3553f8 100644 (file)
@@ -25,6 +25,21 @@ namespace Crow
                internal static ulong currentUid = 0;
                internal ulong uid = 0;
 
+               Interface currentInterface = null;
+
+               public Interface CurrentInterface {
+                       get {
+                               if (currentInterface == null) {
+                                       currentInterface = Interface.CurrentInterface;
+                                       initialize ();
+                               }
+                               return currentInterface;
+                       }
+                       set {
+                               currentInterface = value;
+                       }
+               }
+
                Rectangles clipping = new Rectangles();
                public Rectangles Clipping { get { return clipping; }}
 
@@ -41,23 +56,11 @@ namespace Crow
                {
                        uid = currentUid;
                        currentUid++;
-
-//                     if (CurrentInterface.XmlLoading)
-//                             return;
-//                     loadDefaultValues ();
-               }
-               public GraphicObject (Rectangle _bounds)
-               {
-//                     if (!CurrentInterface.XmlLoading)
-//                             loadDefaultValues ();
-                       
-                       Left = _bounds.Left;
-                       Top = _bounds.Top;
-                       Width = _bounds.Width;
-                       Height = _bounds.Height;
                }
                #endregion
-
+               internal protected virtual void initialize(){
+                       loadDefaultValues ();
+               }
                #region private fields
                LayoutingType registeredLayoutings = LayoutingType.All;
                ILayoutable logicalParent;
@@ -729,7 +732,6 @@ namespace Crow
                        if (RegisteredLayoutings == LayoutingType.None)
                                CurrentInterface.EnqueueForRepaint (this);
                }
-               internal Interface CurrentInterface = null;
                #endregion
 
                #region Layouting
index 5f70dd17a42cdff9af0827e45b451507979c68a6..2a5deeaaa6866c0bf673e177d418324e9fa7c26c 100644 (file)
@@ -39,10 +39,6 @@ namespace Crow
                        : base()
                {
                }
-               public PrivateContainer(Rectangle _bounds)
-                       : base(_bounds)
-               {
-               }
                #endregion
 
                protected GraphicObject child;
index b77c89e3dd6a6bfe2239da0388115010d531d0cb..02d6108ac6b7c5d1f11ef8ff18d8131d58fa3b44 100644 (file)
@@ -36,12 +36,15 @@ namespace Crow
                #region CTOR
                public TemplatedControl () : base()
                {
-//                     if (CurrentInterface.XmlLoading)
-//                             return;
-                       //loadTemplate ();
                }
                #endregion
 
+               internal protected override void initialize ()
+               {
+                       loadTemplate ();
+                       base.initialize ();
+               }
+
                string _template;
                string _itemTemplate;
                public Dictionary<string, ItemTemplate> ItemTemplates = new Dictionary<string, Crow.ItemTemplate>();//TODO: dont instantiate if not used
index bc0d1f98651761d3365a6b03a3d156b4ddf9dd1c..0d97685e5e6d61f63a2defb0b249dbd74464d133 100644 (file)
@@ -56,6 +56,7 @@ namespace Crow
                        FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb;
                }
                public Interface(){
+                       CurrentInterface = this;
                        CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; 
                }
                #endregion
@@ -86,7 +87,7 @@ namespace Crow
                public static FontOptions FontRenderingOptions;
                #endregion
 
-               internal bool XmlLoading = true;
+               internal static Interface CurrentInterface;
 
                public Dictionary<string,object> Ressources = new Dictionary<string, object>();
                public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem> ();