Skip to content

Commit

Permalink
Merge branch 'master' into AvaloniaUI#4948
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacato authored Oct 6, 2023
2 parents 76127b8 + 4ef901b commit 44ea489
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 81 deletions.
36 changes: 13 additions & 23 deletions native/Avalonia.Native/src/OSX/AvnView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @implementation AvnView
bool _isLeftPressed, _isMiddlePressed, _isRightPressed, _isXButton1Pressed, _isXButton2Pressed;
AvnInputModifiers _modifierState;
NSEvent* _lastMouseDownEvent;
bool _lastKeyHandled;
bool _lastKeyConsumeByInputContext;
AvnPixelSize _lastPixelSize;
NSObject<IRenderTarget>* _currentRenderTarget;
AvnPlatformResizeReason _resizeReason;
Expand Down Expand Up @@ -457,27 +457,19 @@ - (void) keyboardEvent: (NSEvent *) event withType: (AvnRawKeyEventType)type
auto physicalKey = PhysicalKeyFromScanCode(scanCode);
auto keySymbol = KeySymbolFromScanCode(scanCode, [event modifierFlags]);
auto keySymbolUtf8 = keySymbol == nullptr ? nullptr : [keySymbol UTF8String];

auto timestamp = static_cast<uint64_t>([event timestamp] * 1000);
auto modifiers = [self getModifiers:[event modifierFlags]];

auto handled = _parent->BaseEvents->RawKeyEvent(type, timestamp, modifiers, key, physicalKey, keySymbolUtf8);
if (key != AvnKeyLeftCtrl && key != AvnKeyRightCtrl) {
_lastKeyHandled = handled;
} else {
_lastKeyHandled = false;
if(!_lastKeyConsumeByInputContext || key <= 32){
auto handled = _parent->BaseEvents->RawKeyEvent(type, timestamp, modifiers, key, physicalKey, keySymbolUtf8);

if(key > 32 && type == KeyDown && !handled){
_parent->BaseEvents->RawTextInputEvent(timestamp, keySymbolUtf8);
}
}
}

- (BOOL)performKeyEquivalent:(NSEvent *)event
{
bool result = _lastKeyHandled;

_lastKeyHandled = false;

return result;
}

- (void)flagsChanged:(NSEvent *)event
{
auto newModifierState = [self getModifiers:[event modifierFlags]];
Expand Down Expand Up @@ -537,15 +529,13 @@ - (void)flagsChanged:(NSEvent *)event

- (void)keyDown:(NSEvent *)event
{
_lastKeyHandled = false;

[self keyboardEvent:event withType:KeyDown];

BOOL isKeyDownConsumed = [[self inputContext] handleEvent:event];
_lastKeyConsumeByInputContext = false;

if(!_lastKeyHandled){
_lastKeyHandled = isKeyDownConsumed == YES;
if(_parent->InputMethod->IsActive()){
_lastKeyConsumeByInputContext = [[self inputContext] handleEvent:event] == YES;
}

[self keyboardEvent:event withType:KeyDown];
}

- (void)keyUp:(NSEvent *)event
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Themes.Simple/Controls/ButtonSpinner.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</ControlTemplate>
</Setter>
<Style Selector="^:left">
<Style Selector="^ /template/ StackPanel#PART_SpinnerPanel">
<Style Selector="^ /template/ UniformGrid#PART_SpinnerPanel">
<Setter Property="DockPanel.Dock" Value="Left" />
</Style>
</Style>
Expand Down
22 changes: 11 additions & 11 deletions tests/Avalonia.Markup.UnitTests/Data/BindingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,10 @@ private class StyledPropertyClass : AvaloniaObject

public double DoubleValue
{
get { return GetValue(DoubleValueProperty); }
set { SetValue(DoubleValueProperty, value); }
get => GetValue(DoubleValueProperty);
set => SetValue(DoubleValueProperty, value);
}

public static StyledProperty<double?> NullableDoubleProperty =
AvaloniaProperty.Register<StyledPropertyClass, double?>(nameof(NullableDoubleProperty), -1);

Expand All @@ -724,8 +724,8 @@ private class DirectPropertyClass : AvaloniaObject
private double _doubleValue;
public double DoubleValue
{
get { return _doubleValue; }
set { SetAndRaise(DoubleValueProperty, ref _doubleValue, value); }
get => _doubleValue;
set => SetAndRaise(DoubleValueProperty, ref _doubleValue, value);
}
}

Expand Down Expand Up @@ -756,7 +756,7 @@ private class TestStackOverflowViewModel : INotifyPropertyChanged

public double Value
{
get { return _value; }
get => _value;
set
{
if (_value != value)
Expand Down Expand Up @@ -788,8 +788,8 @@ private class TwoWayBindingTest : Control

public string TwoWay
{
get { return GetValue(TwoWayProperty); }
set { SetValue(TwoWayProperty, value); }
get => GetValue(TwoWayProperty);
set => SetValue(TwoWayProperty, value);
}
}

Expand All @@ -800,7 +800,7 @@ public class Source : INotifyPropertyChanged

public string Foo
{
get { return _foo; }
get => _foo;
set
{
_foo = value;
Expand Down Expand Up @@ -911,8 +911,8 @@ private class InheritanceTest : Decorator

public int Baz
{
get { return GetValue(BazProperty); }
set { SetValue(BazProperty, value); }
get => GetValue(BazProperty);
set => SetValue(BazProperty, value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Source : INotifyPropertyChanged

public string Foo
{
get { return _foo; }
get => _foo;
set
{
_foo = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ private class Class1 : AvaloniaObject

public Class1 Next
{
get { return GetValue(NextProperty); }
set { SetValue(NextProperty, value); }
get => GetValue(NextProperty);
set => SetValue(NextProperty, value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,7 @@ private class NonIntegerIndexer : NotifyingBase

public string this[string key]
{
get
{
return _storage[key];
}
get => _storage[key];
set
{
_storage[key] = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ private class Class1 : StyledElement
public static readonly StyledProperty<string> FooProperty =
AvaloniaProperty.Register<Class1, string>("Foo");

public ThemeVariant ThemeVariant
public ThemeVariant ThemeVariant
{
get { throw new NotImplementedException(); }
get => throw new NotImplementedException();
}

public event EventHandler ThemeVariantChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,7 @@ private class ViewModel : INotifyPropertyChanged
object _parameter;
public object Parameter
{
get
{
return _parameter;
}
get => _parameter;
set
{
if (_parameter == value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1949,10 +1949,7 @@ public class NonIntegerIndexer : NotifyingBase, INonIntegerIndexerDerived

public string this[string key]
{
get
{
return _storage[key];
}
get => _storage[key];
set
{
_storage[key] = value;
Expand Down Expand Up @@ -1991,10 +1988,7 @@ public class MethodAsCommandDataContext : INotifyPropertyChanged
object _parameter;
public object Parameter
{
get
{
return _parameter;
}
get => _parameter;
set
{
if (_parameter == value)
Expand Down Expand Up @@ -2050,8 +2044,8 @@ public class DataGridLikeControl : Control
private IEnumerable _items;
public IEnumerable Items
{
get { return _items; }
set { SetAndRaise(ItemsProperty, ref _items, value); }
get => _items;
set => SetAndRaise(ItemsProperty, ref _items, value);
}

public AvaloniaList<DataGridLikeColumn> Columns { get; } = new();
Expand Down
10 changes: 5 additions & 5 deletions tests/Avalonia.Markup.Xaml.UnitTests/SampleAvaloniaObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ internal class SampleAvaloniaObject : AvaloniaObject

public int Int
{
get { return GetValue(IntProperty); }
set { SetValue(IntProperty, value); }
get => GetValue(IntProperty);
set => SetValue(IntProperty, value);
}

public string String
{
get { return GetValue(StringProperty); }
set { SetValue(StringProperty, value); }
get => GetValue(StringProperty);
set => SetValue(StringProperty, value);
}
}
}
}
6 changes: 3 additions & 3 deletions tests/Avalonia.Markup.Xaml.UnitTests/TestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TestViewModel : NotifyingBase

public int Integer
{
get { return _integer; }
get => _integer;
set
{
_integer = value;
Expand All @@ -20,7 +20,7 @@ public int Integer

public string String
{
get { return _string; }
get => _string;
set
{
_string = value;
Expand All @@ -30,7 +30,7 @@ public string String

public TestViewModel Child
{
get { return _child; }
get => _child;
set
{
_child = value;
Expand Down
2 changes: 1 addition & 1 deletion tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ private class SelectedItemsViewModel : INotifyPropertyChanged

public IList SelectedItems
{
get { return _selectedItems; }
get => _selectedItems;
set
{
_selectedItems = value;
Expand Down
13 changes: 5 additions & 8 deletions tests/Avalonia.Markup.Xaml.UnitTests/Xaml/NonControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@ public class NonControl : AvaloniaObject

public Control Control
{
get { return GetValue(ControlProperty); }
set { SetValue(ControlProperty, value); }
get => GetValue(ControlProperty);
set => SetValue(ControlProperty, value);
}

public string String
{
get { return GetValue(StringProperty); }
set { SetValue(StringProperty, value); }
get => GetValue(StringProperty);
set => SetValue(StringProperty, value);
}

public string Bar
{
get { return GetValue(BarProperty); }
}
public string Bar => GetValue(BarProperty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ private class Class1 : AvaloniaObject

public string Foo
{
get { return GetValue(FooProperty); }
set { SetValue(FooProperty, value); }
get => GetValue(FooProperty);
set => SetValue(FooProperty, value);
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions tests/Avalonia.RenderTests/Media/ImageBrushTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ public ImageBrushTests()

private string BitmapPath
{
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
get
{
return System.IO.Path.Combine(OutputPath, "github_icon.png");
}
}

private string SmallBitmapPath
{
get { return System.IO.Path.Combine(OutputPath, "github_icon_small.png"); }
get
{
return System.IO.Path.Combine(OutputPath, "github_icon_small.png");
}
}

[Fact]
Expand Down
5 changes: 4 additions & 1 deletion tests/Avalonia.RenderTests/Media/ImageDrawingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public ImageDrawingTests()

private string BitmapPath
{
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
get
{
return System.IO.Path.Combine(OutputPath, "github_icon.png");
}
}

[Fact]
Expand Down
5 changes: 4 additions & 1 deletion tests/Avalonia.RenderTests/Media/VisualBrushTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public VisualBrushTests()

private string BitmapPath
{
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
get
{
return System.IO.Path.Combine(OutputPath, "github_icon.png");
}
}

private Control Visual
Expand Down

0 comments on commit 44ea489

Please sign in to comment.