diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-01-30 09:42:37 +0100 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-01-30 09:42:37 +0100 |
| commit | 9fa17cdc9487e3ba92ef467c0c6d5d9941530de1 (patch) | |
| tree | 0ac2e35c537e132bfa16adc486e7481e166a150d | |
| parent | 0bf825fce6f1946034dbea6b1f7eb8d0dacdab8a (diff) | |
NUnit try, renaming, debugging and uniformizating
50 files changed, 811 insertions, 167 deletions
diff --git a/Crow.csproj b/Crow.csproj index 10a3514c..b65f3170 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -110,13 +110,11 @@ <Compile Include="src\SvgPicture.cs" />
<Compile Include="src\BmpPicture.cs" />
<Compile Include="src\GraphicObjects\TemplatedControl.cs" />
- <Compile Include="src\GraphicObjects\Checkbox.cs" />
<Compile Include="src\GraphicObjects\RadioButton.cs" />
<Compile Include="src\GraphicObjects\Expandable.cs" />
<Compile Include="src\GraphicObjects\PrivateContainer.cs" />
<Compile Include="src\GraphicObjects\TemplatedContainer.cs" />
<Compile Include="src\GraphicObjects\Popper.cs" />
- <Compile Include="src\GraphicObjects\Scrollbar.cs" />
<Compile Include="src\TextChangeEventArgs.cs" />
<Compile Include="src\LayoutChangeEventArgs.cs" />
<Compile Include="src\ReflexionExtensions.cs" />
@@ -124,11 +122,13 @@ <Compile Include="src\GraphicObjects\Grid.cs" />
<Compile Include="src\GraphicObjects\TextRun.cs" />
<Compile Include="src\GraphicObjects\MessageBox.cs" />
- <Compile Include="src\GraphicObjects\Groupbox.cs" />
- <Compile Include="src\GraphicObjects\Combobox.cs" />
<Compile Include="src\SelectionChangeEventArgs.cs" />
<Compile Include="src\ValueChangeEventArgs.cs" />
<Compile Include="src\GraphicObjects\FileDialog.cs" />
+ <Compile Include="src\GraphicObjects\CheckBox.cs" />
+ <Compile Include="src\GraphicObjects\ComboBox.cs" />
+ <Compile Include="src\GraphicObjects\GroupBox.cs" />
+ <Compile Include="src\GraphicObjects\ScrollBar.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
@@ -172,10 +172,8 @@ <EmbeddedResource Include="Images\Icons\buttest2.svg" />
<EmbeddedResource Include="Images\Icons\buttest4.svg" />
<EmbeddedResource Include="Images\Icons\checkbox.svg" />
- <EmbeddedResource Include="Templates\Checkbox.goml" />
<EmbeddedResource Include="Images\Icons\radiobutton.svg" />
<EmbeddedResource Include="Templates\RadioButton.goml" />
- <EmbeddedResource Include="Templates\Listbox.goml" />
<EmbeddedResource Include="Templates\Slider.goml" />
<EmbeddedResource Include="Templates\Spinner.goml" />
<EmbeddedResource Include="Templates\Spinner %28copier%29.goml" />
@@ -187,7 +185,6 @@ <EmbeddedResource Include="Templates\Window.goml" />
<EmbeddedResource Include="Images\Icons\tetra.png" />
<EmbeddedResource Include="Images\Icons\exit.svg" />
- <EmbeddedResource Include="Templates\Scrollbar.goml" />
<EmbeddedResource Include="Templates\AnalogMeter0.goml" />
<EmbeddedResource Include="Images\meter.svg" />
<EmbeddedResource Include="Images\Icons\member.svg" />
@@ -195,9 +192,6 @@ <EmbeddedResource Include="Images\button.svg" />
<EmbeddedResource Include="Templates\MessageBox.goml" />
<EmbeddedResource Include="Images\Icons\iconInfo.svg" />
- <EmbeddedResource Include="Templates\Groupbox.goml" />
- <EmbeddedResource Include="Templates\Combobox.goml" />
- <EmbeddedResource Include="Templates\ComboboxOverlay.goml" />
<EmbeddedResource Include="Templates\FileDialog.goml" />
<EmbeddedResource Include="Templates\tmpDirItem.goml" />
<EmbeddedResource Include="Templates\ScrollingListBox.goml" />
@@ -213,6 +207,12 @@ <EmbeddedResource Include="Images\Icons\Cursors\hand" />
<EmbeddedResource Include="Images\Icons\Cursors\help" />
<EmbeddedResource Include="Images\Icons\Cursors\move" />
+ <EmbeddedResource Include="Templates\CheckBox.goml" />
+ <EmbeddedResource Include="Templates\ComboBox.goml" />
+ <EmbeddedResource Include="Templates\ComboBoxOverlay.goml" />
+ <EmbeddedResource Include="Templates\GroupBox.goml" />
+ <EmbeddedResource Include="Templates\ListBox.goml" />
+ <EmbeddedResource Include="Templates\ScrollBar.goml" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" />
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GOLib", "MonoDe EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Diagram", "..\MonoDevelop.Diagram\MonoDevelop.Diagram.csproj", "{232716B4-D19D-4FD7-B310-94A98FD926F0}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Linux_x86 = Debug|Linux_x86
@@ -21,6 +23,10 @@ Global {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.Build.0 = Debug|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.ActiveCfg = Release|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.Build.0 = Release|Any CPU
+ {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
+ {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.Build.0 = Debug|Any CPU
+ {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Release|Linux_x86.ActiveCfg = Release|Any CPU
+ {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Release|Linux_x86.Build.0 = Release|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.Build.0 = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Any CPU
diff --git a/Crow.userprefs b/Crow.userprefs index 21fdf1d4..b554ec85 100644 --- a/Crow.userprefs +++ b/Crow.userprefs @@ -1,23 +1,15 @@ <Properties GitUserInfo="UsingGIT" StartupItem="Tests/Tests.csproj"> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|Linux_x86" /> - <MonoDevelop.Ide.Workbench ActiveDocument="Images/Icons/button.svg"> + <MonoDevelop.Ide.Workbench ActiveDocument="src/GraphicObjects/TemplatedControl.cs"> <Files> - <File FileName="src/GraphicObjects/ListBox.cs" Line="36" Column="43" /> - <File FileName="Tests/Interfaces/test_Listbox.goml" Line="25" Column="60" /> - <File FileName="Tests/GOLIBTest_Listbox.cs" Line="98" Column="1" /> - <File FileName="src/GraphicObjects/TemplatedControl.cs" Line="151" Column="39" /> - <File FileName="src/GraphicObjects/Scrollbar.cs" Line="49" Column="1" /> - <File FileName="src/GraphicObjects/GenericStack.cs" Line="96" Column="8" /> - <File FileName="src/GraphicObjects/GraphicObject.cs" Line="22" Column="15" /> - <File FileName="src/OpenTKGameWindow.cs" Line="27" Column="71" /> - <File FileName="src/OpenGL/Shader.cs" Line="1" Column="1" /> - <File FileName="src/OpenGL/TexturedShader.cs" Line="1" Column="1" /> - <File FileName="src/OpenGL/QuadVAO.cs" Line="1" Column="1" /> - <File FileName="src/Interface.cs" Line="119" Column="1" /> - <File FileName="bin/Debug/Interfaces/test4.goml.cs" Line="97" Column="35" /> - <File FileName="src/GraphicObjects/Group.cs" Line="308" Column="42" /> - <File FileName="Tests/GOLIBTest_TypeViewer.cs" Line="37" Column="4" /> - <File FileName="Images/Icons/button.svg" Line="1" Column="1" /> + <File FileName="src/GraphicObjects/GraphicObject.cs" Line="848" Column="39" /> + <File FileName="Tests/GOLIBTests.cs" Line="41" Column="1" /> + <File FileName="Tests/Interfaces/testWindow3.goml" Line="10" Column="6" /> + <File FileName="src/GraphicObjects/TemplatedControl.cs" Line="114" Column="1" /> + <File FileName="src/GraphicObjects/Window.cs" Line="214" Column="1" /> + <File FileName="src/GraphicObjects/TemplatedContainer.cs" Line="80" Column="19" /> + <File FileName="src/GraphicObjects/Container.cs" Line="31" Column="1" /> + <File FileName="src/GraphicObjects/PrivateContainer.cs" Line="67" Column="1" /> </Files> </MonoDevelop.Ide.Workbench> <MonoDevelop.Ide.DebuggingService.Breakpoints> diff --git a/Images/Icons/updown.svg b/Images/Icons/updown.svg index a4d5fcb4..ce045245 100644 --- a/Images/Icons/updown.svg +++ b/Images/Icons/updown.svg @@ -14,7 +14,7 @@ version="1.1" inkscape:version="0.91 r13725" sodipodi:docname="updown.svg"> - <metadata +<!-- <metadata id="metadata13"> <rdf:RDF> <cc:Work @@ -45,37 +45,12 @@ inkscape:window-x="0" inkscape:window-y="16" inkscape:window-maximized="0" - inkscape:current-layer="svg2" /> - <defs - id="defs4"> - <filter - height="1.4299999" - y="-0.215" - width="1.3096" - x="-0.1548" - id="filter4391" - style="color-interpolation-filters:sRGB"> - <feGaussianBlur - id="feGaussianBlur4393" - stdDeviation="3.225" /> - </filter> - <filter - height="1.4299999" - y="-0.215" - width="1.3096" - x="-0.1548" - id="filter4391-5" - style="color-interpolation-filters:sRGB"> - <feGaussianBlur - id="feGaussianBlur4393-0" - stdDeviation="3.225" /> - </filter> - </defs> + inkscape:current-layer="svg2" />--> <g id="up" transform="matrix(0.88780545,0,0,0.79362094,4.0529638,4.3893292)"> <path - style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4391)" + style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 32,9 7,44 57,44 Z" id="path4144" inkscape:connector-curvature="0" @@ -85,7 +60,7 @@ id="down" transform="matrix(0.88780545,0,0,0.79362094,4.0529638,4.3893292)"> <path - style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4391-5)" + style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 7,9 57,9 32,44 Z" id="path4144-0" inkscape:connector-curvature="0" diff --git a/Templates/Checkbox.goml b/Templates/CheckBox.goml index 80ec112d..80ec112d 100755 --- a/Templates/Checkbox.goml +++ b/Templates/CheckBox.goml diff --git a/Templates/Combobox.goml b/Templates/ComboBox.goml index 9abd6361..f60b1a1a 100755 --- a/Templates/Combobox.goml +++ b/Templates/ComboBox.goml @@ -1,10 +1,10 @@ <?xml version="1.0"?>
<Border CornerRadius="0" BorderColor="LightGray" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}">
<HorizontalStack Margin="1" Spacing="1" Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}">
- <Label Margin="1" Foreground="Black" Background="White" Text="{../../../Text}"
+ <Label Margin="1" Foreground="Black" Background="White" Text="{../../../Caption}"
Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/>
<Button Width="14" Height="14" >
- <Image Margin="0" Path="#go.Images.Icons.updown.svg" SvgSub="down"/>
+ <Image Margin="0" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
</Button>
</HorizontalStack>
</Border>
\ No newline at end of file diff --git a/Templates/ComboboxOverlay.goml b/Templates/ComboBoxOverlay.goml index cab49531..cab49531 100755 --- a/Templates/ComboboxOverlay.goml +++ b/Templates/ComboBoxOverlay.goml diff --git a/Templates/Expandable.goml b/Templates/Expandable.goml index 4e9a8540..740200ca 100755 --- a/Templates/Expandable.goml +++ b/Templates/Expandable.goml @@ -4,7 +4,7 @@ <VerticalStack Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}">
<HorizontalStack Spacing="1" Height="-1" Width="{../../../TemplatedWidth}">
<Image Margin="2" Width="12" Height="12" Path="{../../../../Image}" SvgSub="{../../../../SvgSub}"/>
- <Label Text="{../../../../Title}" Width="{../../../../TemplatedWidth}"/>
+ <Label Text="{../../../../Caption}" Width="{../../../../TemplatedWidth}"/>
</HorizontalStack>
<Container Name="Content" Visible="false" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/>
</VerticalStack>
diff --git a/Templates/Groupbox.goml b/Templates/GroupBox.goml index 789cd60f..4f6035aa 100755 --- a/Templates/Groupbox.goml +++ b/Templates/GroupBox.goml @@ -5,6 +5,6 @@ <Container Name="Content" Margin="10" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/> </Border> - <Label Text="{../../Title}" VerticalAlignment="Top" Left="15" + <Label Text="{../../Caption}" VerticalAlignment="Top" Left="15" Background="Clear" Margin="1"/> </Group>
\ No newline at end of file diff --git a/Templates/Listbox.goml b/Templates/ListBox.goml index 28241e27..28241e27 100755 --- a/Templates/Listbox.goml +++ b/Templates/ListBox.goml diff --git a/Templates/MessageBox.goml b/Templates/MessageBox.goml index e2eccd71..d6e474c0 100644 --- a/Templates/MessageBox.goml +++ b/Templates/MessageBox.goml @@ -9,19 +9,19 @@ <Label Foreground="White" Width="{../../../../../TemplatedWidth}" Margin="1" TextAlignment="Center" Text="{../../../../../Title}" /> <Border CornerRadius="6" BorderWidth="1" BorderColor="Transparent" Height="12" Width="12" MouseEnter="{BorderColor=White}" MouseLeave="{BorderColor=Transparent}"> - <Image Focusable="true" Name="Image" Margin="0" Width="0" Height="0" Path="#go.Images.Icons.exit2.svg" + <Image Focusable="true" Name="Image" Margin="0" Width="0" Height="0" Path="#Crow.Images.Icons.exit2.svg" MouseClick="../../../../../../butQuitPress"/> </Border> <GraphicObject Width="5" Height="5"/> </HorizontalStack> </Border> - <HorizontalStack Spacing="10" Margin="10" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"> - <Image Name="Image" Width="32" Height="32" - Path="#go.Images.Icons.iconInfo.svg" /> + <HorizontalStack Spacing="3" Margin="3" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"> + <Image Name="Image" Width="24" Height="24" + Path="#Crow.Images.Icons.iconInfo.svg" /> <TextRun Font="serif, 12" Height="{../../../../TemplatedHeight}" Width="{../../../../TemplatedWidth}" Text="{../../../../Message}" Multiline="true" WordWrap="true"/> </HorizontalStack> - <HorizontalStack Height="-1" Width="{../../../TemplatedWidth}" Margin="5"> + <HorizontalStack Height="-1" Width="{../../../TemplatedWidth}" Margin="3"> <GraphicObject Height="5"/> <Button Text="Ok"/> <Button Text="Cancel"/> diff --git a/Templates/Popper.goml b/Templates/Popper.goml index 472fe183..f819e351 100755 --- a/Templates/Popper.goml +++ b/Templates/Popper.goml @@ -2,6 +2,6 @@ <Border BorderWidth="1" BorderColor="LightGray" Height="-1" Width="{../TemplatedWidth}" MouseClick="../onMouseClick">
<HorizontalStack Spacing="1" Height="-1" Width="{../../TemplatedWidth}">
<Image Margin="2" Width="12" Height="12" Path="{../../../Image}" SvgSub="{../../../SvgSub}"/>
- <Label Text="{../../../Title}" Width="{../../../TemplatedWidth}"/>
+ <Label Text="{../../../Caption}" Width="{../../../TemplatedWidth}"/>
</HorizontalStack>
</Border>
\ No newline at end of file diff --git a/Templates/Scrollbar.goml b/Templates/ScrollBar.goml index b14c90da..b14c90da 100755 --- a/Templates/Scrollbar.goml +++ b/Templates/ScrollBar.goml diff --git a/Templates/Spinner.goml b/Templates/Spinner.goml index cbdde9e4..059456f7 100755 --- a/Templates/Spinner.goml +++ b/Templates/Spinner.goml @@ -8,7 +8,7 @@ <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="up"/> </Button> <Button Width="12" Height="8" MouseClick="../../../../onDown"> - <Image Margin="1" Path="#Crow .Images.Icons.updown.svg" SvgSub="down"/> + <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/> </Button> </VerticalStack> </HorizontalStack> diff --git a/Tests/GOLIBTests.cs b/Tests/GOLIBTests.cs index 1e6c79be..23de6cf0 100644 --- a/Tests/GOLIBTests.cs +++ b/Tests/GOLIBTests.cs @@ -36,6 +36,10 @@ namespace test int frameCpt = 0;
int idx = 0;
string[] testFiles = {
+ "test4.goml",
+ "testScrollbar.goml",
+ "2.crow",
+ "test1.goml",
"testWindow2.goml",
// "testCombobox.goml",
"testWindow3.goml",
@@ -48,7 +52,6 @@ namespace test "testLabel.goml",
"testAll.goml",
// "testSpinner.goml",
- "test4.goml",
"testRadioButton2.goml",
"testContainer.goml",
"testBorder.goml",
@@ -57,7 +60,6 @@ namespace test "testMsgBox.goml",
"testGrid.goml",
"testMeter.goml",
- "testScrollbar.goml",
"test_Listbox.goml",
};
diff --git a/Tests/Interfaces/1.crow b/Tests/Interfaces/1.crow new file mode 100755 index 00000000..72a0e062 --- /dev/null +++ b/Tests/Interfaces/1.crow @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<ComboBox/>
\ No newline at end of file diff --git a/Tests/Interfaces/2.crow b/Tests/Interfaces/2.crow new file mode 100755 index 00000000..2e8c766b --- /dev/null +++ b/Tests/Interfaces/2.crow @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<VerticalStack Fit="true"> + <HorizontalStack Margin="5" Fit="true" MouseEnter="{Background=White}" MouseLeave="{Background=Transparent}"> + <Label Text="centered" Width="80" Height="30" Background="DarkBlue" TextAlignment="Center"/> + <Label Text="top left" Width="80" Height="30" Background="DarkBlue" TextAlignment="TopLeft"/> + <Label Text="top right" Width="80" Height="30" Background="DarkBlue" TextAlignment="TopRight"/> + <Label Text="right center" Width="80" Height="30" Background="DarkBlue" TextAlignment="RightCenter"/> + <Label Text="bottom left" Width="80" Height="30" Background="DarkBlue" TextAlignment="BottomLeft"/> + <Label Text="bottom center" Width="80" Height="30" Background="DarkBlue" TextAlignment="BottomCenter"/> + <Label Text="bottom right" Width="80" Height="30" Background="DarkBlue" TextAlignment="BottomRight"/> + </HorizontalStack> + <HorizontalStack Fit="true"> + <Label Text="label1" Foreground="LightBlue" Margin="5" Background="DarkRed"/> + <TextRun Text="textrun1" Width="0"/> + <Button Text="Click Me"/> + <CheckBox/> + <GroupBox Caption="choice"> + <VerticalStack> + <RadioButton Caption="Choice 1" IsChecked="true"/> + <RadioButton Caption="Choice 2"/> + <RadioButton Caption="Choice 3"/> + </VerticalStack> + </GroupBox> + <Expandable Caption="expand me"> + <Label Text="this is a test"/> + </Expandable> + <Popper Caption="pop me"> + <Label Background="Red"/> + </Popper> +<!-- <ComboBox/>--> + </HorizontalStack> + <MessageBox></MessageBox> + <Window><Label/></Window> +</VerticalStack>
\ No newline at end of file diff --git a/Tests/Interfaces/test1.goml b/Tests/Interfaces/test1.goml index 2177065e..5aa1d7f3 100755 --- a/Tests/Interfaces/test1.goml +++ b/Tests/Interfaces/test1.goml @@ -1,7 +1,6 @@ <?xml version="1.0"?>
<Container Name="TopContainer" Width="400" Height="350"
Margin="20" Focusable="True" Background="Yellow">
-
<Container Name="MiddleContainer" Width="0" Height="0"
Margin="20" Focusable="True" Background="Green">
<Image VerticalAlignment="Bottom"
diff --git a/Tests/Interfaces/test4.goml b/Tests/Interfaces/test4.goml index bdb6656c..0e7bfda2 100755 --- a/Tests/Interfaces/test4.goml +++ b/Tests/Interfaces/test4.goml @@ -28,8 +28,8 @@ </HorizontalStack>
</VerticalStack>
<VerticalStack Fit="true">
- <Checkbox Name="chk1"/>
- <Checkbox Name="chk2" IsChecked="true"/>
+ <CheckBox Name="chk1"/>
+ <CheckBox Name="chk2" IsChecked="true"/>
</VerticalStack>
<VerticalStack Fit="true">
@@ -38,39 +38,45 @@ <Button MouseClick="onButClick"/>
</VerticalStack>
</HorizontalStack>
- <TextBoxWidget Name="textbox1" TextAlignment="LeftCenter" Font="droid,14"
+ <TextBox Name="textbox1" TextAlignment="LeftCenter" Font="droid,14"
Width="200" Height="-1" Margin="2" Background="White"
Forground="Black"
BorderColor="DimGray" BorderWidth="1"
Text="editable text"/>
+ <Popper Width="100">
+ <Border Fit="True" Background="ArmyGreen">
+ <Image Margin="10" Fit="true" Path="#Crow.Images.Icons.tetra.png"/>
+ </Border>
+ </Popper>
+
</VerticalStack>
<VerticalStack Fit="true" Margin="0" WidgetSpacing="1">
<Button Margin="1" Width="150" Height="100">
<Image Path="#Tests.image.tetra.png"/>
</Button>
<Popper Width="100">
- <Border Margin="10" Fit="True" Background="ArmyGreen">
- <Image Fit="true" Path="#Crow.Images.Icons.tetra.png"/>
+ <Border Fit="True" Background="ArmyGreen">
+ <Image Margin="10" Fit="true" Path="#Crow.Images.Icons.tetra.png"/>
</Border>
</Popper>
<Expandable Name="expander" Width="150" Height="-1">
<VerticalStack Name="vsExpanded" Width="100">
- <Checkbox Name="chk1"/>
- <Checkbox Name="chk2" IsChecked="true"/>
- <Checkbox Name="chk3"/>
- <Checkbox Name="chk4"/>
+ <CheckBox Name="chk1"/>
+ <CheckBox Name="chk2" IsChecked="true"/>
+ <CheckBox Name="chk3"/>
+ <CheckBox Name="chk4"/>
</VerticalStack>
</Expandable>
<Expandable Name="expander2" Width="150" Height="-1">
<VerticalStack Name="vsExpanded" Width="100">
- <Checkbox Name="chk1"/>
- <Checkbox Name="chk2" IsChecked="true"/>
+ <CheckBox Name="chk1"/>
+ <CheckBox Name="chk2" IsChecked="true"/>
</VerticalStack>
</Expandable>
<Expandable Name="expander3" Width="150" Height="-1">
<VerticalStack Name="vsExpanded" Width="100">
- <Checkbox Name="chk1" IsChecked="true"/>
- <Checkbox Name="chk2"/>
+ <CheckBox Name="chk1" IsChecked="true"/>
+ <CheckBox Name="chk2"/>
</VerticalStack>
</Expandable>
<HorizontalStack>
@@ -103,7 +109,7 @@ BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/> -->
</VerticalStack>
</Scroller>
- <Scrollbar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" MaximumScroll="{../scroller1.MaximumScroll}"
+ <ScrollBar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" MaximumScroll="{../scroller1.MaximumScroll}"
Orientation="Vertical" Width="10" Height="0"/>
</HorizontalStack>
</HorizontalStack>
diff --git a/Tests/Interfaces/testAll.goml b/Tests/Interfaces/testAll.goml index b2766e6d..56016bfb 100755 --- a/Tests/Interfaces/testAll.goml +++ b/Tests/Interfaces/testAll.goml @@ -12,7 +12,7 @@ <TextRun Text="text run test"/>
</VerticalStack>
</Groupbox>-->
- <Groupbox Background="DarkGreen">
+ <GroupBox Background="DarkGreen">
<!-- <Template>
<Group Height="{../TemplatedHeight}" Width="{../TemplatedWidth}">
<Border CornerRadius="5" BorderWidth="1" Margin="0"
@@ -29,7 +29,7 @@ <TextRun Text="text run test" />
<TextRun Text="text run test"/>
</VerticalStack>
- </Groupbox>
+ </GroupBox>
<!-- <Group Fit="true">
<Border CornerRadius="5" BorderWidth="1" Margin="6" Fit="true">
<Container Name="Content" Margin="10" Fit="true">
diff --git a/Tests/Interfaces/testCheckbox.goml b/Tests/Interfaces/testCheckbox.goml index 422435f7..58a3c07c 100755 --- a/Tests/Interfaces/testCheckbox.goml +++ b/Tests/Interfaces/testCheckbox.goml @@ -1,3 +1,3 @@ <?xml version="1.0"?>
-<Checkbox Width="-1" Height="-1" Caption="Checkbox" Background="DimGray" IsChecked="true"/>
+<CheckBox Width="-1" Height="-1" Caption="Checkbox" Background="DimGray" IsChecked="true"/>
diff --git a/Tests/Interfaces/testCombobox.goml b/Tests/Interfaces/testCombobox.goml index ddd92aa5..545fdb87 100755 --- a/Tests/Interfaces/testCombobox.goml +++ b/Tests/Interfaces/testCombobox.goml @@ -1,2 +1,2 @@ <?xml version="1.0"?>
-<Combobox Height="-1" Data="{TestList}" SelectedIndex="0"/>
\ No newline at end of file +<ComboBox Height="-1" Data="{TestList}" SelectedIndex="0"/>
\ No newline at end of file diff --git a/Tests/Interfaces/testExpandable.goml b/Tests/Interfaces/testExpandable.goml index a4c5013f..3a542b8f 100755 --- a/Tests/Interfaces/testExpandable.goml +++ b/Tests/Interfaces/testExpandable.goml @@ -1,10 +1,10 @@ <?xml version="1.0"?>
-<Expandable Title="Test expandable" Background="DimGray">
+<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"/>
+ <CheckBox Name="chk1" Background="Red"/>
+ <CheckBox Name="chk2" IsChecked="true"/>
+ <CheckBox Name="chk3"/>
+ <CheckBox Name="chk4"/>
<HorizontalStack Fit="true" Margin="2" Background="Blue">
<Label Name="captionFps" Text="Fps:" Width="30" TextAlignment="RightCenter"/>
<Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="-1" TextAlignment="Center" Background="AoEnglish"/>
diff --git a/Tests/Interfaces/testGroupBox.goml b/Tests/Interfaces/testGroupBox.goml index b00295a0..bf5e9a75 100755 --- a/Tests/Interfaces/testGroupBox.goml +++ b/Tests/Interfaces/testGroupBox.goml @@ -1,4 +1,4 @@ <?xml version="1.0"?>
-<Groupbox Width="-1" Height="-1" Background="Red">
+<GroupBox Width="-1" Height="-1" Background="Red">
<Label/>
-</Groupbox>
+</GroupBox>
diff --git a/Tests/Interfaces/testPopper.goml b/Tests/Interfaces/testPopper.goml index b5c9b606..eb6683ea 100755 --- a/Tests/Interfaces/testPopper.goml +++ b/Tests/Interfaces/testPopper.goml @@ -1,12 +1,12 @@ <?xml version="1.0"?>
-<Popper Title="TestPopper" Width="100" Background="DimGray">
+<Popper Caption="TestPopper" Width="100" Background="DimGray">
<Border Fit="True" Background="ArmyGreen">
<!-- <Image Fit="true" Path="#go.Images.Icons.tetra.png" Margin="10"/>-->
<VerticalStack Fit="true" Margin="10" Background="CornflowerBlue">
- <Checkbox Name="chk1" Background="Red"/>
- <Checkbox Name="chk2" IsChecked="true"/>
- <Checkbox Name="chk3"/>
- <Checkbox Name="chk4"/>
+ <CheckBox Name="chk1" Background="Red"/>
+ <CheckBox Name="chk2" IsChecked="true"/>
+ <CheckBox Name="chk3"/>
+ <CheckBox Name="chk4"/>
<HorizontalStack Fit="true" Margin="20">
<Label Name="captionFps" Text="Fps:" Width="50" TextAlignment="RightCenter"/>
<Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="50" TextAlignment="Center" Background="AoEnglish"/>
diff --git a/Tests/Interfaces/testScrollbar.goml b/Tests/Interfaces/testScrollbar.goml index b0390f10..27c88650 100755 --- a/Tests/Interfaces/testScrollbar.goml +++ b/Tests/Interfaces/testScrollbar.goml @@ -1,6 +1,5 @@ <?xml version="1.0"?>
<Group Name="TopContainer" Width="400" Height="400"
Focusable="True" Background="Gray">
-
- <Scrollbar Height="0" Orientation="Vertical" Width="16"/>
+ <ScrollBar Height="0" Orientation="Vertical" Width="16" MaximumScroll="100"/>
</Group>
\ No newline at end of file diff --git a/Tests/Interfaces/testWindow.goml b/Tests/Interfaces/testWindow.goml index b2dd8a1a..4e497fff 100755 --- a/Tests/Interfaces/testWindow.goml +++ b/Tests/Interfaces/testWindow.goml @@ -3,17 +3,17 @@ Width="250" Height="300" >
<VerticalStack Name="contentVSStack" Margin="10" Spacing="10">
<Slider Name="slider" Height="10" Width="0"/>
- <Groupbox Text="test" Height="-1" Width="-1" Margin="5">
+ <GroupBox Caption="test" Height="-1" Width="-1" Margin="5">
<VerticalStack Height="-1" Width="0" >
<RadioButton Caption="Radio 1" Background="Red" />
<RadioButton Caption="Radio 2" IsChecked="true" />
<RadioButton Caption="Radio 3" />
</VerticalStack>
- </Groupbox>
+ </GroupBox>
<HorizontalStack Width="0" Height="-1" Margin="10" Background="BlueCrayola">
- <Checkbox Height="-1" Width="80"/>
+ <CheckBox Height="-1" Width="80"/>
<GraphicObject Width="0"/>
- <Checkbox Height="-1" Width="80" IsChecked="true"/>
+ <CheckBox Height="-1" Width="80" IsChecked="true"/>
</HorizontalStack>
<!-- <Checkbox Height="-1" Width="-1" Background="Red" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Right"/>-->
diff --git a/Tests/Interfaces/test_Listbox.goml b/Tests/Interfaces/test_Listbox.goml index fa4b730c..4348439d 100755 --- a/Tests/Interfaces/test_Listbox.goml +++ b/Tests/Interfaces/test_Listbox.goml @@ -15,7 +15,7 @@ <VerticalStack Width="{../../../../TemplatedWidth}" Height="-1" MinimumSize="100;100"
Name="List" Margin="0" VerticalAlignment="Top" />
</Scroller>
- <Scrollbar Name="scrollbar1" Scroll="{../scroller1.ScrollY}"
+ <ScrollBar Name="scrollbar1" Scroll="{../scroller1.ScrollY}"
MaximumScroll="{../scroller1.MaximumScroll}" Orientation="Vertical"
Width="10" Height="{../../../TemplatedHeight}" />
</HorizontalStack>
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 1e63ae8e..e2b21afe 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -190,6 +190,12 @@ <None Include="Interfaces\testWindow3.goml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="Interfaces\2.crow"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Interfaces\1.crow"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup> <Folder Include="Interfaces\" /> diff --git a/UnitTest/ExpectedOutputs/0.png b/UnitTest/ExpectedOutputs/0.png Binary files differnew file mode 100644 index 00000000..acf96fa6 --- /dev/null +++ b/UnitTest/ExpectedOutputs/0.png diff --git a/UnitTest/ExpectedOutputs/1.png b/UnitTest/ExpectedOutputs/1.png Binary files differnew file mode 100644 index 00000000..f792986c --- /dev/null +++ b/UnitTest/ExpectedOutputs/1.png diff --git a/UnitTest/Interfaces/0.crow b/UnitTest/Interfaces/0.crow new file mode 100755 index 00000000..64d6db6d --- /dev/null +++ b/UnitTest/Interfaces/0.crow @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<GraphicObject Width="100" Height="100" Background="Green"> diff --git a/UnitTest/Interfaces/1.crow b/UnitTest/Interfaces/1.crow new file mode 100755 index 00000000..142d0721 --- /dev/null +++ b/UnitTest/Interfaces/1.crow @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<Container Width="300" Height="300" Margin="20" Background="Yellow"> + <Container Width="0" Height="0" Margin="20" Background="Green"> + <GraphicObject VerticalAlignment="Bottom" Width="50" Height="50" + Background="Red"/> + </Container> +</Container>
\ No newline at end of file diff --git a/UnitTest/Interfaces/2.crow b/UnitTest/Interfaces/2.crow new file mode 100755 index 00000000..dcccba04 --- /dev/null +++ b/UnitTest/Interfaces/2.crow @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<VerticalStack Fit="true"> + <HorizontalStack Fit="true"> + <Label Text="label1"/> + <TextRun Text="textrun1"/> + </HorizontalStack> +</VerticalStack>
\ No newline at end of file diff --git a/UnitTest/NUnitCrowWindow.cs b/UnitTest/NUnitCrowWindow.cs new file mode 100644 index 00000000..0c73b8e7 --- /dev/null +++ b/UnitTest/NUnitCrowWindow.cs @@ -0,0 +1,456 @@ +#define MONO_CAIRO_DEBUG_DISPOSE
+
+
+using System;
+using System.Runtime.InteropServices;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+using OpenTK.Input;
+
+using System.Diagnostics;
+
+//using GGL;
+using System.Threading;
+using System.Collections.Generic;
+using System.Linq;
+using Cairo;
+
+
+namespace Crow
+{
+ class NUnitCrowWindow : IValueChange, ILayoutable, IGOLibHost
+ {
+ #region IValueChange implementation
+ public event EventHandler<ValueChangeEventArgs> ValueChanged;
+ public virtual void NotifyValueChanged(string MemberName, object _value)
+ {
+ ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
+ }
+ #endregion
+
+ public Rectangle ClientRectangle = new Rectangle(0,0,800,600);
+ public List<GraphicObject> GraphicObjects = new List<GraphicObject>();
+ public Color Background = Color.Transparent;
+
+ Rectangles _redrawClip = new Rectangles();//should find another way to access it from child
+ List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();
+
+ #region IGOLibHost implementation
+ public Rectangles redrawClip {
+ get {
+ return _redrawClip;
+ }
+ set {
+ _redrawClip = value;
+ }
+ }
+
+ public List<GraphicObject> gobjsToRedraw {
+ get {
+ return _gobjsToRedraw;
+ }
+ set {
+ _gobjsToRedraw = value;
+ }
+ }
+ public void AddWidget(GraphicObject g)
+ {
+ g.Parent = this;
+ GraphicObjects.Insert (0, g);
+
+ g.RegisterForLayouting ((int)LayoutingType.Sizing);
+ }
+ public void DeleteWidget(GraphicObject g)
+ {
+ g.Visible = false;//trick to ensure clip is added to refresh zone
+ g.ClearBinding();
+ GraphicObjects.Remove (g);
+ }
+ public void PutOnTop(GraphicObject g)
+ {
+ if (GraphicObjects.IndexOf(g) > 0)
+ {
+ GraphicObjects.Remove(g);
+ GraphicObjects.Insert(0, g);
+ g.registerClipRect ();
+ }
+ }
+ public void Quit ()
+ {
+ }
+
+ #region focus
+ GraphicObject _activeWidget; //button is pressed on widget
+ GraphicObject _hoverWidget; //mouse is over
+ GraphicObject _focusedWidget; //has keyboard (or other perif) focus
+
+ public GraphicObject activeWidget
+ {
+ get { return _activeWidget; }
+ set
+ {
+ if (_activeWidget == value)
+ return;
+ _activeWidget = value;
+ }
+ }
+ public GraphicObject hoverWidget
+ {
+ get { return _hoverWidget; }
+ set { _hoverWidget = value; }
+ }
+ public GraphicObject FocusedWidget {
+ get { return _focusedWidget; }
+ set {
+ if (_focusedWidget == value)
+ return;
+ if (_focusedWidget != null)
+ _focusedWidget.onUnfocused (this, null);
+ _focusedWidget = value;
+ if (_focusedWidget != null)
+ _focusedWidget.onFocused (this, null);
+ }
+ }
+ #endregion
+
+ #endregion
+
+ #region Events
+ //those events are raised only if mouse isn't in a graphic object
+ public event EventHandler<MouseWheelEventArgs> MouseWheelChanged;
+ public event EventHandler<MouseButtonEventArgs> MouseButtonUp;
+ public event EventHandler<MouseButtonEventArgs> MouseButtonDown;
+ public event EventHandler<MouseButtonEventArgs> MouseClick;
+ public event EventHandler<MouseMoveEventArgs> MouseMove;
+ #endregion
+
+ #region graphic contexte
+ Context ctx;
+ public Surface surf;
+ string testId;
+ #endregion
+
+ #region update
+ public Stopwatch updateTime = new Stopwatch ();
+ public Stopwatch layoutTime = new Stopwatch ();
+ public Stopwatch guTime = new Stopwatch ();
+ public Stopwatch drawingTime = new Stopwatch ();
+
+ public void Update ()
+ {
+ guTime.Reset ();
+ updateTime.Restart ();
+ layoutTime.Restart ();
+
+ ctx = new Context(surf);
+
+ GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
+ GraphicObjects.CopyTo (invGOList,0);
+ invGOList = invGOList.Reverse ().ToArray ();
+
+ //Debug.WriteLine ("======= Layouting queue start =======");
+ lock (Interface.LayoutingQueue) {
+ while (Interface.LayoutingQueue.Count > 0) {
+ // Stopwatch lqiProcTime = new Stopwatch ();
+ // lqiProcTime.Start ();
+ LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+ lqi.ProcessLayouting ();
+ // lqiProcTime.Stop ();
+ // if (lqiProcTime.ElapsedMilliseconds > 10) {
+ // Debug.WriteLine("lqi {2}: {0} ticks \t, {1} ms",
+ // updateTime.ElapsedTicks,
+ // updateTime.ElapsedMilliseconds, lqi.ToString());
+ // }
+ }
+ }
+
+ //final redraw clips should be added only when layout is completed among parents,
+ //that's why it take place in a second pass
+ GraphicObject[] gotr = new GraphicObject[gobjsToRedraw.Count];
+ gobjsToRedraw.CopyTo (gotr);
+ gobjsToRedraw.Clear ();
+ foreach (GraphicObject p in gotr) {
+ p.registerClipRect ();
+ }
+
+ layoutTime.Stop ();
+ guTime.Start ();
+
+ lock (redrawClip) {
+ if (redrawClip.count > 0) {
+ // #if DEBUG_CLIP_RECTANGLE
+ // redrawClip.stroke (ctx, new Color(1.0,0,0,0.3));
+ // #endif
+ redrawClip.clearAndClip (ctx);//rajouté après, tester si utile
+
+ //Link.draw (ctx);
+ foreach (GraphicObject p in invGOList) {
+ if (p.Visible) {
+ drawingTime.Start ();
+
+ ctx.Save ();
+ if (redrawClip.count > 0) {
+ Rectangles clip = redrawClip.intersectingRects (p.Slot);
+
+ if (clip.count > 0)
+ p.Paint (ref ctx, clip);
+ }
+ ctx.Restore ();
+
+ drawingTime.Stop ();
+ }
+ }
+ ctx.ResetClip ();
+ // #if DEBUG_CLIP_RECTANGLE
+ // redrawClip.stroke (ctx, Color.Red.AdjustAlpha(0.1));
+ // #endif
+ redrawClip.Reset ();
+ }
+ }
+ guTime.Stop ();
+ updateTime.Stop ();
+ ctx.Dispose ();
+ Console.WriteLine("{3} => layout:{0,8} t\tdraw:{1,8} t\tupdate:{2,8} t",
+ layoutTime.ElapsedTicks,
+ guTime.ElapsedTicks,
+ updateTime.ElapsedTicks,
+ testId);
+// Console.WriteLine("{3} => layout:{0}ms\tdraw{1}ms\tupdate:{2}ms",
+// layoutTime.ElapsedMilliseconds,
+// guTime.ElapsedMilliseconds,
+// updateTime.ElapsedMilliseconds,
+// testId);
+ surf.WriteToPng (@"ExpectedOutputs/" + testId + ".png");
+ surf.WriteToPng (@"tmp.png");
+ }
+ #endregion
+
+ #region loading
+ public GraphicObject LoadTest (string id)
+ {
+ testId = id;
+ GraphicObject tmp = Interface.Load ("Interfaces/" + testId + ".crow", this);
+ AddWidget (tmp);
+ return tmp;
+ }
+ /// <summary> Remove all Graphic objects from top container </summary>
+ public void ClearInterface()
+ {
+ int i = 0;
+ while (GraphicObjects.Count>0) {
+ GraphicObject g = GraphicObjects [i];
+ g.Visible = false;
+ g.ClearBinding ();
+ GraphicObjects.RemoveAt (0);
+ }
+ }
+ #endregion
+
+ public NUnitCrowWindow (int width, int height)
+ {
+ ClientRectangle.Width = width;
+ ClientRectangle.Height = height;
+
+ surf = new ImageSurface(Format.Argb32, ClientRectangle.Width, ClientRectangle.Height);
+ }
+
+ int frameCpt = 0;
+ int idx = 0;
+
+
+ #region FPS
+ int _fps = 0;
+
+ public int fps {
+ get { return _fps; }
+ set {
+ if (_fps == value)
+ return;
+
+ _fps = value;
+
+ if (_fps > fpsMax) {
+ fpsMax = _fps;
+ ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMax", fpsMax));
+ } else if (_fps < fpsMin) {
+ fpsMin = _fps;
+ ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMin", fpsMin));
+ }
+
+ ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", _fps));
+ ValueChanged.Raise (this, new ValueChangeEventArgs ("update",
+ this.updateTime.ElapsedMilliseconds.ToString () + " ms"));
+ }
+ }
+
+ public int fpsMin = int.MaxValue;
+ public int fpsMax = 0;
+
+ void resetFps ()
+ {
+ fpsMin = int.MaxValue;
+ fpsMax = 0;
+ _fps = 0;
+ }
+ //public string update = "";
+ #endregion
+
+
+ #region Mouse Handling
+ void Mouse_Move(object sender, MouseMoveEventArgs e)
+ {
+ if (_activeWidget != null) {
+ //first, ensure object is still in the graphic tree
+ if (_activeWidget.TopContainer == null) {
+ activeWidget = null;
+ } else {
+
+ //send move evt even if mouse move outside bounds
+ _activeWidget.onMouseMove (_activeWidget, e);
+ return;
+ }
+ }
+
+ if (_hoverWidget != null) {
+ //first, ensure object is still in the graphic tree
+ if (_hoverWidget.TopContainer == null) {
+ hoverWidget = null;
+ } else {
+ //check topmost graphicobject first
+ GraphicObject tmp = _hoverWidget;
+ GraphicObject topc = null;
+ while (tmp is GraphicObject) {
+ topc = tmp;
+ tmp = tmp.Parent as GraphicObject;
+ }
+ int idxhw = GraphicObjects.IndexOf (topc);
+ if (idxhw != 0) {
+ int i = 0;
+ while (i < idxhw) {
+ if (GraphicObjects [i].MouseIsIn (e.Position)) {
+ _hoverWidget.onMouseLeave (this, e);
+ GraphicObjects [i].checkHoverWidget (e);
+ return;
+ }
+ i++;
+ }
+ }
+
+
+ if (_hoverWidget.MouseIsIn (e.Position)) {
+ _hoverWidget.checkHoverWidget (e);
+ return;
+ } else {
+ _hoverWidget.onMouseLeave (this, e);
+ //seek upward from last focused graph obj's
+ while (_hoverWidget.Parent as GraphicObject != null) {
+ _hoverWidget = _hoverWidget.Parent as GraphicObject;
+ if (_hoverWidget.MouseIsIn (e.Position)) {
+ _hoverWidget.checkHoverWidget (e);
+ return;
+ } else
+ _hoverWidget.onMouseLeave (this, e);
+ }
+ }
+ }
+ }
+
+ //top level graphic obj's parsing
+ for (int i = 0; i < GraphicObjects.Count; i++) {
+ GraphicObject g = GraphicObjects[i];
+ if (g.MouseIsIn (e.Position)) {
+ g.checkHoverWidget (e);
+ PutOnTop (g);
+ return;
+ }
+ }
+ _hoverWidget = null;
+ MouseMove.Raise (this, e);
+ }
+ void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ if (_activeWidget == null) {
+ MouseButtonUp.Raise (this, e);
+ return;
+ }
+
+ _activeWidget.onMouseButtonUp (this, e);
+ _activeWidget = null;
+ }
+ void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ if (_hoverWidget == null) {
+ MouseButtonDown.Raise (this, e);
+ return;
+ }
+
+ GraphicObject g = _hoverWidget;
+ while (!g.Focusable) {
+ g = g.Parent as GraphicObject;
+ if (g == null) {
+ return;
+ }
+ }
+
+ _activeWidget = g;
+ _activeWidget.onMouseButtonDown (this, e);
+ }
+
+ void Mouse_WheelChanged(object sender, MouseWheelEventArgs e)
+ {
+ if (_hoverWidget == null) {
+ MouseWheelChanged.Raise (this, e);
+ return;
+ }
+ _hoverWidget.onMouseWheel (this, e);
+ }
+ #endregion
+
+ #region keyboard Handling
+ void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
+ {
+ if (_focusedWidget == null)
+ return;
+ _focusedWidget.onKeyDown (sender, e);
+ }
+ #endregion
+
+ #region ILayoutable implementation
+
+ public void RegisterForLayouting (int layoutType) { throw new NotImplementedException (); }
+ public void UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
+ public Rectangle ContextCoordinates (Rectangle r)
+ {
+ return r;
+ }
+ public Rectangle ScreenCoordinates (Rectangle r)
+ {
+ return r;
+ }
+
+ public ILayoutable Parent {
+ get {
+ return null;
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+ Rectangle ILayoutable.ClientRectangle {
+ get { return new Size(this.ClientRectangle.Size.Width,this.ClientRectangle.Size.Height); }
+ }
+ public IGOLibHost TopContainer {
+ get { return this; }
+ }
+
+ public Rectangle getSlot ()
+ {
+ return ClientRectangle;
+ }
+ public Rectangle getBounds ()//redundant but fill ILayoutable implementation
+ {
+ return ClientRectangle;
+ }
+ #endregion
+ }
+}
\ No newline at end of file diff --git a/UnitTest/Test.cs b/UnitTest/Test.cs new file mode 100644 index 00000000..11555696 --- /dev/null +++ b/UnitTest/Test.cs @@ -0,0 +1,64 @@ +// +// Test.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 NUnit.Framework; +using System; +using Crow; +using System.IO; + +namespace UnitTest +{ + [TestFixture ()] + public class Test + { + NUnitCrowWindow win; + + [SetUp] + public void Init() + { + win = new NUnitCrowWindow (400,400); + } + + [Test ()] + [Category("Alignment")] + public void GraphicObject () + { + string[] tests = new string[] { "0","1" }; + + foreach (string s in tests) { + win.LoadTest (s); + win.Update (); + win.Update (); + byte[] model = File.ReadAllBytes("ExpectedOutputs/" + s + ".png"); + byte[] result = File.ReadAllBytes(@"tmp.png"); + + CollectionAssert.AreEqual (model, result); + + win.ClearInterface (); + } + } + + void testAlignment(GraphicObject g){ + g.HorizontalAlignment = HorizontalAlignment.Left; + + } + } +} + diff --git a/UnitTest/UnitTest.csproj b/UnitTest/UnitTest.csproj new file mode 100644 index 00000000..ddd53b61 --- /dev/null +++ b/UnitTest/UnitTest.csproj @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}</ProjectGuid> + <OutputType>Library</OutputType> + <RootNamespace>UnitTest</RootNamespace> + <AssemblyName>UnitTest</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug</OutputPath> + <DefineConstants>DEBUG;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>full</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="Mono.Cairo" /> + <Reference Include="OpenTK"> + <HintPath>..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll</HintPath> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Xml" /> + <Reference Include="nunit.framework, Version=2.6.4.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77"> + <Package>nunit</Package> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="Test.cs" /> + <Compile Include="NUnitCrowWindow.cs" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <ItemGroup> + <None Include="packages.config" /> + <None Include="Interfaces\0.crow"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="ExpectedOutputs\0.png"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Interfaces\1.crow"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="ExpectedOutputs\1.png"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Interfaces\2.crow"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Crow.csproj"> + <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project> + <Name>Crow</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Folder Include="Interfaces\" /> + <Folder Include="ExpectedOutputs\" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/UnitTest/packages.config b/UnitTest/packages.config new file mode 100644 index 00000000..b183023e --- /dev/null +++ b/UnitTest/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="NUnit" version="3.0.1" targetFramework="net45" /> +</packages>
\ No newline at end of file diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs index c598c3e3..5d3e81ca 100644 --- a/src/GraphicObjects/Button.cs +++ b/src/GraphicObjects/Button.cs @@ -26,12 +26,12 @@ namespace Crow #endregion
#region GraphicObject Overrides
- [XmlAttributeAttribute()][DefaultValue(60)]
+ [XmlAttributeAttribute()][DefaultValue(50)]
public override int Width {
get { return base.Width; }
set { base.Width = value; }
}
- [XmlAttributeAttribute()][DefaultValue(30)]
+ [XmlAttributeAttribute()][DefaultValue(20)]
public override int Height {
get { return base.Height; }
set { base.Height = value; }
diff --git a/src/GraphicObjects/Checkbox.cs b/src/GraphicObjects/CheckBox.cs index 36181602..a08f9fdb 100644 --- a/src/GraphicObjects/Checkbox.cs +++ b/src/GraphicObjects/CheckBox.cs @@ -16,15 +16,15 @@ using System.ComponentModel; namespace Crow
{
- [DefaultTemplate("#Crow.Templates.Checkbox.goml")]
- public class Checkbox : TemplatedControl
+ [DefaultTemplate("#Crow.Templates.CheckBox.goml")]
+ public class CheckBox : TemplatedControl
{
string caption;
string image;
bool isChecked;
#region CTOR
- public Checkbox() : base()
+ public CheckBox() : base()
{
}
#endregion
diff --git a/src/GraphicObjects/Combobox.cs b/src/GraphicObjects/ComboBox.cs index 473c10ff..5d9c8e97 100644 --- a/src/GraphicObjects/Combobox.cs +++ b/src/GraphicObjects/ComboBox.cs @@ -20,16 +20,16 @@ using System.Threading; namespace Crow
{
- [DefaultTemplate("#Crow.Templates.Combobox.goml")]
- [DefaultOverlayTemplate("#Crow.Templates.ComboboxOverlay.goml")]
- public class Combobox : TemplatedContainer
+ [DefaultTemplate("#Crow.Templates.ComboBox.goml")]
+ [DefaultOverlayTemplate("#Crow.Templates.ComboBoxOverlay.goml")]
+ public class ComboBox : TemplatedContainer
{
#region CTOR
- public Combobox() : base(){ }
+ public ComboBox() : base(){ }
#endregion
bool _isPopped;
- string text;
+ string caption;
GraphicObject _overlay;
Group _list;
IList data;
@@ -77,7 +77,7 @@ namespace Crow _itemTemplate = value;
}
}
- [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ComboboxOverlay.goml")]
+ [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ComboBoxOverlay.goml")]
public string OverlayTemplate {
get { return _overlayTemplate; }
set {
@@ -109,9 +109,9 @@ namespace Crow SelectedItemChanged.Raise (this, new SelectionChangeEventArgs(_selectedItem));
if (SelectedItem == null)
- Text = "";
+ Caption = "";
else
- Text = _selectedItem.ToString ();
+ Caption = _selectedItem.ToString ();
}
}
public object SelectedItem{
@@ -125,9 +125,9 @@ namespace Crow SelectedItemChanged.Raise (this, new SelectionChangeEventArgs(_selectedItem));
if (SelectedItem == null)
- Text = "";
+ Caption = "";
else
- Text = _selectedItem.ToString ();
+ Caption = _selectedItem.ToString ();
}
get { return _selectedItem; }
@@ -243,13 +243,13 @@ namespace Crow }
}
[XmlAttributeAttribute()][DefaultValue("Combobox")]
- public string Text {
- get { return text; }
+ public string Caption {
+ get { return caption; }
set {
- if (text == value)
+ if (caption == value)
return;
- text = value;
- NotifyValueChanged ("Text", text);
+ caption = value;
+ NotifyValueChanged ("Caption", caption);
}
}
[XmlAttributeAttribute()][DefaultValue(false)]
diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index 172406c2..f1e2bdeb 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -22,7 +22,7 @@ namespace Crow public class Expandable : TemplatedContainer
{
bool _isExpanded;
- string title;
+ string caption;
string image;
Container _contentContainer;
@@ -62,13 +62,13 @@ namespace Crow }
[XmlAttributeAttribute()][DefaultValue("Expandable")]
- public string Title {
- get { return title; }
+ public string Caption {
+ get { return caption; }
set {
- if (title == value)
+ if (caption == value)
return;
- title = value;
- NotifyValueChanged ("Title", title);
+ caption = value;
+ NotifyValueChanged ("Caption", caption);
}
}
[XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.expandable.svg")]
diff --git a/src/GraphicObjects/Groupbox.cs b/src/GraphicObjects/GroupBox.cs index e1f33d84..81bac117 100644 --- a/src/GraphicObjects/Groupbox.cs +++ b/src/GraphicObjects/GroupBox.cs @@ -18,14 +18,14 @@ using System.IO; namespace Crow
{
- [DefaultTemplate("#Crow.Templates.Groupbox.goml")]
- public class Groupbox : TemplatedContainer
+ [DefaultTemplate("#Crow.Templates.GroupBox.goml")]
+ public class GroupBox : TemplatedContainer
{
- string title;
+ string caption;
Container _contentContainer;
#region CTOR
- public Groupbox() : base(){}
+ public GroupBox() : base(){}
#endregion
#region Template overrides
@@ -55,13 +55,13 @@ namespace Crow #endregion
[XmlAttributeAttribute()][DefaultValue("Groupbox")]
- public string Title {
- get { return title; }
+ public string Caption {
+ get { return caption; }
set {
- if (title == value)
+ if (caption == value)
return;
- title = value;
- NotifyValueChanged ("Title", title);
+ caption = value;
+ NotifyValueChanged ("Caption", caption);
}
}
}
diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs index 8d9880ad..a0ab540e 100644 --- a/src/GraphicObjects/ListBox.cs +++ b/src/GraphicObjects/ListBox.cs @@ -31,7 +31,7 @@ using System.Threading; namespace Crow { - [DefaultTemplate("#Crow.Templates.Listbox.goml")] + [DefaultTemplate("#Crow.Templates.ListBox.goml")] //[DefaultTemplate("#Crow.Templates.ItemTemplate.goml")] public class ListBox : TemplatedControl//, IXmlSerializable { diff --git a/src/GraphicObjects/MessageBox.cs b/src/GraphicObjects/MessageBox.cs index 40f48e4a..18c4afb3 100644 --- a/src/GraphicObjects/MessageBox.cs +++ b/src/GraphicObjects/MessageBox.cs @@ -54,16 +54,16 @@ namespace Crow } } #region GraphicObject overrides - [XmlAttributeAttribute][DefaultValue(350)] + [XmlAttributeAttribute][DefaultValue(250)] public override int Width { get { return base.Width; } set { base.Width = value; } } - [XmlAttributeAttribute][DefaultValue(150)] - public override int Height { - get { return base.Height; } - set { base.Height = value; } - } +// [XmlAttributeAttribute][DefaultValue(80)] +// public override int Height { +// get { return base.Height; } +// set { base.Height = value; } +// } [XmlAttributeAttribute()][DefaultValue(true)] public override bool Focusable { diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 5842faf8..15a209ce 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -27,7 +27,7 @@ namespace Crow }
#endregion
bool _isPopped;
- string title;
+ string caption;
string image;
GraphicObject _content;
@@ -66,15 +66,16 @@ namespace Crow if (tc == null)
return;
Rectangle r = this.ScreenCoordinates (this.Slot);
- if (e.LayoutType == LayoutingType.Width) {
+ if (((int)e.LayoutType & (int)LayoutingType.Width) > 0) {
if (Content.Slot.Width < tc.ClientRectangle.Width) {
if (r.Left + Content.Slot.Width > tc.ClientRectangle.Right)
Content.Left = tc.ClientRectangle.Right - Content.Slot.Width;
else
Content.Left = r.Left;
- }else
+ } else
Content.Left = 0;
- }else if (e.LayoutType == LayoutingType.Height) {
+ }
+ if (((int)e.LayoutType & (int)LayoutingType.Height) > 0) {
if (Content.Slot.Height < tc.ClientRectangle.Height) {
if (r.Bottom + Content.Slot.Height > tc.ClientRectangle.Bottom)
Content.Top = r.Top - Content.Slot.Height;
@@ -116,13 +117,13 @@ namespace Crow }
[XmlAttributeAttribute()][DefaultValue("Popper")]
- public string Title {
- get { return title; }
+ public string Caption {
+ get { return caption; }
set {
- if (title == value)
+ if (caption == value)
return;
- title = value;
- NotifyValueChanged ("Title", title);
+ caption = value;
+ NotifyValueChanged ("Caption", caption);
}
}
[XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.expandable.svg")]
@@ -165,6 +166,7 @@ namespace Crow if (Content.Parent == null)
tc.AddWidget (Content);
tc.PutOnTop (Content);
+ _content_LayoutChanged (this, new LayoutChangeEventArgs (LayoutingType.Sizing));
}
Pop.Raise (this, e);
}
@@ -182,6 +184,5 @@ namespace Crow IsPopped = !IsPopped;
base.onMouseClick (sender, e);
}
-
}
}
diff --git a/src/GraphicObjects/Scrollbar.cs b/src/GraphicObjects/ScrollBar.cs index f68bdb77..905efc55 100644 --- a/src/GraphicObjects/Scrollbar.cs +++ b/src/GraphicObjects/ScrollBar.cs @@ -16,8 +16,8 @@ using System.ComponentModel; namespace Crow
{
- [DefaultTemplate("#Crow.Templates.Scrollbar.goml")]
- public class Scrollbar : TemplatedControl, IValueChange
+ [DefaultTemplate("#Crow.Templates.ScrollBar.goml")]
+ public class ScrollBar : TemplatedControl, IValueChange
{
#region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
@@ -28,7 +28,7 @@ namespace Crow double _maximumScroll;
double _scroll;
- public Scrollbar() : base()
+ public ScrollBar() : base()
{
}
diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index 97bc177f..7b44a93e 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -154,6 +154,7 @@ namespace Crow cursor.TopLeft = new Point ((int)(p1.X - r.Width / 2),
r.Top + (int)(Value * unity));
}
+ cursor.Inflate (-1);
}
#region mouse handling
diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs index 097ecaa1..9fca2fea 100644 --- a/src/GraphicObjects/TextBox.cs +++ b/src/GraphicObjects/TextBox.cs @@ -12,16 +12,16 @@ using System.Runtime.InteropServices; namespace Crow
{
- public class TextBoxWidget : Label
+ public class TextBox : Label
{
#region CTOR
- public TextBoxWidget(string _initialValue)
+ public TextBox(string _initialValue)
: base(_initialValue)
{
}
- public TextBoxWidget()
+ public TextBox()
{ }
#endregion
diff --git a/src/Interface.cs b/src/Interface.cs index c1713838..b6e5b3f1 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -112,8 +112,11 @@ namespace Crow if (path.StartsWith ("#")) { string resId = path.Substring (1); - stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); - if (stream == null)//try to find ressource in golib assembly + //try/catch added to prevent nunit error + try { + stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); + } catch (Exception ex) {} + if (stream == null)//try to find ressource in Crow assembly stream = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId); if (stream == null) throw new Exception ("Resource not found: " + path); |