]> O.S.I.I.S - jp/crow.git/commitdiff
Prevent multiple template loading
authorjpbruyere <jp.bruyere@hotmail.com>
Wed, 23 Dec 2015 17:24:28 +0000 (18:24 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Wed, 23 Dec 2015 17:24:28 +0000 (18:24 +0100)
debug group and stack layouting , onLayoutChanged
divers debug

Tests/GOLIBTests.cs
Tests/Interfaces/testAll.goml
Tests/Interfaces/testCheckbox.goml
Tests/Interfaces/testWindow.goml
Tests/Interfaces/testWindow3.goml [new file with mode: 0755]
Tests/Tests.csproj
src/GraphicObjects/Expandable.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/TemplatedControl.cs

index 2e8e29ccfe432f3f3d1d025bdedbaf0aab33edfb..794811cb42904a895927a7100d89aa31fc562a8e 100644 (file)
@@ -36,22 +36,24 @@ namespace test
                int frameCpt = 0;\r
                int idx = 0;\r
                string[] testFiles = {\r
+                       "testWindow3.goml",\r
+                       "testExpandable.goml",\r
+                       "testPopper.goml",\r
+                       "testCheckbox.goml",\r
+                       "fps.goml",\r
+                       "testLabel.goml",\r
                        "testAll.goml",\r
-                       "test4.goml",\r
+                       "testWindow.goml",\r
+                       "testWindow2.goml",\r
 //                     "testSpinner.goml",\r
 //                     "test_Listbox.goml",\r
+                       "test4.goml",\r
                        "testRadioButton2.goml",\r
-                       "fps.goml",\r
-                       "testCheckbox.goml",\r
-                       "testExpandable.goml",\r
                        "testContainer.goml",\r
                        "testBorder.goml",\r
-                       "testLabel.goml",\r
                        "testRadioButton.goml",\r
                        "testSpinner.goml",\r
-                       "testPopper.goml",\r
                        "testGroupBox.goml",\r
-                       "testWindow.goml",\r
                        "testMsgBox.goml",\r
                        "testGrid.goml",\r
                        "testMeter.goml",\r
index c2b307977b08baf1518ef26ac5851f5ab81fbacf..b2766e6d2cc5923c09046bcdca0edc64f492ea20 100755 (executable)
        <Groupbox  Background="DarkGreen">              \r
 <!--           <Template>\r
                        <Group Height="{../TemplatedHeight}" Width="{../TemplatedWidth}">\r
-                               <Border CornerRadius="5" BorderWidth="1" Margin="6"\r
+                               <Border CornerRadius="5" BorderWidth="1" Margin="0"\r
                                        Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}">\r
-                                       <Container Name="Content" Margin="10"\r
+                                       <Container Name="Content" Margin="0"\r
                                                        Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/>\r
                                </Border>\r
                                <Label Text="{../../Title}" VerticalAlignment="Top" Left="15"\r
                                        Background="Clear" Margin="1"/>\r
                        </Group>\r
                </Template>-->\r
-               <VerticalStack Fit="true" Background="Red" Margin="0">\r
+               <VerticalStack Fit="true" Background="Red" Margin="10">\r
                        <TextRun Text="text run test" />\r
                        <TextRun Text="text run test" />\r
                        <TextRun Text="text run test"/>\r
index 966455e6dd70b5071d34b23edbdfaf9990867616..422435f7c88be9760bc347b4df01764ad436de65 100755 (executable)
@@ -1,3 +1,3 @@
 <?xml version="1.0"?>\r
-<Checkbox Width="-1" Height="-1" Caption="Checkbox" Background="DimGray" IsChecked="false"/>\r
+<Checkbox Width="-1" Height="-1" Caption="Checkbox" Background="DimGray" IsChecked="true"/>\r
 \r
index 255efa69f1099088ee59bee4e2b30517228ad8fe..c48f08e2227b693584273c5c82cbd70f1b9cbe7d 100755 (executable)
@@ -3,12 +3,6 @@
                Width="250" Height="300" >\r
        <VerticalStack Name="contentVSStack" Margin="10" Spacing="10">\r
                <Slider Name="slider" Height="10" Width="0"/>\r
-\r
-               <HorizontalStack Width="0" Height="-1" Margin="10" Background="BlueCrayola">\r
-                       <Checkbox Height="-1" Width="80"/>\r
-                       <GraphicObject Width="0"/>\r
-                       <Checkbox Height="-1" Width="80"/>\r
-               </HorizontalStack>\r
                <Groupbox Text="test"  Height="-1" Width="-1" Margin="5">\r
                        <VerticalStack  Height="-1" Width="0" >\r
                                <RadioButton  Caption="Radio 1" Background="Red" />\r
                                <RadioButton  Caption="Radio 3" />\r
                        </VerticalStack>\r
                </Groupbox>\r
+               <HorizontalStack Width="0" Height="-1" Margin="10" Background="BlueCrayola">\r
+                       <Checkbox Height="-1" Width="80"/>\r
+                       <GraphicObject Width="0"/>\r
+                       <Checkbox Height="-1" Width="80" IsChecked="true"/>\r
+               </HorizontalStack>\r
+\r
 <!--           <Checkbox Height="-1" Width="-1" Background="Red" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Right"/>-->\r
        </VerticalStack>\r
 </Window>\r
diff --git a/Tests/Interfaces/testWindow3.goml b/Tests/Interfaces/testWindow3.goml
new file mode 100755 (executable)
index 0000000..13495b1
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>\r
+<!--<Group>-->\r
+<Window Name="window1" Left="10" Top="10" Title="Test window" Width="200" Height="200" Background="0,5;0,5;0,5;0,8" \r
+       Focusable="True"  CornerRadius="20" MinimumSize="100;100" MaximumSize="500;500">\r
+       <Template>\r
+               <Container Margin="20" Name="Content" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" Background="0,5;0,5;0,5;0,5"/>\r
+       </Template>\r
+       <Group Background="Green">\r
+               <GraphicObject Height="50" Width="50" Background="Red" Margin="5"/>     \r
+       </Group>\r
+</Window>\r
index d9a5ebc8cba5182966cd7457e66067378b978c13..14c98c01af0c5f3cf803a578504457c9e4b37138 100644 (file)
     <None Include="Interfaces\testAll.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\testWindow3.goml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index 3d4ef2294f1bfe684c27a892185b60e7962a90f9..d4dd315f92e576b85b8d3b30cd65ea7487153d18 100644 (file)
@@ -102,12 +102,16 @@ namespace go
 \r
                public virtual void onExpand(object sender, EventArgs e)\r
                {\r
-                       _contentContainer.Visible = true;\r
+                       if (_contentContainer != null)\r
+                               _contentContainer.Visible = true;\r
+                       \r
                        Expand.Raise (this, e);\r
                }\r
                public virtual void onCollapse(object sender, EventArgs e)\r
                {\r
-                       _contentContainer.Visible = false;\r
+                       if (_contentContainer != null)\r
+                               _contentContainer.Visible = false;\r
+                       \r
                        Collapse.Raise (this, e);\r
                }\r
                        \r
index f50a442781680ceee451868489523366fbca5e61..b5af394d6241d09c326fca7b4866d3fab4cd70e5 100644 (file)
@@ -102,6 +102,7 @@ namespace go
                {                       \r
                        if (Parent == null)\r
                                return;\r
+\r
                        base.RegisterForLayouting (layoutType);\r
 \r
                        if ((layoutType & (int)LayoutingType.PositionChildren) > 0)\r
index 0374527ddfe88c20267d959d136e087719c6b3a5..4c68236d21211427b3f0948a91d144ea95d0e15f 100644 (file)
@@ -493,6 +493,9 @@ namespace go
                {\r
                        if (Parent == null)\r
                                return;\r
+                       #if DEBUG_LAYOUTING\r
+                       Debug.WriteLine ("RegisterForLayouting => {1}->{0}", layoutType, this.ToString());\r
+                       #endif\r
                        lock (Interface.LayoutingQueue) {\r
                                Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
 \r
@@ -504,9 +507,9 @@ namespace go
                                                Width = -1;\r
                                \r
                                        if (Bounds.Width == 0) //stretch in parent\r
-                                       Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);\r
+                                               Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);\r
                                        else if (Bounds.Width < 0) //fit \r
-                                       Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);\r
+                                               Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);\r
                                        else\r
                                                Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
                                }\r
@@ -518,20 +521,20 @@ namespace go
                                                Height = -1;\r
 \r
                                        if (Bounds.Height == 0) //stretch in parent\r
-                                       Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);\r
+                                               Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);\r
                                        else if (Bounds.Height < 0) //fit \r
-                                       Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this);\r
+                                               Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this);\r
                                        else\r
                                                Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
                                }\r
 \r
                                if ((layoutType & (int)LayoutingType.X) > 0)\r
-                               //for x positionning, sizing of parent and this have to be done\r
-                               Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);\r
+                                       //for x positionning, sizing of parent and this have to be done\r
+                                       Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);\r
 \r
                                if ((layoutType & (int)LayoutingType.Y) > 0)\r
-                               //for x positionning, sizing of parent and this have to be done\r
-                               Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);\r
+                                       //for x positionning, sizing of parent and this have to be done\r
+                                       Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);\r
                        }\r
                }\r
 \r
index b2e341da9057772c6dc24f194b98d22d9d351946..89afa5f242dd78087463732e0240a4fc89908e45 100644 (file)
@@ -147,26 +147,35 @@ namespace go
                {\r
                        base.OnLayoutChanges (layoutType);\r
 \r
+                       GenericStack gs = this as GenericStack;\r
                        //position smaller objects in group when group size is fit\r
                        switch (layoutType) {\r
-                       case LayoutingType.Width:                               \r
-                               if (Width < 0) {\r
-                                       int crw = ClientRectangle.Width;\r
-                                       foreach (GraphicObject c in Children.Where(ch => ch.Visible))\r
-                                               c.RegisterForLayouting ((int)LayoutingType.X);                                          \r
-                               } else {\r
-                                       foreach (GraphicObject c in Children.Where(ch => ch.Width == 0 && ch.Visible))\r
-                                               c.RegisterForLayouting ((int)LayoutingType.Width);                                                                                      \r
+                       case LayoutingType.Width:\r
+                               if (gs != null) {\r
+                                       if (gs.Orientation == Orientation.Horizontal) {\r
+                                               this.RegisterForLayouting ((int)LayoutingType.PositionChildren);\r
+                                               break;\r
+                                       }\r
+                               }       \r
+                               foreach (GraphicObject c in Children.Where(ch => ch.Visible)) {\r
+                                       if (c.getBounds ().Width == 0)\r
+                                               c.RegisterForLayouting ((int)LayoutingType.Width);\r
+                                       else\r
+                                               c.RegisterForLayouting ((int)LayoutingType.X);                                  \r
                                }\r
                                break;\r
                        case LayoutingType.Height:\r
-                               if (Height < 0) {\r
-                                       int crh = ClientRectangle.Height;\r
-                                       foreach (GraphicObject c in Children.Where(ch => ch.Visible))\r
-                                               c.RegisterForLayouting ((int)LayoutingType.Y);                                          \r
-                               } else {\r
-                                       foreach (GraphicObject c in Children.Where(ch => ch.Height == 0 && ch.Visible))\r
-                                               c.RegisterForLayouting ((int)LayoutingType.Height);                                                                                     \r
+                               if (gs != null) {\r
+                                       if (gs.Orientation == Orientation.Vertical) {\r
+                                               this.RegisterForLayouting ((int)LayoutingType.PositionChildren);\r
+                                               break;\r
+                                       }\r
+                               }\r
+                               foreach (GraphicObject c in Children.Where(ch => ch.Visible)) {\r
+                                       if (c.getBounds ().Height == 0)\r
+                                               c.RegisterForLayouting ((int)LayoutingType.Height);\r
+                                       else\r
+                                               c.RegisterForLayouting ((int)LayoutingType.Y);\r
                                }\r
                                break;\r
                        }\r
index 4ab3a362478cb57b6c72e4e69aba49b4ab3f3287..fc1a61f2f4e7b36c22ce5efd951f7c039d57e9f3 100644 (file)
@@ -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 ();