]> O.S.I.I.S - jp/crow.git/commitdiff
Implement TemplatedWidth and TemplatedHeight PropertyLess bindings to
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 14 Sep 2015 23:38:48 +0000 (01:38 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 14 Sep 2015 23:38:48 +0000 (01:38 +0200)
propagate sizing policy inside template

15 files changed:
Templates/Checkbox.goml
Templates/Expandable.goml
Templates/Listbox.goml
Templates/MessageBox.goml
Templates/Popper.goml
Templates/RadioButton.goml
Templates/Spinner.goml
Templates/Window.goml
Tests/GOLIBTests.cs
Tests/Interfaces/testCheckbox.goml
Tests/Interfaces/testMsgBox.goml
Tests/Interfaces/testWindow.goml
src/GraphicObjects/Checkbox.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/Window.cs

index 10ec033fd966be375175037064897f03a7034728..130b01937e59f154e2339eb0e7c95d1a022b46ca 100755 (executable)
@@ -1,5 +1,9 @@
 <?xml version="1.0"?>\r
-<HorizontalStack Spacing="1" Height="-1" Width="0">\r
-       <Image Margin="2" Width="14" Height="14" Path="{Image}" SvgSub="{SvgSub}"/>\r
+<!--<HorizontalStack Spacing="1" Height="-1" Width="0">\r
+       <Image Margin="2" Width="14" Height="14" Path="{Image}" SvgSub="{SvgSub2}"/>\r
        <Label Text="{Caption}" Width="0"/>\r
+</HorizontalStack>-->\r
+<HorizontalStack Spacing="1" Height="{TemplatedHeight}" Width="{TemplatedWidth}">\r
+       <Image Margin="2" Width="14" Height="14" Path="{Image}" SvgSub="{SvgSub}"/>\r
+       <Label Text="{Caption}" Height="{TemplatedHeight}" Width="{TemplatedWidth}"/>\r
 </HorizontalStack>
\ No newline at end of file
index 79544dbe651fdc7c3bf5748f954a1d65e1c8d32b..844cacb4777af95d766d24fba18cd1ebeb367cf1 100755 (executable)
@@ -1,10 +1,10 @@
 <?xml version="1.0"?>\r
-<Border BorderWidth="1" BorderColor="LightGray"  Height="-1" Width="0" MouseClick="onMouseClick">\r
-       <VerticalStack Height="-1" Width="0">\r
-               <HorizontalStack Spacing="1" Height="-1" Width="0">\r
+<Border BorderWidth="1" BorderColor="LightGray" Height="{TemplatedHeight}" Width="{TemplatedWidth}" MouseClick="onMouseClick">\r
+       <VerticalStack Height="{TemplatedHeight}" Width="{TemplatedWidth}">\r
+               <HorizontalStack Spacing="1" Height="-1" Width="{TemplatedWidth}">\r
                        <Image Margin="2" Width="12" Height="12" Path="{Image}" SvgSub="{SvgSub}"/>\r
-                       <Label Text="{Title}" Width="0"/>\r
+                       <Label Text="{Title}" Width="{TemplatedWidth}"/>\r
                </HorizontalStack>\r
-               <Container Name="Content" Visible="false"/>\r
+               <Container Name="Content" Visible="false" Height="{TemplatedHeight}" Width="{TemplatedWidth}"/>\r
        </VerticalStack>\r
 </Border>
\ No newline at end of file
index 08b650d51f577075ea71146dac9ce240da929cf4..0e5f70b657232cbd543f3869611a1ed1b43a0ec9 100755 (executable)
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>\r
-<Border BorderWidth="1" Margin="1" MinimumSize="0;100" Fit="True" Background="Gray">\r
-       <VerticalStack Name="List" Margin="1" VerticalAlignment="Top"/>\r
+<Border BorderWidth="1" Margin="1" MinimumSize="0;100" Height="{TemplatedHeight}" Width="{TemplatedWidth}" Background="Gray">\r
+       <VerticalStack Name="List" Margin="1" Height="{TemplatedHeight}" Width="{TemplatedWidth}"/>\r
 </Border>
\ No newline at end of file
index 7f48fa65f599bc239cfa57146fb952d09ba44056..6488deb9265582d4b082ef1fb113a14eca636c8e 100644 (file)
@@ -1,29 +1,28 @@
 <?xml version="1.0"?>
-<Border Height="-1" BorderWidth="1" BorderColor="White" CornerRadius="10" >
-       <VerticalStack Height="-1" Background="0,4;0,4;0,4;0,4">
-               <Border BorderWidth="1" BorderColor="White"  Height="18" Background="0,1;0,5;1,0;0,5">
-                       <HorizontalStack Name="hs" Margin="1" Spacing="1" Height="-1" >
-                               <GraphicObject Width="5"/>
-                               <Image Name="Image" Margin="1" Width="12" Height="12" Path="#go.Images.Icons.tetra.png"/>
-                               <Label Foreground="White" Width="0" Text="{Title}" Margin="1" TextAlignment="Center" />
-                               <Border CornerRadius="6" BorderWidth="1" Margin="0" BorderColor="Transparent"  Height="12" Width="12"
+<Border Height="{TemplatedHeight}" Width="{TemplatedWidth}" BorderWidth="1" BorderColor="White" CornerRadius="10" >
+       <VerticalStack Height="{TemplatedHeight}" Width="{TemplatedWidth}" Background="0,4;0,4;0,4;0,4">
+               <Border BorderWidth="1" BorderColor="White" Width="{TemplatedWidth}" Height="-1" 
+                               Background="0,1;0,5;1,0;0,5">
+                       <HorizontalStack Name="hs" Margin="1" Spacing="1" Width="{TemplatedWidth}" Height="-1" >
+                               <GraphicObject Width="5" Height="5"/>
+                               <Image Margin="1" Width="12" Height="12" Path="{Icon}"/>
+                               <Label Foreground="White" Width="{TemplatedWidth}" Margin="1" TextAlignment="Center" Text="{Title}" />
+                               <Border CornerRadius="6" BorderWidth="1" BorderColor="Transparent"  Height="12" Width="12"
                                        MouseEnter="{BorderColor=White}" MouseLeave="{BorderColor=Transparent}">
                                        <Image Focusable="true" Name="Image" Margin="0" Width="0" Height="0" Path="#go.Images.Icons.exit2.svg"
                                                 MouseClick="butQuitPress"/>
                                </Border>
-                               <GraphicObject Width="5"/>
+                               <GraphicObject Width="5" Height="5"/>
                        </HorizontalStack>
                </Border>
-<!--           <Container Name="Content"/>-->
-               <HorizontalStack Spacing="10">
-                       <GraphicObject Width="20"/>
+               <HorizontalStack Spacing="10" Margin="10" Height="{TemplatedHeight}" Width="{TemplatedWidth}">
                        <Image Name="Image" Width="32" Height="32"
                                Path="#go.Images.Icons.iconInfo.svg" />
-                       <TextRun Font="serif, 12" Width="0" Height="80" Text="{Message}"
+                       <TextRun Font="serif, 12" Height="{TemplatedHeight}" Width="{TemplatedWidth}" Text="{Message}"
                                Multiline="true" WordWrap="true"/>              
                </HorizontalStack>
-               <HorizontalStack Height="-1" Margin="5">
-                       <GraphicObject/>
+               <HorizontalStack Height="-1" Width="{TemplatedWidth}" Margin="5">
+                       <GraphicObject Height="5"/>
                        <Button Text="Ok"/>
                        <Button Text="Cancel"/>
                </HorizontalStack>
index a935404fba1506b4bcaab2f75b3d8b2d689c6869..534c677f29e5bea7fd07f9a540c34f3ee6607e00 100755 (executable)
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>\r
-<Border BorderWidth="1" BorderColor="LightGray" Height="-1" MouseClick="onMouseClick">\r
-       <HorizontalStack Spacing="1" Height="-1" >\r
+<Border BorderWidth="1" BorderColor="LightGray" Height="-1" Width="{TemplatedWidth}" MouseClick="onMouseClick">\r
+       <HorizontalStack Spacing="1" Height="-1"  Width="{TemplatedWidth}">\r
                <Image Margin="2" Width="12" Height="12" Path="{Image}" SvgSub="{SvgSub}"/>\r
-               <Label Text="{Title}" Width="0"/>\r
+               <Label Text="{Title}"  Width="{TemplatedWidth}"/>\r
        </HorizontalStack>\r
 </Border>
\ No newline at end of file
index 10ec033fd966be375175037064897f03a7034728..44e66817567c1cdee9f179e87841c869a1da3735 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>\r
-<HorizontalStack Spacing="1" Height="-1" Width="0">\r
+<HorizontalStack Spacing="1" Height="{TemplatedHeight}" Width="{TemplatedWidth}">\r
        <Image Margin="2" Width="14" Height="14" Path="{Image}" SvgSub="{SvgSub}"/>\r
-       <Label Text="{Caption}" Width="0"/>\r
+       <Label Text="{Caption}" Height="{TemplatedHeight}" Width="{TemplatedWidth}"/>\r
 </HorizontalStack>
\ No newline at end of file
index 59897fe3b8d412ef03f1f087ae6c33d3122ecc2e..f9bc82b1e7d723cfd804555676ae74d2930966a0 100755 (executable)
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
-<Border BorderWidth="1" Width="{Width}" Height="{Height}" Background="White">
-       <HorizontalStack Name="hstack" Margin="0" Spacing="2" Width="{Width}" Height="{Height}">
-               <Label Foreground="DimGray" Width="0" Height="{Height}" Name="labCpt
+<Border BorderWidth="1" Height="{TemplatedHeight}" Width="{TemplatedWidth}" Background="White">
+       <HorizontalStack Name="hstack" Margin="0" Spacing="2" Height="{TemplatedHeight}" Width="{TemplatedWidth}">
+               <Label Foreground="DimGray" Height="{TemplatedHeight}" Width="{TemplatedWidth}
                        Text="{Value}" Margin="1" TextAlignment="RightCenter"/>
-               <VerticalStack Width="-1" Height="-1" Spacing="1" >
+               <VerticalStack Width="-1" Height="{TemplatedHeight}" Spacing="1" >
                        <Button Width="12" Height="8" MouseClick="onUp">
                                <Image Margin="1" Path="#go.Images.Icons.updown.svg" SvgSub="up"/>
                        </Button>
index 46e823908ebcb1037980bc48113fe1fdbbf8664a..d6f08cde05f33de82d3d65af7267532e2236ceb1 100755 (executable)
@@ -1,11 +1,12 @@
 <?xml version="1.0"?>\r
-<Border BorderWidth="1" BorderColor="White" CornerRadius="20">\r
-       <VerticalStack Height="0">\r
-               <Border BorderWidth="1" BorderColor="White"  Height="-1" Background="0,1;0,5;1,0;0,5">\r
-                       <HorizontalStack Name="hs" Margin="1" Spacing="1" Height="-1" >\r
+<Border BorderWidth="1" BorderColor="White" CornerRadius="20" Height="{TemplatedHeight}" Width="{TemplatedWidth}">\r
+       <VerticalStack Height="{TemplatedHeight}" Width="{TemplatedWidth}">\r
+               <Border BorderWidth="1" BorderColor="White" Width="{TemplatedWidth}" Height="-1" \r
+                               Background="0,1;0,5;1,0;0,5">\r
+                       <HorizontalStack Name="hs" Margin="1" Spacing="1" Width="{TemplatedWidth}" Height="-1" >\r
                                <GraphicObject Width="5"/>\r
                                <Image Margin="1" Width="12" Height="12" Path="{Icon}"/>\r
-                               <Label Foreground="White" Width="0" Margin="1" TextAlignment="Center" Text="{Title}" />\r
+                               <Label Foreground="White" Width="{TemplatedWidth}" Margin="1" TextAlignment="Center" Text="{Title}" />\r
                                <Border CornerRadius="6" BorderWidth="1" BorderColor="Transparent"  Height="12" Width="12"\r
                                        MouseEnter="{BorderColor=White}" MouseLeave="{BorderColor=Transparent}">\r
                                        <Image Focusable="true" Name="Image" Margin="0" Width="0" Height="0" Path="#go.Images.Icons.exit2.svg"\r
@@ -14,6 +15,6 @@
                                <GraphicObject Width="5"/>\r
                        </HorizontalStack>\r
                </Border>\r
-               <Container Name="Content" Background="0,5;0,5;0,5;0,5"/>\r
+               <Container Name="Content" Height="{TemplatedHeight}" Width="{TemplatedWidth}" Background="0,5;0,5;0,5;0,5"/>\r
        </VerticalStack>\r
 </Border>
\ No newline at end of file
index 38eaf8691a011d830ba24ef8099eff3ba4c4fbc1..2585ad6c4ebc56b42a9500118fabf447b3ab8979 100644 (file)
@@ -31,6 +31,7 @@ namespace test
                int frameCpt = 0;\r
                int idx = 0;\r
                string[] testFiles = {\r
+                       "testCheckbox.goml",\r
                        "testWindow.goml",\r
                        "test0.goml",\r
                        "test1.goml",\r
@@ -38,7 +39,6 @@ namespace test
                        "test1.2.goml",\r
                        "testLabel.goml",\r
                        "testContainer.goml",\r
-                       "testCheckbox.goml",\r
                        "testRadioButton.goml",\r
                        "testSpinner.goml",\r
                        "testPopper.goml",\r
index 4a0288cdd69928bff7cccd7ede7147001e23a9ee..7f5078a5a105ec736c3de08c1d943c5659d589b6 100755 (executable)
@@ -1,3 +1,3 @@
 <?xml version="1.0"?>\r
-<Checkbox Caption="Checkbox" Background="DimGray"/>\r
+<Checkbox Width="100" Height="-1" Caption="Checkbox" Background="DimGray"/>\r
 \r
index c1beef527ee12ad8ecb0b2fbdb389ab39d94e980..9cd0e33929f1547ebcade7bb4a2a1997d6cf18fe 100755 (executable)
@@ -1,2 +1,2 @@
 <?xml version="1.0"?>
-<MessageBox/>
\ No newline at end of file
+<MessageBox Width="200" Height="-1"/>
\ No newline at end of file
index e6589bd59045888d13295219a1e2d54b98e49d88..1f5cf4e422eabad8094eebaf8dc7d21e7e5b888f 100755 (executable)
                        <Checkbox Height="-1" Width="80"/>\r
                </HorizontalStack>\r
                <GroupBox Text="test"  Height="-1" Width="0" Margin="5">\r
-                       <VerticalStack  Height="-1" Width="0">\r
-                               <RadioButton  Caption="Radio 1"/>\r
-                               <RadioButton  Caption="Radio 2" IsChecked="true"/>\r
-                               <RadioButton  Caption="Radio 3"/>\r
+                       <VerticalStack  Height="-1" Width="0" >\r
+                               <RadioButton  Caption="Radio 1" Background="Red" />\r
+                               <RadioButton  Caption="Radio 2" IsChecked="true" />\r
+                               <RadioButton  Caption="Radio 3" />\r
                        </VerticalStack>\r
                </GroupBox>\r
 <!--           <Checkbox Height="-1" Width="-1" Background="Red" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Right"/>-->\r
index d4deb1710ffed13e595ff92644b54a79324adda8..b6796659a82d796ed3935548c270e82dbefb5119 100644 (file)
@@ -31,11 +31,11 @@ namespace go
 \r
 \r
                #region GraphicObject overrides\r
-               [XmlAttributeAttribute()][DefaultValue(-1)]\r
-               public override int Height {\r
-                       get { return base.Height; }\r
-                       set { base.Height = value; }\r
-               }\r
+//             [XmlAttributeAttribute()][DefaultValue(-1)]\r
+//             public override int Height {\r
+//                     get { return base.Height; }\r
+//                     set { base.Height = value; }\r
+//             }\r
                [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true\r
                public override bool Focusable\r
                {\r
index 37da50cfc5b3097ca350e418e94aafddf35dd414..ca3ed68c05f79fe38fedaf3a7fa1f549f2c08871 100644 (file)
@@ -60,14 +60,31 @@ namespace go
 //                     set { _templatePath = value; }
 //             }
 
-
-               protected virtual void loadTemplate(GraphicObject template = null)
-               {
-                       if (template == null) {
-                               DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault();
-                               this.SetChild (Interface.Load (dt.Path, this));
-                       }else
-                               this.SetChild (template);
+               #region GraphicObject overrides
+               [XmlAttributeAttribute()][DefaultValue(-1)]
+               public override int Width {
+                       get { return base.Width; }
+                       set { 
+                               base.Width = value; 
+                               //PropertyLess binding for sizing policy in template
+                               if (base.Width < 1) //send size policy to template elements
+                                       NotifyValueChanged ("TemplatedWidth", base.Width);
+                               else //stretched in control if size is fixed
+                                       NotifyValueChanged ("TemplatedWidth", 0);
+                       }
+               }
+               [XmlAttributeAttribute()][DefaultValue(-1)]
+               public override int Height {
+                       get { return base.Height; }
+                       set { 
+                               base.Height = value; 
+
+                               //PropertyLess binding for sizing policy in template
+                               if (base.Height < 1) //send size policy to template elements
+                                       NotifyValueChanged ("TemplatedHeight", base.Height);
+                               else //stretched in control if size is fixed
+                                       NotifyValueChanged ("TemplatedHeight", 0);
+                       }
                }
 
                protected override void loadDefaultValues ()
@@ -76,12 +93,23 @@ namespace go
                                loadTemplate ();
                        base.loadDefaultValues ();
                }
-
                public override GraphicObject FindByName (string nameToFind)
                {
                        //prevent name searching in template
                        return nameToFind == this.Name ? this : null;
                }
+               #endregion
+
+               protected virtual void loadTemplate(GraphicObject template = null)
+               {
+                       if (template == null) {
+                               DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault();
+                               this.SetChild (Interface.Load (dt.Path, this));
+                       }else
+                               this.SetChild (template);
+               }
+
+
 
                #region IXmlSerializable
 
index 18ea1fd4c7e333885fa3c5654219df2ed3b9df68..cbe1cc9b6ca874fc8b6d4024a12b056f7d75aea1 100644 (file)
@@ -9,9 +9,27 @@ namespace go
        [DefaultTemplate("#go.Templates.Window.goml")]
        public class Window : TemplatedContainer
        {
+               enum Direction
+               {
+                       None,
+                       N,
+                       S,
+                       E,
+                       W,
+                       NW,
+                       NE,
+                       SW,
+                       SE,
+               }
+
                string _title;
                string _icon;
                Container _contentContainer;
+               Direction currentDirection = Direction.None;
+
+               #region CTOR
+               public Window () : base() {}
+               #endregion
 
                #region GraphicObject overrides
                [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true
@@ -46,25 +64,7 @@ namespace go
                                NotifyValueChanged ("Icon", _icon);
                        }
                } 
-
-               public Window () : base()
-               {
-               }
                        
-               enum Direction
-               {
-                       None,
-                       N,
-                       S,
-                       E,
-                       W,
-                       NW,
-                       NE,
-                       SW,
-                       SE,
-               }
-               Direction currentDirection = Direction.None;
-
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseMove (sender, e);