Skip to content

Commit

Permalink
Merge branch 'master' into feature/drawing-image
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacato committed Jan 8, 2020
2 parents db76f04 + 08c9710 commit a71b3ba
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 78 deletions.
3 changes: 3 additions & 0 deletions native/Avalonia.Native/src/OSX/window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,9 @@ -(AvnWindow*) initWithParent: (WindowBaseImpl*) parent
_closed = false;

_lastScaling = [self backingScaleFactor];
[self setOpaque:NO];
[self setBackgroundColor: [NSColor clearColor]];
[self invalidateShadow];
return self;
}

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>NuGet</b> 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 <b>NuGet</b> 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:
```
Expand Down
64 changes: 0 additions & 64 deletions scripts/avalonia-rename.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion src/Avalonia.Animation/IterationCount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public IterationCount(ulong value, IterationType type)
public IterationType RepeatType => _type;

/// <summary>
/// Gets a value that indicates whether the <see cref="IterationCount"/> is set to loop.
/// Gets a value that indicates whether the <see cref="IterationCount"/> is set to Infinite.
/// </summary>
public bool IsInfinite => _type == IterationType.Infinite;

Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Controls/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,12 @@ protected override void OnKeyDown(KeyEventArgs e)
bool movement = false;
bool selection = false;
bool handled = false;
var modifiers = e.Modifiers;
var modifiers = e.KeyModifiers;

var keymap = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>();

bool Match(List<KeyGesture> 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))
{
Expand Down
14 changes: 7 additions & 7 deletions src/Avalonia.Input/Platform/PlatformHotkeyConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,9 +75,9 @@ public PlatformHotkeyConfiguration() : this(InputModifiers.Control)
};
}

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<KeyGesture> Copy { get; set; }
public List<KeyGesture> Cut { get; set; }
public List<KeyGesture> Paste { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Native/AvaloniaNativePlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void DoInitialize(AvaloniaNativePlatformOptions options)
.Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
.Bind<ISystemDialogImpl>().ToConstant(new SystemDialogs(_factory.CreateSystemDialogs()))
.Bind<IWindowingPlatformGlFeature>().ToConstant(new GlPlatformFeature(_factory.ObtainGlFeature()))
.Bind<PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(InputModifiers.Windows))
.Bind<PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Meta))
.Bind<IMountedVolumeInfoProvider>().ToConstant(new MacOSMountedVolumeInfoProvider());
}

Expand Down
4 changes: 3 additions & 1 deletion src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ private void Render(DrawingContext context, IVisual visual, Rect clipRect)

if (!child.ClipToBounds || clipRect.Intersects(childBounds))
{
var childClipRect = clipRect.Translate(-childBounds.Position);
var childClipRect = child.RenderTransform == null
? clipRect.Translate(-childBounds.Position)
: clipRect;
Render(context, child, childClipRect);
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.X11/X11Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Initialize(X11PlatformOptions options)
.Bind<IPlatformThreadingInterface>().ToConstant(new X11PlatformThreading(this))
.Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
.Bind<IRenderLoop>().ToConstant(new RenderLoop())
.Bind<PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(InputModifiers.Control))
.Bind<PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Control))
.Bind<IKeyboardDevice>().ToFunc(() => KeyboardDevice)
.Bind<IStandardCursorFactory>().ToConstant(new X11CursorFactory(Display))
.Bind<IClipboard>().ToConstant(new X11Clipboard(this))
Expand Down
136 changes: 136 additions & 0 deletions tests/Avalonia.Visuals.UnitTests/Rendering/ImmediateRendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,141 @@ public void Should_Render_Child_In_Parent_With_RenderTransform2()

Assert.Equal(1, rendered);
}

[Fact]
public void Should_Not_Clip_Children_With_RenderTransform_When_In_Bounds()
{
const int RootWidth = 300;
const int RootHeight = 300;

var rootGrid = new Grid
{
Width = RootWidth,
Height = RootHeight,
ClipToBounds = true
};

var stackPanel = new StackPanel
{
Orientation = Orientation.Horizontal,
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Right,
Margin = new Thickness(0, 10, 0, 0),
RenderTransformOrigin = new RelativePoint(new Point(0, 0), RelativeUnit.Relative),
RenderTransform = new TransformGroup
{
Children =
{
new RotateTransform { Angle = 90 },
new TranslateTransform { X = 240 }
}
}
};

rootGrid.Children.Add(stackPanel);

TestControl CreateControl()
=> new TestControl
{
Width = 80,
Height = 40,
Margin = new Thickness(0, 0, 5, 0),
ClipToBounds = true
};

var control1 = CreateControl();
var control2 = CreateControl();
var control3 = CreateControl();

stackPanel.Children.Add(control1);
stackPanel.Children.Add(control2);
stackPanel.Children.Add(control3);

var root = new TestRoot(rootGrid);
root.Renderer = new ImmediateRenderer(root);
root.LayoutManager.ExecuteInitialLayoutPass(root);

var rootSize = new Size(RootWidth, RootHeight);
root.Measure(rootSize);
root.Arrange(new Rect(rootSize));

root.Renderer.Paint(root.Bounds);

Assert.True(control1.Rendered);
Assert.True(control2.Rendered);
Assert.True(control3.Rendered);
}

[Fact]
public void Should_Not_Render_Clipped_Child_With_RenderTransform_When_Not_In_Bounds()
{
const int RootWidth = 300;
const int RootHeight = 300;

var rootGrid = new Grid
{
Width = RootWidth,
Height = RootHeight,
ClipToBounds = true
};

var stackPanel = new StackPanel
{
Orientation = Orientation.Horizontal,
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Right,
Margin = new Thickness(0, 10, 0, 0),
RenderTransformOrigin = new RelativePoint(new Point(0, 0), RelativeUnit.Relative),
RenderTransform = new TransformGroup
{
Children =
{
new RotateTransform { Angle = 90 },
new TranslateTransform { X = 280 }
}
}
};

rootGrid.Children.Add(stackPanel);

TestControl CreateControl()
=> new TestControl
{
Width = 160,
Height = 40,
Margin = new Thickness(0, 0, 5, 0),
ClipToBounds = true
};

var control1 = CreateControl();
var control2 = CreateControl();
var control3 = CreateControl();

stackPanel.Children.Add(control1);
stackPanel.Children.Add(control2);
stackPanel.Children.Add(control3);

var root = new TestRoot(rootGrid);
root.Renderer = new ImmediateRenderer(root);
root.LayoutManager.ExecuteInitialLayoutPass(root);

var rootSize = new Size(RootWidth, RootHeight);
root.Measure(rootSize);
root.Arrange(new Rect(rootSize));

root.Renderer.Paint(root.Bounds);

Assert.True(control1.Rendered);
Assert.True(control2.Rendered);
Assert.False(control3.Rendered);
}

private class TestControl : Control
{
public bool Rendered { get; private set; }

public override void Render(DrawingContext context)
=> Rendered = true;
}
}
}

0 comments on commit a71b3ba

Please sign in to comment.