diff --git a/native/Avalonia.Native/src/OSX/window.mm b/native/Avalonia.Native/src/OSX/window.mm
index 908b9e1022..3acc5e365b 100644
--- a/native/Avalonia.Native/src/OSX/window.mm
+++ b/native/Avalonia.Native/src/OSX/window.mm
@@ -1283,6 +1283,9 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
_closed = false;
_lastScaling = [self backingScaleFactor];
+ [self setOpaque:NO];
+ [self setBackgroundColor: [NSColor clearColor]];
+ [self invalidateShadow];
return self;
}
diff --git a/readme.md b/readme.md
index 512b35a454..97c6509362 100644
--- a/readme.md
+++ b/readme.md
@@ -22,7 +22,7 @@ Avalonia [Visual Studio Extension](https://marketplace.visualstudio.com/items?it
For those without Visual Studio, a starter guide for .NET Core CLI can be found [here](http://avaloniaui.net/docs/quickstart/create-new-project#net-core).
-Avalonia is delivered via NuGet package manager. You can find the packages here: ([stable(ish)](https://www.nuget.org/packages/Avalonia/), [nightly](https://github.com/AvaloniaUI/Avalonia/wiki/Using-nightly-build-feed))
+Avalonia is delivered via NuGet package manager. You can find the packages here: [stable(ish)](https://www.nuget.org/packages/Avalonia/)
Use these commands in the Package Manager console to install Avalonia manually:
```
diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml
index 874560a294..cbe2c62890 100644
--- a/samples/ControlCatalog/MainView.xaml
+++ b/samples/ControlCatalog/MainView.xaml
@@ -32,7 +32,11 @@
-
+
+
+
diff --git a/samples/ControlCatalog/Pages/ImagePage.xaml b/samples/ControlCatalog/Pages/ImagePage.xaml
index b44fac27cb..9b8f8af765 100644
--- a/samples/ControlCatalog/Pages/ImagePage.xaml
+++ b/samples/ControlCatalog/Pages/ImagePage.xaml
@@ -1,45 +1,52 @@
-
- Image
- Displays an image
-
-
-
- No Stretch
-
-
-
-
- Fill
-
-
+
+
+ Image
+ Displays an image
+
-
- Uniform
-
-
+
+
+
+ Bitmap
+
+ None
+ Fill
+ Uniform
+ UniformToFill
+
+
+
-
- UniformToFill
-
-
-
-
- Window Icon as an Image
-
-
-
+
+ Drawing
+
+ None
+ Fill
+ Uniform
+ UniformToFill
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/ControlCatalog/Pages/ImagePage.xaml.cs b/samples/ControlCatalog/Pages/ImagePage.xaml.cs
index 792b25963e..bbe89d1dfd 100644
--- a/samples/ControlCatalog/Pages/ImagePage.xaml.cs
+++ b/samples/ControlCatalog/Pages/ImagePage.xaml.cs
@@ -1,40 +1,41 @@
-using System.IO;
-using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
-using Avalonia.Media.Imaging;
+using Avalonia.Media;
namespace ControlCatalog.Pages
{
public class ImagePage : UserControl
{
- private Image iconImage;
+ private readonly Image _bitmapImage;
+ private readonly Image _drawingImage;
+
public ImagePage()
{
- this.InitializeComponent();
+ InitializeComponent();
+ _bitmapImage = this.FindControl("bitmapImage");
+ _drawingImage = this.FindControl("drawingImage");
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
- iconImage = this.Get("Icon");
}
- protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
+ public void BitmapStretchChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (_bitmapImage != null)
+ {
+ var comboxBox = (ComboBox)sender;
+ _bitmapImage.Stretch = (Stretch)comboxBox.SelectedIndex;
+ }
+ }
+
+ public void DrawingStretchChanged(object sender, SelectionChangedEventArgs e)
{
- base.OnAttachedToVisualTree(e);
- if (iconImage.Source == null)
+ if (_drawingImage != null)
{
- var windowRoot = e.Root as Window;
- if (windowRoot != null)
- {
- using (var stream = new MemoryStream())
- {
- windowRoot.Icon.Save(stream);
- stream.Seek(0, SeekOrigin.Begin);
- iconImage.Source = new Bitmap(stream);
- }
- }
+ var comboxBox = (ComboBox)sender;
+ _drawingImage.Stretch = (Stretch)comboxBox.SelectedIndex;
}
}
}
diff --git a/samples/RenderDemo/Pages/RenderTargetBitmapPage.cs b/samples/RenderDemo/Pages/RenderTargetBitmapPage.cs
index 3eb2276c48..f263786ab7 100644
--- a/samples/RenderDemo/Pages/RenderTargetBitmapPage.cs
+++ b/samples/RenderDemo/Pages/RenderTargetBitmapPage.cs
@@ -39,7 +39,7 @@ namespace RenderDemo.Pages
ctx.FillRectangle(Brushes.Fuchsia, new Rect(50, 50, 100, 100));
}
- context.DrawImage(_bitmap, 1,
+ context.DrawImage(_bitmap,
new Rect(0, 0, 200, 200),
new Rect(0, 0, 200, 200));
Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Background);
diff --git a/scripts/avalonia-rename.ps1 b/scripts/avalonia-rename.ps1
deleted file mode 100644
index c77dffb55d..0000000000
--- a/scripts/avalonia-rename.ps1
+++ /dev/null
@@ -1,64 +0,0 @@
-function Get-NewDirectoryName {
- param ([System.IO.DirectoryInfo]$item)
-
- $name = $item.Name.Replace("perspex", "avalonia")
- $name = $name.Replace("Perspex", "Avalonia")
- Join-Path $item.Parent.FullName $name
-}
-
-function Get-NewFileName {
- param ([System.IO.FileInfo]$item)
-
- $name = $item.Name.Replace("perspex", "avalonia")
- $name = $name.Replace("Perspex", "Avalonia")
- Join-Path $item.DirectoryName $name
-}
-
-function Rename-Contents {
- param ([System.IO.FileInfo] $file)
-
- $extensions = @(".cs",".xaml",".csproj",".sln",".md",".json",".yml",".partial",".ps1",".nuspec",".htm",".html",".gitmodules".".xml",".plist",".targets",".projitems",".shproj",".xib")
-
- if ($extensions.Contains($file.Extension)) {
- $text = [IO.File]::ReadAllText($file.FullName)
- $text = $text.Replace("github.com/perspex", "github.com/avaloniaui")
- $text = $text.Replace("github.com/Perspex", "github.com/AvaloniaUI")
- $text = $text.Replace("perspex", "avalonia")
- $text = $text.Replace("Perspex", "Avalonia")
- $text = $text.Replace("PERSPEX", "AVALONIA")
- [IO.File]::WriteAllText($file.FullName, $text)
- }
-}
-
-function Process-Files {
- param ([System.IO.DirectoryInfo] $item)
-
- $dirs = Get-ChildItem -Path $item.FullName -Directory
- $files = Get-ChildItem -Path $item.FullName -File
-
- foreach ($dir in $dirs) {
- Process-Files $dir.FullName
- }
-
- foreach ($file in $files) {
- Rename-Contents $file
-
- $renamed = Get-NewFileName $file
-
- if ($file.FullName -ne $renamed) {
- Write-Host git mv $file.FullName $renamed
- & git mv $file.FullName $renamed
- }
- }
-
- $renamed = Get-NewDirectoryName $item
-
- if ($item.FullName -ne $renamed) {
- Write-Host git mv $item.FullName $renamed
- & git mv $item.FullName $renamed
- }
-}
-
-& git submodule deinit .
-& git clean -xdf
-Process-Files .
diff --git a/src/Avalonia.Animation/IterationCount.cs b/src/Avalonia.Animation/IterationCount.cs
index e9cd0686d8..9f57455639 100644
--- a/src/Avalonia.Animation/IterationCount.cs
+++ b/src/Avalonia.Animation/IterationCount.cs
@@ -63,7 +63,7 @@ namespace Avalonia.Animation
public IterationType RepeatType => _type;
///
- /// Gets a value that indicates whether the is set to loop.
+ /// Gets a value that indicates whether the is set to Infinite.
///
public bool IsInfinite => _type == IterationType.Infinite;
diff --git a/src/Avalonia.Controls/DrawingPresenter.cs b/src/Avalonia.Controls/DrawingPresenter.cs
index b30a8668fd..ee27aa7ec1 100644
--- a/src/Avalonia.Controls/DrawingPresenter.cs
+++ b/src/Avalonia.Controls/DrawingPresenter.cs
@@ -1,9 +1,11 @@
-using Avalonia.Controls.Shapes;
+using System;
+using Avalonia.Controls.Shapes;
using Avalonia.Media;
using Avalonia.Metadata;
namespace Avalonia.Controls
{
+ [Obsolete("Use Image control with DrawingImage source")]
public class DrawingPresenter : Control
{
static DrawingPresenter()
diff --git a/src/Avalonia.Controls/Image.cs b/src/Avalonia.Controls/Image.cs
index ff6cd482df..41b6e5449a 100644
--- a/src/Avalonia.Controls/Image.cs
+++ b/src/Avalonia.Controls/Image.cs
@@ -14,8 +14,8 @@ namespace Avalonia.Controls
///
/// Defines the property.
///
- public static readonly StyledProperty SourceProperty =
- AvaloniaProperty.Register(nameof(Source));
+ public static readonly StyledProperty SourceProperty =
+ AvaloniaProperty.Register(nameof(Source));
///
/// Defines the property.
@@ -23,6 +23,14 @@ namespace Avalonia.Controls
public static readonly StyledProperty StretchProperty =
AvaloniaProperty.Register(nameof(Stretch), Stretch.Uniform);
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty StretchDirectionProperty =
+ AvaloniaProperty.Register(
+ nameof(StretchDirection),
+ StretchDirection.Both);
+
static Image()
{
AffectsRender(SourceProperty, StretchProperty);
@@ -30,9 +38,9 @@ namespace Avalonia.Controls
}
///
- /// Gets or sets the bitmap image that will be displayed.
+ /// Gets or sets the image that will be displayed.
///
- public IBitmap Source
+ public IImage Source
{
get { return GetValue(SourceProperty); }
set { SetValue(SourceProperty, value); }
@@ -43,10 +51,19 @@ namespace Avalonia.Controls
///
public Stretch Stretch
{
- get { return (Stretch)GetValue(StretchProperty); }
+ get { return GetValue(StretchProperty); }
set { SetValue(StretchProperty, value); }
}
+ ///
+ /// Gets or sets a value controlling in what direction the image will be stretched.
+ ///
+ public StretchDirection StretchDirection
+ {
+ get { return GetValue(StretchDirectionProperty); }
+ set { SetValue(StretchDirectionProperty, value); }
+ }
+
///
/// Renders the control.
///
@@ -58,8 +75,8 @@ namespace Avalonia.Controls
if (source != null)
{
Rect viewPort = new Rect(Bounds.Size);
- Size sourceSize = new Size(source.PixelSize.Width, source.PixelSize.Height);
- Vector scale = Stretch.CalculateScaling(Bounds.Size, sourceSize);
+ Size sourceSize = source.Size;
+ Vector scale = Stretch.CalculateScaling(Bounds.Size, sourceSize, StretchDirection);
Size scaledSize = sourceSize * scale;
Rect destRect = viewPort
.CenterRect(new Rect(scaledSize))
@@ -69,7 +86,7 @@ namespace Avalonia.Controls
var interpolationMode = RenderOptions.GetBitmapInterpolationMode(this);
- context.DrawImage(source, 1, sourceRect, destRect, interpolationMode);
+ context.DrawImage(source, sourceRect, destRect, interpolationMode);
}
}
@@ -85,15 +102,7 @@ namespace Avalonia.Controls
if (source != null)
{
- Size sourceSize = new Size(source.PixelSize.Width, source.PixelSize.Height);
- if (double.IsInfinity(availableSize.Width) || double.IsInfinity(availableSize.Height))
- {
- result = sourceSize;
- }
- else
- {
- result = Stretch.CalculateSize(availableSize, sourceSize);
- }
+ result = Stretch.CalculateSize(availableSize, source.Size, StretchDirection);
}
return result;
@@ -106,7 +115,7 @@ namespace Avalonia.Controls
if (source != null)
{
- var sourceSize = new Size(source.PixelSize.Width, source.PixelSize.Height);
+ var sourceSize = source.Size;
var result = Stretch.CalculateSize(finalSize, sourceSize);
return result;
}
diff --git a/src/Avalonia.Controls/Remote/RemoteWidget.cs b/src/Avalonia.Controls/Remote/RemoteWidget.cs
index 539fe1ec4b..c7a1a24c25 100644
--- a/src/Avalonia.Controls/Remote/RemoteWidget.cs
+++ b/src/Avalonia.Controls/Remote/RemoteWidget.cs
@@ -83,7 +83,7 @@ namespace Avalonia.Controls.Remote
Marshal.Copy(_lastFrame.Data, y * _lastFrame.Stride,
new IntPtr(l.Address.ToInt64() + l.RowBytes * y), lineLen);
}
- context.DrawImage(_bitmap, 1, new Rect(0, 0, _bitmap.PixelSize.Width, _bitmap.PixelSize.Height),
+ context.DrawImage(_bitmap, new Rect(0, 0, _bitmap.PixelSize.Width, _bitmap.PixelSize.Height),
new Rect(Bounds.Size));
}
base.Render(context);
diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs
index 3d472fca18..fbac2e02ec 100644
--- a/src/Avalonia.Controls/TextBox.cs
+++ b/src/Avalonia.Controls/TextBox.cs
@@ -390,8 +390,10 @@ namespace Avalonia.Controls
{
return;
}
+
_undoRedoHelper.Snapshot();
HandleTextInput(text);
+ _undoRedoHelper.Snapshot();
}
protected override void OnKeyDown(KeyEventArgs e)
@@ -401,12 +403,12 @@ namespace Avalonia.Controls
bool movement = false;
bool selection = false;
bool handled = false;
- var modifiers = e.Modifiers;
+ var modifiers = e.KeyModifiers;
var keymap = AvaloniaLocator.Current.GetService();
bool Match(List gestures) => gestures.Any(g => g.Matches(e));
- bool DetectSelection() => e.Modifiers.HasFlag(keymap.SelectionModifiers);
+ bool DetectSelection() => e.KeyModifiers.HasFlag(keymap.SelectionModifiers);
if (Match(keymap.SelectAll))
{
diff --git a/src/Avalonia.Input/Platform/PlatformHotkeyConfiguration.cs b/src/Avalonia.Input/Platform/PlatformHotkeyConfiguration.cs
index a758a328be..053f894755 100644
--- a/src/Avalonia.Input/Platform/PlatformHotkeyConfiguration.cs
+++ b/src/Avalonia.Input/Platform/PlatformHotkeyConfiguration.cs
@@ -4,14 +4,14 @@ namespace Avalonia.Input.Platform
{
public class PlatformHotkeyConfiguration
{
- public PlatformHotkeyConfiguration() : this(InputModifiers.Control)
+ public PlatformHotkeyConfiguration() : this(KeyModifiers.Control)
{
}
- public PlatformHotkeyConfiguration(InputModifiers commandModifiers,
- InputModifiers selectionModifiers = InputModifiers.Shift,
- InputModifiers wholeWordTextActionModifiers = InputModifiers.Control)
+ public PlatformHotkeyConfiguration(KeyModifiers commandModifiers,
+ KeyModifiers selectionModifiers = KeyModifiers.Shift,
+ KeyModifiers wholeWordTextActionModifiers = KeyModifiers.Control)
{
CommandModifiers = commandModifiers;
SelectionModifiers = selectionModifiers;
@@ -75,9 +75,9 @@ namespace Avalonia.Input.Platform
};
}
- public InputModifiers CommandModifiers { get; set; }
- public InputModifiers WholeWordTextActionModifiers { get; set; }
- public InputModifiers SelectionModifiers { get; set; }
+ public KeyModifiers CommandModifiers { get; set; }
+ public KeyModifiers WholeWordTextActionModifiers { get; set; }
+ public KeyModifiers SelectionModifiers { get; set; }
public List Copy { get; set; }
public List Cut { get; set; }
public List Paste { get; set; }
diff --git a/src/Avalonia.Native/AvaloniaNativePlatform.cs b/src/Avalonia.Native/AvaloniaNativePlatform.cs
index 571475c7ea..756619fa9f 100644
--- a/src/Avalonia.Native/AvaloniaNativePlatform.cs
+++ b/src/Avalonia.Native/AvaloniaNativePlatform.cs
@@ -101,7 +101,7 @@ namespace Avalonia.Native
.Bind().ToConstant(new DefaultRenderTimer(60))
.Bind().ToConstant(new SystemDialogs(_factory.CreateSystemDialogs()))
.Bind().ToConstant(new GlPlatformFeature(_factory.ObtainGlFeature()))
- .Bind().ToConstant(new PlatformHotkeyConfiguration(InputModifiers.Windows))
+ .Bind().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Meta))
.Bind().ToConstant(new MacOSMountedVolumeInfoProvider());
}
diff --git a/src/Avalonia.Styling/Styling/ISetStyleParent.cs b/src/Avalonia.Styling/Controls/ISetResourceParent.cs
similarity index 61%
rename from src/Avalonia.Styling/Styling/ISetStyleParent.cs
rename to src/Avalonia.Styling/Controls/ISetResourceParent.cs
index bca3d9d714..a1264adc34 100644
--- a/src/Avalonia.Styling/Styling/ISetStyleParent.cs
+++ b/src/Avalonia.Styling/Controls/ISetResourceParent.cs
@@ -1,29 +1,27 @@
-using Avalonia.Controls;
-
-namespace Avalonia.Styling
+namespace Avalonia.Controls
{
///
- /// Defines an interface through which a 's parent can be set.
+ /// Defines an interface through which an 's parent can be set.
///
///
/// You should not usually need to use this interface - it is for internal use only.
///
- public interface ISetStyleParent : IStyle
+ public interface ISetResourceParent : IResourceNode
{
///
- /// Sets the style parent.
+ /// Sets the resource parent.
///
/// The parent.
void SetParent(IResourceNode parent);
///
- /// Notifies the style that a change has been made to resources that apply to it.
+ /// Notifies the resource node that a change has been made to the resources in its parent.
///
/// The event args.
///
/// This method will be called automatically by the framework, you should not need to call
/// this method yourself.
///
- void NotifyResourcesChanged(ResourcesChangedEventArgs e);
+ void ParentResourcesChanged(ResourcesChangedEventArgs e);
}
}
diff --git a/src/Avalonia.Styling/Controls/ResourceDictionary.cs b/src/Avalonia.Styling/Controls/ResourceDictionary.cs
index 901e27b7b7..acc2db1ff7 100644
--- a/src/Avalonia.Styling/Controls/ResourceDictionary.cs
+++ b/src/Avalonia.Styling/Controls/ResourceDictionary.cs
@@ -12,8 +12,12 @@ namespace Avalonia.Controls
///
/// An indexed dictionary of resources.
///
- public class ResourceDictionary : AvaloniaDictionary