aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-17 08:44:34 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-17 08:44:34 +0100
commita8156b149f2e4a3c087bcb090db293d08116bd67 (patch)
tree51dd4165422863f70c656de8e0bbfa7c079142bb
parent3c1dbdbbc58d38d45276e3147c3717d19a69adf2 (diff)
parentbf27b88a6cbfcc65d7ed6360f9193d52f96b1598 (diff)
Merge branch 'DefTemplateSizing0'
-rw-r--r--Crow.csproj13
-rw-r--r--Crow.sln14
-rw-r--r--MonoDevelop.GOLib/MonoDevelop.GOLib.csproj2
-rwxr-xr-xTemplates/ArrowButTemplate.crow2
-rwxr-xr-xTemplates/Button.crow2
-rwxr-xr-xTemplates/CheckBox.goml6
-rwxr-xr-xTemplates/ComboBox.goml8
-rwxr-xr-xTemplates/Dummy.goml8
-rwxr-xr-xTemplates/Expandable.goml11
-rwxr-xr-xTemplates/GroupBox.goml6
-rwxr-xr-xTemplates/ListBox.goml9
-rw-r--r--Templates/MessageBox.goml16
-rwxr-xr-xTemplates/Popper.goml6
-rwxr-xr-xTemplates/RadioButton.goml4
-rwxr-xr-xTemplates/ScrollBar.goml6
-rw-r--r--Templates/ScrollingListBox.goml10
-rwxr-xr-xTemplates/Spinner.goml8
-rw-r--r--Templates/TabItem.crow22
-rw-r--r--Templates/TreeItem.crow31
-rw-r--r--Templates/TreeView.crow7
-rwxr-xr-xTemplates/Window.goml12
-rw-r--r--Tests/GOLIBTests.cs39
-rwxr-xr-xTests/Interfaces/0.crow11
-rwxr-xr-xTests/Interfaces/1.crow13
-rwxr-xr-xTests/Interfaces/TmpExpandable.goml14
-rwxr-xr-xTests/Interfaces/testAll.goml6
-rwxr-xr-xTests/Interfaces/testCheckbox.goml8
-rwxr-xr-xTests/Interfaces/testColorList.crow10
-rwxr-xr-xTests/Interfaces/testDirViewer.goml10
-rwxr-xr-xTests/Interfaces/testExpandable.goml16
-rwxr-xr-xTests/Interfaces/testOutOfClipUpdate.crow6
-rwxr-xr-xTests/Interfaces/testRadioButton2.goml4
-rw-r--r--Tests/Interfaces/testTabView.crow59
-rwxr-xr-xTests/Interfaces/testTreeView.crow2
-rwxr-xr-xTests/Interfaces/testWindow2.goml12
-rwxr-xr-xTests/Interfaces/testWindow3.goml2
-rwxr-xr-xTests/Interfaces/test_Listbox.goml10
-rw-r--r--Tests/Tests.csproj11
-rw-r--r--UnitTest/NUnitCrowWindow.cs3
-rw-r--r--UnitTest/UnitTest.csproj2
-rw-r--r--src/GraphicObjects/Border.cs5
-rw-r--r--src/GraphicObjects/Button.cs7
-rw-r--r--src/GraphicObjects/CheckBox.cs24
-rw-r--r--src/GraphicObjects/DummyTemplate.cs33
-rw-r--r--src/GraphicObjects/Expandable.cs72
-rw-r--r--src/GraphicObjects/GenericStack.cs236
-rw-r--r--src/GraphicObjects/GraphicObject.cs154
-rw-r--r--src/GraphicObjects/Grid.cs10
-rw-r--r--src/GraphicObjects/Group.cs159
-rw-r--r--src/GraphicObjects/GroupBox.cs14
-rw-r--r--src/GraphicObjects/ILayoutable.cs1
-rw-r--r--src/GraphicObjects/Image.cs9
-rw-r--r--src/GraphicObjects/Label.cs31
-rw-r--r--src/GraphicObjects/Popper.cs15
-rw-r--r--src/GraphicObjects/PrivateContainer.cs36
-rw-r--r--src/GraphicObjects/RadioButton.cs26
-rw-r--r--src/GraphicObjects/ScrollBar.cs13
-rw-r--r--src/GraphicObjects/Scroller.cs55
-rw-r--r--src/GraphicObjects/Splitter.cs114
-rw-r--r--src/GraphicObjects/TabItem.cs216
-rw-r--r--src/GraphicObjects/TabView.cs216
-rw-r--r--src/GraphicObjects/TemplatedControl.cs71
-rw-r--r--src/GraphicObjects/TextRun.cs39
-rw-r--r--src/GraphicObjects/TreeView.cs35
-rw-r--r--src/LayoutingQueueItem.cs15
-rw-r--r--src/OpenTKGameWindow.cs74
-rw-r--r--src/Rectangles.cs12
67 files changed, 1519 insertions, 614 deletions
diff --git a/Crow.csproj b/Crow.csproj
index a29b7721..05f0841d 100644
--- a/Crow.csproj
+++ b/Crow.csproj
@@ -23,7 +23,7 @@
<SchemaVersion>2.0</SchemaVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ReleaseVersion>0.3</ReleaseVersion>
+ <ReleaseVersion>0.4</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
@@ -133,11 +133,15 @@
<Compile Include="src\LayoutingEventArgs.cs" />
<Compile Include="src\ScrollingEventArgs.cs" />
<Compile Include="src\GraphicObjects\Trend.cs" />
+ <Compile Include="src\GraphicObjects\Splitter.cs" />
+ <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" />
<Reference Include="System.Data" />
- <Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
<Reference Include="glib-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<Package>glib-sharp-3.0</Package>
@@ -148,6 +152,7 @@
</Reference>
<Reference Include="Mono.Cairo" />
<Reference Include="rsvg2-sharp, Version=2.18.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <Reference Include="System.Drawing" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -222,6 +227,10 @@
<EmbeddedResource Include="Images\crow0.svg">
<LogicalName>Crow.image.crow0.svg</LogicalName>
</EmbeddedResource>
+ <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/Crow.sln b/Crow.sln
index 2b78e809..27ea466c 100644
--- a/Crow.sln
+++ b/Crow.sln
@@ -41,7 +41,19 @@ Global
$0.DotNetNamingPolicy = $2
$2.DirectoryNamespaceAssociation = None
$2.ResourceNamePolicy = FileFormatDefault
+ $0.TextStylePolicy = $3
+ $3.FileWidth = 120
+ $3.TabsToSpaces = False
+ $3.EolMarker = Unix
+ $3.inheritsSet = VisualStudio
+ $3.inheritsScope = text/plain
+ $3.scope = text/x-csharp
+ $0.CSharpFormattingPolicy = $4
+ $4.AfterDelegateDeclarationParameterComma = True
+ $4.inheritsSet = Mono
+ $4.inheritsScope = text/x-csharp
+ $4.scope = text/x-csharp
description = @C.R.O.W. Collaborative Radiant Open Widgets\n\nA pure c# toolkit with XML definition of interface with binding and\ndynamic delegates
- version = 0.3
+ version = 0.4
EndGlobalSection
EndGlobal
diff --git a/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj b/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
index d094fdf3..adbc70fb 100644
--- a/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
+++ b/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
@@ -23,7 +23,7 @@
</Command>
</CustomCommands>
</CustomCommands>
- <ReleaseVersion>0.3</ReleaseVersion>
+ <ReleaseVersion>0.4</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
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..0e55491f 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 Margin="1" Spacing="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}">
+ <Image Margin="2" Width="14" Height="14" Path="{../../Image}" SvgSub="{../../SvgSub}"/>
+ <Label 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..6757fb68 100755
--- a/Templates/Expandable.goml
+++ b/Templates/Expandable.goml
@@ -1,11 +1,12 @@
<?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 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 0a21be0f..fa8d514e 100755
--- a/Templates/ListBox.goml
+++ b/Templates/ListBox.goml
@@ -1,11 +1,8 @@
<?xml version="1.0"?>
-<!--<Border BorderWidth="1" Margin="1" MinimumSize="0;100" Height="{TemplatedHeight}" Width="{TemplatedWidth}" Background="Gray">
- <VerticalStack Name="List" Margin="1" Height="{TemplatedHeight}" Width="{TemplatedWidth}"/>
-</Border>-->
-<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/TabItem.crow b/Templates/TabItem.crow
new file mode 100644
index 00000000..a889f4ee
--- /dev/null
+++ b/Templates/TabItem.crow
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<GenericStack Orientation="Vertical" Spacing="0"
+ Width="{../../WidthPolicy}" Height="{../../HeightPolicy}"
+ Background="vgradient|0:DimGray|1:Black"
+ MouseEnter="{Background=vgradient|0:Gray|1:Black}"
+ MouseLeave="{Background=vgradient|0:DimGray|1:Black}">
+ <HorizontalStack Margin="2" Left="{../../TabOffset}"
+ Name="TabTitle"
+ HorizontalAlignment="Left"
+ Height="{../../../TabThickness}"
+ Width="-1">
+ <Label Text="{../../../Caption}"/>
+ <Border CornerRadius="5" 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"
+ MouseClick="../../../../butCloseTabClick"/>
+ </Border>
+ </HorizontalStack>
+ <Container
+ Name="Content" Width="{../../../WidthPolicy}" Height="{../../../HeightPolicy}"/>
+</GenericStack>
+
diff --git a/Templates/TreeItem.crow b/Templates/TreeItem.crow
new file mode 100644
index 00000000..b3458ec1
--- /dev/null
+++ b/Templates/TreeItem.crow
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--<Container Fit="true" Margin="0" Focusable="true" Background="Gray"
+ MouseEnter="{Background=SteelBlue}"
+ MouseLeave="{Background=Gray}">
+ <Label Text="{}"/>
+</Container>-->
+<Expandable Caption="{}">
+ <Template>
+ <Border BorderWidth="1" Foreground="LightGray" Height="{../HeightPolicy}" Width="{../WidthPolicy}"
+ MouseClick="../onMouseClick">
+ <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="{../../../../WidthPolicy}"/>
+ </HorizontalStack>
+ <Container Name="Content" Visible="false" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/>
+ </VerticalStack>
+ </Border>
+ </Template>
+</Expandable>
+<!-- <VerticalStack
+ Height="{../HeightPolicy}" Width="{../WidthPolicy}"
+ MouseClick="../onMouseClick">
+ <HorizontalStack Spacing="1" Height="-1" Width="{../../WidthPolicy}">
+ <Image Margin="2" Width="12" Height="12" Path="{../../../Image}" SvgSub="{../../../SvgSub}"/>
+ <Label Text="{../../../Caption}" Width="{../../../WidthPolicy}"/>
+ </HorizontalStack>
+ <ListBox Name="Content" Visible="false"
+ Height="-1" Width="{../../WidthPolicy}"/>
+ </VerticalStack>-->
+
diff --git a/Templates/TreeView.crow b/Templates/TreeView.crow
new file mode 100644
index 00000000..165cea1c
--- /dev/null
+++ b/Templates/TreeView.crow
@@ -0,0 +1,7 @@
+<Border Background="DimGray" BorderWidth="1" Margin="1" MinimumSize="100;100"
+ Width="{../WidthPolicy}" Height="{../HeightPolicy}">
+ <VerticalStack
+ Height="0" Width="0" Name="List" Margin="0" VerticalAlignment="Top"/>
+
+</Border>
+
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 a98fccf7..3d6e619f 100644
--- a/Tests/GOLIBTests.cs
+++ b/Tests/GOLIBTests.cs
@@ -37,6 +37,14 @@ namespace test
int frameCpt = 0;
int idx = 0;
string[] testFiles = {
+ "testCheckbox.goml",
+ "testTabView.crow",
+ "testExpandable.goml",
+ "0.crow",
+ "testImage.crow",
+ "testOutOfClipUpdate.crow",
+ "test_Listbox.goml",
+ "testTreeView.crow",
"1.crow",
"testWindow.goml",
"clip4.crow",
@@ -44,33 +52,28 @@ namespace test
"clip2.crow",
"clip0.crow",
"clip1.crow",
- "0.crow",
"5.crow",
"testCombobox.goml",
"testPopper.goml",
"testTextBox.crow",
"testColorList.crow",
- "testExpandable.goml",
"4.crow",
"testSpinner.goml",
"testScrollbar.goml",
"testGroupBox.goml",
"testGrid.goml",
- "test_Listbox.goml",
"testButton.crow",
"testBorder.goml",
// "testButton2.crow",
"test2WayBinding.crow",
"fps.goml",
- "testImage.crow",
"test4.goml",
"2.crow",
"test1.goml",
"testWindow2.goml",
"testWindow3.goml",
- "testCheckbox.goml",
"testLabel.goml",
"testAll.goml",
// "testSpinner.goml",
@@ -149,6 +152,24 @@ namespace test
return;
NotifyValueChanged ("alignment", Enum.Parse(typeof(Alignment), rb.Caption));
}
+ public IList<String> List2 = new List<string>(new string[]
+ {
+ "string1",
+ "string2",
+ "string3",
+ "string4",
+ "string5",
+ "string6",
+ "string7",
+ "string8",
+ "string8",
+ "string8",
+ "string8",
+ "string8",
+ "string8",
+ "string9"
+ }
+ );
IList<Color> testList = Color.ColorDic.ToList();
public IList<Color> TestList {
set{
@@ -218,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/0.crow b/Tests/Interfaces/0.crow
index 0d84b541..d067f4ff 100755
--- a/Tests/Interfaces/0.crow
+++ b/Tests/Interfaces/0.crow
@@ -1,18 +1,19 @@
<?xml version="1.0"?>
<!--<Label Text="test" Background="BlueCrayola"/>-->
<!--<GraphicObject Width="10" Height="10" Background="Red"/>-->
-<VerticalStack Fit="true" Margin="2" Spacing="2">
- <ProgressBar CornerRadius="5" Background="DimGray" Margin="1" Maximum="1000" Value="{fps}" Width="200" Height="15"/>
- <Label Text="test" Background="BlueCrayola"/>
+<VerticalStack Width="400" Height="400" Margin="2" Spacing="2">
+ <Label Left="20" Text="test" Background="BlueCrayola"/>
+ <GraphicObject Background="LimeGreen" Width="300" Height="300"/>
+<!-- <ProgressBar CornerRadius="5" Background="DimGray" Margin="1" Maximum="1000" Value="{fps}" Width="200" Height="15"/>
<RadioButton Caption="test radiobutton"/>
<Image Width="50" Height="50" Background="vgradient|0:SkyBlue|1:White" Path="#Tests.image.crow0.svg"/>
<Button Caption="test button"/>
<TextRun Text="text run test"/>
<TextBox Text="text run test"/>
- <Border CornerRadius="5" Background="DimGray" >
+ <Border CornerRadius="5" Background="DimGray" Fit="true" >
<Trend HighThreshold="{fpsMax}" LowThreshold="{fpsMin}" NbValues="5"
Height="100" Width="400" NewValue="{fps}" Name="trend" Maximum="600" Foreground="White"/>
- </Border>
+ </Border>-->
</VerticalStack>
<!-- <HorizontalStack Fit="true">
<Label Text="Memory:" Width="50" TextAlignment="Right"/>
diff --git a/Tests/Interfaces/1.crow b/Tests/Interfaces/1.crow
index 732814a5..11560723 100755
--- a/Tests/Interfaces/1.crow
+++ b/Tests/Interfaces/1.crow
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<VerticalStack Fit="true">
<GraphicObject CornerRadius="5" Height="10" Width="600" Background="vgradient|0:Transparent|0,5:White|1:Transparent"/>
- <HorizontalStack Fit="true">
+ <HorizontalStack Fit="true" HorizontalAlignment="Left">
<Border Fit="true" CornerRadius="10" BorderWidth="1">
<VerticalStack Margin="10">
<CheckBox IsChecked="false" Caption="Check 1" Background="hgradient|0:LimeGreen|1:Transparent"/>
@@ -10,22 +10,26 @@
<CheckBox IsChecked="false" Caption="Check 4" Background="hgradient|0:LimeGreen|1:Transparent"/>
</VerticalStack>
</Border>
+ <Splitter/>
<Border Fit="true" CornerRadius="10" BorderWidth="1">
<VerticalStack Margin="10">
<RadioButton IsChecked="false" Caption="Choice 1" Background="hgradient|0:DarkRed|1:Transparent"/>
- <RadioButton IsChecked="false" Caption="Choice 2" Background="hgradient|0:DarkRed|1:Transparent"/>
+ <Splitter/>
+ <RadioButton Width="0" IsChecked="false" Caption="Choice 2" Background="hgradient|0:DarkRed|1:Transparent"/>
<RadioButton IsChecked="true" Caption="Choice 3" Background="hgradient|0:DarkRed|1:Transparent"/>
<RadioButton IsChecked="false" Caption="Choice 4" Background="hgradient|0:DarkRed|1:Transparent"/>
</VerticalStack>
</Border>
- <Border Fit="true" CornerRadius="10" BorderWidth="1">
+ <Splitter Thickness="3" />
+ <Border Fit="true" CornerRadius="10" BorderWidth="1" MaximumSize="150;150" MinimumSize="50;50">
<VerticalStack Margin="10">
<Label Text="label 1" Background="hgradient|0:BlueCrayola|1:Transparent"/>
<Label Text="label 2" Background="hgradient|0:BlueCrayola|1:Transparent"/>
<Label Text="label 3" Background="hgradient|0:BlueCrayola|1:Transparent"/>
- <Label Text="label 4" Background="hgradient|0:BlueCrayola|1:Transparent"/>
+ <Label Text="label 4" Width="0" Background="hgradient|0:BlueCrayola|1:Transparent"/>
</VerticalStack>
</Border>
+ <Splitter/>
<Border Fit="true" CornerRadius="10" BorderWidth="1">
<VerticalStack Margin="10">
<Button Caption="Button 1" Background="hgradient|0:Red|1:DarkRed" CornerRadius="5"/>
@@ -34,6 +38,7 @@
<Button Caption="Button 4" Background="hgradient|0:DarkRed|1:Transparent" CornerRadius="8"/>
</VerticalStack>
</Border>
+ <Splitter/>
</HorizontalStack>
<GraphicObject CornerRadius="5" Height="10" Width="600" Background="vgradient|0:Transparent|0,5:White|1:Transparent"/>
</VerticalStack> \ No newline at end of file
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..86813332 100755
--- a/Tests/Interfaces/testCheckbox.goml
+++ b/Tests/Interfaces/testCheckbox.goml
@@ -1,3 +1,9 @@
<?xml version="1.0"?>
-<CheckBox Width="-1" Height="-1" Caption="Checkbox" Background="DimGray" IsChecked="true"/>
+<VerticalStack Fit="true" Margin="10" Background="DimGray" >
+ <CheckBox Background="Gray"/>
+ <CheckBox Background="Gray"/>
+ <CheckBox Background="Gray"/>
+ <CheckBox Background="Gray"/>
+ <CheckBox Background="Gray"/>
+</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 a2fb1e78..1a61085b 100755
--- a/Tests/Interfaces/testExpandable.goml
+++ b/Tests/Interfaces/testExpandable.goml
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
-<Expandable Caption="Test expandable" Background="DimGray">
- <VerticalStack Width="-1" Height="-1">
- <CheckBox Name="chk1" Background="Red"/>
- <CheckBox Name="chk2" IsChecked="true"/>
- <CheckBox Name="chk3"/>
- <CheckBox Name="chk4"/>
- <HorizontalStack Fit="true" Margin="2" Background="Blue">
+<Expandable Fit="true" Caption="Test expandable" Background="DimGray">
+ <VerticalStack Margin="5" Background="Green" Fit="true">
+ <CheckBox Name="chk1" Background="Red" Fit="true"/>
+ <CheckBox Name="chk2" IsChecked="true" Fit="true"/>
+ <CheckBox Name="chk3" Fit="true"/>
+ <CheckBox Name="chk4" Fit="true"/>
+<!-- <HorizontalStack Fit="true" Margin="2" Background="Blue">
<Label Name="captionFps" Text="Fps:" Width="30" TextAlignment="Right"/>
<Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="-1" TextAlignment="Center" Background="AoEnglish"/>
- </HorizontalStack>
+ </HorizontalStack>-->
</VerticalStack>
</Expandable>
diff --git a/Tests/Interfaces/testOutOfClipUpdate.crow b/Tests/Interfaces/testOutOfClipUpdate.crow
new file mode 100755
index 00000000..b255af7f
--- /dev/null
+++ b/Tests/Interfaces/testOutOfClipUpdate.crow
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<Container Width="200" Height="100" Background="DimGray" Margin="5">
+ <Container Width="0" Height="300" Background="DarkBlue">
+ <Label Text="{fps}" Background="BlueCrayola" VerticalAlignment="Center"/>
+ </Container>
+</Container>
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
new file mode 100644
index 00000000..3a081597
--- /dev/null
+++ b/Tests/Interfaces/testTabView.crow
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<HorizontalStack Fit="true">
+ <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">
+ <VerticalStack Fit="true">
+ <CheckBox/>
+ <CheckBox/>
+ <CheckBox/>
+ <CheckBox/>
+ <Label Text="{fps}" HorizontalAlignment="Right" Foreground="Black" Background="Yellow"/>
+ </VerticalStack>
+ </TabItem>
+ <TabItem
+ Name="TabItem2" Caption="tab 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>
+ </TabView>
+</HorizontalStack>
+
diff --git a/Tests/Interfaces/testTreeView.crow b/Tests/Interfaces/testTreeView.crow
new file mode 100755
index 00000000..86bcae88
--- /dev/null
+++ b/Tests/Interfaces/testTreeView.crow
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<TreeView Height="400" Width="200" Data="{List2}" ItemTemplate="#Crow.Templates.TreeViewItem.crow"/> \ No newline at end of file
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/Tests/Tests.csproj b/Tests/Tests.csproj
index 48afea5c..91ebc43a 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -13,7 +13,7 @@
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ReleaseVersion>0.3</ReleaseVersion>
+ <ReleaseVersion>0.4</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\bin\Debug</OutputPath>
@@ -238,6 +238,15 @@
<None Include="Interfaces\clip4.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\testTreeView.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\testOutOfClipUpdate.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\testTabView.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
diff --git a/UnitTest/NUnitCrowWindow.cs b/UnitTest/NUnitCrowWindow.cs
index 8be6a568..961001e7 100644
--- a/UnitTest/NUnitCrowWindow.cs
+++ b/UnitTest/NUnitCrowWindow.cs
@@ -37,6 +37,9 @@ namespace Crow
List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();
#region IGOLibHost implementation
+ public XCursor MouseCursor {
+ set { throw new NotImplementedException ();}
+ }
public Rectangles clipping {
get {
return _redrawClip;
diff --git a/UnitTest/UnitTest.csproj b/UnitTest/UnitTest.csproj
index 47c7e261..ddc46b62 100644
--- a/UnitTest/UnitTest.csproj
+++ b/UnitTest/UnitTest.csproj
@@ -10,7 +10,7 @@
<RootNamespace>UnitTest</RootNamespace>
<AssemblyName>UnitTest</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <ReleaseVersion>0.3</ReleaseVersion>
+ <ReleaseVersion>0.4</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
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/Button.cs b/src/GraphicObjects/Button.cs
index 5bf11f68..9903888b 100644
--- a/src/GraphicObjects/Button.cs
+++ b/src/GraphicObjects/Button.cs
@@ -18,12 +18,7 @@ namespace Crow
{
#region CTOR
public Button() : base()
- {
- //MouseEnter += delegate { Background = Color.RedDevil;};
- //MouseLeave += delegate { Background = Color.Transparent;};
-// MouseButtonDown += delegate { BackImgSub = "pressed"; registerForGraphicUpdate();};
-// MouseButtonUp += delegate { BackImgSub = "normal";registerForGraphicUpdate();};
- }
+ {}
#endregion
string caption;
diff --git a/src/GraphicObjects/CheckBox.cs b/src/GraphicObjects/CheckBox.cs
index fa34522d..05bb0cac 100644
--- a/src/GraphicObjects/CheckBox.cs
+++ b/src/GraphicObjects/CheckBox.cs
@@ -1,24 +1,13 @@
using System;
-
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-//using OpenTK.Graphics.OpenGL;
-
-using Cairo;
-
-using winColors = System.Drawing.Color;
-using System.Diagnostics;
-using System.Xml.Serialization;
using OpenTK.Input;
using System.ComponentModel;
+using System.Xml.Serialization;
namespace Crow
{
[DefaultTemplate("#Crow.Templates.CheckBox.goml")]
- public class CheckBox : TemplatedControl
- {
+ public class CheckBox : TemplatedControl
+ {
string caption;
string image;
bool isChecked;
@@ -33,12 +22,7 @@ namespace Crow
public event EventHandler Unchecked;
#region GraphicObject overrides
-// [XmlAttributeAttribute()][DefaultValue(-1)]
-// public override int Height {
-// get { return base.Height; }
-// set { base.Height = value; }
-// }
- [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true
+ [XmlAttributeAttribute()][DefaultValue(true)]
public override bool Focusable
{
get { return base.Focusable; }
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/Expandable.cs b/src/GraphicObjects/Expandable.cs
index f44e5e27..4214ed93 100644
--- a/src/GraphicObjects/Expandable.cs
+++ b/src/GraphicObjects/Expandable.cs
@@ -1,33 +1,39 @@
using System;
-
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-//using OpenTK.Graphics.OpenGL;
-
-using Cairo;
-
-using winColors = System.Drawing.Color;
-using System.Diagnostics;
-using System.Xml.Serialization;
using OpenTK.Input;
using System.ComponentModel;
-using System.Xml;
-using System.IO;
+using System.Xml.Serialization;
namespace Crow
{
[DefaultTemplate("#Crow.Templates.Expandable.goml")]
public class Expandable : TemplatedContainer
- {
+ {
+ #region CTOR
+ public Expandable() : base()
+ {
+ }
+ #endregion
+
+ #region Private fields
bool _isExpanded;
string caption;
string image;
Container _contentContainer;
+ #endregion
+ #region Event Handlers
public event EventHandler Expand;
public event EventHandler Collapse;
+ #endregion
+
+ #region GraphicObject overrides
+ [XmlAttributeAttribute()][DefaultValue(true)]
+ public override bool Focusable
+ {
+ get { return base.Focusable; }
+ set { base.Focusable = value; }
+ }
+ #endregion
public override GraphicObject Content {
get {
@@ -37,30 +43,25 @@ namespace Crow
_contentContainer.SetChild(value);
}
}
-
- public Expandable() : base()
- {
- }
-
protected override void loadTemplate(GraphicObject template = null)
{
base.loadTemplate (template);
_contentContainer = this.child.FindByName ("Content") as Container;
}
-
- [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true
- public override bool Focusable
+ public override void onMouseClick (object sender, MouseButtonEventArgs e)
{
- get { return base.Focusable; }
- set { base.Focusable = value; }
+ IsExpanded = !IsExpanded;
+ base.onMouseClick (sender, e);
}
- [XmlAttributeAttribute()][DefaultValue(-1)]
- public override int Height {
- get { return base.Height; }
- set { base.Height = value; }
+ public override void ResolveBindings ()
+ {
+ base.ResolveBindings ();
+ if (Content != null)
+ Content.ResolveBindings ();
}
+ #region Public properties
[XmlAttributeAttribute()][DefaultValue("Expandable")]
public string Caption {
get { return caption; }
@@ -99,6 +100,7 @@ namespace Crow
NotifyValueChanged ("SvgSub", "collapsed");
}
}
+ #endregion
public virtual void onExpand(object sender, EventArgs e)
{
@@ -114,17 +116,5 @@ namespace Crow
Collapse.Raise (this, e);
}
-
- public override void onMouseClick (object sender, MouseButtonEventArgs e)
- {
- IsExpanded = !IsExpanded;
- base.onMouseClick (sender, e);
- }
- public override void ResolveBindings ()
- {
- base.ResolveBindings ();
- if (Content != null)
- Content.ResolveBindings ();
- }
}
}
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index 665ba65d..2a1da6c3 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -10,12 +10,6 @@ namespace Crow
{
public class GenericStack : Group
{
- internal class Page
- {
- public byte[] bmp;
- public int Size;
- }
-
#region CTOR
public GenericStack()
: base()
@@ -28,18 +22,6 @@ namespace Crow
Orientation _orientation;
#endregion
- public override T AddChild<T> (T child)
- {
- T tmp = base.AddChild (child);
- this.RegisterForLayouting (LayoutingType.PositionChildren);
- return tmp;
- }
- public override void RemoveChild (GraphicObject child)
- {
- base.RemoveChild (child);
- this.RegisterForLayouting (LayoutingType.PositionChildren);
- }
-
#region Public Properties
[XmlAttributeAttribute()][DefaultValue(2)]
public int Spacing
@@ -61,40 +43,55 @@ namespace Crow
#endregion
#region GraphicObject Overrides
- protected override Size measureRawSize ()
+ public override bool ArrangeChildren { get { return true; } }
+ public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType)
{
- 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;
+ //Prevent child repositionning in the direction of stacking
+ if (Orientation == Orientation.Horizontal)
+ layoutType &= (~LayoutingType.X);
+ else
+ layoutType &= (~LayoutingType.Y);
+ }
+ protected override int measureRawSize (LayoutingType lt)
+ {
+ 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()
{
- #if DEBUG_LAYOUTING
- Debug.WriteLine("ComputeChildrenPosition: " + this.ToString());
- #endif
int d = 0;
if (Orientation == Orientation.Horizontal) {
foreach (GraphicObject c in Children) {
@@ -120,86 +117,87 @@ namespace Crow
{
RegisteredLayoutings &= (~layoutType);
- LayoutingType childSizeToCheck;
- if (Orientation == Orientation.Horizontal)
- childSizeToCheck = LayoutingType.Width;
- else
- childSizeToCheck = LayoutingType.Height;
-
- foreach (GraphicObject g in Children) {
- if (!g.Visible)
- continue;
- if (g.RegisteredLayoutings.HasFlag (childSizeToCheck))
- return false;
- }
-
- if (layoutType == LayoutingType.PositionChildren) {
- //allow 1 child to have size to 0 if stack has fixed or streched size,
+ if (layoutType == LayoutingType.ArrangeChildren) {
+ //allow 1 child to have size to 0 if stack has fixed or streched size policy,
//this child will occupy remaining space
+ //if stack size policy is Fit, no child may have stretch enabled
+ //in the direction of stacking.
if (Orientation == Orientation.Horizontal) {
- if (Width >= 0) {
- GraphicObject stretchedGO = null;
- int tmpWidth = Slot.Width;
- int cptChildren = 0;
- for (int i = 0; i < Children.Count; i++) {
- if (!Children [i].Visible)
- continue;
- cptChildren++;
- if (Children [i].Width == 0) {
- if (stretchedGO != null)
- throw new Exception ("Only one child in stack may have size to stretched");
- stretchedGO = Children [i];
- if (i < Children.Count - 1)
- tmpWidth -= Spacing;
- continue;
+ GraphicObject stretchedGO = null;
+ int tmpWidth = Slot.Width;
+ int cptChildren = 0;
+ for (int i = 0; i < Children.Count; i++) {
+ if (!Children [i].Visible)
+ continue;
+ //requeue Positionning if child is not layouted
+ if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ return false;
+ cptChildren++;
+ if (Children [i].Width == 0) {
+ if (!(stretchedGO == null && Width >= 0)) {
+ //change size policy of other stretched children
+ Children [i].Width = -1;
+ return false;
}
- tmpWidth -= Children[i].Slot.Width + Spacing;
+ stretchedGO = Children [i];
+ if (i < Children.Count - 1)
+ tmpWidth -= Spacing;
+ continue;
}
- if (stretchedGO != null) {
- tmpWidth += (Spacing - 2 * Margin);
- if (tmpWidth < MinimumSize.Width)
- tmpWidth = MinimumSize.Width;
- else if (tmpWidth > MaximumSize.Width && MaximumSize.Width > 0)
- tmpWidth = MaximumSize.Width;
- if (stretchedGO.LastSlots.Width != tmpWidth) {
- stretchedGO.Slot.Width = tmpWidth;
- stretchedGO.bmp = null;
- stretchedGO.OnLayoutChanges (LayoutingType.Width);
- stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
- }
+ tmpWidth -= Children [i].Slot.Width + Spacing;
+ }
+ if (stretchedGO != null && Width >= 0) {
+ tmpWidth += (Spacing - 2 * Margin);
+ if (tmpWidth < MinimumSize.Width)
+ tmpWidth = MinimumSize.Width;
+ else if (tmpWidth > MaximumSize.Width && MaximumSize.Width > 0)
+ tmpWidth = MaximumSize.Width;
+ if (stretchedGO.LastSlots.Width != tmpWidth) {
+ stretchedGO.Slot.Width = tmpWidth;
+ stretchedGO.bmp = null;
+ #if DEBUG_LAYOUTING
+ Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
+ #endif
+ stretchedGO.OnLayoutChanges (LayoutingType.Width);
+ stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
}
- }
+ }
} else {
- if (Height >= 0) {
- GraphicObject stretchedGO = null;
- int tmpHeight = Slot.Height;
- int cptChildren = 0;
- for (int i = 0; i < Children.Count; i++) {
- if (!Children [i].Visible)
- continue;
- cptChildren++;
- if (Children [i].Height == 0) {
- if (stretchedGO != null)
- throw new Exception ("Only one child in stack may have size to stretched");
- stretchedGO = Children [i];
- if (i < Children.Count - 1)
- tmpHeight -= Spacing;
- continue;
+ GraphicObject stretchedGO = null;
+ int tmpHeight = Slot.Height;
+ int cptChildren = 0;
+ for (int i = 0; i < Children.Count; i++) {
+ if (!Children [i].Visible)
+ continue;
+ if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ return false;
+ cptChildren++;
+ if (Children [i].Height == 0) {
+ if (!(stretchedGO == null && Height >= 0)){
+ Children [i].Height = -1;
+ return false;
}
- tmpHeight -= Children[i].Slot.Height + Spacing;
+ stretchedGO = Children [i];
+ if (i < Children.Count - 1)
+ tmpHeight -= Spacing;
+ continue;
}
- if (stretchedGO != null) {
- tmpHeight += (Spacing - 2 * Margin);
- if (tmpHeight < MinimumSize.Height)
- tmpHeight = MinimumSize.Height;
- else if (tmpHeight > MaximumSize.Height && MaximumSize.Height > 0)
- tmpHeight = MaximumSize.Height;
- if (stretchedGO.LastSlots.Height != tmpHeight) {
- stretchedGO.Slot.Height = tmpHeight;
- stretchedGO.bmp = null;
- stretchedGO.OnLayoutChanges (LayoutingType.Height);
- stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
- }
+ tmpHeight -= Children[i].Slot.Height + Spacing;
+ }
+ if (stretchedGO != null && Height >= 0) {
+ tmpHeight += (Spacing - 2 * Margin);
+ if (tmpHeight < MinimumSize.Height)
+ tmpHeight = MinimumSize.Height;
+ else if (tmpHeight > MaximumSize.Height && MaximumSize.Height > 0)
+ tmpHeight = MaximumSize.Height;
+ if (stretchedGO.LastSlots.Height != tmpHeight) {
+ stretchedGO.Slot.Height = tmpHeight;
+ stretchedGO.bmp = null;
+ #if DEBUG_LAYOUTING
+ Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString());
+ #endif
+ stretchedGO.OnLayoutChanges (LayoutingType.Height);
+ stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
}
}
}
@@ -226,14 +224,14 @@ namespace Crow
if (Orientation == Orientation.Horizontal) {
if (this.Bounds.Width < 0)
this.RegisterForLayouting (LayoutingType.Width);
- this.RegisterForLayouting (LayoutingType.PositionChildren);
+ this.RegisterForLayouting (LayoutingType.ArrangeChildren);
}
break;
case LayoutingType.Height:
if (Orientation == Orientation.Vertical) {
if (this.Bounds.Height < 0)
this.RegisterForLayouting (LayoutingType.Height);
- this.RegisterForLayouting (LayoutingType.PositionChildren);
+ this.RegisterForLayouting (LayoutingType.ArrangeChildren);
}
break;
}
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 171a8eaa..9f20fca9 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -1,23 +1,14 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-//using OpenTK.Graphics.OpenGL;
-using System.Drawing.Imaging;
+using System.ComponentModel;
using System.Diagnostics;
-using OpenTK.Input;
-
-using Cairo;
-
-using System.Xml.Serialization;
+using System.Linq;
using System.Reflection;
-using System.ComponentModel;
-using System.IO;
-//using System.Xml;
-using System.Xml;
-using System.Runtime.CompilerServices;
using System.Reflection.Emit;
+using System.Runtime.CompilerServices;
+using System.Xml.Serialization;
+using Cairo;
+using OpenTK.Input;
namespace Crow
{
@@ -54,7 +45,6 @@ namespace Crow
return;
loadDefaultValues ();
- registerForGraphicUpdate ();
}
public GraphicObject (Rectangle _bounds)
{
@@ -63,7 +53,6 @@ namespace Crow
loadDefaultValues ();
Bounds = _bounds;
- registerForGraphicUpdate ();
}
#endregion
@@ -249,6 +238,8 @@ namespace Crow
Bounds.Width = value;
NotifyValueChanged ("Width", Bounds.Width);
+ NotifyValueChanged ("WidthPolicy", WidthPolicy);
+
this.RegisterForLayouting (LayoutingType.Width);
}
}
@@ -261,17 +252,22 @@ namespace Crow
Bounds.Height = value;
NotifyValueChanged ("Height", Bounds.Height);
+ NotifyValueChanged ("HeightPolicy", HeightPolicy);
+
this.RegisterForLayouting (LayoutingType.Height);
}
}
+ [XmlIgnore]public virtual int WidthPolicy { get { return Width < 1 ? Width : 0; } }
+ [XmlIgnore]public virtual int HeightPolicy { get { return Height < 1 ? Height : 0; } }
+
[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)]
@@ -385,12 +381,14 @@ namespace Crow
if (!_isVisible && this.Contains (HostContainer.hoverWidget))
HostContainer.hoverWidget = null;
+ if (Parent is GraphicObject)
+ Parent.RegisterForLayouting (LayoutingType.Sizing);
if (Parent is GenericStack)
- Parent.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.PositionChildren);
-
+ Parent.RegisterForLayouting (LayoutingType.ArrangeChildren);
RegisterForLayouting (LayoutingType.Sizing);
RegisterForRedraw ();
+
NotifyValueChanged ("Visible", _isVisible);
}
}
@@ -426,7 +424,7 @@ namespace Crow
/// <summary> Loads the default values from XML attributes default </summary>
protected virtual void loadDefaultValues()
- {
+ {
Type thisType = this.GetType ();
if (Interface.DefaultValuesLoader.ContainsKey(thisType.FullName)) {
Interface.DefaultValuesLoader[thisType.FullName] (this);
@@ -451,20 +449,19 @@ namespace Crow
il.Emit(OpCodes.Nop);
+ StyleAttribute[] style = thisType.GetCustomAttributes().OfType<StyleAttribute>().ToArray();
+
foreach (PropertyInfo pi in thisType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
string name = "";
+ object defaultValue = null;
#region retrieve custom attributes
if (pi.GetSetMethod () == null)
continue;
+
XmlIgnoreAttribute xia = (XmlIgnoreAttribute)pi.GetCustomAttribute (typeof(XmlIgnoreAttribute));
if (xia != null)
- continue;
- DefaultValueAttribute dv = (DefaultValueAttribute)pi.GetCustomAttribute (typeof(DefaultValueAttribute));
- if (dv == null)
- continue;
- object defaultValue = dv.Value;
-
+ continue;
XmlAttributeAttribute xaa = (XmlAttributeAttribute)pi.GetCustomAttribute (typeof(XmlAttributeAttribute));
if (xaa != null) {
if (string.IsNullOrEmpty (xaa.AttributeName))
@@ -472,6 +469,16 @@ namespace Crow
else
name = xaa.AttributeName;
}
+
+ StyleAttribute piStyle = style.Where(s => s.PropertyName == pi.Name).FirstOrDefault();
+ if (piStyle != null){
+ defaultValue = piStyle.DefaultValue;
+ }else{
+ DefaultValueAttribute dv = (DefaultValueAttribute)pi.GetCustomAttribute (typeof(DefaultValueAttribute));
+ if (dv == null)
+ continue;
+ defaultValue = dv.Value;
+ }
#endregion
il.Emit (OpCodes.Ldarg_0);
@@ -618,12 +625,15 @@ namespace Crow
get { return layoutingTries; }
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){
+ }
+ public virtual bool ArrangeChildren { get { return false; } }
public virtual void RegisterForLayouting(LayoutingType layoutType){
if (Parent == null)
return;
@@ -633,15 +643,12 @@ namespace Crow
if (Height == 0)
layoutType &= (~LayoutingType.Y);
- //Prevent child repositionning in a stack
- //TODO:this should be done inside GenericStack
- GenericStack gs = Parent as GenericStack;
- if (gs != null) {
- if (gs.Orientation == Orientation.Horizontal)
- layoutType &= (~LayoutingType.X);
- else
- layoutType &= (~LayoutingType.Y);
- }
+ if (!ArrangeChildren)
+ layoutType &= (~LayoutingType.ArrangeChildren);
+
+ //apply constraints depending on parent type
+ if (Parent is GraphicObject)
+ (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType);
//prevent queueing same LayoutingType for this
layoutType &= (~RegisteredLayoutings);
@@ -650,7 +657,7 @@ namespace Crow
return;
#if DEBUG_LAYOUTING
- Debug.WriteLine ("RegisterForLayouting => {1}->{0}", layoutType, this.ToString());
+ Debug.WriteLine ("REGLayout => {1}->{0}", layoutType, this.ToString());
#endif
//enqueue LQI LayoutingTypes separately
@@ -662,15 +669,15 @@ namespace Crow
Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
if (layoutType.HasFlag (LayoutingType.Y))
Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
- if (layoutType.HasFlag (LayoutingType.PositionChildren))
- Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.PositionChildren, this));
+ if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
+ Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
}
/// <summary> trigger dependant sizing component update </summary>
public virtual void OnLayoutChanges(LayoutingType layoutType)
{
#if DEBUG_LAYOUTING
- Debug.WriteLine ("Layout change: " + this.ToString () + ":" + LastSlots.ToString() + "=>" + Slot.ToString ());
+ Debug.WriteLine ("\t " + LastSlots.ToString() + "\n\t => " + Slot.ToString ());
#endif
switch (layoutType) {
@@ -697,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) {
@@ -726,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) {
@@ -753,16 +762,14 @@ namespace Crow
LastSlots.Y = Slot.Y;
break;
case LayoutingType.Width:
- //force sizing to fit if parent is sizing on children and
- //this object has stretched size
- if (Parent.getBounds ().Width < 0 && Width == 0)
- Width = -1;
-
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;
@@ -783,15 +790,14 @@ namespace Crow
LastSlots.Width = Slot.Width;
break;
case LayoutingType.Height:
- //force sizing to fit if parent is sizing on children
- if (Parent.getBounds ().Height < 0 && Height == 0)
- Height = -1;
-
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;
@@ -915,8 +921,11 @@ namespace Crow
return false;
if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) {
Scroller scr = Parent as Scroller;
- if (scr == null)
- return true;
+ if (scr == null) {
+ if (Parent is GraphicObject)
+ return (Parent as GraphicObject).MouseIsIn (m);
+ else return true;
+ }
return scr.MouseIsIn (scr.savedMousePos);
}
return false;
@@ -1013,11 +1022,11 @@ namespace Crow
#region Binding
public virtual void ResolveBindings()
{
+ if (Bindings.Count == 0)
+ return;
#if DEBUG_BINDING
Debug.WriteLine ("ResolveBinding => " + this.ToString ());
#endif
- if (Bindings.Count == 0)
- return;
Dictionary<object,List<Binding>> resolved = new Dictionary<object, List<Binding>>();
foreach (Binding b in Bindings) {
if (b.Resolved)
@@ -1028,12 +1037,14 @@ namespace Crow
continue;
}
}
- if (!b.FindTarget ())
+ if (!b.FindTarget ()) {
+ Debug.WriteLine ("BINDING ERROR: target not found => " + b.ToString());
continue;
+ }
if (b.Source.Member.MemberType == MemberTypes.Event) {
//register handler for event
if (b.Target.Method == null) {
- Debug.WriteLine ("Handler Method not found: " + b.Expression);
+ Debug.WriteLine ("Handler Method not found: " + b.ToString());
continue;
}
@@ -1041,6 +1052,9 @@ namespace Crow
Delegate del = Delegate.CreateDelegate (b.Source.Event.EventHandlerType, b.Target.Instance, b.Target.Method);
addHandler.Invoke (this, new object[] { del });
b.Resolved = true;
+ #if DEBUG_BINDING
+ Debug.WriteLine ("\tHandler binded => " + b.ToString());
+ #endif
continue;
}
List<Binding> bindings = null;
@@ -1050,6 +1064,9 @@ namespace Crow
}
bindings.Add (b);
b.Resolved = true;
+ #if DEBUG_BINDING
+ Debug.WriteLine ("\tmarked as resolved => " + b.ToString());
+ #endif
}
MethodInfo stringEquals = typeof(string).GetMethod
@@ -1336,6 +1353,9 @@ namespace Crow
addHandler.Invoke(this, new object[] {del});
binding.Resolved = true;
+ #if DEBUG_BINDING
+ Debug.WriteLine ("\tCompiled Event Source => " + binding.ToString());
+ #endif
}
/// <summary>
/// Remove dynamic delegates by ids from dataSource
diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs
index c242899f..281f4ae0 100644
--- a/src/GraphicObjects/Grid.cs
+++ b/src/GraphicObjects/Grid.cs
@@ -32,13 +32,13 @@ namespace Crow
public override T AddChild<T> (T child)
{
T tmp = base.AddChild (child);
- this.RegisterForLayouting (LayoutingType.PositionChildren);
+ this.RegisterForLayouting (LayoutingType.ArrangeChildren);
return tmp;
}
public override void RemoveChild (GraphicObject child)
{
base.RemoveChild (child);
- this.RegisterForLayouting (LayoutingType.PositionChildren);
+ this.RegisterForLayouting (LayoutingType.ArrangeChildren);
}
#region Public Properties
@@ -59,7 +59,7 @@ namespace Crow
_columnCount = value;
NotifyValueChanged ("ColumnCount", ColumnCount);
- this.RegisterForLayouting (LayoutingType.PositionChildren);
+ this.RegisterForLayouting (LayoutingType.ArrangeChildren);
}
}
[XmlAttributeAttribute()][DefaultValue(1)]
@@ -73,7 +73,7 @@ namespace Crow
_rowCount = value;
NotifyValueChanged ("RowCount", RowCount);
- this.RegisterForLayouting (LayoutingType.PositionChildren);
+ this.RegisterForLayouting (LayoutingType.ArrangeChildren);
}
}
public virtual int CaseWidth {
@@ -130,7 +130,7 @@ namespace Crow
{
RegisteredLayoutings &= (~layoutType);
- if (layoutType == LayoutingType.PositionChildren) {
+ if (layoutType == LayoutingType.ArrangeChildren) {
ComputeChildrenPositions ();
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index 486e07f9..6e2417a9 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Drawing;
-using System.Diagnostics;
-using Cairo;
-using System.Xml.Serialization;
using System.ComponentModel;
+using System.Xml.Serialization;
+using Cairo;
+using OpenTK.Input;
+
namespace Crow
{
@@ -45,9 +43,9 @@ namespace Crow
public virtual T AddChild<T>(T child)
{
GraphicObject g = child as GraphicObject;
- children.Add(g);
+ Children.Add(g);
g.Parent = this as GraphicObject;
- g.RegisterForLayouting (LayoutingType.Sizing);
+ g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
g.LayoutChanged += OnChildLayoutChanges;
return (T)child;
}
@@ -55,36 +53,46 @@ namespace Crow
{
child.LayoutChanged -= OnChildLayoutChanges;
child.ClearBinding ();
- child.Parent = null;
- children.Remove(child);
- this.RegisterForLayouting (LayoutingType.Sizing);
+ //child.Parent = null;
+ Children.Remove(child);
+
+ if (child == largestChild)
+ searchLargestChild ();
+ if (child == tallestChild)
+ searchTallestChild ();
+
+ this.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
}
public virtual void ClearChildren()
{
- while(children.Count > 0){
- GraphicObject g = children[children.Count-1];
+ while(Children.Count > 0){
+ GraphicObject g = Children[Children.Count-1];
g.LayoutChanged -= OnChildLayoutChanges;
g.ClearBinding ();
g.Parent = null;
- children.RemoveAt(children.Count-1);
+ Children.RemoveAt(Children.Count-1);
}
+
+ resetChildrenMaxSize ();
+
this.RegisterForLayouting (LayoutingType.Sizing);
ChildrenCleared.Raise (this, new EventArgs ());
}
+
public void putWidgetOnTop(GraphicObject w)
{
- if (children.Contains(w))
+ if (Children.Contains(w))
{
- children.Remove(w);
- children.Add(w);
+ Children.Remove(w);
+ Children.Add(w);
}
}
public void putWidgetOnBottom(GraphicObject w)
{
- if (children.Contains(w))
+ if (Children.Contains(w))
{
- children.Remove(w);
- children.Insert(0, w);
+ Children.Remove(w);
+ Children.Insert(0, w);
}
}
@@ -92,7 +100,7 @@ namespace Crow
public override void ResolveBindings ()
{
base.ResolveBindings ();
- foreach (GraphicObject w in children)
+ foreach (GraphicObject w in Children)
w.ResolveBindings ();
}
public override GraphicObject FindByName (string nameToFind)
@@ -100,7 +108,7 @@ namespace Crow
if (Name == nameToFind)
return this;
- foreach (GraphicObject w in children) {
+ foreach (GraphicObject w in Children) {
GraphicObject r = w.FindByName (nameToFind);
if (r != null)
return r;
@@ -109,7 +117,7 @@ namespace Crow
}
public override bool Contains (GraphicObject goToFind)
{
- foreach (GraphicObject w in children) {
+ foreach (GraphicObject w in Children) {
if (w == goToFind)
return true;
if (w.Contains (goToFind))
@@ -117,9 +125,30 @@ namespace Crow
}
return false;
}
- protected override Size measureRawSize ()
+ protected override int measureRawSize (LayoutingType lt)
{
- return new Size(maxChildrenWidth + 2 * Margin, maxChildrenHeight + 2 * Margin);
+ if (Children.Count == 0)
+ return base.measureRawSize (lt);
+
+ if (lt == LayoutingType.Width) {
+ if (largestChild == null)
+ searchLargestChild ();
+ if (largestChild == null){
+ //if still null, not possible to determine a width
+ //because all children are stretched, force first one to fit
+ Children[0].Width = -1;
+ return -1;//cancel actual sizing to let child computation take place
+ }
+ return maxChildrenWidth + 2 * Margin;
+ }else{
+ if (tallestChild == null)
+ searchTallestChild ();
+ if (tallestChild == null) {
+ Children[0].Height = -1;
+ return -1;
+ }
+ return maxChildrenHeight + 2 * Margin;
+ }
}
public override void OnLayoutChanges (LayoutingType layoutType)
@@ -129,14 +158,14 @@ namespace Crow
//position smaller objects in group when group size is fit
switch (layoutType) {
case LayoutingType.Width:
- foreach (GraphicObject c in children) {
+ foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
c.RegisterForLayouting (LayoutingType.X | LayoutingType.Width);
}
break;
case LayoutingType.Height:
- foreach (GraphicObject c in children) {
+ foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
c.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height); }
@@ -147,10 +176,6 @@ namespace Crow
{
GraphicObject g = sender as GraphicObject;
switch (arg.LayoutType) {
- case LayoutingType.X:
- break;
- case LayoutingType.Y:
- break;
case LayoutingType.Width:
if (g.Slot.Width > maxChildrenWidth) {
maxChildrenWidth = g.Slot.Width;
@@ -158,15 +183,10 @@ namespace Crow
if (this.Bounds.Width < 0)
this.RegisterForLayouting (LayoutingType.Width);
} else if (g == largestChild) {
- //search for the new largest child
+
largestChild = null;
maxChildrenWidth = 0;
- for (int i = 0; i < children.Count; i++) {
- if (children [i].Slot.Width > maxChildrenWidth) {
- maxChildrenWidth = children [i].Slot.Width;
- largestChild = children [i];
- }
- }
+
if (this.Bounds.Width < 0)
this.RegisterForLayouting (LayoutingType.Width);
}
@@ -178,15 +198,10 @@ namespace Crow
if (this.Bounds.Height < 0)
this.RegisterForLayouting (LayoutingType.Height);
} else if (g == tallestChild) {
- //search for the new tallest child
+
tallestChild = null;
maxChildrenHeight = 0;
- for (int i = 0; i < children.Count; i++) {
- if (children [i].Slot.Height > maxChildrenHeight) {
- maxChildrenHeight = children [i].Slot.Height;
- tallestChild = children [i];
- }
- }
+
if (this.Bounds.Height < 0)
this.RegisterForLayouting (LayoutingType.Height);
}
@@ -194,6 +209,42 @@ namespace Crow
}
}
+ //TODO: x,y position should be taken in account for computation of width and height
+ void resetChildrenMaxSize(){
+ largestChild = null;
+ tallestChild = null;
+ maxChildrenWidth = 0;
+ maxChildrenHeight = 0;
+ }
+ void searchLargestChild(){
+ largestChild = null;
+ maxChildrenWidth = 0;
+ 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];
+ }
+ }
+ }
+ void searchTallestChild(){
+ tallestChild = null;
+ maxChildrenHeight = 0;
+ 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];
+ }
+ }
+ }
+
protected override void onDraw (Context gr)
{
base.onDraw (gr);
@@ -203,7 +254,7 @@ namespace Crow
CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
gr.Clip ();
- foreach (GraphicObject g in children) {
+ foreach (GraphicObject g in Children) {
g.Paint (ref gr);
}
gr.Restore ();
@@ -223,7 +274,7 @@ namespace Crow
CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
gr.Clip ();
- foreach (GraphicObject c in children) {
+ foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
if (Clipping.intersect(c.Slot + ClientRectangle.Position))
@@ -245,17 +296,16 @@ namespace Crow
#region Mouse handling
- public override void checkHoverWidget (OpenTK.Input.MouseMoveEventArgs e)
+ public override void checkHoverWidget (MouseMoveEventArgs e)
{
if (HostContainer.hoverWidget != this) {
HostContainer.hoverWidget = this;
onMouseEnter (this, e);
}
- foreach (GraphicObject g in children)
- {
- if (g.MouseIsIn(e.Position))
+ for (int i = Children.Count - 1; i >= 0; i--) {
+ if (Children[i].MouseIsIn(e.Position))
{
- g.checkHoverWidget (e);
+ Children[i].checkHoverWidget (e);
return;
}
}
@@ -263,6 +313,7 @@ namespace Crow
}
#endregion
+
#region IXmlSerializable
public override System.Xml.Schema.XmlSchema GetSchema()
@@ -297,7 +348,7 @@ namespace Crow
{
base.WriteXml(writer);
- foreach (GraphicObject go in children)
+ foreach (GraphicObject go in Children)
{
writer.WriteStartElement(go.GetType().Name);
(go as IXmlSerializable).WriteXml(writer);
@@ -308,7 +359,7 @@ namespace Crow
#endregion
public override void ClearBinding(){
- foreach (GraphicObject c in children)
+ foreach (GraphicObject c in Children)
c.ClearBinding ();
base.ClearBinding ();
}
diff --git a/src/GraphicObjects/GroupBox.cs b/src/GraphicObjects/GroupBox.cs
index 9206792a..e3001663 100644
--- a/src/GraphicObjects/GroupBox.cs
+++ b/src/GraphicObjects/GroupBox.cs
@@ -1,20 +1,6 @@
using System;
-
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-//using OpenTK.Graphics.OpenGL;
-
-using Cairo;
-
-using winColors = System.Drawing.Color;
-using System.Diagnostics;
using System.Xml.Serialization;
-using OpenTK.Input;
using System.ComponentModel;
-using System.Xml;
-using System.IO;
namespace Crow
{
diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs
index bbf1b4a6..51abc25d 100644
--- a/src/GraphicObjects/ILayoutable.cs
+++ b/src/GraphicObjects/ILayoutable.cs
@@ -19,6 +19,7 @@ namespace Crow
IGOLibHost HostContainer { get; }
+ bool ArrangeChildren { get; }
LayoutingType RegisteredLayoutings { get; set; }
void RegisterForLayouting(LayoutingType layoutType);
void RegisterClip(Rectangle clip);
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..ad6549a1 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(new Size(
+ measureRawSize(LayoutingType.Width), measureRawSize(LayoutingType.Height)));
rText.Width -= 2 * Margin;
rText.Height -= 2 * Margin;
diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs
index 171e54e4..c99b0889 100644
--- a/src/GraphicObjects/Popper.cs
+++ b/src/GraphicObjects/Popper.cs
@@ -1,20 +1,7 @@
using System;
-
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-//using OpenTK.Graphics.OpenGL;
-
-using Cairo;
-
-using winColors = System.Drawing.Color;
-using System.Diagnostics;
using System.Xml.Serialization;
-using OpenTK.Input;
using System.ComponentModel;
-using System.Xml;
-using System.IO;
+using OpenTK.Input;
namespace Crow
{
diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs
index 77bf655f..640e8d0b 100644
--- a/src/GraphicObjects/PrivateContainer.cs
+++ b/src/GraphicObjects/PrivateContainer.cs
@@ -91,11 +91,35 @@ 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)
+ {
+ if (child != null) {
+ //force sizing to fit if sizing on children and
+ //child has stretched size
+ switch (layoutType) {
+ case LayoutingType.Width:
+ if (Width < 0 && child.Width == 0)
+ child.Width = -1;
+ break;
+ case LayoutingType.Height:
+ if (Height < 0 && child.Height == 0)
+ child.Height = -1;
+ break;
+ }
+ }
+ return base.UpdateLayout (layoutType);
}
-
public override void OnLayoutChanges (LayoutingType layoutType)
{
base.OnLayoutChanges (layoutType);
@@ -212,8 +236,8 @@ namespace Crow
{
base.checkHoverWidget (e);
if (child != null)
- if (child.MouseIsIn (e.Position))
- child.checkHoverWidget (e);
+ if (child.MouseIsIn (e.Position))
+ child.checkHoverWidget (e);
}
#endregion
diff --git a/src/GraphicObjects/RadioButton.cs b/src/GraphicObjects/RadioButton.cs
index 297b4c2b..4fd45c58 100644
--- a/src/GraphicObjects/RadioButton.cs
+++ b/src/GraphicObjects/RadioButton.cs
@@ -1,18 +1,7 @@
using System;
-
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-//using OpenTK.Graphics.OpenGL;
-
-using Cairo;
-
-using winColors = System.Drawing.Color;
-using System.Diagnostics;
-using System.Xml.Serialization;
using OpenTK.Input;
using System.ComponentModel;
+using System.Xml.Serialization;
namespace Crow
{
@@ -31,17 +20,12 @@ namespace Crow
public event EventHandler Unchecked;
#region GraphicObject overrides
- [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true
+ [XmlAttributeAttribute()][DefaultValue(true)]
public override bool Focusable
{
get { return base.Focusable; }
set { base.Focusable = value; }
}
- [XmlAttributeAttribute()][DefaultValue(-1)]
- public override int Height {
- get { return base.Height; }
- set { base.Height = value; }
- }
#endregion
[XmlAttributeAttribute()][DefaultValue("RadioButton")]
@@ -91,8 +75,12 @@ namespace Crow
{
Group pg = Parent as Group;
if (pg != null) {
- foreach (RadioButton c in pg.Children.OfType<RadioButton>())
+ for (int i = 0; i < pg.Children.Count; i++) {
+ RadioButton c = pg.Children [i] as RadioButton;
+ if (c == null)
+ continue;
c.IsChecked = (c == this);
+ }
} else
IsChecked = !IsChecked;
diff --git a/src/GraphicObjects/ScrollBar.cs b/src/GraphicObjects/ScrollBar.cs
index dddd441e..d1ef12a3 100644
--- a/src/GraphicObjects/ScrollBar.cs
+++ b/src/GraphicObjects/ScrollBar.cs
@@ -1,18 +1,7 @@
using System;
-
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-//using OpenTK.Graphics.OpenGL;
-
-using Cairo;
-
-using winColors = System.Drawing.Color;
-using System.Diagnostics;
using System.Xml.Serialization;
-using OpenTK.Input;
using System.ComponentModel;
+using OpenTK.Input;
namespace Crow
{
diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs
index 1924aac0..459205fe 100644
--- a/src/GraphicObjects/Scroller.cs
+++ b/src/GraphicObjects/Scroller.cs
@@ -1,13 +1,30 @@
-using System;
+//
+// Scroller.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;
+using System.Xml.Serialization;
+using System.ComponentModel;
using System.Diagnostics;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Drawing;
using Cairo;
-using System.Xml.Serialization;
using OpenTK.Input;
-using System.ComponentModel;
namespace Crow
{
@@ -95,7 +112,6 @@ namespace Crow
}
#endregion
-
public Scroller()
: base(){}
@@ -192,14 +208,6 @@ namespace Crow
{
return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY);
}
-// protected override void onDraw (Context gr)
-// {
-// gr.Save ();
-// //gr.ResetClip ();
-//
-// base.onDraw (gr);
-// gr.Restore ();
-// }
protected override void onDraw (Context gr)
{
Rectangle rBack = new Rectangle (Slot.Size);
@@ -218,20 +226,5 @@ namespace Crow
child.Paint (ref gr);
gr.Restore ();
}
-
-// public override void Paint (ref Context ctx)
-// {
-// ctx.Save ();
-// //ctx.ResetClip ();
-// ctx.Translate (-ScrollX, -ScrollY);
-// base.Paint (ref ctx);
-// ctx.Restore ();
-// }
-// public override void registerClipRect ()
-// {
-// HostContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));
-// }
-
-
}
}
diff --git a/src/GraphicObjects/Splitter.cs b/src/GraphicObjects/Splitter.cs
new file mode 100644
index 00000000..f3fdb341
--- /dev/null
+++ b/src/GraphicObjects/Splitter.cs
@@ -0,0 +1,114 @@
+//
+// Spliter.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;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace Crow
+{
+ [StyleAttribute("Background", "DimGray")]
+ public class Splitter : GraphicObject
+ {
+ #region CTOR
+ public Splitter (): base(){}
+ #endregion
+
+ int thickness;
+ [XmlAttributeAttribute()][DefaultValue(1)]
+ public virtual int Thickness {
+ get { return thickness; }
+ set {
+ if (thickness == value)
+ return;
+ thickness = value;
+ NotifyValueChanged ("Thickness", thickness);
+ RegisterForLayouting (LayoutingType.Sizing);
+ registerForGraphicUpdate ();
+ }
+ }
+ #region GraphicObject override
+ public override ILayoutable Parent {
+ get { return base.Parent; }
+ set {
+ if (value != null) {
+ GenericStack gs = value as GenericStack;
+ if (gs == null)
+ throw new Exception ("Splitter may only be chil of stack");
+
+ }
+ base.Parent = value;
+ }
+ }
+ public override void onMouseEnter (object sender, OpenTK.Input.MouseMoveEventArgs e)
+ {
+ base.onMouseEnter (sender, e);
+ if ((Parent as GenericStack).Orientation == Orientation.Horizontal)
+ this.HostContainer.MouseCursor = XCursor.H;
+ else
+ this.HostContainer.MouseCursor = XCursor.V;
+ }
+ public override void onMouseLeave (object sender, OpenTK.Input.MouseMoveEventArgs e)
+ {
+ base.onMouseLeave (sender, e);
+ this.HostContainer.MouseCursor = XCursor.Default;
+ }
+ public override void onMouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e)
+ {
+ base.onMouseMove (sender, e);
+
+ if (!IsActive)
+ return;
+
+ GenericStack gs = Parent as GenericStack;
+ int ptrThis = gs.Children.IndexOf (this);
+
+ if (gs.Orientation == Orientation.Horizontal) {
+ if (ptrThis >= 0)
+ gs.Children [ptrThis - 1].Width = Math.Max(gs.Children [ptrThis - 1].Slot.Width + e.XDelta*2, 1);
+ if (ptrThis < gs.Children.Count - 1)
+ gs.Children [ptrThis + 1].Width = Math.Max(gs.Children [ptrThis + 1].Slot.Width - e.XDelta*2, 1);
+ } else {
+ if (ptrThis >= 0)
+ gs.Children [ptrThis - 1].Height = Math.Max(gs.Children [ptrThis - 1].Slot.Height + e.YDelta*2, 1);
+ if (ptrThis < gs.Children.Count - 1)
+ gs.Children [ptrThis + 1].Height = Math.Max(gs.Children [ptrThis + 1].Slot.Height - e.YDelta*2, 1);
+ }
+ }
+ public override bool UpdateLayout (LayoutingType layoutType)
+ {
+ GenericStack gs = Parent as GenericStack;
+ if (layoutType == LayoutingType.Width){
+ if (gs.Orientation == Orientation.Horizontal)
+ Width = thickness;
+ else
+ Width = 0;
+ } else if (layoutType == LayoutingType.Height){
+ if (gs.Orientation == Orientation.Vertical)
+ Height = thickness;
+ else
+ Height = 0;
+ }
+ return base.UpdateLayout (layoutType);
+ }
+ #endregion
+ }
+}
+
diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs
new file mode 100644
index 00000000..b0e733fb
--- /dev/null
+++ b/src/GraphicObjects/TabItem.cs
@@ -0,0 +1,216 @@
+//
+// TabItem.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;
+using System.Xml.Serialization;
+using System.ComponentModel;
+using System.Diagnostics;
+
+namespace Crow
+{
+ [DefaultTemplate("#Crow.Templates.TabItem.crow")]
+ public class TabItem : TemplatedContainer
+ {
+ #region Private fields
+ string caption;
+ Container _contentContainer;
+ GraphicObject _tabTitle;
+ int tabOffset;
+ #endregion
+
+ #region CTOR
+ public TabItem () : base()
+ {
+ }
+ #endregion
+
+ #region TemplatedControl overrides
+ public override GraphicObject Content {
+ get {
+ return _contentContainer == null ? null : _contentContainer.Child;
+ }
+ set {
+ _contentContainer.SetChild(value);
+ }
+ }
+ public override void ResolveBindings ()
+ {
+ base.ResolveBindings ();
+ if (_contentContainer != null)
+ _contentContainer.ResolveBindings ();
+ }
+ protected override void loadTemplate(GraphicObject template = null)
+ {
+ base.loadTemplate (template);
+
+ _contentContainer = this.child.FindByName ("Content") as Container;
+ _tabTitle = this.child.FindByName ("TabTitle");
+ }
+ internal GraphicObject TabTitle { get { return _tabTitle; }}
+ #endregion
+
+ #region GraphicObject overrides
+ [XmlAttributeAttribute()][DefaultValue(true)]
+ public override bool Focusable
+ {
+ get { return base.Focusable; }
+ set { base.Focusable = value; }
+ }
+ //prevent caching, because drawing order is different depending on selected tab
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public override bool CacheEnabled {
+ get {return false;}
+ set { }
+ }
+ #endregion
+
+ [XmlAttributeAttribute()][DefaultValue(0)]
+ public virtual int TabOffset {
+ get { return tabOffset; }
+ set {
+ if (tabOffset == value)
+ return;
+ tabOffset = value;
+ NotifyValueChanged ("TabOffset", tabOffset);
+
+ RegisterForLayouting (LayoutingType.X);
+ registerForGraphicUpdate ();
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue("TabItem")]
+ public string Caption {
+ get { return caption; }
+ set {
+ if (caption == value)
+ return;
+ caption = value;
+ NotifyValueChanged ("Caption", caption);
+ }
+ }
+ bool isSelected;
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public virtual bool IsSelected {
+ get { return isSelected; }
+ set {
+ if (isSelected == value)
+ return;
+ isSelected = value;
+ NotifyValueChanged ("IsSelected", isSelected);
+ }
+ }
+ protected override void onDraw (Cairo.Context gr)
+ {
+ int spacing = (Parent as TabView).Spacing;
+ gr.MoveTo (0, TabTitle.Slot.Bottom);
+ gr.LineTo (TabTitle.Slot.Left - spacing, TabTitle.Slot.Bottom);
+ gr.CurveTo (
+ TabTitle.Slot.Left - spacing / 2, TabTitle.Slot.Bottom,
+ TabTitle.Slot.Left - spacing / 2, 1,
+ TabTitle.Slot.Left, 1);
+ gr.LineTo (TabTitle.Slot.Right, 1);
+ gr.CurveTo (
+ TabTitle.Slot.Right + spacing / 2, 1,
+ TabTitle.Slot.Right + spacing / 2, TabTitle.Slot.Bottom,
+ TabTitle.Slot.Right + spacing, TabTitle.Slot.Bottom);
+ gr.LineTo (Slot.Width, TabTitle.Slot.Bottom);
+
+ gr.LineWidth = 1;
+ Foreground.SetAsSource (gr);
+ gr.StrokePreserve ();
+
+ gr.LineTo (Slot.Width, Slot.Height);
+ gr.LineTo (0, Slot.Height);
+ gr.ClosePath ();
+ gr.Save ();
+ gr.Clip ();
+ base.onDraw (gr);
+ gr.Restore ();
+ }
+
+ #region Mouse Handling
+ public override bool MouseIsIn (Point m)
+ {
+ if (!Visible)
+ return false;
+
+ bool mouseIsInTitle = TabTitle.ScreenCoordinates (TabTitle.Slot).ContainsOrIsEqual (m);
+ if (!IsSelected)
+ return mouseIsInTitle;
+
+ return _contentContainer.ScreenCoordinates (_contentContainer.Slot).ContainsOrIsEqual (m)
+ || mouseIsInTitle;
+ }
+ bool holdCursor = false;
+ public override void onMouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
+ {
+ base.onMouseDown (sender, e);
+ holdCursor = true;
+ }
+ public override void onMouseUp (object sender, OpenTK.Input.MouseButtonEventArgs e)
+ {
+ base.onMouseUp (sender, e);
+ holdCursor = false;
+ (Parent as TabView).UpdateLayout (LayoutingType.ArrangeChildren);
+ }
+ public override void onMouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e)
+ {
+ base.onMouseMove (sender, e);
+
+ if (!(HasFocus&&holdCursor))
+ return;
+ TabView tv = Parent as TabView;
+ TabItem previous = null, next = null;
+ int tmp = TabOffset + e.XDelta;
+ if (tmp < tv.Spacing)
+ TabOffset = tv.Spacing;
+ else if (tmp > Parent.getSlot ().Width - TabTitle.Slot.Width - tv.Spacing)
+ TabOffset = Parent.getSlot ().Width - TabTitle.Slot.Width - tv.Spacing;
+ else{
+ int idx = tv.Children.IndexOf (this);
+ if (idx > 0 && e.XDelta < 0) {
+ previous = tv.Children [idx - 1] as TabItem;
+
+ if (tmp < previous.TabOffset + previous.TabTitle.Slot.Width / 2) {
+ tv.Children.RemoveAt (idx);
+ tv.Children.Insert (idx - 1, this);
+ tv.SelectedTab = idx - 1;
+ tv.UpdateLayout (LayoutingType.ArrangeChildren);
+ }
+
+ }else if (idx < tv.Children.Count - 1 && e.XDelta > 0) {
+ next = tv.Children [idx + 1] as TabItem;
+ if (tmp > next.TabOffset - next.TabTitle.Slot.Width / 2){
+ tv.Children.RemoveAt (idx);
+ tv.Children.Insert (idx + 1, this);
+ tv.SelectedTab = idx + 1;
+ tv.UpdateLayout (LayoutingType.ArrangeChildren);
+ }
+ }
+ TabOffset = tmp;
+ }
+ }
+ public void butCloseTabClick (object sender, OpenTK.Input.MouseButtonEventArgs e){
+ (Parent as TabView).RemoveChild(this);
+ }
+ #endregion
+
+ }
+}
+
diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs
new file mode 100644
index 00000000..a480ae09
--- /dev/null
+++ b/src/GraphicObjects/TabView.cs
@@ -0,0 +1,216 @@
+//
+// TabView.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;
+using System.Xml.Serialization;
+using System.ComponentModel;
+using Cairo;
+using System.Diagnostics;
+using OpenTK.Input;
+
+namespace Crow
+{
+ public class TabView : Group
+ {
+ #region Private fields
+ int _spacing;
+ Orientation _orientation;
+ int selectedTab = 0;
+ #endregion
+
+ public TabView () : base()
+ {
+ }
+
+ [XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
+ public virtual Orientation Orientation
+ {
+ get { return _orientation; }
+ set {
+ if (_orientation == value)
+ return;
+ _orientation = value;
+ NotifyValueChanged ("Orientation", _orientation);
+ if (_orientation == Orientation.Horizontal)
+ NotifyValueChanged ("TabOrientation", Orientation.Vertical);
+ else
+ NotifyValueChanged ("TabOrientation", Orientation.Horizontal);
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue(2)]
+ public int Spacing
+ {
+ get { return _spacing; }
+ set {
+ if (_spacing == value)
+ return;
+ _spacing = value;
+ NotifyValueChanged ("Spacing", Spacing);
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue(0)]
+ public virtual int SelectedTab {
+ get { return selectedTab; }
+ set {
+ if (selectedTab < Children.Count && SelectedTab >= 0)
+ (Children [selectedTab] as TabItem).IsSelected = false;
+
+ selectedTab = value;
+
+ if (selectedTab < Children.Count && SelectedTab >= 0)
+ (Children [selectedTab] as TabItem).IsSelected = true;
+
+ NotifyValueChanged ("SelectedTab", selectedTab);
+ registerForGraphicUpdate ();
+ }
+ }
+ int tabThickness;
+ [XmlAttributeAttribute()][DefaultValue(22)]
+ public virtual int TabThickness {
+ get { return tabThickness; }
+ set {
+ if (tabThickness == value)
+ return;
+ tabThickness = value;
+ NotifyValueChanged ("TabThickness", tabThickness);
+ }
+ }
+
+ //prevent caching, because drawing order is different depending on selected tab
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public override bool CacheEnabled {
+ get {return false;}
+ set { }
+ }
+
+ public override T AddChild<T> (T child)
+ {
+ TabItem ti = child as TabItem;
+ if (ti == null)
+ throw new Exception ("TabView control accept only TabItem as child.");
+
+ ti.MouseDown += Ti_MouseDown;
+
+ if (Children.Count == 0) {
+ ti.IsSelected = true;
+ SelectedTab = 0;
+ }
+
+ return base.AddChild (child);
+ }
+ public override void RemoveChild (GraphicObject child)
+ {
+ int idx = Children.IndexOf (child);
+ base.RemoveChild (child);
+ if (selectedTab > Children.Count - 1)
+ SelectedTab--;
+ else
+ SelectedTab = selectedTab;
+ }
+ public override bool ArrangeChildren { get { return true; } }
+ public override bool UpdateLayout (LayoutingType layoutType)
+ {
+ RegisteredLayoutings &= (~layoutType);
+
+ if (layoutType == LayoutingType.ArrangeChildren) {
+ int curOffset = Spacing;
+ for (int i = 0; i < Children.Count; i++) {
+ if (!Children [i].Visible)
+ continue;
+ TabItem ti = Children [i] as TabItem;
+ ti.TabOffset = curOffset;
+ if (Orientation == Orientation.Horizontal) {
+ if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ return false;
+ curOffset += ti.TabTitle.Slot.Width + Spacing;
+ } else {
+ if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ return false;
+ curOffset += ti.TabTitle.Slot.Height + Spacing;
+ }
+ }
+
+ //if no layouting remains in queue for item, registre for redraw
+ if (RegisteredLayoutings == LayoutingType.None && bmp==null)
+ this.RegisterForRedraw ();
+
+ return true;
+ }
+
+ return base.UpdateLayout(layoutType);
+ }
+ protected override void onDraw (Context gr)
+ {
+ Rectangle rBack = new Rectangle (Slot.Size);
+
+ Background.SetAsSource (gr, rBack);
+ CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
+ gr.Fill ();
+
+ gr.Save ();
+ //clip to client zone
+ CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+ gr.Clip ();
+
+ for (int i = 0; i < Children.Count; i++) {
+ if (i == SelectedTab)
+ continue;
+ Children [i].Paint (ref gr);
+ }
+
+ if (SelectedTab < Children.Count && SelectedTab >= 0)
+ Children [SelectedTab].Paint (ref gr);
+
+ gr.Restore ();
+ }
+
+ #region Mouse handling
+ public override void checkHoverWidget (MouseMoveEventArgs e)
+ {
+ if (HostContainer.hoverWidget != this) {
+ HostContainer.hoverWidget = this;
+ onMouseEnter (this, e);
+ }
+
+ if (SelectedTab > Children.Count - 1)
+ return;
+
+ if (((Children[SelectedTab] as TabItem).Content.Parent as GraphicObject).MouseIsIn(e.Position))
+ {
+ Children[SelectedTab].checkHoverWidget (e);
+ return;
+ }
+ for (int i = Children.Count - 1; i >= 0; i--) {
+ TabItem ti = Children [i] as TabItem;
+ if (ti.TabTitle.MouseIsIn(e.Position))
+ {
+ Children[i].checkHoverWidget (e);
+ return;
+ }
+ }
+ }
+ #endregion
+ void Ti_MouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
+ {
+ SelectedTab = Children.IndexOf (sender as GraphicObject);
+ }
+ }
+}
+
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs
index 50199f7a..75176c34 100644
--- a/src/GraphicObjects/TemplatedControl.cs
+++ b/src/GraphicObjects/TemplatedControl.cs
@@ -38,6 +38,16 @@ namespace Crow
}
}
[AttributeUsage(AttributeTargets.Class)]
+ public class StyleAttribute : Attribute
+ {
+ public string PropertyName = "";
+ public object DefaultValue = null;
+ public StyleAttribute(string _property, object _defValue){
+ PropertyName = _property;
+ DefaultValue = _defValue;
+ }
+ }
+ [AttributeUsage(AttributeTargets.Class)]
public class DefaultTemplate : TemplateAttribute
{
public DefaultTemplate(string path) : base(path){}
@@ -61,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..bb308eb6 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(new Size(
+ measureRawSize(LayoutingType.Width), measureRawSize(LayoutingType.Height)));
rText.Width -= 2 * Margin;
rText.Height -= 2 * Margin;
diff --git a/src/GraphicObjects/TreeView.cs b/src/GraphicObjects/TreeView.cs
new file mode 100644
index 00000000..64d4afcb
--- /dev/null
+++ b/src/GraphicObjects/TreeView.cs
@@ -0,0 +1,35 @@
+//
+// TreeView.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
+{
+ //treeview expect expandable child (or not)
+ //if their are expandable, some functions and events are added
+ [DefaultTemplate("#Crow.Templates.TreeView.crow")]
+ public class TreeView : ListBox
+ {
+ public TreeView () : base()
+ {
+ }
+ }
+}
+
diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs
index 03a39c5c..ef56d6c6 100644
--- a/src/LayoutingQueueItem.cs
+++ b/src/LayoutingQueueItem.cs
@@ -32,8 +32,7 @@ namespace Crow
Width = 0x04,
Height = 0x08,
Sizing = 0x0C,
- PositionChildren = 0x10,
- ChildAddition = 0x20,
+ ArrangeChildren = 0x10,
All = 0xFF
}
@@ -57,18 +56,20 @@ namespace Crow
Debug.WriteLine ("ERROR: processLayouting, no parent for: " + this.ToString ());
return;
}
+ #if DEBUG_LAYOUTING
+ Debug.WriteLine ("Layouting => " + this.ToString ());
+ #endif
if (!GraphicObject.UpdateLayout (LayoutType)) {
#if DEBUG_LAYOUTING
- Debug.WriteLine ("Requeuing => " + this.ToString ());
+ Debug.WriteLine ("\tRequeuing => " + this.ToString ());
#endif
GraphicObject.LayoutingTries ++;
- if (GraphicObject.LayoutingTries < Interface.MaxLayoutingTries)
+ if (GraphicObject.LayoutingTries < Interface.MaxLayoutingTries) {
+ GraphicObject.RegisteredLayoutings |= LayoutType;
Interface.LayoutingQueue.Enqueue (this);
+ }
} else {
GraphicObject.LayoutingTries = 0;
- #if DEBUG_LAYOUTING
- Debug.WriteLine ("Layouting => " + this.ToString ());
- #endif
}
}
diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs
index 39b48182..17d9581f 100644
--- a/src/OpenTKGameWindow.cs
+++ b/src/OpenTKGameWindow.cs
@@ -1,8 +1,26 @@
-// Released to the public domain. Use, modify and relicense at will.
+//
+// OpenTKGameWindow.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;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading;
@@ -12,8 +30,6 @@ using OpenTK;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
-
-
namespace Crow
{
public class OpenTKGameWindow : GameWindow, ILayoutable, IGOLibHost
@@ -144,13 +160,23 @@ namespace Crow
{
int i = 0;
while (GraphicObjects.Count>0) {
+ //TODO:parent is not reset to null because object will be added
+ //to ObjectToRedraw list, and without parent, it fails
GraphicObject g = GraphicObjects [i];
g.Visible = false;
g.ClearBinding ();
GraphicObjects.RemoveAt (0);
}
}
-
+ public GraphicObject FindByName (string nameToFind)
+ {
+ foreach (GraphicObject w in GraphicObjects) {
+ GraphicObject r = w.FindByName (nameToFind);
+ if (r != null)
+ return r;
+ }
+ return null;
+ }
#region Events
//those events are raised only if mouse isn't in a graphic object
public event EventHandler<MouseWheelEventArgs> MouseWheelChanged;
@@ -217,10 +243,18 @@ namespace Crow
shader.Enable ();
- GL.TexSubImage2D (TextureTarget.Texture2D, 0,
- 0, 0, ClientRectangle.Width, ClientRectangle.Height,
- OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp);
-
+ if (isDirty) {
+ byte[] tmp = new byte[4 * DirtyRect.Width * DirtyRect.Height];
+ for (int y = 0; y < DirtyRect.Height; y++) {
+ Array.Copy(bmp,
+ ((DirtyRect.Top + y) * ClientRectangle.Width * 4) + DirtyRect.Left * 4,
+ tmp, y * DirtyRect.Width * 4, DirtyRect.Width *4);
+ }
+ GL.TexSubImage2D (TextureTarget.Texture2D, 0,
+ DirtyRect.Left, DirtyRect.Top, DirtyRect.Width, DirtyRect.Height,
+ OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, tmp);
+ isDirty = false;
+ }
uiQuad.Render (PrimitiveType.TriangleStrip);
GL.BindTexture(TextureTarget.Texture2D, 0);
@@ -237,6 +271,9 @@ namespace Crow
public Stopwatch drawingTime = new Stopwatch ();
#endif
+ bool isDirty = false;
+ Rectangle DirtyRect;
+
#region update
void update ()
{
@@ -302,7 +339,6 @@ namespace Crow
continue;
if (!clipping.intersect (p.Slot))
continue;
-
ctx.Save ();
p.Paint (ref ctx);
@@ -314,6 +350,17 @@ namespace Crow
clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
#endif
+ if (isDirty)
+ DirtyRect += clipping.Bounds;
+ else
+ DirtyRect = clipping.Bounds;
+ isDirty = true;
+
+ DirtyRect.Left = Math.Max (0, DirtyRect.Left);
+ DirtyRect.Top = Math.Max (0, DirtyRect.Top);
+ DirtyRect.Width = Math.Min (ClientRectangle.Width - DirtyRect.Left, DirtyRect.Width);
+ DirtyRect.Height = Math.Min (ClientRectangle.Height - DirtyRect.Top, DirtyRect.Height);
+
clipping.Reset ();
}
@@ -404,10 +451,8 @@ namespace Crow
{
base.OnResize (e);
createContext ();
- foreach (GraphicObject g in GraphicObjects) {
+ foreach (GraphicObject g in GraphicObjects)
g.RegisterForLayouting (LayoutingType.All);
- //g.registerForGraphicUpdate();
- }
}
#endregion
@@ -551,6 +596,7 @@ namespace Crow
public void RegisterClip(Rectangle r){
clipping.AddRectangle (r);
}
+ public bool ArrangeChildren { get { return false; }}
public int LayoutingTries {
get { throw new NotImplementedException (); }
set { throw new NotImplementedException (); }
@@ -583,4 +629,4 @@ namespace Crow
public Rectangle getBounds () => ClientRectangle;
#endregion
}
-} \ No newline at end of file
+}
diff --git a/src/Rectangles.cs b/src/Rectangles.cs
index c507b2ba..5168f3db 100644
--- a/src/Rectangles.cs
+++ b/src/Rectangles.cs
@@ -171,11 +171,15 @@ namespace Crow
Rectangle _bounds;
bool boundsUpToDate = true;
public Rectangle Bounds {
- get {
+ get {
if (!boundsUpToDate) {
- _bounds = Rectangle.Empty;
- foreach (Rectangle rInList in list)
- _bounds += rInList;
+ if (list.Count > 0) {
+ _bounds = list [0];
+ for (int i = 1; i < list.Count; i++) {
+ _bounds += list [i];
+ }
+ } else
+ _bounds = Rectangle.Empty;
boundsUpToDate = true;
}
return _bounds;