Browse Source

Finalizing Gallery work

pull/156/head
Nelson Carrillo 11 years ago
parent
commit
d8b95e8bc3
  1. 691
      samples/TestApplication/Program.cs
  2. 5
      samples/TestApplication/TestApplication.csproj
  3. BIN
      samples/TestApplication/pattern.jpg
  4. 15
      src/Gtk/Perspex.Cairo/Media/DrawingContext.cs
  5. 3
      src/Gtk/Perspex.Cairo/Media/StreamGeometryContextImpl.cs
  6. 6
      src/Gtk/Perspex.Cairo/Media/StreamGeometryImpl.cs
  7. 2
      src/Gtk/Perspex.Cairo/Media/TileBrushes.cs
  8. 3
      src/Gtk/Perspex.Cairo/Perspex.Cairo.csproj
  9. 1
      src/Gtk/Perspex.Cairo/packages.config
  10. 1
      src/Gtk/Perspex.Gtk/WindowImpl.cs
  11. 17
      src/Perspex.Themes.Default/ToggleButtonStyle.cs

691
samples/TestApplication/Program.cs

@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using System.Linq;
using System.IO; using System.IO;
using System.Reactive.Linq; using System.Reactive.Linq;
using Perspex; using Perspex;
@ -122,7 +123,7 @@ namespace TestApplication
ButtonsTab(), ButtonsTab(),
TextTab(), TextTab(),
HtmlTab(), HtmlTab(),
ImagesTab(), ImagesTab(),
ListsTab(), ListsTab(),
LayoutTab(), LayoutTab(),
AnimationsTab(), AnimationsTab(),
@ -160,13 +161,13 @@ namespace TestApplication
{ {
Text = "Button", Text = "Button",
FontWeight = FontWeight.Medium, FontWeight = FontWeight.Medium,
FontSize = 13, FontSize = 20,
Foreground = SolidColorBrush.Parse("#212121"), Foreground = SolidColorBrush.Parse("#212121"),
}, },
new TextBlock new TextBlock
{ {
Text = "A button control", Text = "A button control",
FontSize = 20, FontSize = 13,
Foreground = SolidColorBrush.Parse("#727272"), Foreground = SolidColorBrush.Parse("#727272"),
Margin = new Thickness(0, 0, 0, 10) Margin = new Thickness(0, 0, 0, 10)
}, },
@ -183,18 +184,31 @@ namespace TestApplication
}, },
new TextBlock new TextBlock
{ {
Text = "Toggle button", Margin = new Thickness(0, 40, 0, 0),
Text = "ToggleButton",
FontWeight = FontWeight.Medium, FontWeight = FontWeight.Medium,
FontSize = 13, FontSize = 20,
Foreground = SolidColorBrush.Parse("#212121"), Foreground = SolidColorBrush.Parse("#212121"),
}, },
new TextBlock new TextBlock
{ {
Text = "A button control", Text = "A toggle button control",
FontSize = 20, FontSize = 13,
Foreground = SolidColorBrush.Parse("#727272"), Foreground = SolidColorBrush.Parse("#727272"),
Margin = new Thickness(0, 0, 0, 10) Margin = new Thickness(0, 0, 0, 10)
}, },
new ToggleButton
{
Width = 150,
IsChecked = true,
Content = "On"
},
new ToggleButton
{
Width = 150,
IsChecked = false,
Content = "Off"
},
} }
} }
}, },
@ -221,7 +235,7 @@ namespace TestApplication
{ {
new TextBlock new TextBlock
{ {
Text = "Text block", Text = "TextBlock",
FontWeight = FontWeight.Medium, FontWeight = FontWeight.Medium,
FontSize = 20, FontSize = 20,
Foreground = SolidColorBrush.Parse("#212121"), Foreground = SolidColorBrush.Parse("#212121"),
@ -255,11 +269,11 @@ namespace TestApplication
Text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", Text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
FontSize = 11, FontSize = 11,
FontStyle = FontStyle.Italic, FontStyle = FontStyle.Italic,
Margin = new Thickness(0, 0, 0, 20)
}, },
new TextBlock new TextBlock
{ {
Text = "HTML label", Margin = new Thickness(0, 40, 0, 0),
Text = "HtmlLabel",
FontWeight = FontWeight.Medium, FontWeight = FontWeight.Medium,
FontSize = 20, FontSize = 20,
Foreground = SolidColorBrush.Parse("#212121"), Foreground = SolidColorBrush.Parse("#212121"),
@ -303,196 +317,367 @@ namespace TestApplication
return new TabItem return new TabItem
{ {
Header = "Input", Header = "Input",
Content = new StackPanel Content = new ScrollViewer()
{ {
Margin = new Thickness(10), Content = new StackPanel
Orientation = Orientation.Vertical, {
Gap = 4, Margin = new Thickness(10),
Children = new Controls Orientation = Orientation.Vertical,
{ Gap = 4,
new TextBlock Children = new Controls
{ {
Text = "Check box", new TextBlock
FontWeight = FontWeight.Medium, {
FontSize = 20, Text = "TextBox",
Foreground = SolidColorBrush.Parse("#212121"), FontWeight = FontWeight.Medium,
}, FontSize = 20,
new TextBlock Foreground = SolidColorBrush.Parse("#212121"),
{ },
Text = "A check box control", new TextBlock
FontSize = 13, {
Foreground = SolidColorBrush.Parse("#727272"), Text = "A text box control",
Margin = new Thickness(0, 0, 0, 10) FontSize = 13,
}, Foreground = SolidColorBrush.Parse("#727272"),
new CheckBox { IsChecked = true, Margin = new Thickness(0, 0, 0, 5), Content = "Checked" }, Margin = new Thickness(0, 0, 0, 10)
new CheckBox { IsChecked = false, Content = "Unchecked" }, },
new TextBlock new TextBox { Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", Width = 200 },
{ new TextBox { AcceptsReturn = true, TextWrapping = TextWrapping.Wrap, Width = 200, Height = 150, Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est." },
Margin = new Thickness(0, 40, 0, 0), new TextBlock
Text = "Radio button", {
FontWeight = FontWeight.Medium, Margin = new Thickness(0, 40, 0, 0),
FontSize = 20, Text = "CheckBox",
Foreground = SolidColorBrush.Parse("#212121"), FontWeight = FontWeight.Medium,
}, FontSize = 20,
new TextBlock Foreground = SolidColorBrush.Parse("#212121"),
{ },
Text = "A radio button control", new TextBlock
FontSize = 13, {
Foreground = SolidColorBrush.Parse("#727272"), Text = "A check box control",
Margin = new Thickness(0, 0, 0, 10) FontSize = 13,
}, Foreground = SolidColorBrush.Parse("#727272"),
Margin = new Thickness(0, 0, 0, 10)
new RadioButton { IsChecked = true, Margin = new Thickness(0, 0, 0, 5), Content = "Option 1" }, },
new RadioButton { IsChecked = false, Content = "Option 2" }, new CheckBox { IsChecked = true, Margin = new Thickness(0, 0, 0, 5), Content = "Checked" },
new RadioButton { IsChecked = false, Content = "Option 3" }, new CheckBox { IsChecked = false, Content = "Unchecked" },
} new TextBlock
} {
Margin = new Thickness(0, 40, 0, 0),
Text = "RadioButton",
FontWeight = FontWeight.Medium,
FontSize = 20,
Foreground = SolidColorBrush.Parse("#212121"),
},
new TextBlock
{
Text = "A radio button control",
FontSize = 13,
Foreground = SolidColorBrush.Parse("#727272"),
Margin = new Thickness(0, 0, 0, 10)
},
new RadioButton { IsChecked = true, Content = "Option 1" },
new RadioButton { IsChecked = false, Content = "Option 2" },
new RadioButton { IsChecked = false, Content = "Option 3" },
}
}
}
}; };
} }
private static TabItem ImagesTab()
private static TabItem ListsTab()
{ {
ScrollBar size;
return new TabItem return new TabItem
{ {
Header = "Images", Header = "Lists",
Content = new StackPanel Content = new ScrollViewer()
{ {
Orientation = Orientation.Vertical, CanScrollHorizontally = false,
HorizontalAlignment = HorizontalAlignment.Center, Content = new StackPanel
VerticalAlignment = VerticalAlignment.Center, {
Gap = 8, HorizontalAlignment = HorizontalAlignment.Left,
Children = new Controls Orientation = Orientation.Vertical,
{ VerticalAlignment = VerticalAlignment.Top,
new Perspex.Controls.Shapes.Path { Gap = 4,
Fill = Brushes.Red, Margin = new Thickness(10),
Stroke = Brushes.Orange, DataTemplates = new DataTemplates
Width = 400, {
Height = 400, new DataTemplate<Item>(x =>
Data = StreamGeometry.Parse("M18.71,19.5C17.88,20.74 17,21.95 15.66,21.97C14.32,22 13.89,21.18 12.37,21.18C10.84,21.18 10.37,21.95 9.1,22C7.79,22.05 6.8,20.68 5.96,19.47C4.25,17 2.94,12.45 4.7,9.39C5.57,7.87 7.13,6.91 8.82,6.88C10.1,6.86 11.32,7.75 12.11,7.75C12.89,7.75 14.37,6.68 15.92,6.84C16.57,6.87 18.39,7.1 19.56,8.82C19.47,8.88 17.39,10.1 17.41,12.63C17.44,15.65 20.06,16.66 20.09,16.67C20.06,16.74 19.67,18.11 18.71,19.5M13,3.5C13.73,2.67 14.94,2.04 15.94,2C16.07,3.17 15.6,4.35 14.9,5.19C14.21,6.04 13.07,6.7 11.95,6.61C11.8,5.46 12.36,4.26 13,3.5Z") new StackPanel
{
Gap = 4,
Orientation = Orientation.Horizontal,
Children = new Controls
{
new Image { Width = 50, Height = 50, Source = new Bitmap("github_icon.png") },
new TextBlock { Text = x.Name, FontSize = 18 }
}
})
}, },
(size = new ScrollBar Children = new Controls
{ {
Minimum = 100, new TextBlock
Maximum = 400, {
Value = 100, Text = "ListBox",
Orientation = Orientation.Horizontal, FontWeight = FontWeight.Medium,
}), FontSize = 20,
new ScrollViewer Foreground = SolidColorBrush.Parse("#212121"),
{ },
Width = 200, new TextBlock
Height = 200, {
CanScrollHorizontally = true, Text = "A list box control.",
Content = new Image FontSize = 13,
{ Foreground = SolidColorBrush.Parse("#727272"),
Source = new Bitmap("github_icon.png"), Margin = new Thickness(0, 0, 0, 10)
[!Layoutable.WidthProperty] = size[!RangeBase.ValueProperty], },
[!Layoutable.HeightProperty] = size[!RangeBase.ValueProperty], new ListBox
}, {
}, BorderThickness = 2,
new ProgressBar Items = s_listBoxData,
{ Height = 300,
[!RangeBase.MinimumProperty] = size[!RangeBase.MinimumProperty], Width = 300,
[!RangeBase.MaximumProperty] = size[!RangeBase.MaximumProperty], },
[!RangeBase.ValueProperty] = size[!RangeBase.ValueProperty], new TextBlock
} {
} Margin = new Thickness(0, 40, 0, 0),
}, Text = "TreeView",
FontWeight = FontWeight.Medium,
FontSize = 20,
Foreground = SolidColorBrush.Parse("#212121"),
},
new TextBlock
{
Text = "A tree view control.",
FontSize = 13,
Foreground = SolidColorBrush.Parse("#727272"),
Margin = new Thickness(0, 0, 0, 10)
},
new TreeView
{
Name = "treeView",
Items = s_treeData,
Height = 300,
BorderThickness = 2,
Width = 300,
}
}
},
}
}; };
} }
private static TabItem ListsTab() private static TabItem ImagesTab()
{ {
ListBox listBox; var imageDeck = new Deck
{
Width = 400,
Height = 400,
Transition = new PageSlide(TimeSpan.FromSeconds(0.25)),
Items = new[]
{
new Image { Source = new Bitmap("github_icon.png"), Width = 400, Height = 400 },
new Image { Source = new Bitmap("pattern.jpg"), Width = 400, Height = 400 },
}
};
return new TabItem imageDeck.AutoSelect = true;
{
Header = "Lists", var next = new Button
Content = new StackPanel {
{ VerticalAlignment = VerticalAlignment.Center,
DataTemplates = new DataTemplates Padding = new Thickness(20),
{ Content = new Perspex.Controls.Shapes.Path
new DataTemplate<Item>(x => {
new StackPanel Data = StreamGeometry.Parse("M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z"),
{ Fill = Brushes.Black
Children = new Controls }
{ };
new TextBlock { Text = x.Name, FontSize = 24 },
new TextBlock { Text = x.Value }, var prev = new Button
} {
}) VerticalAlignment = VerticalAlignment.Center,
}, Padding = new Thickness(20),
Orientation = Orientation.Horizontal, Content = new Perspex.Controls.Shapes.Path
HorizontalAlignment = HorizontalAlignment.Center, {
VerticalAlignment = VerticalAlignment.Center, Data = StreamGeometry.Parse("M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"),
Gap = 8, Fill = Brushes.Black
Children = new Controls }
{ };
new TreeView
{ prev.Click += (s, e) =>
Name = "treeView", {
Items = s_treeData, if (imageDeck.SelectedIndex == 0)
}, imageDeck.SelectedIndex = 1;
(listBox = new ListBox else
{ imageDeck.SelectedIndex--;
Items = s_listBoxData, };
MaxHeight = 300,
}), next.Click += (s, e) =>
new DropDown {
{ if (imageDeck.SelectedIndex == 1)
Items = s_listBoxData, imageDeck.SelectedIndex = 0;
SelectedItem = s_listBoxData[0], else
VerticalAlignment = VerticalAlignment.Center, imageDeck.SelectedIndex++;
} };
}
}, return new TabItem
}; {
} Header = "Images",
Content = new ScrollViewer
{
Content = new StackPanel
{
HorizontalAlignment = HorizontalAlignment.Left,
Orientation = Orientation.Vertical,
VerticalAlignment = VerticalAlignment.Top,
Gap = 4,
Margin = new Thickness(10),
Children = new Controls
{
new TextBlock
{
Text = "Deck",
FontWeight = FontWeight.Medium,
FontSize = 20,
Foreground = SolidColorBrush.Parse("#212121"),
},
new TextBlock
{
Text = "An items control that displays its items as pages that fill the controls.",
FontSize = 13,
Foreground = SolidColorBrush.Parse("#727272"),
Margin = new Thickness(0, 0, 0, 10)
},
new StackPanel
{
Name = "deckVisual",
Orientation = Orientation.Horizontal,
Gap = 4,
Children = new Controls
{
prev,
imageDeck,
next
}
}
}
}
}
};
}
private static TabItem LayoutTab() private static TabItem LayoutTab()
{ {
return new TabItem return new TabItem
{ {
Header = "Layout", Header = "Layout",
Content = new Grid Content = new ScrollViewer
{ {
ColumnDefinitions = new ColumnDefinitions Content = new StackPanel
{ {
new ColumnDefinition(1, GridUnitType.Star), HorizontalAlignment = HorizontalAlignment.Left,
new ColumnDefinition(1, GridUnitType.Star), Orientation = Orientation.Vertical,
}, VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness(50), Gap = 4,
Children = new Controls Margin = new Thickness(10),
{ Children = new Controls
new StackPanel {
{ new TextBlock
Orientation = Orientation.Vertical, {
Gap = 8, Text = "Grid",
Children = new Controls FontWeight = FontWeight.Medium,
{ FontSize = 20,
new Button { HorizontalAlignment = HorizontalAlignment.Left, Content = "Left Aligned" }, Foreground = SolidColorBrush.Parse("#212121"),
new Button { HorizontalAlignment = HorizontalAlignment.Center, Content = "Center Aligned" }, },
new Button { HorizontalAlignment = HorizontalAlignment.Right, Content = "Right Aligned" }, new TextBlock
new Button { HorizontalAlignment = HorizontalAlignment.Stretch, Content = "Stretch" }, {
}, Text = "Lays out child controls according to a grid.",
[Grid.ColumnProperty] = 0, FontSize = 13,
}, Foreground = SolidColorBrush.Parse("#727272"),
new StackPanel Margin = new Thickness(0, 0, 0, 10)
{ },
Orientation = Orientation.Horizontal, new Grid
Gap = 8, {
Children = new Controls Width = 600,
{ ColumnDefinitions = new ColumnDefinitions
new Button { VerticalAlignment = VerticalAlignment.Top, Content = "Top Aligned" }, {
new Button { VerticalAlignment = VerticalAlignment.Center, Content = "Center Aligned" }, new ColumnDefinition(1, GridUnitType.Star),
new Button { VerticalAlignment = VerticalAlignment.Bottom, Content = "Bottom Aligned" }, new ColumnDefinition(1, GridUnitType.Star),
new Button { VerticalAlignment = VerticalAlignment.Stretch, Content = "Stretch" }, },
},
[Grid.ColumnProperty] = 1, RowDefinitions = new RowDefinitions
}, {
}, new RowDefinition(1, GridUnitType.Auto),
} new RowDefinition(1, GridUnitType.Auto)
},
Children = new Controls
{
new Rectangle
{
Fill = SolidColorBrush.Parse("#FF5722"),
[Grid.ColumnSpanProperty] = 2,
Height = 200,
Margin = new Thickness(2.5)
},
new Rectangle
{
Fill = SolidColorBrush.Parse("#FF5722"),
[Grid.RowProperty] = 1,
Height = 100,
Margin = new Thickness(2.5)
},
new Rectangle
{
Fill = SolidColorBrush.Parse("#FF5722"),
[Grid.RowProperty] = 1,
[Grid.ColumnProperty] = 1,
Height = 100,
Margin = new Thickness(2.5)
},
},
},
new TextBlock
{
Margin = new Thickness(0, 40, 0, 0),
Text = "StackPanel",
FontWeight = FontWeight.Medium,
FontSize = 20,
Foreground = SolidColorBrush.Parse("#212121"),
},
new TextBlock
{
Text = "A panel which lays out its children horizontally or vertically.",
FontSize = 13,
Foreground = SolidColorBrush.Parse("#727272"),
Margin = new Thickness(0, 0, 0, 10)
},
new StackPanel
{
Orientation = Orientation.Vertical,
Gap = 4,
Width = 300,
Children = new Controls
{
new Rectangle
{
Fill = SolidColorBrush.Parse("#FFC107"),
Height = 50,
},
new Rectangle
{
Fill = SolidColorBrush.Parse("#FFC107"),
Height = 50,
},
new Rectangle
{
Fill = SolidColorBrush.Parse("#FFC107"),
Height = 50,
},
}
},
}
}
}
}; };
} }
@ -506,70 +691,88 @@ namespace TestApplication
var result = new TabItem var result = new TabItem
{ {
Header = "Animations", Header = "Animations",
Content = new Grid Content = new StackPanel
{ {
ColumnDefinitions = new ColumnDefinitions HorizontalAlignment = HorizontalAlignment.Left,
{ Orientation = Orientation.Vertical,
new ColumnDefinition(1, GridUnitType.Star), VerticalAlignment = VerticalAlignment.Top,
new ColumnDefinition(1, GridUnitType.Star), Gap = 4,
}, Margin = new Thickness(10),
RowDefinitions = new RowDefinitions
{
new RowDefinition(1, GridUnitType.Star),
new RowDefinition(GridLength.Auto),
},
Children = new Controls Children = new Controls
{ {
(border1 = new Border new TextBlock
{ {
Width = 100, Text = "Animations",
Height = 100, FontWeight = FontWeight.Medium,
HorizontalAlignment = HorizontalAlignment.Center, FontSize = 20,
VerticalAlignment = VerticalAlignment.Center, Foreground = SolidColorBrush.Parse("#212121"),
Background = Brushes.Crimson, },
RenderTransform = new RotateTransform(), new TextBlock
Child = new TextBox {
{ Text = "A few animations showcased below",
Background = Brushes.White, FontSize = 13,
Text = "Hello!", Foreground = SolidColorBrush.Parse("#727272"),
HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, 0, 0, 10)
VerticalAlignment = VerticalAlignment.Center, },
}, (button1 = new Button
}), {
(border2 = new Border Content = "Animate",
{ Width = 120,
Width = 100, [Grid.ColumnProperty] = 1,
Height = 100, [Grid.RowProperty] = 1,
HorizontalAlignment = HorizontalAlignment.Center, }),
VerticalAlignment = VerticalAlignment.Center, new Canvas
Background = Brushes.Coral, {
Child = new Image Children = new Controls
{ {
Source = new Bitmap("github_icon.png"), (border1 = new Border
HorizontalAlignment = HorizontalAlignment.Center, {
VerticalAlignment = VerticalAlignment.Center, Width = 100,
}, Height = 100,
RenderTransform = (rotate = new RotateTransform HorizontalAlignment = HorizontalAlignment.Center,
{ VerticalAlignment = VerticalAlignment.Center,
PropertyTransitions = new PropertyTransitions Background = Brushes.Crimson,
{ RenderTransform = new RotateTransform(),
RotateTransform.AngleProperty.Transition(500), Child = new TextBox
} {
}), Background = Brushes.White,
PropertyTransitions = new PropertyTransitions Text = "Hello!",
{ HorizontalAlignment = HorizontalAlignment.Center,
Layoutable.WidthProperty.Transition(300), VerticalAlignment = VerticalAlignment.Center,
Layoutable.HeightProperty.Transition(1000), },
}, [Canvas.LeftProperty] = 100,
[Grid.ColumnProperty] = 1, [Canvas.TopProperty] = 100,
}), }),
(button1 = new Button (border2 = new Border
{ {
HorizontalAlignment = HorizontalAlignment.Center, Width = 100,
Content = "Animate", Height = 100,
[Grid.ColumnProperty] = 1, HorizontalAlignment = HorizontalAlignment.Center,
[Grid.RowProperty] = 1, VerticalAlignment = VerticalAlignment.Center,
}), Background = Brushes.Coral,
Child = new Image
{
Source = new Bitmap("github_icon.png"),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
},
RenderTransform = (rotate = new RotateTransform
{
PropertyTransitions = new PropertyTransitions
{
RotateTransform.AngleProperty.Transition(500),
}
}),
PropertyTransitions = new PropertyTransitions
{
Layoutable.WidthProperty.Transition(300),
Layoutable.HeightProperty.Transition(1000),
},
[Canvas.LeftProperty] = 400,
[Canvas.TopProperty] = 100,
}),
}
}
}, },
}, },
}; };

5
samples/TestApplication/TestApplication.csproj

@ -84,7 +84,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Gtk\Perspex.Cairo\Perspex.Cairo.csproj"> <ProjectReference Include="..\..\src\Gtk\Perspex.Cairo\Perspex.Cairo.csproj">
<Project>{fb05ac90-89ba-4f2f-a924-f37875fb547c}</Project> <Project>{FB05AC90-89BA-4F2F-A924-F37875FB547C}</Project>
<Name>Perspex.Cairo</Name> <Name>Perspex.Cairo</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\src\Perspex.Animation\Perspex.Animation.csproj"> <ProjectReference Include="..\..\src\Perspex.Animation\Perspex.Animation.csproj">
@ -153,6 +153,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<EmbeddedResource Include="html.htm" /> <EmbeddedResource Include="html.htm" />
<Content Include="pattern.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\src\Shared\perspex.platform.targets" /> <Import Project="..\..\src\Shared\perspex.platform.targets" />

BIN
samples/TestApplication/pattern.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

15
src/Gtk/Perspex.Cairo/Media/DrawingContext.cs

@ -248,8 +248,10 @@ namespace Perspex.Cairo.Media
private double opacityOverride = 1.0f; private double opacityOverride = 1.0f;
private BrushImpl SetBrush(Brush brush, Size destinationSize) private IDisposable SetBrush(Brush brush, Size destinationSize)
{ {
_context.Save ();
var solid = brush as SolidColorBrush; var solid = brush as SolidColorBrush;
var linearGradientBrush = brush as LinearGradientBrush; var linearGradientBrush = brush as LinearGradientBrush;
var imageBrush = brush as ImageBrush; var imageBrush = brush as ImageBrush;
@ -278,11 +280,13 @@ namespace Perspex.Cairo.Media
} }
_context.SetSource(impl.PlatformBrush); _context.SetSource(impl.PlatformBrush);
return Disposable.Create(() =>
return impl; {
_context.Restore();
});
} }
private BrushImpl SetPen(Pen pen, Size destinationSize) private IDisposable SetPen(Pen pen, Size destinationSize)
{ {
if (pen.DashStyle != null) if (pen.DashStyle != null)
{ {
@ -302,6 +306,9 @@ namespace Perspex.Cairo.Media
_context.LineJoin = Cairo.LineJoin.Miter; _context.LineJoin = Cairo.LineJoin.Miter;
_context.LineCap = Cairo.LineCap.Butt; _context.LineCap = Cairo.LineCap.Butt;
if (pen.Brush == null)
return Disposable.Empty;
return SetBrush(pen.Brush, destinationSize); return SetBrush(pen.Brush, destinationSize);
} }
} }

3
src/Gtk/Perspex.Cairo/Media/StreamGeometryContextImpl.cs

@ -60,9 +60,8 @@ namespace Perspex.Cairo.Media
_context.ClosePath (); _context.ClosePath ();
Path = _context.CopyPath (); Path = _context.CopyPath ();
Bounds = _context.FillExtents ().ToPerspex ();
} }
Bounds = _context.FillExtents ().ToPerspex ();
} }
public void Dispose() public void Dispose()

6
src/Gtk/Perspex.Cairo/Media/StreamGeometryImpl.cs

@ -18,9 +18,9 @@ namespace Perspex.Cairo.Media
_impl = new StreamGeometryContextImpl(null); _impl = new StreamGeometryContextImpl(null);
} }
public StreamGeometryImpl(Cairo.Path path) public StreamGeometryImpl(StreamGeometryContextImpl impl)
{ {
_impl = new StreamGeometryContextImpl(path); _impl = impl;
} }
public Rect Bounds public Rect Bounds
@ -53,7 +53,7 @@ namespace Perspex.Cairo.Media
public IStreamGeometryImpl Clone() public IStreamGeometryImpl Clone()
{ {
return new StreamGeometryImpl(_impl.Path); return new StreamGeometryImpl(_impl);
} }
public Rect GetRenderBounds(double strokeThickness) public Rect GetRenderBounds(double strokeThickness)

2
src/Gtk/Perspex.Cairo/Media/TileBrushes.cs

@ -30,7 +30,7 @@ namespace Perspex.Cairo.Media
var translate = CalculateTranslate(brush, sourceRect, destinationRect, scale); var translate = CalculateTranslate(brush, sourceRect, destinationRect, scale);
var intermediateSize = CalculateIntermediateSize(tileMode, targetSize, destinationRect.Size); var intermediateSize = CalculateIntermediateSize(tileMode, targetSize, destinationRect.Size);
using (var intermediate = new ImageSurface(Format.ARGB32, (int)intermediateSize.Width, (int)intermediateSize.Height)) var intermediate = new ImageSurface (Format.ARGB32, (int)intermediateSize.Width, (int)intermediateSize.Height);
using (var context = new Context(intermediate)) using (var context = new Context(intermediate))
{ {
Rect drawRect; Rect drawRect;

3
src/Gtk/Perspex.Cairo/Perspex.Cairo.csproj

@ -54,6 +54,9 @@
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Splat, Version=1.6.2.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath> <HintPath>..\..\..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
</Reference> </Reference>
<Reference Include="OpenTK">
<HintPath>..\..\..\packages\OpenTK.1.1.1589.5942\lib\NET40\OpenTK.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CairoPlatform.cs" /> <Compile Include="CairoPlatform.cs" />

1
src/Gtk/Perspex.Cairo/packages.config

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="OpenTK" version="1.1.1589.5942" targetFramework="net45" />
<package id="Rx-Core" version="2.2.5" targetFramework="net45" userInstalled="true" /> <package id="Rx-Core" version="2.2.5" targetFramework="net45" userInstalled="true" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" userInstalled="true" /> <package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" userInstalled="true" />
<package id="Splat" version="1.6.2" targetFramework="net45" userInstalled="true" /> <package id="Splat" version="1.6.2" targetFramework="net45" userInstalled="true" />

1
src/Gtk/Perspex.Gtk/WindowImpl.cs

@ -89,7 +89,6 @@ namespace Perspex.Gtk
public void Invalidate(Rect rect) public void Invalidate(Rect rect)
{ {
base.GdkWindow.InvalidateRect (new Rectangle ((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), true); base.GdkWindow.InvalidateRect (new Rectangle ((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), true);
} }
public Point PointToScreen(Point point) public Point PointToScreen(Point point)

17
src/Perspex.Themes.Default/ToggleButtonStyle.cs

@ -29,8 +29,8 @@ namespace Perspex.Themes.Default
Setters = new[] Setters = new[]
{ {
new Setter(TemplatedControl.TemplateProperty, new ControlTemplate<ToggleButton>(Template)), new Setter(TemplatedControl.TemplateProperty, new ControlTemplate<ToggleButton>(Template)),
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffdddddd)), new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffaaaaaa)),
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff707070)), new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xffaaaaaa)),
new Setter(TemplatedControl.BorderThicknessProperty, 2.0), new Setter(TemplatedControl.BorderThicknessProperty, 2.0),
new Setter(Control.FocusAdornerProperty, new FuncTemplate<IControl>(ButtonStyle.FocusAdornerTemplate)), new Setter(Control.FocusAdornerProperty, new FuncTemplate<IControl>(ButtonStyle.FocusAdornerTemplate)),
new Setter(TemplatedControl.ForegroundProperty, new SolidColorBrush(0xff000000)), new Setter(TemplatedControl.ForegroundProperty, new SolidColorBrush(0xff000000)),
@ -42,36 +42,37 @@ namespace Perspex.Themes.Default
{ {
Setters = new[] Setters = new[]
{ {
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff7f7f7f)), new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff777777)),
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff77777)),
}, },
}, },
new Style(x => x.OfType<ToggleButton>().Class(":pointerover").Template().Name("border")) new Style(x => x.OfType<ToggleButton>().Class(":pointerover").Template().Name("border"))
{ {
Setters = new[] Setters = new[]
{ {
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffbee6fd)), new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff888888)),
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff3c7fb1)), new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff888888)),
}, },
}, },
new Style(x => x.OfType<ToggleButton>().Class(":checked").Class(":pointerover").Template().Name("border")) new Style(x => x.OfType<ToggleButton>().Class(":checked").Class(":pointerover").Template().Name("border"))
{ {
Setters = new[] Setters = new[]
{ {
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffa0a0a0)), new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff777777)),
}, },
}, },
new Style(x => x.OfType<ToggleButton>().Class(":pointerover").Class(":pressed").Template().Name("border")) new Style(x => x.OfType<ToggleButton>().Class(":pointerover").Class(":pressed").Template().Name("border"))
{ {
Setters = new[] Setters = new[]
{ {
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffc4e5f6)), new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff888888)),
}, },
}, },
new Style(x => x.OfType<ToggleButton>().Class(":pressed").Template().Name("border")) new Style(x => x.OfType<ToggleButton>().Class(":pressed").Template().Name("border"))
{ {
Setters = new[] Setters = new[]
{ {
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xffff628b)), new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff888888)),
}, },
}, },
new Style(x => x.OfType<ToggleButton>().Class(":disabled").Template().Name("border")) new Style(x => x.OfType<ToggleButton>().Class(":disabled").Template().Name("border"))

Loading…
Cancel
Save