From: jpbruyere Date: Tue, 16 Aug 2016 13:23:34 +0000 (+0200) Subject: Correct bug 'Instanciing from code instead of IML' X-Git-Tag: v0.4~6 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=8c7cd405658cbe7e4d64be189549b8125300964f;p=jp%2Fcrow.git Correct bug 'Instanciing from code instead of IML' 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 --- diff --git a/Crow.OpenTK.nuspec b/Crow.OpenTK.nuspec index e3f20cd6..1a6221f7 100644 --- a/Crow.OpenTK.nuspec +++ b/Crow.OpenTK.nuspec @@ -2,7 +2,7 @@ Crow.OpenTK - 0.4.6 + 0.4.8 C# Rapid Open Widget Toolkit JP Bruyere Grand Tetras Software @@ -22,7 +22,7 @@ Crow.OpenTK is the OpenTK ready version. For more information, please visit https://jpbruyere.github.io/Crow/. - pre-alpha release, minimal OpenTK implementation. + alpha release Copyright 2016 diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index 79d3745d..7a73574b 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -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); diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs index fb4a7834..0b6045bb 100644 --- a/src/GraphicObjects/Container.cs +++ b/src/GraphicObjects/Container.cs @@ -14,10 +14,6 @@ namespace Crow : base() { } - public Container(Rectangle _bounds) - : base(_bounds) - { - } #endregion [XmlIgnore] diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index bd96b76c..0cde106a 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -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 diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 5f70dd17..2a5deeaa 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -39,10 +39,6 @@ namespace Crow : base() { } - public PrivateContainer(Rectangle _bounds) - : base(_bounds) - { - } #endregion protected GraphicObject child; diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index b77c89e3..02d6108a 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -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 ItemTemplates = new Dictionary();//TODO: dont instantiate if not used diff --git a/src/Interface.cs b/src/Interface.cs index bc0d1f98..0d97685e 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -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 Ressources = new Dictionary(); public Queue LayoutingQueue = new Queue ();