]> O.S.I.I.S - jp/crow.git/commitdiff
CurrentInterface in GraphicObject base 19/head
authorjpbruyere <jp.bruyere@hotmail.com>
Sun, 14 Aug 2016 23:49:35 +0000 (01:49 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Sun, 14 Aug 2016 23:49:35 +0000 (01:49 +0200)
27 files changed:
Crow.csproj
Templates/DirectoryView.template
Templates/Window.template
Templates/treeList.crow [new file with mode: 0755]
Tests/BasicTests.cs
Tests/Interfaces/basicTests/0.crow
src/CompilerServices/CompilerServices.cs
src/GraphicObjects/Border.cs
src/GraphicObjects/FileDialog.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Grid.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/ListBox.cs
src/GraphicObjects/Popper.cs
src/GraphicObjects/Splitter.cs
src/GraphicObjects/TabView.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/TextBox.cs
src/GraphicObjects/Window.cs
src/GraphicObjects/Wrapper.cs
src/IMLReader.cs
src/Instantiator.cs
src/Interface.cs
src/ItemTemplate.cs
src/LayoutingQueueItem.cs

index cf48acaa5a05aa18cc3f74dbb071c872040d61af..05d5dbd943651bf56b7fece919c2cf84140293d2 100644 (file)
       <LogicalName>Crow.Window.template</LogicalName>
     </EmbeddedResource>
     <EmbeddedResource Include="Images\Icons\Cursors\ibeam" />
+    <EmbeddedResource Include="Templates\treeList.crow" />
   </ItemGroup>
   <ItemGroup>
     <None Include="README.md" />
index e861ef8e5def9afd417136b57791cf42a193bb0f..13f10f1100da5f9feddd327822c23706ebdd7aba 100755 (executable)
@@ -32,7 +32,7 @@
                        <HorizontalStack Height="Fit" Width="{./WidthPolicy}">
                                <GraphicObject Width="12" Height="10"/>
                                <TreeView Name="List" Height="Fit" Width="{./WidthPolicy}"
-                                       Template="#Tests.Interfaces.treeList.crow" />
+                                       Template="#Crow.Templates.treeList.crow" />
                        </HorizontalStack>
                </Expandable>
        </ItemTemplate>
index 1ca344d6fad8b4b87346bc6bdd0df8ebb1702478..481c030b119998e31b77797c454eca1a0cda1ff9 100755 (executable)
@@ -1,8 +1,8 @@
 <?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="White" CornerRadius="20" Height="{./HeightPolicy}" Width="{./WidthPolicy}"
+<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}" Height="{./HeightPolicy}" Width="{./WidthPolicy}"
                                MouseEnter="./onBorderMouseEnter"
                                MouseLeave="./onBorderMouseLeave">
-       <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+       <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}" Spacing="0">
 <!--           <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{./WidthPolicy}" Height="Fit"
                                Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">-->
                        <HorizontalStack Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9"
diff --git a/Templates/treeList.crow b/Templates/treeList.crow
new file mode 100755 (executable)
index 0000000..61ee12a
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<VerticalStack
+       Height="Fit" Width="{../WidthPolicy}" Name="List"/>
\ No newline at end of file
index 970480f26abd726e53830d1e53906b7f6461d684..1114cdf304fcc6d6fd1528ad0843c1452979a5b7 100644 (file)
@@ -157,7 +157,7 @@ namespace Tests
                                Instantiator i = new Instantiator(fi.FullName);
                                lock (CrowInterface.UpdateMutex) {
                                        (CrowInterface.FindByName ("crowContainer") as Container).SetChild
-                                       (i.CreateInstance());
+                                       (i.CreateInstance(CrowInterface));
                                        CurSources = i.GetImlSourcesCode();
                                }
                        }
@@ -172,7 +172,7 @@ namespace Tests
                        }
                        lock (CrowInterface.UpdateMutex) {
                                (CrowInterface.FindByName ("crowContainer") as Container).SetChild
-                               (i.CreateInstance());
+                               (i.CreateInstance(CrowInterface));
                        }
                }
                void onButClick(object send, MouseButtonEventArgs e)
index c41c13178d23ffc96afdb02d1227a876fffa3870..42930b0a6740b8a5bbe7557995cc19d7d9474c6f 100755 (executable)
@@ -1,7 +1,8 @@
 <?xml version="1.0"?>
-<Group Background="SeaGreen" Fit="true" Margin="1">
-<Border Foreground="White" Margin="10" Width="Fit" Height="Fit" Background="DarkRed" BorderWidth="1">
+<CheckBox/>
+<!--<Group Background="SeaGreen" Fit="true" Margin="1">
+<Border Foreground="White" Margin="2" CornerRadius="20" Width="Fit" Height="Fit" Background="DarkRed" BorderWidth="1">
        <TextBox Multiline="true" Font="mono, 12" Margin="0" 
                Text="this is a test of double click\n and here a second line of text\n and again a third one"/>
 </Border>
-</Group>
\ No newline at end of file
+</Group>-->
\ No newline at end of file
index d06cd29b2c623c1565c43c53bbe06b7be422ac6e..79d3745d896f79cb528e2ef88f1fac1de283f988 100644 (file)
@@ -13,8 +13,14 @@ namespace Crow
        public static class CompilerServices
        {
                static MethodInfo miAddBinding = typeof(GraphicObject).GetMethod ("BindMember");
+               static FieldInfo miSetCurIface = typeof(GraphicObject).
+                       GetField ("CurrentInterface", BindingFlags.NonPublic | BindingFlags.Instance);
 
-
+               public static void emitSetCurInterface(ILGenerator il){
+                       il.Emit (OpCodes.Ldloc_0);
+                       il.Emit (OpCodes.Ldarg_1);
+                       il.Emit (OpCodes.Stfld, miSetCurIface);
+               }
                public static void emitBindingCreation(ILGenerator il, string memberName, string expression){
                        il.Emit (OpCodes.Ldloc_0);
                        il.Emit (OpCodes.Ldstr, memberName);
index a6e5432b29b045522da9bb7a529019eb26156d08..c91001b7aeb873d27cdf016b4282a3d4464fac1b 100644 (file)
@@ -60,7 +60,7 @@ namespace Crow
                        gr.Save ();
                        if (ClipToClientRect) {
                                //clip to client zone
-                               CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+                               CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin));
                                gr.Clip ();
                        }
 
index da85580ae487540bd37f1efb5935ec10cc3de103..16a60a4f0f62c59437b5030b36b821f08bf279ec 100644 (file)
@@ -48,7 +48,7 @@ namespace Crow
                public FileDialog ()
                {
                        currentDir = new DirectoryInfo (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
-                       window = Interface.Load("#Crow.Templates.FileDialog.goml") as Window;
+                       //window = Interface..Load("#Crow.Templates.FileDialog.goml") as Window;
                        window.DataSource = this;
                }
                #endregion
index fcc90e98e07f7b5d7b21cf3b8013f607818c910a..840e883f95557ba6428d944aac2e2c28285aef1b 100644 (file)
@@ -100,7 +100,7 @@ namespace Crow
 
                                //if no layouting remains in queue for item, registre for redraw
                                if (RegisteredLayoutings == LayoutingType.None && bmp == null)
-                                       Interface.CurrentInterface.EnqueueForRepaint (this);
+                                       CurrentInterface.EnqueueForRepaint (this);
 
                                return true;
                        }
index d5c920112620a0f5b2b65f492da6df876f7d08aa..bd96b76c3f594c811b8a222cc9a6568dfecf33a3 100644 (file)
@@ -42,14 +42,14 @@ namespace Crow
                        uid = currentUid;
                        currentUid++;
 
-                       if (Interface.CurrentInterface.XmlLoading)
-                               return;
-                       loadDefaultValues ();
+//                     if (CurrentInterface.XmlLoading)
+//                             return;
+//                     loadDefaultValues ();
                }
                public GraphicObject (Rectangle _bounds)
                {
-                       if (!Interface.CurrentInterface.XmlLoading)
-                               loadDefaultValues ();
+//                     if (!CurrentInterface.XmlLoading)
+//                             loadDefaultValues ();
                        
                        Left = _bounds.Left;
                        Top = _bounds.Top;
@@ -443,12 +443,9 @@ namespace Crow
 
                                isVisible = value;
 
-                               if (Interface.CurrentInterface == null)
-                                       return;
-
                                //ensure main win doesn't keep hidden childrens ref
-                               if (!isVisible && this.Contains (Interface.CurrentInterface.HoverWidget))
-                                       Interface.CurrentInterface.HoverWidget = null;
+                               if (!isVisible && this.Contains (CurrentInterface.HoverWidget))
+                                       CurrentInterface.HoverWidget = null;
 
                                if (Parent is GraphicObject)
                                        (Parent as GraphicObject).RegisterForLayouting (LayoutingType.Sizing);
@@ -457,7 +454,7 @@ namespace Crow
 
                                if (isVisible)
                                        RegisterForLayouting (LayoutingType.Sizing);
-                               Interface.CurrentInterface.EnqueueForRepaint (this);
+                               CurrentInterface.EnqueueForRepaint (this);
 
                                NotifyValueChanged ("Visible", isVisible);
                        }
@@ -722,7 +719,7 @@ namespace Crow
                        if (Width == Measure.Fit || Height == Measure.Fit)
                                RegisterForLayouting (LayoutingType.Sizing);
                        else if (RegisteredLayoutings == LayoutingType.None)
-                               Interface.CurrentInterface.EnqueueForRepaint (this);
+                               CurrentInterface.EnqueueForRepaint (this);
                }
                /// <summary> query an update of the content, a redraw </summary>
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -730,19 +727,9 @@ namespace Crow
                {
                        bmp = null;
                        if (RegisteredLayoutings == LayoutingType.None)
-                               Interface.CurrentInterface.EnqueueForRepaint (this);
-               }
-               //              public Interface CurrentInterface {
-               //                      get {
-               //                              ILayoutable tmp = this.Parent;
-               //                              while (tmp != null) {
-               //                                      if (tmp is Interface)
-               //                                              return tmp as Interface;
-               //                                      tmp = tmp.Parent;
-               //                              }
-               //                              return null;
-               //                      }
-               //              }
+                               CurrentInterface.EnqueueForRepaint (this);
+               }
+               internal Interface CurrentInterface = null;
                #endregion
 
                #region Layouting
@@ -763,7 +750,7 @@ namespace Crow
                public virtual void RegisterForLayouting(LayoutingType layoutType){
                        if (Parent == null)
                                return;
-                       lock (Interface.CurrentInterface.LayoutMutex) {
+                       lock (CurrentInterface.LayoutMutex) {
                                //dont set position for stretched item
                                if (Width == Measure.Stretched)
                                        layoutType &= (~LayoutingType.X);
@@ -785,15 +772,15 @@ namespace Crow
 
                                //enqueue LQI LayoutingTypes separately
                                if (layoutType.HasFlag (LayoutingType.Width))
-                                       Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
+                                       CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
                                if (layoutType.HasFlag (LayoutingType.Height))
-                                       Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
+                                       CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
                                if (layoutType.HasFlag (LayoutingType.X))
-                                       Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
+                                       CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
                                if (layoutType.HasFlag (LayoutingType.Y))
-                                       Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
+                                       CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
                                if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
-                                       Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
+                                       CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
                        }
                }
 
@@ -963,7 +950,7 @@ namespace Crow
 
                        //if no layouting remains in queue for item, registre for redraw
                        if (this.registeredLayoutings == LayoutingType.None && bmp == null)
-                               Interface.CurrentInterface.EnqueueForRepaint (this);
+                               CurrentInterface.EnqueueForRepaint (this);
 
                        return true;
                }
@@ -1090,8 +1077,8 @@ namespace Crow
                }
                public virtual void checkHoverWidget(MouseMoveEventArgs e)
                {
-                       if (Interface.CurrentInterface.HoverWidget != this) {
-                               Interface.CurrentInterface.HoverWidget = this;
+                       if (CurrentInterface.HoverWidget != this) {
+                               CurrentInterface.HoverWidget = this;
                                onMouseEnter (this, e);
                        }
 
@@ -1107,13 +1094,13 @@ namespace Crow
                        MouseMove.Raise (sender, e);
                }
                public virtual void onMouseDown(object sender, MouseButtonEventArgs e){
-                       if (Interface.CurrentInterface.activeWidget == null)
-                               Interface.CurrentInterface.activeWidget = this;
+                       if (CurrentInterface.activeWidget == null)
+                               CurrentInterface.activeWidget = this;
                        if (this.Focusable && !Interface.FocusOnHover) {
                                BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg;
                                if (be.Focused == null) {
                                        be.Focused = this;
-                                       Interface.CurrentInterface.FocusedWidget = this;
+                                       CurrentInterface.FocusedWidget = this;
                                }
                        }
                        //bubble event to the top
@@ -1464,6 +1451,7 @@ namespace Crow
                {
                        Type type = this.GetType ();
                        GraphicObject result = (GraphicObject)Activator.CreateInstance (type);
+                       result.CurrentInterface = CurrentInterface;
 
                        foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
                                if (pi.GetSetMethod () == null)
index ed0cd98607cd86e97caf7b5174a41da751c1fa02..a0f0cb69df497399b48062e490730a9fc9346981 100644 (file)
@@ -135,7 +135,7 @@ namespace Crow
 
                                //if no layouting remains in queue for item, registre for redraw
                                if (RegisteredLayoutings == LayoutingType.None && bmp == null)
-                                       Interface.CurrentInterface.EnqueueForRepaint (this);
+                                       CurrentInterface.EnqueueForRepaint (this);
                                
                                return true;
                        }
index 66f2f57e860c67983ee29e1da48d5a9e4caa0072..950992e27c313559629c85ed5bc6117a2cfdf2cb 100644 (file)
@@ -292,8 +292,8 @@ namespace Crow
                #region Mouse handling
                public override void checkHoverWidget (MouseMoveEventArgs e)
                {
-                       if (Interface.CurrentInterface.HoverWidget != this) {
-                               Interface.CurrentInterface.HoverWidget = this;
+                       if (CurrentInterface.HoverWidget != this) {
+                               CurrentInterface.HoverWidget = this;
                                onMouseEnter (this, e);
                        }
                        for (int i = Children.Count - 1; i >= 0; i--) {
index 37a32a2f9d84f32615920aac9a61b9b0b89cab9f..666f00a28d80853d8feaaddeec2224572b9e2f39 100644 (file)
@@ -663,12 +663,12 @@ namespace Crow
                {
                        base.onMouseEnter (sender, e);
                        if (Selectable)
-                               Interface.CurrentInterface.MouseCursor = XCursor.Text;
+                               CurrentInterface.MouseCursor = XCursor.Text;
                }
                public override void onMouseLeave (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseLeave (sender, e);
-                       Interface.CurrentInterface.MouseCursor = XCursor.Default;
+                       CurrentInterface.MouseCursor = XCursor.Default;
                }
                public override void onFocused (object sender, EventArgs e)
                {
index 315bad87d04d4616e939471f27a4a2b5d85d9a60..ffbaf3e8cd2478d9475877866b91c3d59c6895f2 100644 (file)
@@ -62,7 +62,7 @@ namespace Crow
 
                                NotifyValueChanged ("Data", data);
 
-                               lock (Interface.CurrentInterface.UpdateMutex)
+                               lock (CurrentInterface.UpdateMutex)
                                        _list.ClearChildren ();
                                if (_gsList.Orientation == Orientation.Horizontal)
                                        _gsList.Width = -1;
@@ -167,7 +167,7 @@ namespace Crow
                                //g.LogicalParent = this;
                        }
 
-                       lock (Interface.CurrentInterface.LayoutMutex)
+                       lock (CurrentInterface.LayoutMutex)
                                _list.AddChild (page);
 
                        #if DEBUG_LOAD
@@ -187,8 +187,8 @@ namespace Crow
                        else
                                iTemp = ItemTemplates ["default"];
 
-                       lock (Interface.CurrentInterface.LayoutMutex) {
-                               g = iTemp.CreateInstance();
+                       lock (CurrentInterface.LayoutMutex) {
+                               g = iTemp.CreateInstance(CurrentInterface);
                                page.AddChild (g);
                                g.DataSource = data [i];
                        }
index 029a9837b57051b7ddae7e8908542f3d8f92ff42..8d62f002eb4ab23f6cb456ab872654639bc9e2d4 100644 (file)
@@ -169,7 +169,7 @@ namespace Crow
                        //ensure popped window is cleared
                        if (Content != null) {
                                if (Content.Parent != null)
-                                       Interface.CurrentInterface.DeleteWidget (Content);
+                                       CurrentInterface.DeleteWidget (Content);
                        }
                        base.ClearBinding ();
                }
@@ -194,21 +194,17 @@ namespace Crow
                        
                public virtual void onPop(object sender, EventArgs e)
                {
-                       if (Interface.CurrentInterface == null)
-                               return;
                        if (Content != null) {
                                Content.Visible = true;
                                if (Content.Parent == null)
-                                       Interface.CurrentInterface.AddWidget (Content);
-                               Interface.CurrentInterface.PutOnTop (Content);
+                                       CurrentInterface.AddWidget (Content);
+                               CurrentInterface.PutOnTop (Content);
                                _content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing));
                        }
                        Pop.Raise (this, e);
                }
                public virtual void onUnpop(object sender, EventArgs e)
                {
-                       if (Interface.CurrentInterface == null)
-                               return;
                        if (Content != null)
                                Content.Visible = false;
                        Unpop.Raise (this, e);
index 1a1558af73c195462e85ae63fa7f8984bedf4406..43c1ab08dc37f60e7ec9ef436eaa78a8eb080080 100644 (file)
@@ -61,14 +61,14 @@ namespace Crow
                {
                        base.onMouseEnter (sender, e);
                        if ((Parent as GenericStack).Orientation == Orientation.Horizontal)
-                               Interface.CurrentInterface.MouseCursor = XCursor.H;
+                               CurrentInterface.MouseCursor = XCursor.H;
                        else
-                               Interface.CurrentInterface.MouseCursor = XCursor.V;
+                               CurrentInterface.MouseCursor = XCursor.V;
                }
                public override void onMouseLeave (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseLeave (sender, e);
-                       Interface.CurrentInterface.MouseCursor = XCursor.Default;
+                       CurrentInterface.MouseCursor = XCursor.Default;
                }
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
index 7f87fa111d175518d361428dd08056dc23aeddfb..a1d1a093cbd427a4bd8cea88395b42b717d1925c 100644 (file)
@@ -143,7 +143,7 @@ namespace Crow
 
                                //if no layouting remains in queue for item, registre for redraw
                                if (RegisteredLayoutings == LayoutingType.None && bmp == null)
-                                       Interface.CurrentInterface.EnqueueForRepaint (this);
+                                       CurrentInterface.EnqueueForRepaint (this);
 
                                return true;
                        }
@@ -181,8 +181,8 @@ namespace Crow
                #region Mouse handling
                public override void checkHoverWidget (MouseMoveEventArgs e)
                {
-                       if (Interface.CurrentInterface.HoverWidget != this) {
-                               Interface.CurrentInterface.HoverWidget = this;
+                       if (CurrentInterface.HoverWidget != this) {
+                               CurrentInterface.HoverWidget = this;
                                onMouseEnter (this, e);
                        }
 
index b10d89eb98e1045fd91c7dadcca44774a1294e3e..b77c89e3dd6a6bfe2239da0388115010d531d0cb 100644 (file)
@@ -36,9 +36,9 @@ namespace Crow
                #region CTOR
                public TemplatedControl () : base()
                {
-                       if (Interface.CurrentInterface.XmlLoading)
-                               return;
-                       loadTemplate ();
+//                     if (CurrentInterface.XmlLoading)
+//                             return;
+                       //loadTemplate ();
                }
                #endregion
 
@@ -57,7 +57,7 @@ namespace Crow
                                if (string.IsNullOrEmpty(_template))
                                        loadTemplate ();
                                else
-                                       loadTemplate (Interface.Load (_template));
+                                       loadTemplate (CurrentInterface.Load (_template));
                        }
                }
                [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
@@ -100,7 +100,7 @@ namespace Crow
                        if (template == null) {
                                if (!Interface.DefaultTemplates.ContainsKey (this.GetType ().FullName))
                                        throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName));
-                               this.SetChild (Interface.Load (Interface.DefaultTemplates[this.GetType ().FullName]));
+                               this.SetChild (CurrentInterface.Load (Interface.DefaultTemplates[this.GetType ().FullName]));
                        }else
                                this.SetChild (template);
 
@@ -178,7 +178,7 @@ namespace Crow
                                                }
                                        }
                                } else
-                                       loadTemplate (Interface.Load (template));
+                                       loadTemplate (CurrentInterface.Load (template));
 
                                //if no template found, load default one
                                if (this.child == null)
index 2be9585a4bab7be9ad4747a7b1c321affae12639..44690342649fbbe1a7cf0754a44803986d31a550 100644 (file)
@@ -87,7 +87,7 @@ namespace Crow
                                        if (!MoveRight ())
                                                return;
                                }else if (e.Shift)
-                                       Interface.CurrentInterface.Clipboard = this.SelectedText;
+                                       CurrentInterface.Clipboard = this.SelectedText;
                                this.DeleteChar ();
                                break;
                        case Key.Enter:
@@ -136,9 +136,9 @@ namespace Crow
                                break;
                        case Key.Insert:
                                if (e.Shift)
-                                       this.Insert (Interface.CurrentInterface.Clipboard);
+                                       this.Insert (CurrentInterface.Clipboard);
                                else if (e.Control && !selectionIsEmpty)
-                                       Interface.CurrentInterface.Clipboard = this.SelectedText;
+                                       CurrentInterface.Clipboard = this.SelectedText;
                                break;
                        case Key.Left:
                                if (e.Shift) {
index bf6bd5cf2614c8856b711ff2569c45adcdfa536a..9ef9e6429eb8f4cbdfa45dbde6670031cc17d705 100644 (file)
@@ -144,11 +144,11 @@ namespace Crow
                {
                        base.onMouseMove (sender, e);
 
-                       Interface otkgw = Interface.CurrentInterface;
+                       Interface otkgw = CurrentInterface;
 
                        if (!hoverBorder) {
                                currentDirection = Direction.None;
-                               Interface.CurrentInterface.MouseCursor = XCursor.Default;
+                               CurrentInterface.MouseCursor = XCursor.Default;
                                return;
                        }
 
@@ -314,7 +314,7 @@ namespace Crow
                {
                        hoverBorder = false;
                        currentDirection = Direction.None;
-                       Interface.CurrentInterface.MouseCursor = XCursor.Default;
+                       CurrentInterface.MouseCursor = XCursor.Default;
                }
                protected void onBorderMouseEnter (object sender, MouseMoveEventArgs e)
                {
@@ -327,13 +327,13 @@ namespace Crow
                }
                protected void butQuitPress (object sender, MouseButtonEventArgs e)
                {
-                       Interface.CurrentInterface.MouseCursor = XCursor.Default;
+                       CurrentInterface.MouseCursor = XCursor.Default;
                        close ();
                }
 
                void close(){
                        Closing.Raise (this, null);
-                       Interface.CurrentInterface.DeleteWidget (this);
+                       CurrentInterface.DeleteWidget (this);
                }
        }
 }
index 68e8cab6891894336f88cdd3d3b5713926bde95f..03251af99286e3f59a955719ec650ac94401f5e2 100644 (file)
@@ -181,7 +181,7 @@ namespace Crow
 
                                //if no layouting remains in queue for item, registre for redraw
                                if (RegisteredLayoutings == LayoutingType.None && bmp == null)
-                                       Interface.CurrentInterface.EnqueueForRepaint (this);
+                                       CurrentInterface.EnqueueForRepaint (this);
 
                                return true;
                        }
index 78f1880a71db92b3272639f7a9da015f6f93e22e..e4f98ecbd505e380e1a172d24f3df79d3c8a3efe 100644 (file)
@@ -30,7 +30,7 @@ namespace Crow
 {
        public class IMLReader : XmlTextReader
        {
-               Interface.LoaderInvoker loader = null;
+               InstanciatorInvoker loader = null;
 
                string ImlPath;
                Stream ImlStream;
@@ -43,12 +43,12 @@ namespace Crow
                /// <summary>
                /// Finalize instatiator MSIL and return LoaderInvoker delegate
                /// </summary>
-               public Interface.LoaderInvoker GetLoader(){
+               public InstanciatorInvoker GetLoader(){
                        if (loader != null)
                                return loader;
 
                        il.Emit(OpCodes.Ret);
-                       loader = (Interface.LoaderInvoker)dm.CreateDelegate (typeof(Interface.LoaderInvoker));
+                       loader = (InstanciatorInvoker)dm.CreateDelegate (typeof(InstanciatorInvoker));
                        return loader;
                }
 
@@ -92,7 +92,7 @@ namespace Crow
                        dm = new DynamicMethod("dyn_instantiator",
                                MethodAttributes.Family | MethodAttributes.FamANDAssem | MethodAttributes.NewSlot,
                                CallingConventions.Standard,
-                               typeof(void),new Type[] {typeof(object)}, RootType, true);
+                               typeof(void),new Type[] {typeof(object), typeof(Interface)}, RootType, true);
 
                        il = dm.GetILGenerator(256);
                        il.DeclareLocal(typeof(GraphicObject));
@@ -100,6 +100,7 @@ namespace Crow
                        //set local GraphicObject to root object passed as 1st argument
                        il.Emit (OpCodes.Ldarg_0);
                        il.Emit (OpCodes.Stloc_0);
+                       CompilerServices.emitSetCurInterface (il);
                }
                void emitLoader(Type crowType){
                        string tmpXml = ReadOuterXml ();
@@ -151,9 +152,10 @@ namespace Crow
                                                if (string.IsNullOrEmpty (templatePath)) {
                                                        reader.il.Emit (OpCodes.Ldnull);//default template loading
                                                }else{
+                                                       reader.il.Emit (OpCodes.Ldarg_1);//load currentInterface
                                                        reader.il.Emit (OpCodes.Ldstr, templatePath); //Load template path string
                                                        reader.il.Emit (OpCodes.Callvirt,//call Interface.Load(path)
-                                                                       typeof(Interface).GetMethod ("Load", BindingFlags.Static | BindingFlags.Public));
+                                                                       typeof(Interface).GetMethod ("Load", BindingFlags.Instance | BindingFlags.Public));
                                                }
                                                reader.il.Emit (OpCodes.Callvirt,//load template
                                                        crowType.GetMethod ("loadTemplate", BindingFlags.Instance | BindingFlags.NonPublic));
@@ -288,6 +290,7 @@ namespace Crow
 
                                        reader.il.Emit(OpCodes.Newobj, t.GetConstructors () [0]);//TODO:search parameterless ctor
                                        reader.il.Emit (OpCodes.Stloc_0);//child is now loc_0
+                                       CompilerServices.emitSetCurInterface (il);
 
                                        reader.emitLoader(t);
 
index fc3595f43a68f923d7a2c403975cd6e02a941ed8..1a8cdb7551bdb253e1f7df05d4050cc4ea444af8 100644 (file)
@@ -26,10 +26,12 @@ using System.Diagnostics;
 
 namespace Crow
 {
+       public delegate void InstanciatorInvoker(object instance, Interface iface);
+
        public class Instantiator
        {
                public Type RootType;
-               Interface.LoaderInvoker loader;
+               InstanciatorInvoker loader;
                string imlPath;
 
 
@@ -80,16 +82,16 @@ namespace Crow
                                loadingTime.ElapsedTicks, loadingTime.ElapsedMilliseconds, imlPath);
                        #endif
                }
-               public Instantiator (Type _root, Interface.LoaderInvoker _loader)
+               public Instantiator (Type _root, InstanciatorInvoker _loader)
                {
                        RootType = _root;
                        loader = _loader;
                }
                #endregion
 
-               public GraphicObject CreateInstance(){
+               public GraphicObject CreateInstance(Interface iface){
                        GraphicObject tmp = (GraphicObject)Activator.CreateInstance(RootType);
-                       loader (tmp);
+                       loader (tmp, iface);
                        return tmp;
                }
                public string GetImlSourcesCode(){
index 052a5a19fa5383fe19f1401480e321300107f595..bc0d1f98651761d3365a6b03a3d156b4ddf9dd1c 100644 (file)
@@ -56,7 +56,6 @@ namespace Crow
                        FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb;
                }
                public Interface(){
-                       Interface.CurrentInterface = this;
                        CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; 
                }
                #endregion
@@ -208,10 +207,10 @@ namespace Crow
                                xs.Serialize (s, graphicObject, xn);
                        }
                }
-               public static GraphicObject Load (string path)
+               public GraphicObject Load (string path)
                {
                        try {
-                               return GetInstantiator (path).CreateInstance ();
+                               return GetInstantiator (path).CreateInstance (this);
                        } catch (Exception ex) {
                                throw new Exception ("Error loading <" + path + ">:", ex);
                        }
@@ -232,7 +231,7 @@ namespace Crow
                public GraphicObject LoadInterface (string path)
                {
                        lock (UpdateMutex) {
-                               GraphicObject tmp = Interface.Load (path);
+                               GraphicObject tmp = Load (path);
                                AddWidget (tmp);
 
                                return tmp;
@@ -249,8 +248,6 @@ namespace Crow
 
                public List<GraphicObject> GraphicTree = new List<GraphicObject>();
 
-               public static Interface CurrentInterface;
-
                Rectangles _redrawClip = new Rectangles();
 
                Context ctx;
@@ -324,8 +321,6 @@ namespace Crow
 
 
                public void Update(){
-                       CurrentInterface = this;
-
                        if (mouseRepeatCount > 0) {
                                int mc = mouseRepeatCount;
                                mouseRepeatCount -= mc;
@@ -384,9 +379,9 @@ namespace Crow
                        #if MEASURE_TIME
                        clippingTime.Restart ();
                        #endif
-                       lock (CurrentInterface.DrawingQueue) {
-                               while (CurrentInterface.DrawingQueue.Count > 0) {
-                                       GraphicObject g = CurrentInterface.DrawingQueue.Dequeue ();
+                       lock (DrawingQueue) {
+                               while (DrawingQueue.Count > 0) {
+                                       GraphicObject g = DrawingQueue.Dequeue ();
                                        g.IsQueueForRedraw = false;
                                        try {
                                                if (g.Parent == null)
@@ -431,7 +426,7 @@ namespace Crow
                                                #if DEBUG_CLIP_RECTANGLE
                                                clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
                                                #endif
-                                               lock (Interface.CurrentInterface.RenderMutex) {
+                                               lock (RenderMutex) {
                                                        if (IsDirty)
                                                                DirtyRect += clipping.Bounds;
                                                        else
index 1afefe2b0f5fbaeaa8e1bd449b94f89db9cad70d..cc5d507543409d1e77b5641441b1dedbebc3145f 100644 (file)
@@ -39,7 +39,7 @@ namespace Crow
                public ItemTemplate(string path) 
                        : base(path) {
                }
-               public ItemTemplate (Type _root, Interface.LoaderInvoker _loader,string _dataType, string _fetchDataMethod)
+               public ItemTemplate (Type _root, InstanciatorInvoker _loader,string _dataType, string _fetchDataMethod)
                        :base(_root, _loader)
                {
                        strDataType = _dataType;
index e33d209c53c61da2b859f0654d77138d3142ef79..6de5be7b09b6053607802e354a995e0405647ab7 100644 (file)
@@ -101,12 +101,12 @@ namespace Crow
                                if (LayoutingTries < Interface.MaxLayoutingTries) {
                                        LayoutingTries++;
                                        Layoutable.RegisteredLayoutings |= LayoutType;
-                                       Interface.CurrentInterface.LayoutingQueue.Enqueue (this);
+                                       (Layoutable as GraphicObject).CurrentInterface.LayoutingQueue.Enqueue (this);
                                } else if (DiscardCount < Interface.MaxDiscardCount) {
                                        LayoutingTries = 0;
                                        DiscardCount++;
                                        Layoutable.RegisteredLayoutings |= LayoutType;
-                                       Interface.CurrentInterface.DiscardQueue.Enqueue (this);
+                                       (Layoutable as GraphicObject).CurrentInterface.DiscardQueue.Enqueue (this);
                                }
                                #if DEBUG_LAYOUTING
                                else