diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-02-17 00:53:59 +0100 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-02-17 00:53:59 +0100 |
| commit | a8a5562df0358b314197f3685fc7622ecfd307d0 (patch) | |
| tree | 02cdd70b6b0f999dd2a2eab7bf8018da03ffdd9f | |
| parent | 61d1d07d37a5cc9d6ae1c4fcc333ec8ae644aca3 (diff) | |
splitted measure with fault checking, changing default template sizing to 0, lots of bugs.
40 files changed, 383 insertions, 235 deletions
diff --git a/Crow.csproj b/Crow.csproj index 6d0c6d3a..05f0841d 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -137,6 +137,7 @@ <Compile Include="src\GraphicObjects\TreeView.cs" /> <Compile Include="src\GraphicObjects\TabView.cs" /> <Compile Include="src\GraphicObjects\TabItem.cs" /> + <Compile Include="src\GraphicObjects\DummyTemplate.cs" /> </ItemGroup> <ItemGroup> <Reference Include="System" /> @@ -229,6 +230,7 @@ <EmbeddedResource Include="Templates\TreeView.crow" /> <EmbeddedResource Include="Templates\TabItem.crow" /> <EmbeddedResource Include="Templates\TreeItem.crow" /> + <EmbeddedResource Include="Templates\Dummy.goml" /> </ItemGroup> <ItemGroup> <None Include="README.md" /> diff --git a/Templates/ArrowButTemplate.crow b/Templates/ArrowButTemplate.crow index c90f1b60..942c9f75 100755 --- a/Templates/ArrowButTemplate.crow +++ b/Templates/ArrowButTemplate.crow @@ -5,7 +5,7 @@ </HorizontalStack>--> <Border Name="Content" Background="vgradient|0:White|0,1:LightGray|0,9:LightGray|1:Black" Foreground="DarkGray" - Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" + Height="{../HeightPolicy}" Width="{../WidthPolicy}" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=DarkGray}" MouseDown="{Background=vgradient|0:Black|0,1:LightGray|0,9:LightGray|1:White}" diff --git a/Templates/Button.crow b/Templates/Button.crow index 75decb21..76d5dd8e 100755 --- a/Templates/Button.crow +++ b/Templates/Button.crow @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<Border Background="{../Background}" MinimumSize="50;20" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" +<Border Background="{../Background}" MinimumSize="50;20" Height="{../HeightPolicy}" Width="{../WidthPolicy}" Foreground="Transparent" CornerRadius="{../CornerRadius}" BorderWidth="1" MouseEnter="{Foreground=vgradient|0:White|0,2:Gray|0,9:Gray|1:Black;caption.Foreground=White}" MouseLeave="{Foreground=Transparent;caption.Foreground=DimGray}" diff --git a/Templates/CheckBox.goml b/Templates/CheckBox.goml index 5f5807aa..ffdb2202 100755 --- a/Templates/CheckBox.goml +++ b/Templates/CheckBox.goml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<HorizontalStack Spacing="1" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> - <Image Margin="2" Width="14" Height="14" Path="{../../Image}" SvgSub="{../../SvgSub}"/> - <Label Text="{../../Caption}" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"/> +<HorizontalStack Spacing="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <Image Background="Red" Margin="2" Width="14" Height="14" Path="{../../Image}" SvgSub="{../../SvgSub}"/> + <Label Background="Blue" Text="{../../Caption}" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/> </HorizontalStack>
\ No newline at end of file diff --git a/Templates/ComboBox.goml b/Templates/ComboBox.goml index 7af1e2d3..7a735307 100755 --- a/Templates/ComboBox.goml +++ b/Templates/ComboBox.goml @@ -1,11 +1,11 @@ <?xml version="1.0"?> -<Popper Name="popper" PopDirection="Bottom" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> +<Popper Name="popper" PopDirection="Bottom" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> <Template> - <Border CornerRadius="0" Foreground="LightGray" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> - <HorizontalStack Margin="1" Spacing="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> + <Border CornerRadius="0" Foreground="LightGray" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <HorizontalStack Margin="1" Spacing="1" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> <TextBox MinimumSize="80;10" Margin="1" Foreground="Black" Background="White" Text="{../../../../SelectedItem}" Focusable="true" - Height="{../../../../TemplatedHeight}" Width="{../../../../TemplatedWidth}"/> + Height="{../../../../HeightPolicy}" Width="{../../../../WidthPolicy}"/> <Button Width="14" Height="14" MouseClick="../../../onMouseClick" Template="#Crow.Templates.ArrowButTemplate.crow"> <Image Margin="0" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/> diff --git a/Templates/Dummy.goml b/Templates/Dummy.goml new file mode 100755 index 00000000..cfd82865 --- /dev/null +++ b/Templates/Dummy.goml @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<!--<Group Margin="5" Background="Red" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> +<Label Margin="0" Text="DUMMY2" Background="Green" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/> +</Group>--> +<HorizontalStack Margin="5" Background="Red" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <Label Margin="0" Text="DUMMY" Background="Blue" Height="{../../HeightPolicy}" Width="20"/> + <Label Margin="0" Text="DUMMY2" Background="Green" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/> +</HorizontalStack> diff --git a/Templates/Expandable.goml b/Templates/Expandable.goml index 427c1880..b2465abb 100755 --- a/Templates/Expandable.goml +++ b/Templates/Expandable.goml @@ -1,11 +1,11 @@ <?xml version="1.0"?> -<Border BorderWidth="1" Foreground="LightGray" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" +<Border BorderWidth="1" Foreground="LightGray" Height="{../HeightPolicy}" Width="{../WidthPolicy}" MouseClick="../onMouseClick"> - <VerticalStack Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> - <HorizontalStack Spacing="1" Height="-1" Width="{../../../TemplatedWidth}"> + <VerticalStack Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> + <HorizontalStack Spacing="1" Height="-1" Width="{../../../WidthPolicy}"> <Image Margin="2" Width="12" Height="12" Path="{../../../../Image}" SvgSub="{../../../../SvgSub}"/> - <Label Text="{../../../../Caption}" Width="{../../../../TemplatedWidth}"/> + <Label Text="{../../../../Caption}" Width="{../../../../WidthPolicy}"/> </HorizontalStack> - <Container Name="Content" Visible="false" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/> + <Container Background="Red" Name="Content" Visible="false" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/> </VerticalStack> </Border>
\ No newline at end of file diff --git a/Templates/GroupBox.goml b/Templates/GroupBox.goml index b92ee8b2..5b042429 100755 --- a/Templates/GroupBox.goml +++ b/Templates/GroupBox.goml @@ -1,9 +1,9 @@ <?xml version="1.0"?> -<Group Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> +<Group Height="{../HeightPolicy}" Width="{../WidthPolicy}"> <Border CornerRadius="5" BorderWidth="1" Margin="6" Foreground="{../../Foreground}" - Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> + Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> <Container Name="Content" Margin="10" - Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/> + Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/> </Border> <Label Text="{../../Caption}" VerticalAlignment="Top" Left="15" Background="Clear" Margin="1"/> diff --git a/Templates/ListBox.goml b/Templates/ListBox.goml index 5d8122e0..fa8d514e 100755 --- a/Templates/ListBox.goml +++ b/Templates/ListBox.goml @@ -1,8 +1,8 @@ <?xml version="1.0"?> -<Border BorderWidth="1" Margin="1" MinimumSize="20;20" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" > +<Border BorderWidth="1" Margin="1" MinimumSize="20;20" Height="{../HeightPolicy}" Width="{../WidthPolicy}" > <Scroller Name="scroller1" Margin="1" VerticalScrolling="true" - Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> + Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> <VerticalStack LayoutChanged="../../../_list_LayoutChanged" - Height="-1" Width="{../../../TemplatedWidth}" Name="List" Margin="0" VerticalAlignment="Top"/> + Height="-1" Width="{../../../WidthPolicy}" Name="List" Margin="0" VerticalAlignment="Top"/> </Scroller> </Border>
\ No newline at end of file diff --git a/Templates/MessageBox.goml b/Templates/MessageBox.goml index 7620645a..fe6ce620 100644 --- a/Templates/MessageBox.goml +++ b/Templates/MessageBox.goml @@ -1,12 +1,12 @@ <?xml version="1.0"?> -<Border Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" BorderWidth="1" Foreground="White" CornerRadius="10" > - <VerticalStack Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}" Background="0,4;0,4;0,4;0,4"> - <Border BorderWidth="1" Foreground="White" Width="{../../../TemplatedWidth}" Height="-1" +<Border Height="{../HeightPolicy}" Width="{../WidthPolicy}" BorderWidth="1" Foreground="White" CornerRadius="10" > + <VerticalStack Height="{../../HeightPolicy}" Width="{../../WidthPolicy}" Background="0,4;0,4;0,4;0,4"> + <Border BorderWidth="1" Foreground="White" Width="{../../../WidthPolicy}" Height="-1" Background="0,1;0,5;1,0;0,5"> - <HorizontalStack Name="hs" Margin="1" Spacing="1" Width="{../../../../TemplatedWidth}" Height="-1" > + <HorizontalStack Name="hs" Margin="1" Spacing="1" Width="{../../../../WidthPolicy}" 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}" /> + <Label Foreground="White" Width="{../../../../../WidthPolicy}" Margin="1" TextAlignment="Center" Text="{../../../../../Title}" /> <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> <Image Focusable="true" Name="Image" Margin="0" Width="0" Height="0" Path="#Crow.Images.Icons.exit2.svg" @@ -15,13 +15,13 @@ <GraphicObject Width="5" Height="5"/> </HorizontalStack> </Border> - <HorizontalStack Spacing="3" Margin="3" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"> + <HorizontalStack Spacing="3" Margin="3" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"> <Image Name="Image" Width="24" Height="24" Path="#Crow.Images.Icons.iconInfo.svg" /> - <TextRun Font="serif, 12" Height="{../../../../TemplatedHeight}" Width="{../../../../TemplatedWidth}" Text="{../../../../Message}" + <TextRun Font="serif, 12" Height="{../../../../HeightPolicy}" Width="{../../../../WidthPolicy}" Text="{../../../../Message}" Multiline="true" WordWrap="true"/> </HorizontalStack> - <HorizontalStack Height="-1" Width="{../../../TemplatedWidth}" Margin="3"> + <HorizontalStack Height="-1" Width="{../../../WidthPolicy}" Margin="3"> <GraphicObject Height="5"/> <Button Caption="Ok"/> <Button Caption="Cancel"/> diff --git a/Templates/Popper.goml b/Templates/Popper.goml index 42a81d1d..9fd80681 100755 --- a/Templates/Popper.goml +++ b/Templates/Popper.goml @@ -1,7 +1,7 @@ <?xml version="1.0"?> -<Border BorderWidth="1" Foreground="LightGray" Height="-1" Width="{../TemplatedWidth}"> - <HorizontalStack Spacing="1" Height="-1" Width="{../../TemplatedWidth}"> +<Border BorderWidth="1" Foreground="LightGray" Height="-1" Width="{../WidthPolicy}"> + <HorizontalStack Spacing="1" Height="-1" Width="{../../WidthPolicy}"> <Image Margin="2" Width="12" Height="12" Path="{../../../Image}" SvgSub="{../../../SvgSub}"/> - <Label Text="{../../../Caption}" Width="{../../../TemplatedWidth}"/> + <Label Text="{../../../Caption}" Width="{../../../WidthPolicy}"/> </HorizontalStack> </Border>
\ No newline at end of file diff --git a/Templates/RadioButton.goml b/Templates/RadioButton.goml index 5f5807aa..b69331be 100755 --- a/Templates/RadioButton.goml +++ b/Templates/RadioButton.goml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<HorizontalStack Spacing="1" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> +<HorizontalStack Spacing="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> <Image Margin="2" Width="14" Height="14" Path="{../../Image}" SvgSub="{../../SvgSub}"/> - <Label Text="{../../Caption}" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"/> + <Label Text="{../../Caption}" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/> </HorizontalStack>
\ No newline at end of file diff --git a/Templates/ScrollBar.goml b/Templates/ScrollBar.goml index b643c36b..ffcc121e 100755 --- a/Templates/ScrollBar.goml +++ b/Templates/ScrollBar.goml @@ -1,7 +1,7 @@ <?xml version="1.0"?> -<Border BorderWidth="1" Foreground="LightGray" Width="{../TemplatedWidth}" Height="{../TemplatedHeight}"> +<Border BorderWidth="1" Foreground="LightGray" Width="{../WidthPolicy}" Height="{../HeightPolicy}"> <GenericStack Orientation="{../../Orientation}" Spacing="0" - Width="{../../TemplatedWidth}" Height="{../../TemplatedHeight}"> + Width="{../../WidthPolicy}" Height="{../../HeightPolicy}"> <Button MouseRepeat="true" Width="12" Height="12" MouseClick="../../../onScrollBack" Template="#Crow.Templates.ArrowButTemplate.crow"> <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="up"/> @@ -13,7 +13,7 @@ LargeIncrement="{../../../LargeIncrement}" SmallIncrement="{../../../SmallIncrement}" Background="hgradient|0:DimGray|0,1:Gray|0,95:Gray|1:White" - Width="{../../../TemplatedWidth}" Height="{../../../TemplatedHeight}" + Width="{../../../WidthPolicy}" Height="{../../../HeightPolicy}" ValueChanged="../../../onSliderValueChange"/> <Button MouseRepeat="true" Width="12" Height="12" MouseClick="../../../onScrollForth" Template="#Crow.Templates.ArrowButTemplate.crow"> diff --git a/Templates/ScrollingListBox.goml b/Templates/ScrollingListBox.goml index 0de4bf26..5f50929f 100644 --- a/Templates/ScrollingListBox.goml +++ b/Templates/ScrollingListBox.goml @@ -1,15 +1,15 @@ <?xml version="1.0"?> -<Border BorderWidth="1" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> - <HorizontalStack Margin="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}" > - <Scroller Name="scroller1" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}" +<Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <HorizontalStack Margin="1" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}" > + <Scroller Name="scroller1" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}" Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}" ValueChanged="../../../_scroller_ValueChanged"> - <VerticalStack Width="{../../../../TemplatedWidth}" Height="-1" MinimumSize="100;100" + <VerticalStack Width="{../../../../WidthPolicy}" Height="-1" MinimumSize="100;100" Name="List" Margin="0" VerticalAlignment="Top" LayoutChanged="../../../../_list_LayoutChanged"/> </Scroller> <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}" Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical" - Width="14" Height="{../../../TemplatedHeight}" /> + Width="14" Height="{../../../HeightPolicy}" /> </HorizontalStack> </Border>
\ No newline at end of file diff --git a/Templates/Spinner.goml b/Templates/Spinner.goml index bd202c1a..b8fbf832 100755 --- a/Templates/Spinner.goml +++ b/Templates/Spinner.goml @@ -1,11 +1,11 @@ <?xml version="1.0"?> -<Border BorderWidth="1" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" +<Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}" Foreground="Gray" Background="White"> - <HorizontalStack Name="hstack" Margin="0" Spacing="2" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> - <Label Foreground="DimGray" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}" + <HorizontalStack Name="hstack" Margin="0" Spacing="2" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> + <Label Foreground="DimGray" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}" Text="{../../../Value}" Margin="1" TextAlignment="Right"/> - <VerticalStack Width="-1" Height="{../../../TemplatedHeight}" Spacing="0" > + <VerticalStack Width="-1" Height="{../../../HeightPolicy}" Spacing="0" > <Button MouseRepeat="true" Width="12" Height="8" MouseClick="../../../../onUp" Template="#Crow.Templates.ArrowButTemplate.crow"> <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="up"/> diff --git a/Templates/TreeItem.crow b/Templates/TreeItem.crow index 037736a9..b3458ec1 100644 --- a/Templates/TreeItem.crow +++ b/Templates/TreeItem.crow @@ -6,26 +6,26 @@ </Container>-->
<Expandable Caption="{}">
<Template>
- <Border BorderWidth="1" Foreground="LightGray" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"
+ <Border BorderWidth="1" Foreground="LightGray" Height="{../HeightPolicy}" Width="{../WidthPolicy}"
MouseClick="../onMouseClick">
- <VerticalStack Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}">
- <HorizontalStack Spacing="1" Height="-1" Width="{../../../TemplatedWidth}">
+ <VerticalStack Height="{../../HeightPolicy}" Width="{../../WidthPolicy}">
+ <HorizontalStack Spacing="1" Height="-1" Width="{../../../WidthPolicy}">
<Image Margin="2" Width="12" Height="12" Path="{../../../../Image}" SvgSub="{../../../../SvgSub}"/>
- <Label Text="{../../../../Caption}" Width="{../../../../TemplatedWidth}"/>
+ <Label Text="{../../../../Caption}" Width="{../../../../WidthPolicy}"/>
</HorizontalStack>
- <Container Name="Content" Visible="false" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/>
+ <Container Name="Content" Visible="false" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/>
</VerticalStack>
</Border>
</Template>
</Expandable>
<!-- <VerticalStack
- Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"
+ Height="{../HeightPolicy}" Width="{../WidthPolicy}"
MouseClick="../onMouseClick">
- <HorizontalStack Spacing="1" Height="-1" Width="{../../TemplatedWidth}">
+ <HorizontalStack Spacing="1" Height="-1" Width="{../../WidthPolicy}">
<Image Margin="2" Width="12" Height="12" Path="{../../../Image}" SvgSub="{../../../SvgSub}"/>
- <Label Text="{../../../Caption}" Width="{../../../TemplatedWidth}"/>
+ <Label Text="{../../../Caption}" Width="{../../../WidthPolicy}"/>
</HorizontalStack>
<ListBox Name="Content" Visible="false"
- Height="-1" Width="{../../TemplatedWidth}"/>
+ Height="-1" Width="{../../WidthPolicy}"/>
</VerticalStack>-->
diff --git a/Templates/TreeView.crow b/Templates/TreeView.crow index 132c7eb6..165cea1c 100644 --- a/Templates/TreeView.crow +++ b/Templates/TreeView.crow @@ -1,5 +1,5 @@ <Border Background="DimGray" BorderWidth="1" Margin="1" MinimumSize="100;100" - Width="{../TemplatedWidth}" Height="{../TemplatedHeight}"> + Width="{../WidthPolicy}" Height="{../HeightPolicy}"> <VerticalStack Height="0" Width="0" Name="List" Margin="0" VerticalAlignment="Top"/> diff --git a/Templates/Window.goml b/Templates/Window.goml index dd3fec7d..1aa20a84 100755 --- a/Templates/Window.goml +++ b/Templates/Window.goml @@ -1,13 +1,13 @@ <?xml version="1.0"?> -<Border BorderWidth="1" Foreground="White" CornerRadius="20" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> - <VerticalStack Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> - <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{../../../TemplatedWidth}" Height="-1" +<Border BorderWidth="1" Foreground="White" CornerRadius="20" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <VerticalStack Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> + <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{../../../WidthPolicy}" Height="-1" Background="vgradient|0:0,1;0,5;1,0;0,5|1:0,0;0,1;0,3;0,9"> <!-- Background="0,1;0,5;1,0;0,5"--> - <HorizontalStack Name="hs" Margin="1" Spacing="1" Width="{../../../../TemplatedWidth}" Height="-1" > + <HorizontalStack Name="hs" Margin="1" Spacing="1" Width="{../../../../WidthPolicy}" Height="-1" > <GraphicObject Width="5"/> <Image Margin="1" Width="12" Height="12" Path="{../../../../../Icon}"/> - <Label Foreground="White" Width="{../../../../../TemplatedWidth}" Margin="1" TextAlignment="Center" Text="{../../../../../Title}" /> + <Label Foreground="White" Width="{../../../../../WidthPolicy}" Margin="1" TextAlignment="Center" Text="{../../../../../Title}" /> <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> <Image Focusable="true" Name="Image" Margin="0" Width="0" Height="0" Path="#Crow.Images.Icons.exit2.svg" @@ -16,6 +16,6 @@ <GraphicObject Width="5"/> </HorizontalStack> </Border> - <Container Name="Content" Height="{../../../../TemplatedHeight}" Width="{../../../../TemplatedWidth}" Background="0,5;0,5;0,5;0,5"/> + <Container Name="Content" Height="{../../../../HeightPolicy}" Width="{../../../../WidthPolicy}" Background="0,5;0,5;0,5;0,5"/> </VerticalStack> </Border>
\ No newline at end of file diff --git a/Tests/GOLIBTests.cs b/Tests/GOLIBTests.cs index c508c0e1..3d6e619f 100644 --- a/Tests/GOLIBTests.cs +++ b/Tests/GOLIBTests.cs @@ -37,6 +37,7 @@ namespace test int frameCpt = 0; int idx = 0; string[] testFiles = { + "testCheckbox.goml", "testTabView.crow", "testExpandable.goml", "0.crow", @@ -73,7 +74,6 @@ namespace test "testWindow2.goml", "testWindow3.goml", - "testCheckbox.goml", "testLabel.goml", "testAll.goml", // "testSpinner.goml", @@ -239,7 +239,13 @@ namespace test { Console.WriteLine ("button clicked:" + send.ToString()); } - + void onAddTabButClick(object sender, MouseButtonEventArgs e){ + + TabView tv = this.FindByName("tabview1") as TabView; + if (tv == null) + return; + tv.AddChild (new TabItem () { Caption = "NewTab" }); + } [STAThread] static void Main () { diff --git a/Tests/Interfaces/TmpExpandable.goml b/Tests/Interfaces/TmpExpandable.goml index ee0884ff..1cd05fd7 100755 --- a/Tests/Interfaces/TmpExpandable.goml +++ b/Tests/Interfaces/TmpExpandable.goml @@ -1,12 +1,12 @@ <?xml version="1.0"?> -<!--<VerticalStack Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" MouseClick="../onMouseClick"> - <Label Text="{../../Caption}" Width="{../../TemplatedWidth}"/> - <Container Name="Content" Visible="false" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"/> +<!--<VerticalStack Height="{../HeightPolicy}" Width="{../WidthPolicy}" MouseClick="../onMouseClick"> + <Label Text="{../../Caption}" Width="{../../WidthPolicy}"/> + <Container Name="Content" Visible="false" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/> </VerticalStack>--> -<Group BorderWidth="1" Foreground="LightGray" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" +<Group BorderWidth="1" Foreground="LightGray" Height="{../HeightPolicy}" Width="{../WidthPolicy}" MouseClick="../onMouseClick"> - <VerticalStack Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> - <Label Text="{../../../Caption}" Width="{../../../TemplatedWidth}"/> - <Container Name="Content" Visible="false" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/> + <VerticalStack Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> + <Label Text="{../../../Caption}" Width="{../../../WidthPolicy}"/> + <Container Name="Content" Visible="false" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/> </VerticalStack> </Group>
\ No newline at end of file diff --git a/Tests/Interfaces/testAll.goml b/Tests/Interfaces/testAll.goml index 1959bf4a..6f5be081 100755 --- a/Tests/Interfaces/testAll.goml +++ b/Tests/Interfaces/testAll.goml @@ -14,11 +14,11 @@ </Groupbox>--> <GroupBox Background="DarkGreen"> <!-- <Template> - <Group Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> + <Group Height="{../HeightPolicy}" Width="{../WidthPolicy}"> <Border CornerRadius="5" BorderWidth="1" Margin="0" - Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> + Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> <Container Name="Content" Margin="0" - Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/> + Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/> </Border> <Label Text="{../../Title}" VerticalAlignment="Top" Left="15" Background="Clear" Margin="1"/> diff --git a/Tests/Interfaces/testCheckbox.goml b/Tests/Interfaces/testCheckbox.goml index a8cc4eea..4db4393b 100755 --- a/Tests/Interfaces/testCheckbox.goml +++ b/Tests/Interfaces/testCheckbox.goml @@ -1,3 +1,36 @@ <?xml version="1.0"?> -<CheckBox Width="-1" Height="-1" Caption="Checkbox" Background="DimGray" IsChecked="true"/> +<VerticalStack Fit="true" Margin="10" Background="DimGray" > +<!-- <Label Text="label1" Width="0" Height="0"/> + <Label Text="label2" Width="0" Height="0"/>--> + <CheckBox Background="Gray"/> + <CheckBox Background="Gray"/> + <CheckBox Background="Gray"/> + <CheckBox Background="Gray"/> + <CheckBox Background="Gray"/> +<!-- <CheckBox Background="Gray"/>--> +<!-- <HorizontalStack Fit="true" Margin="5" Background="Green"> + <Label Background="Red"/> + <Label Background="Red"/> + </HorizontalStack>--> + <DummyTemplate Fit="true"/> + <DummyTemplate/> + <DummyTemplate/> + <DummyTemplate/> + <DummyTemplate/> + <DummyTemplate/> + <DummyTemplate Height="-1"/> +<!-- <Label Margin="5" Background="Red"/> + <Label Background="Red"/> + <Container Width="100" Height="50" Margin="5" Background="Green"> + <Label Width="0" Height="0" Background="Red"/> + </Container> + + <Container Fit="true" Margin="5" Background="Green"> + <Label Background="Red" Height="5"/> + </Container> + <HorizontalStack Margin="5" Background="Red" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <Label Background="Green"/> + <Label Background="Green"/> + </HorizontalStack>--> +</VerticalStack> diff --git a/Tests/Interfaces/testColorList.crow b/Tests/Interfaces/testColorList.crow index fc5e023d..76bf8d6e 100755 --- a/Tests/Interfaces/testColorList.crow +++ b/Tests/Interfaces/testColorList.crow @@ -5,18 +5,18 @@ HorizontalAlignment="Center" Width="-1" Height="350" Margin="5" ItemTemplate="#Tests.Interfaces.colorItem.crow"> <Template> - <Border BorderWidth="1" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> - <HorizontalStack Margin="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}" > - <Scroller Name="scroller1" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}" + <Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <HorizontalStack Margin="1" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}" > + <Scroller Name="scroller1" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}" Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}" ValueChanged="../../../_scroller_ValueChanged"> - <VerticalStack Width="{../../../../TemplatedWidth}" Height="-1" MinimumSize="100;100" + <VerticalStack Width="{../../../../WidthPolicy}" Height="-1" MinimumSize="100;100" Name="List" Margin="0" VerticalAlignment="Top" LayoutChanged="../../../../_list_LayoutChanged"/> </Scroller> <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}" Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical" - Width="14" Height="{../../../TemplatedHeight}" /> + Width="14" Height="{../../../HeightPolicy}" /> </HorizontalStack> </Border> </Template> diff --git a/Tests/Interfaces/testDirViewer.goml b/Tests/Interfaces/testDirViewer.goml index 1e3ebd31..22787c3e 100755 --- a/Tests/Interfaces/testDirViewer.goml +++ b/Tests/Interfaces/testDirViewer.goml @@ -9,14 +9,14 @@ SelectedItemChanged="OnSelectedItemChanged" ItemTemplate="Interfaces/tmpDirItem.goml" > <Template> - <Border BorderWidth="1" MinimumSize="20;20" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> - <HorizontalStack Margin="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> - <Scroller Name="scroller1" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}" + <Border BorderWidth="1" MinimumSize="20;20" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <HorizontalStack Margin="1" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> + <Scroller Name="scroller1" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}" Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}"> - <VerticalStack Width="{../../../../TemplatedWidth}" Height="-1" Name="List" Margin="0" VerticalAlignment="Top"/> + <VerticalStack Width="{../../../../WidthPolicy}" Height="-1" Name="List" Margin="0" VerticalAlignment="Top"/> </Scroller> <Scrollbar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" MaximumScroll="{../scroller1.MaximumScroll}" - Orientation="Vertical" Width="10" Height="{../../../TemplatedHeight}" /> + Orientation="Vertical" Width="10" Height="{../../../HeightPolicy}" /> </HorizontalStack> </Border> </Template> diff --git a/Tests/Interfaces/testExpandable.goml b/Tests/Interfaces/testExpandable.goml index d46f4831..8c2787fb 100755 --- a/Tests/Interfaces/testExpandable.goml +++ b/Tests/Interfaces/testExpandable.goml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <Expandable Caption="Test expandable" Background="DimGray"> - <VerticalStack Width="-1" Height="-1"> + <VerticalStack Margin="5" Background="Green"> <CheckBox Name="chk1" Background="Red"/> <CheckBox Name="chk2" IsChecked="true"/> <CheckBox Name="chk3"/> diff --git a/Tests/Interfaces/testRadioButton2.goml b/Tests/Interfaces/testRadioButton2.goml index 1c97f16f..d32c46d0 100755 --- a/Tests/Interfaces/testRadioButton2.goml +++ b/Tests/Interfaces/testRadioButton2.goml @@ -5,9 +5,9 @@ <RadioButton Caption="Radio3"/> <RadioButton Caption="Radio4"> <Template> - <HorizontalStack Spacing="1" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> + <HorizontalStack Spacing="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> <Image Margin="2" Width="14" Height="14" Path="{../../Image}" SvgSub="{../../SvgSub}"/> - <Label Text="{../../Caption}" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"/> + <Label Text="{../../Caption}" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/> </HorizontalStack> </Template> </RadioButton> diff --git a/Tests/Interfaces/testTabView.crow b/Tests/Interfaces/testTabView.crow index 953dd8c1..3a081597 100644 --- a/Tests/Interfaces/testTabView.crow +++ b/Tests/Interfaces/testTabView.crow @@ -1,34 +1,38 @@ <?xml version="1.0" encoding="UTF-8" ?> <HorizontalStack Fit="true"> - <TabView Margin="20" - Width="400" Height="200" Orientation="Horizontal" Spacing="20"> - <TabItem Name="TabItem1" Caption="tab item 1" Width="0" Height="0" Margin="0"> - <VerticalStack Fit="true"> - <CheckBox/> - <CheckBox/> - <CheckBox/> - <CheckBox/> - <Label Text="{fps}" HorizontalAlignment="Right" Foreground="Black" Background="Yellow"/> - </VerticalStack> - </TabItem> - <TabItem Name="TabItem2" Caption="tab item 2" Width="0" Height="0" Margin="0" Background="Gray"> - <VerticalStack Fit="true"> - <RadioButton/> - <RadioButton/> - <RadioButton/> - <RadioButton/> - <Label Text="{fps}" HorizontalAlignment="Left" Background="LimeGreen"/> - </VerticalStack> - </TabItem> - <TabItem Name="TabItem2" Caption="tab item 3" Width="0" Height="0" Margin="0" Background="Gray"> - <Container Margin="5" CornerRadius="2" Width="0" Height="0"> - <TextBox Margin="5" Width="0" Height="0" Multiline="true" TextAlignment="TopLeft"/> - </Container> - </TabItem> - <TabItem Name="TabItem2" Caption="tab item 4" Width="0" Height="0" Margin="0" Background="Gray"> - <TextBox/> - </TabItem> - </TabView> + <VerticalStack Fit="true"> + <TabView Name="tabview1" + Width="400" Height="200" Orientation="Horizontal" Spacing="20"> + <TabItem Name="TabItem1" Caption="tab item 1" Margin="0"> + <VerticalStack Fit="true"> + <CheckBox/> + <CheckBox/> + <CheckBox/> + <CheckBox/> +<!-- <Label Text="{fps}" HorizontalAlignment="Right" Foreground="Black" Background="Yellow"/>--> + </VerticalStack> + </TabItem> + <TabItem Name="TabItem2" Caption="tab item 2" Width="0" Height="0" Margin="0" Background="Gray"> + <VerticalStack Fit="true"> + <RadioButton/> + <RadioButton/> + <RadioButton/> + <RadioButton/> +<!-- <Label Text="{fps}" HorizontalAlignment="Left" Background="LimeGreen"/>--> + </VerticalStack> + </TabItem> + <TabItem Name="TabItem2" Caption="tab item 3" Width="0" Height="0" Margin="0" Background="Gray"> + <Container Margin="5" CornerRadius="2" Width="0" Height="0"> + <TextBox Margin="5" Width="0" Height="0" Multiline="true" TextAlignment="TopLeft"/> + </Container> + </TabItem> + <TabItem Name="TabItem2" Caption="tab item 4" Width="0" Height="0" Margin="0" Background="Gray"> + <TextBox/> + </TabItem> + </TabView> + <Button Background="vgradient|0:DimGray|1:Black" HorizontalAlignment="Right" + Caption="Add new tab" Width="-1" Height="30" MouseClick="onAddTabButClick"/> + </VerticalStack> <TabView CacheEnabled="false" Width="200" Height="200" Orientation="Horizontal" Spacing="20" Margin="0"> <TabItem Name="TabItem1" Caption="tab 1" Width="0" Height="0" Margin="0" Background="Gray"> diff --git a/Tests/Interfaces/testWindow2.goml b/Tests/Interfaces/testWindow2.goml index 25ea8f30..20d5ba62 100755 --- a/Tests/Interfaces/testWindow2.goml +++ b/Tests/Interfaces/testWindow2.goml @@ -2,14 +2,14 @@ <Window Name="window1" Left="10" Top="10" Title="Test window" Width="200" Height="200" Background="0,5;0,5;0,5;0,8" Focusable="True" CornerRadius="20" MinimumSize="100;100" MaximumSize="500;500"> <Template> - <Border BorderWidth="1" Foreground="White" CornerRadius="20" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> - <VerticalStack Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}"> - <Border BorderWidth="1" Foreground="White" Width="{../../../TemplatedWidth}" Height="-1" + <Border BorderWidth="1" Foreground="White" CornerRadius="20" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <VerticalStack Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"> + <Border BorderWidth="1" Foreground="White" Width="{../../../WidthPolicy}" Height="-1" Background="0,1;0,5;1,0;0,5"> - <HorizontalStack Name="hs" Margin="1" Spacing="1" Width="{../../../../TemplatedWidth}" Height="-1" > + <HorizontalStack Name="hs" Margin="1" Spacing="1" Width="{../../../../WidthPolicy}" Height="-1" > <GraphicObject Width="5"/> <Image Margin="1" Width="12" Height="12" Path="{../../../../../Icon}"/> - <Label Foreground="White" Width="{../../../../../TemplatedWidth}" Margin="1" TextAlignment="Center" Text="{../../../../../Title}" /> + <Label Foreground="White" Width="{../../../../../WidthPolicy}" Margin="1" TextAlignment="Center" Text="{../../../../../Title}" /> <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> <Image Focusable="true" Name="Image" Margin="0" Width="0" Height="0" Path="#Crow.Images.Icons.exit2.svg" @@ -18,7 +18,7 @@ <GraphicObject Width="5"/> </HorizontalStack> </Border> - <Container Name="Content" Height="{../../../../TemplatedHeight}" Width="{../../../../TemplatedWidth}" Background="0,5;0,5;0,5;0,5"/> + <Container Name="Content" Height="{../../../../HeightPolicy}" Width="{../../../../WidthPolicy}" Background="0,5;0,5;0,5;0,5"/> </VerticalStack> </Border> </Template> diff --git a/Tests/Interfaces/testWindow3.goml b/Tests/Interfaces/testWindow3.goml index ffcf4625..1c150471 100755 --- a/Tests/Interfaces/testWindow3.goml +++ b/Tests/Interfaces/testWindow3.goml @@ -2,7 +2,7 @@ <Window Left="10" Top="10" Title="Test window" Width="200" Height="200" Background="0,5;0,5;0,5;0,8" Focusable="True" CornerRadius="20" MinimumSize="100;100" MaximumSize="500;500"> <Template> - <Container Margin="20" Name="Content" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" Background="0,5;0,5;0,5;0,5"/> + <Container Margin="20" Name="Content" Height="{../HeightPolicy}" Width="{../WidthPolicy}" Background="0,5;0,5;0,5;0,5"/> </Template> <!-- <Group Background="Green">--> <GraphicObject Height="50" Width="50" Background="Red" Margin="5"/> diff --git a/Tests/Interfaces/test_Listbox.goml b/Tests/Interfaces/test_Listbox.goml index 8c9eaa09..71afb828 100755 --- a/Tests/Interfaces/test_Listbox.goml +++ b/Tests/Interfaces/test_Listbox.goml @@ -8,16 +8,16 @@ <ListBox Data="{TestList}" Background="0,5;0,5;0,5;0,5" HorizontalAlignment="Center" Width="-1" Height="150" Margin="5"> <Template> - <Border BorderWidth="1" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"> - <HorizontalStack Margin="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}" > - <Scroller Name="scroller1" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}" + <Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}"> + <HorizontalStack Margin="1" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}" > + <Scroller Name="scroller1" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}" Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"> - <VerticalStack Width="{../../../../TemplatedWidth}" Height="-1" MinimumSize="100;100" + <VerticalStack Width="{../../../../WidthPolicy}" Height="-1" MinimumSize="100;100" Name="List" Margin="0" VerticalAlignment="Top" /> </Scroller> <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}" Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical" - Width="10" Height="{../../../TemplatedHeight}" /> + Width="10" Height="{../../../HeightPolicy}" /> </HorizontalStack> </Border> </Template> diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs index 7011690e..be08a7d8 100644 --- a/src/GraphicObjects/Border.cs +++ b/src/GraphicObjects/Border.cs @@ -40,9 +40,10 @@ namespace Crow } } - protected override Size measureRawSize () + protected override int measureRawSize (LayoutingType lt) { - return child == null ? Bounds.Size : child.Slot.Size + 2 * (Margin + BorderWidth); + int tmp = base.measureRawSize (lt); + return tmp < 0 ? tmp : tmp + 2 * BorderWidth; } protected override void onDraw (Cairo.Context gr) { diff --git a/src/GraphicObjects/DummyTemplate.cs b/src/GraphicObjects/DummyTemplate.cs new file mode 100644 index 00000000..68597d18 --- /dev/null +++ b/src/GraphicObjects/DummyTemplate.cs @@ -0,0 +1,33 @@ +// +// DummyTemplate.cs +// +// Author: +// Jean-Philippe Bruyère <jp_bruyere@hotmail.com> +// +// Copyright (c) 2016 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +using System; + +namespace Crow +{ + [DefaultTemplate("#Crow.Templates.Dummy.goml")] + public class DummyTemplate : TemplatedControl + { + public DummyTemplate () : base() + { + } + } +} + diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index bbbc52ec..2a1da6c3 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -52,34 +52,43 @@ namespace Crow else layoutType &= (~LayoutingType.Y); } - protected override Size measureRawSize () + protected override int measureRawSize (LayoutingType lt) { - Size tmp = new Size (); - - if (Orientation == Orientation.Horizontal) { - foreach (GraphicObject c in Children) { - if (!c.Visible) - continue; - tmp.Width += c.Slot.Width + Spacing; - tmp.Height = Math.Max (tmp.Height, Math.Max(c.Slot.Bottom, c.Slot.Height)); - } - if (tmp.Width > 0) - tmp.Width -= Spacing; - } else { - foreach (GraphicObject c in Children) { - if (!c.Visible) - continue; - tmp.Width = Math.Max (tmp.Width, Math.Max(c.Slot.Right, c.Slot.Width)); - tmp.Height += c.Slot.Height + Spacing; + int tmp = 0; + switch (lt) { + case LayoutingType.Width: + if (Orientation == Orientation.Horizontal) { + if (Children.Count > 0) { + foreach (GraphicObject c in Children) { + if (!c.Visible) + continue; + if (c.RegisteredLayoutings.HasFlag (LayoutingType.Width)) + return -1; + tmp += c.Slot.Width + Spacing; + } + tmp -= Spacing; + } + break; + } + return base.measureRawSize (lt); + case LayoutingType.Height: + if (Orientation == Orientation.Vertical) { + if (Children.Count > 0) { + foreach (GraphicObject c in Children) { + if (!c.Visible) + continue; + if (c.RegisteredLayoutings.HasFlag (LayoutingType.Height)) + return -1; + tmp += c.Slot.Height + Spacing; + } + tmp -= Spacing; + } + break; } - if (tmp.Height > 0) - tmp.Height -= Spacing; + return base.measureRawSize (lt); } - tmp.Width += 2 * Margin; - tmp.Height += 2 * Margin; - - return tmp; + return tmp + 2 * Margin; } public virtual void ComputeChildrenPositions() { diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index f10f2244..9f20fca9 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -262,12 +262,12 @@ namespace Crow [XmlAttributeAttribute()][DefaultValue(false)] public virtual bool Fit { - get { return Bounds.Width < 0 && Bounds.Height < 0 ? true : false; } + get { return Width < 0 && Height < 0 ? true : false; } set { if (value == Fit) return; - Bounds.Width = Bounds.Height = -1; + Width = Height = -1; } } [XmlAttributeAttribute()][DefaultValue(false)] @@ -626,8 +626,8 @@ namespace Crow set { layoutingTries = value; } } /// <summary> return size of content + margins </summary> - protected virtual Size measureRawSize () { - return Bounds.Size; + protected virtual int measureRawSize (LayoutingType lt) { + return lt == LayoutingType.Width ? Bounds.Size.Width : Bounds.Size.Height; } /// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary> public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){ @@ -704,7 +704,8 @@ namespace Crow case LayoutingType.X: if (Bounds.X == 0) { - if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width)) + if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) || + RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; switch (HorizontalAlignment) { @@ -733,7 +734,8 @@ namespace Crow case LayoutingType.Y: if (Bounds.Y == 0) { - if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height)) + if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) || + RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; switch (VerticalAlignment) { @@ -762,9 +764,12 @@ namespace Crow case LayoutingType.Width: if (Width > 0) Slot.Width = Width; - else if (Width < 0) - Slot.Width = measureRawSize ().Width; - else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width)) + else if (Width < 0) { + int tmp = measureRawSize (LayoutingType.Width); + if (tmp < 0) + return false; + Slot.Width = tmp; + }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; else Slot.Width = Parent.ClientRectangle.Width; @@ -787,9 +792,12 @@ namespace Crow case LayoutingType.Height: if (Height > 0) Slot.Height = Height; - else if (Height < 0) - Slot.Height = measureRawSize ().Height; - else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height)) + else if (Height < 0){ + int tmp = measureRawSize (LayoutingType.Height); + if (tmp < 0) + return false; + Slot.Height = tmp; + }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; else Slot.Height = Parent.ClientRectangle.Height; diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index ba65ba0c..2a960029 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -125,9 +125,21 @@ namespace Crow } return false; } - protected override Size measureRawSize () + protected override int measureRawSize (LayoutingType lt) { - return new Size(maxChildrenWidth + 2 * Margin, maxChildrenHeight + 2 * Margin); + if (lt == LayoutingType.Width) { + if (largestChild == null) + searchLargestChild (); + if (largestChild == null)//if still null, not possible to determine a width + return -1; + return maxChildrenWidth + 2 * Margin; + }else{ + if (tallestChild == null) + searchTallestChild (); + if (tallestChild == null) + return -1; + return maxChildrenHeight + 2 * Margin; + } } public override void OnLayoutChanges (LayoutingType layoutType) @@ -162,8 +174,9 @@ namespace Crow if (this.Bounds.Width < 0) this.RegisterForLayouting (LayoutingType.Width); } else if (g == largestChild) { - - searchLargestChild (); + + largestChild = null; + maxChildrenWidth = 0; if (this.Bounds.Width < 0) this.RegisterForLayouting (LayoutingType.Width); @@ -177,7 +190,8 @@ namespace Crow this.RegisterForLayouting (LayoutingType.Height); } else if (g == tallestChild) { - searchTallestChild (); + tallestChild = null; + maxChildrenHeight = 0; if (this.Bounds.Height < 0) this.RegisterForLayouting (LayoutingType.Height); @@ -186,6 +200,7 @@ namespace Crow } } + //TODO: x,y position should be taken in account for computation of width and height void resetChildrenMaxSize(){ largestChild = null; tallestChild = null; @@ -198,6 +213,8 @@ namespace Crow for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; + if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width)) + continue; if (Children [i].Slot.Width > maxChildrenWidth) { maxChildrenWidth = Children [i].Slot.Width; largestChild = Children [i]; @@ -210,6 +227,8 @@ namespace Crow for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; + if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height)) + continue; if (Children [i].Slot.Height > maxChildrenHeight) { maxChildrenHeight = Children [i].Slot.Height; tallestChild = Children [i]; diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs index bd6a57c9..6755653e 100644 --- a/src/GraphicObjects/Image.cs +++ b/src/GraphicObjects/Image.cs @@ -94,12 +94,15 @@ namespace Crow #endregion #region GraphicObject overrides - protected override Size measureRawSize () + protected override int measureRawSize (LayoutingType lt) { if (_pic == null) _pic = "#Crow.Images.Icons.IconAlerte.svg"; - - return _pic.Dimensions + Margin * 2; + //TODO:take scalling in account + if (lt == LayoutingType.Width) + return _pic.Dimensions.Width + 2 * Margin; + else + return _pic.Dimensions.Height + 2 * Margin; } protected override void onDraw (Context gr) { diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index 4c7e7006..dd5b89e2 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -319,13 +319,11 @@ namespace Crow set { base.Height = value; } } - protected override Size measureRawSize() - { - Size size; - + protected override int measureRawSize(LayoutingType lt) + { if (lines == null) lines = getLines; - + using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) { using (Context gr = new Context (img)) { //Cairo.FontFace cf = gr.GetContextFontFace (); @@ -333,8 +331,19 @@ namespace Crow gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight); gr.SetFontSize (Font.Size); + + fe = gr.FontExtents; te = new TextExtents(); + if (lt == LayoutingType.Height){ + int lc = lines.Count; + //ensure minimal height = text line height + if (lc == 0) + lc = 1; + + return (int)(fe.Height * lc) + Margin * 2; + } + foreach (string s in lines) { string l = s.Replace("\t", new String (' ', Interface.TabSize)); @@ -346,16 +355,9 @@ namespace Crow if (tmp.XAdvance > te.XAdvance) te = tmp; } - fe = gr.FontExtents; - int lc = lines.Count; - //ensure minimal height = text line height - if (lc == 0) - lc = 1; - size = new Size ((int)Math.Ceiling (te.XAdvance) + Margin * 2, (int)(fe.Height * lc) + Margin*2); + return (int)Math.Ceiling (te.XAdvance) + Margin * 2; } } - - return size;; } protected override void onDraw (Context gr) { @@ -368,7 +370,8 @@ namespace Crow //gr.FontOptions.Antialias = Antialias.Subpixel; //gr.FontOptions.HintMetrics = HintMetrics.On; - rText = new Rectangle(measureRawSize()); + rText = new Rectangle( + measureRawSize(LayoutingType.Width), measureRawSize(LayoutingType.Height)); rText.Width -= 2 * Margin; rText.Height -= 2 * Margin; diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index f3c9f43d..640e8d0b 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -91,9 +91,16 @@ namespace Crow return child == goToFind ? true : child == null ? false : child.Contains(goToFind); } - protected override Size measureRawSize () - { - return child == null ? Bounds.Size : child.Slot.Size + 2 * Margin; + protected override int measureRawSize (LayoutingType lt) + { + if (child == null) + return base.measureRawSize (lt); + if (lt == LayoutingType.Width) + return child.RegisteredLayoutings.HasFlag(LayoutingType.Width) ? + -1 : child.Slot.Size.Width + 2 * Margin; + else + return child.RegisteredLayoutings.HasFlag(LayoutingType.Height) ? + -1 : child.Slot.Size.Height + 2 * Margin; } public override bool UpdateLayout (LayoutingType layoutType) { diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index dd7c742d..75176c34 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -71,38 +71,47 @@ namespace Crow string _template; - [XmlAttributeAttribute][DefaultValue("#Crow.Templates.Template.goml")] + [XmlAttributeAttribute][DefaultValue(null)] public string Template { get { return _template; } - set { _template = value; } - } + set { + if (Template == value) + return; + _template = value; - #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); + if (string.IsNullOrEmpty(_template)) + loadTemplate (); + else + loadTemplate (Interface.Load (_template, this)); } } - [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); - } - } + #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); +// } +// } public override GraphicObject FindByName (string nameToFind) { //prevent name searching in template diff --git a/src/GraphicObjects/TextRun.cs b/src/GraphicObjects/TextRun.cs index a426bdee..ef19cb04 100644 --- a/src/GraphicObjects/TextRun.cs +++ b/src/GraphicObjects/TextRun.cs @@ -144,13 +144,11 @@ namespace Crow set { base.Margin = value; } } - protected override Size measureRawSize() - { - Size size; - + protected override int measureRawSize(LayoutingType lt) + { if (lines == null) lines = getLines; - + using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) { using (Context gr = new Context (img)) { //Cairo.FontFace cf = gr.GetContextFontFace (); @@ -158,30 +156,34 @@ namespace Crow gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight); gr.SetFontSize (Font.Size); + + fe = gr.FontExtents; te = new TextExtents(); + if (lt == LayoutingType.Height){ + int lc = lines.Count; + //ensure minimal height = text line height + if (lc == 0) + lc = 1; + + return (int)(fe.Height * lc) + Margin * 2; + } + foreach (string s in lines) { string l = s.Replace("\t", new String (' ', Interface.TabSize)); -#if _WIN32 || _WIN64 + #if _WIN32 || _WIN64 TextExtents tmp = gr.TextExtents(str.ToUtf8()); -#elif __linux__ + #elif __linux__ TextExtents tmp = gr.TextExtents (l); -#endif + #endif if (tmp.XAdvance > te.XAdvance) te = tmp; } - fe = gr.FontExtents; - int lc = lines.Count; - //ensure minimal height = text line height - if (lc == 0) - lc = 1; - size = new Size ((int)Math.Ceiling (te.XAdvance) + Margin * 2, (int)(fe.Height * lc) + Margin*2); + return (int)Math.Ceiling (te.XAdvance) + Margin * 2; } } - - return size;; - } + } protected override void onDraw (Context gr) { base.onDraw (gr); @@ -193,7 +195,8 @@ namespace Crow //gr.FontOptions.Antialias = Antialias.Subpixel; //gr.FontOptions.HintMetrics = HintMetrics.On; - rText = new Rectangle(measureRawSize()); + rText = new Rectangle( + measureRawSize(LayoutingType.Width), measureRawSize(LayoutingType.Height)); rText.Width -= 2 * Margin; rText.Height -= 2 * Margin; |