diff options
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | Tests/GOLIBTests.cs | 6 | ||||
| -rwxr-xr-x | Tests/Interfaces/colorItem.crow | 8 | ||||
| -rwxr-xr-x | Tests/Interfaces/testColorList.crow | 2 | ||||
| -rw-r--r-- | Tests/Tests.csproj | 3 | ||||
| -rw-r--r-- | UnitTest/NUnitCrowWindow.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/GenericStack.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 14 | ||||
| -rw-r--r-- | src/GraphicObjects/Grid.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/ILayoutable.cs | 2 | ||||
| -rw-r--r-- | src/LayoutingQueue.cs | 45 | ||||
| -rw-r--r-- | src/LayoutingQueueItem.cs | 4 | ||||
| -rw-r--r-- | src/OpenTKGameWindow.cs | 2 |
13 files changed, 63 insertions, 33 deletions
@@ -1,13 +1,15 @@ Win_x86 Debug - +packages /GOLib.suo /bin/* /obj/* /GOLib.userprefs /Tests/obj/* /Tests/bin/* +/UnitTest/obj +/UnitTest/bin MonoDevelop.GOLib/bin/ MonoDevelop.GOLib/build/ MonoDevelop.GOLib/obj/ diff --git a/Tests/GOLIBTests.cs b/Tests/GOLIBTests.cs index 41b7eb5e..087547c8 100644 --- a/Tests/GOLIBTests.cs +++ b/Tests/GOLIBTests.cs @@ -38,11 +38,12 @@ namespace test int idx = 0; string[] testFiles = { "testColorList.crow", + "testGroupBox.goml", + "testGrid.goml", "test_Listbox.goml", "testButton.crow", "testBorder.goml", - "testButton2.crow", - "testGroupBox.goml", +// "testButton2.crow", "test2WayBinding.crow", "0.crow", "testSpinner.goml", @@ -67,7 +68,6 @@ namespace test "testContainer.goml", "testRadioButton.goml", "testMsgBox.goml", - "testGrid.goml", "testMeter.goml", }; diff --git a/Tests/Interfaces/colorItem.crow b/Tests/Interfaces/colorItem.crow index 9901ddf3..f0ccb5a1 100755 --- a/Tests/Interfaces/colorItem.crow +++ b/Tests/Interfaces/colorItem.crow @@ -1,8 +1,8 @@ <?xml version="1.0"?> <HorizontalStack Height="-1" Width="200" - MouseEnter="{Background=SteelBlue}" - MouseLeave="{Background=Transparent}"> - <GraphicObject Height="10" Width="30" Background="{}"/> - <TextRun Text="{Name}"/> + MouseEnter="{Background=Red}" + MouseLeave="{Background=Transparent}"> + <GraphicObject Height="10" Width="30" Background="{}" Margin="0" CornerRadius="3"/> + <TextRun Text="{Name}" Margin="0"/> </HorizontalStack> diff --git a/Tests/Interfaces/testColorList.crow b/Tests/Interfaces/testColorList.crow index 1eb7437a..e00b52b8 100755 --- a/Tests/Interfaces/testColorList.crow +++ b/Tests/Interfaces/testColorList.crow @@ -14,7 +14,7 @@ </Scroller> <ScrollBar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" MaximumScroll="{../scroller1.MaximumScroll}" Orientation="Vertical" - Width="10" Height="{../../../TemplatedHeight}" /> + Width="14" Height="{../../../TemplatedHeight}" /> </HorizontalStack> </Border> </Template> diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 3e25ee30..ad4e7b42 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -209,9 +209,6 @@ <None Include="Interfaces\test2WayBinding.crow"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> - <None Include="Interfaces\testButton2.crow"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> <None Include="Interfaces\testColorList.crow"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> diff --git a/UnitTest/NUnitCrowWindow.cs b/UnitTest/NUnitCrowWindow.cs index 5c265343..086e122b 100644 --- a/UnitTest/NUnitCrowWindow.cs +++ b/UnitTest/NUnitCrowWindow.cs @@ -417,6 +417,8 @@ namespace Crow #region ILayoutable implementation + //TODO:uneeded list, should be removed + public List<LayoutingQueueItem> RegisteredLQIs { get; } = new List<LayoutingQueueItem>(); public void RegisterForLayouting (int layoutType) { throw new NotImplementedException (); } public void UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); } public Rectangle ContextCoordinates (Rectangle r) diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 53aff76b..dd27d21a 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -166,7 +166,7 @@ namespace Crow } ComputeChildrenPositions (); //if no layouting remains in queue for item, registre for redraw - if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0 && bmp==null) + if (RegisteredLQIs.Count () <= 0 && bmp==null) this.RegisterForRedraw (); }else base.UpdateLayout(layoutType); diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 8bbf67b0..1a608f36 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -90,6 +90,8 @@ namespace Crow #endregion #region ILayoutable + + public List<LayoutingQueueItem> RegisteredLQIs { get; } = new List<LayoutingQueueItem>(); //TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject // or we could add to the interface the mouse events [XmlIgnore]public ILayoutable Parent { @@ -486,6 +488,13 @@ namespace Crow { return Bounds.Size; } + void deleteLQI(int lt){ + LayoutingQueueItem[] lqis = this.RegisteredLQIs.Where (lq => (lt & (int)lq.LayoutType) > 0).ToArray (); + for (int i = 0; i < lqis.Length; i++) { + Interface.LayoutingQueue.Remove (lqis [i]); + lqis [i].DeleteLayoutableRef(); + } + } /// <summary> clear current layoutingQueue items for object and /// trigger a new layouting pass for a layoutType </summary> public virtual void RegisterForLayouting(int layoutType) @@ -496,8 +505,7 @@ namespace Crow Debug.WriteLine ("RegisterForLayouting => {1}->{0}", layoutType, this.ToString()); #endif lock (Interface.LayoutingQueue) { - Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0); - + deleteLQI (layoutType); if ((layoutType & (int)LayoutingType.Width) > 0) { if (Bounds.Width == 0) //stretch in parent Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this); @@ -693,7 +701,7 @@ namespace Crow } lock (Interface.LayoutingQueue) { //if no layouting remains in queue for item, registre for redraw - if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0 && bmp == null) + if (this.RegisteredLQIs.Count () <= 0 && bmp == null) this.RegisterForRedraw (); } } diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs index 6ce9a3c5..08241d9c 100644 --- a/src/GraphicObjects/Grid.cs +++ b/src/GraphicObjects/Grid.cs @@ -137,7 +137,7 @@ namespace Crow if (layoutType == LayoutingType.PositionChildren) { ComputeChildrenPositions (); //if no layouting remains in queue for item, registre for redraw - if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0 && bmp==null) + if (RegisteredLQIs.Count () <= 0 && bmp==null) this.RegisterForRedraw (); }else base.UpdateLayout(layoutType); diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs index 000d377b..3a7135e0 100644 --- a/src/GraphicObjects/ILayoutable.cs +++ b/src/GraphicObjects/ILayoutable.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Crow { @@ -12,6 +13,7 @@ namespace Crow IGOLibHost HostContainer { get; } + List<LayoutingQueueItem> RegisteredLQIs { get; } void RegisterForLayouting(int layoutType); void UpdateLayout(LayoutingType layoutType); diff --git a/src/LayoutingQueue.cs b/src/LayoutingQueue.cs index ca4dede9..51ec702e 100644 --- a/src/LayoutingQueue.cs +++ b/src/LayoutingQueue.cs @@ -31,28 +31,30 @@ namespace Crow } public void Enqueue(LayoutingType _lt, ILayoutable _object) { - Interface.LayoutingQueue.RemoveAll(lq => lq.GraphicObject == _object && lq.LayoutType == _lt); - Interface.LayoutingQueue.Add (new LayoutingQueueItem (_lt, _object)); + this.Add (new LayoutingQueueItem (_lt, _object)); + } + LayoutingQueueItem searchLqi(ILayoutable go, LayoutingType lt){ + return go.RegisteredLQIs.Where(lq => lq.LayoutType == lt).LastOrDefault(); } - public void EnqueueAfterParentSizing (LayoutingType _lt, ILayoutable _object) { LayoutingQueueItem lqi = new LayoutingQueueItem (_lt, _object); - int idxParentSz = Interface.LayoutingQueue.IndexOf - (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == _object.Parent && lq.LayoutType == _lt).LastOrDefault()); + LayoutingQueueItem parentLqi = searchLqi (_object.Parent, _lt); - Interface.LayoutingQueue.Insert (idxParentSz + 1, lqi); + if (parentLqi == null) + this.Insert (0, lqi); + else + this.Insert (this.IndexOf (parentLqi) + 1, lqi); } public void EnqueueBeforeParentSizing (LayoutingType _lt, ILayoutable _object) { LayoutingQueueItem lqi = new LayoutingQueueItem (_lt, _object); - int idxParentSz = Interface.LayoutingQueue.IndexOf - (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == _object.Parent && lq.LayoutType == _lt).FirstOrDefault()); + LayoutingQueueItem parentLqi = searchLqi (_object.Parent, _lt); - if (idxParentSz < 0) - Interface.LayoutingQueue.Enqueue (_lt, _object); + if (parentLqi == null) + this.Add (lqi); else - Interface.LayoutingQueue.Insert (idxParentSz, lqi); + this.Insert (this.IndexOf (parentLqi), lqi); } public void EnqueueAfterThisAndParentSizing (LayoutingType _lt, ILayoutable _object) { @@ -61,16 +63,27 @@ namespace Crow if (_lt == LayoutingType.Y) sizing = LayoutingType.Height; - - int idxW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where - (lq => (lq.GraphicObject == _object.Parent || lq.GraphicObject == _object) && lq.LayoutType == sizing).LastOrDefault()); - Interface.LayoutingQueue.Insert (idxW + 1, lqi); - } + LayoutingQueueItem parentLqi = searchLqi (_object.Parent, sizing); + LayoutingQueueItem thisLqi = searchLqi (_object, sizing); + int idx = -1; + + if (parentLqi == null) { + if (thisLqi != null) + idx = this.IndexOf (thisLqi); + } else { + if (thisLqi == null) + idx = this.IndexOf (parentLqi); + else + idx = Math.Max(this.IndexOf (parentLqi), this.IndexOf (thisLqi)); + } + this.Insert (idx + 1, lqi); + } public LayoutingQueueItem Dequeue() { LayoutingQueueItem tmp = this [0]; + tmp.DeleteLayoutableRef (); this.RemoveAt (0); return tmp; } diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs index 95234112..d1cfaeb9 100644 --- a/src/LayoutingQueueItem.cs +++ b/src/LayoutingQueueItem.cs @@ -45,6 +45,10 @@ namespace Crow { LayoutType = _layoutType; GraphicObject = _graphicObject; + GraphicObject.RegisteredLQIs.Add (this); + } + public void DeleteLayoutableRef(){ + GraphicObject.RegisteredLQIs.Remove(this); } public void ProcessLayouting() { diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index 078e1c0a..b5317cef 100644 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -547,6 +547,8 @@ namespace Crow #region ILayoutable implementation + //TODO:uneeded list, should be removed + public List<LayoutingQueueItem> RegisteredLQIs { get; } = new List<LayoutingQueueItem>(); public void RegisterForLayouting (int layoutType) { throw new NotImplementedException (); } public void UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); } public Rectangle ContextCoordinates (Rectangle r) |