From b6fccb76291456485af671082b58e18fe37d395e Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Wed, 23 Dec 2015 18:24:28 +0100 Subject: [PATCH] Prevent multiple template loading debug group and stack layouting , onLayoutChanged divers debug --- Tests/GOLIBTests.cs | 16 ++++++----- Tests/Interfaces/testAll.goml | 6 ++-- Tests/Interfaces/testCheckbox.goml | 2 +- Tests/Interfaces/testWindow.goml | 12 ++++---- Tests/Interfaces/testWindow3.goml | 11 ++++++++ Tests/Tests.csproj | 3 ++ src/GraphicObjects/Expandable.cs | 8 ++++-- src/GraphicObjects/GenericStack.cs | 1 + src/GraphicObjects/GraphicObject.cs | 19 +++++++------ src/GraphicObjects/Group.cs | 39 ++++++++++++++++---------- src/GraphicObjects/TemplatedControl.cs | 15 ++++++---- 11 files changed, 84 insertions(+), 48 deletions(-) create mode 100755 Tests/Interfaces/testWindow3.goml diff --git a/Tests/GOLIBTests.cs b/Tests/GOLIBTests.cs index 2e8e29cc..794811cb 100644 --- a/Tests/GOLIBTests.cs +++ b/Tests/GOLIBTests.cs @@ -36,22 +36,24 @@ namespace test int frameCpt = 0; int idx = 0; string[] testFiles = { + "testWindow3.goml", + "testExpandable.goml", + "testPopper.goml", + "testCheckbox.goml", + "fps.goml", + "testLabel.goml", "testAll.goml", - "test4.goml", + "testWindow.goml", + "testWindow2.goml", // "testSpinner.goml", // "test_Listbox.goml", + "test4.goml", "testRadioButton2.goml", - "fps.goml", - "testCheckbox.goml", - "testExpandable.goml", "testContainer.goml", "testBorder.goml", - "testLabel.goml", "testRadioButton.goml", "testSpinner.goml", - "testPopper.goml", "testGroupBox.goml", - "testWindow.goml", "testMsgBox.goml", "testGrid.goml", "testMeter.goml", diff --git a/Tests/Interfaces/testAll.goml b/Tests/Interfaces/testAll.goml index c2b30797..b2766e6d 100755 --- a/Tests/Interfaces/testAll.goml +++ b/Tests/Interfaces/testAll.goml @@ -15,16 +15,16 @@ - + diff --git a/Tests/Interfaces/testCheckbox.goml b/Tests/Interfaces/testCheckbox.goml index 966455e6..422435f7 100755 --- a/Tests/Interfaces/testCheckbox.goml +++ b/Tests/Interfaces/testCheckbox.goml @@ -1,3 +1,3 @@  - + diff --git a/Tests/Interfaces/testWindow.goml b/Tests/Interfaces/testWindow.goml index 255efa69..c48f08e2 100755 --- a/Tests/Interfaces/testWindow.goml +++ b/Tests/Interfaces/testWindow.goml @@ -3,12 +3,6 @@ Width="250" Height="300" > - - - - - - @@ -16,6 +10,12 @@ + + + + + + diff --git a/Tests/Interfaces/testWindow3.goml b/Tests/Interfaces/testWindow3.goml new file mode 100755 index 00000000..13495b1b --- /dev/null +++ b/Tests/Interfaces/testWindow3.goml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index d9a5ebc8..14c98c01 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -187,6 +187,9 @@ PreserveNewest + + PreserveNewest + diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index 3d4ef229..d4dd315f 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -102,12 +102,16 @@ namespace go public virtual void onExpand(object sender, EventArgs e) { - _contentContainer.Visible = true; + if (_contentContainer != null) + _contentContainer.Visible = true; + Expand.Raise (this, e); } public virtual void onCollapse(object sender, EventArgs e) { - _contentContainer.Visible = false; + if (_contentContainer != null) + _contentContainer.Visible = false; + Collapse.Raise (this, e); } diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index f50a4427..b5af394d 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -102,6 +102,7 @@ namespace go { if (Parent == null) return; + base.RegisterForLayouting (layoutType); if ((layoutType & (int)LayoutingType.PositionChildren) > 0) diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 0374527d..4c68236d 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -493,6 +493,9 @@ namespace go { if (Parent == null) return; + #if DEBUG_LAYOUTING + Debug.WriteLine ("RegisterForLayouting => {1}->{0}", layoutType, this.ToString()); + #endif lock (Interface.LayoutingQueue) { Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0); @@ -504,9 +507,9 @@ namespace go Width = -1; if (Bounds.Width == 0) //stretch in parent - Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this); + Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this); else if (Bounds.Width < 0) //fit - Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this); + Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this); else Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this)); } @@ -518,20 +521,20 @@ namespace go Height = -1; if (Bounds.Height == 0) //stretch in parent - Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this); + Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this); else if (Bounds.Height < 0) //fit - Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this); + Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this); else Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this)); } if ((layoutType & (int)LayoutingType.X) > 0) - //for x positionning, sizing of parent and this have to be done - Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this); + //for x positionning, sizing of parent and this have to be done + Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this); if ((layoutType & (int)LayoutingType.Y) > 0) - //for x positionning, sizing of parent and this have to be done - Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this); + //for x positionning, sizing of parent and this have to be done + Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this); } } diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index b2e341da..89afa5f2 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -147,26 +147,35 @@ namespace go { base.OnLayoutChanges (layoutType); + GenericStack gs = this as GenericStack; //position smaller objects in group when group size is fit switch (layoutType) { - case LayoutingType.Width: - if (Width < 0) { - int crw = ClientRectangle.Width; - foreach (GraphicObject c in Children.Where(ch => ch.Visible)) - c.RegisterForLayouting ((int)LayoutingType.X); - } else { - foreach (GraphicObject c in Children.Where(ch => ch.Width == 0 && ch.Visible)) - c.RegisterForLayouting ((int)LayoutingType.Width); + case LayoutingType.Width: + if (gs != null) { + if (gs.Orientation == Orientation.Horizontal) { + this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + break; + } + } + foreach (GraphicObject c in Children.Where(ch => ch.Visible)) { + if (c.getBounds ().Width == 0) + c.RegisterForLayouting ((int)LayoutingType.Width); + else + c.RegisterForLayouting ((int)LayoutingType.X); } break; case LayoutingType.Height: - if (Height < 0) { - int crh = ClientRectangle.Height; - foreach (GraphicObject c in Children.Where(ch => ch.Visible)) - c.RegisterForLayouting ((int)LayoutingType.Y); - } else { - foreach (GraphicObject c in Children.Where(ch => ch.Height == 0 && ch.Visible)) - c.RegisterForLayouting ((int)LayoutingType.Height); + if (gs != null) { + if (gs.Orientation == Orientation.Vertical) { + this.RegisterForLayouting ((int)LayoutingType.PositionChildren); + break; + } + } + foreach (GraphicObject c in Children.Where(ch => ch.Visible)) { + if (c.getBounds ().Height == 0) + c.RegisterForLayouting ((int)LayoutingType.Height); + else + c.RegisterForLayouting ((int)LayoutingType.Y); } break; } diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index 4ab3a362..fc1a61f2 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -96,8 +96,8 @@ namespace go protected override void loadDefaultValues () { - if (child == null)//trigger loading of default template if child is empty - loadTemplate (); +// if (child == null)//trigger loading of default template if child is empty +// loadTemplate (); base.loadDefaultValues (); } public override GraphicObject FindByName (string nameToFind) @@ -159,15 +159,18 @@ namespace go xr.Read ();//go close tag xr.Read ();//Template close tag break; - } else { - xr.ReadInnerXml (); - } + } else + xr.ReadInnerXml (); } } } else loadTemplate (Interface.Load (template, this)); - + if (this.child == null) { + loadTemplate (); + loadDefaultValues (); + } + //normal xml read using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) { xr.Read (); -- 2.47.3