1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

Upgrade Avalonia to 11 rc1

This commit is contained in:
Robert 2023-06-05 23:39:57 +02:00
parent 70b6035b0d
commit f249f80d19
16 changed files with 64 additions and 95 deletions

View File

@ -16,11 +16,11 @@
<None Remove=".gitignore" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc1.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-rc1.1" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
</ItemGroup>
<ItemGroup>

View File

@ -15,11 +15,11 @@
<None Remove=".gitignore" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc1.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-rc1.1" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
</ItemGroup>
<ItemGroup>

View File

@ -10,14 +10,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-preview8" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-rc1.1" />
<PackageReference Include="DynamicData" Version="7.13.1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview8" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.0.0-preview3" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-rc1" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.0.1" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
<PackageReference Include="RGB.NET.Core" Version="2.0.0-prerelease.69" />

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
@ -68,7 +69,7 @@ public partial class DraggableNumberBox : UserControl
public DraggableNumberBox()
{
InitializeComponent();
PointerPressed += OnPointerPressed;
PointerMoved += OnPointerMoved;
PointerReleased += OnPointerReleased;
@ -186,8 +187,9 @@ public partial class DraggableNumberBox : UserControl
private void HandleKeyUp(object? sender, KeyEventArgs e)
{
IInputElement? toFocus = this.GetLogicalAncestors().OfType<IInputElement>().LastOrDefault();
if (e.Key == Key.Enter || e.Key == Key.Escape)
FocusManager.Instance?.Focus(Parent as IInputElement);
toFocus?.Focus();
}
private void OnPointerPressed(object? sender, PointerPressedEventArgs e)
@ -215,7 +217,7 @@ public partial class DraggableNumberBox : UserControl
if (!_moved)
{
// Let our parent take focus, it would make more sense to take focus ourselves but that hides the collider
FocusManager.Instance?.Focus(Parent as IInputElement);
(Parent as IInputElement)?.Focus();
_moved = true;
e.Pointer.Capture(this);
DragStarted?.Invoke(this, EventArgs.Empty);

View File

@ -9,6 +9,7 @@ using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using Avalonia.VisualTree;
using DryIoc;
using FluentAvalonia.Core;
using Humanizer;
@ -78,7 +79,7 @@ public partial class HotkeyBox : UserControl
private void InputServiceOnKeyboardKeyUp(object? sender, ArtemisKeyboardKeyEventArgs e)
{
if (e.Modifiers == KeyboardModifierKey.None)
Dispatcher.UIThread.Post(() => FocusManager.Instance?.Focus(null));
Dispatcher.UIThread.Post(() => this.FindAncestorOfType<InputElement>()?.Focus());
}
private void UpdateDisplayTextBox()
@ -96,7 +97,7 @@ public partial class HotkeyBox : UserControl
private void Button_OnClick(object? sender, RoutedEventArgs e)
{
Hotkey = null;
FocusManager.Instance?.Focus(null);
this.FindAncestorOfType<InputElement>()?.Focus();
UpdateDisplayTextBox();
}

View File

@ -48,7 +48,7 @@ public class ReactiveAppWindow<TViewModel> : AppWindow, IViewFor<TViewModel> whe
return;
TransparencyBackgroundFallback = Brushes.Transparent;
TransparencyLevelHint = WindowTransparencyLevel.Mica;
TransparencyLevelHint = new[] {WindowTransparencyLevel.Mica};
TryEnableMicaEffect();
}

View File

@ -1,7 +1,5 @@
using System;
using System.ComponentModel;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Input.Platform;
@ -14,12 +12,9 @@ namespace Artemis.UI.Shared;
/// </summary>
public static class UI
{
private static readonly BehaviorSubject<bool> KeyBindingsEnabledSubject = new(false);
static UI()
{
if (KeyboardDevice.Instance != null)
KeyboardDevice.Instance.PropertyChanged += InstanceOnPropertyChanged;
KeyBindingsEnabled = InputElement.GotFocusEvent.Raised.Select(e => e.Item2.Source is not TextBox);
}
/// <summary>
@ -35,15 +30,5 @@ public static class UI
/// <summary>
/// Gets a boolean indicating whether hotkeys are to be disabled.
/// </summary>
public static IObservable<bool> KeyBindingsEnabled { get; } = KeyBindingsEnabledSubject.AsObservable();
private static void InstanceOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (KeyboardDevice.Instance == null || e.PropertyName != nameof(KeyboardDevice.FocusedElement))
return;
bool enabled = KeyboardDevice.Instance.FocusedElement is not TextBox;
if (KeyBindingsEnabledSubject.Value != enabled)
KeyBindingsEnabledSubject.OnNext(enabled);
}
public static IObservable<bool> KeyBindingsEnabled { get; }
}

View File

@ -21,12 +21,12 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc1.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Win32" Version="11.0.0-preview8" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Win32" Version="11.0.0-rc1.1" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="Microsoft.Win32" Version="2.0.1" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" />

View File

@ -15,20 +15,20 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc1.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-preview8" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-rc1.1" />
<PackageReference Include="DryIoc.dll" Version="5.4.0" />
<PackageReference Include="DynamicData" Version="7.13.1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview8" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-rc1" />
<PackageReference Include="Flurl.Http" Version="3.2.4" />
<PackageReference Include="Live.Avalonia" Version="1.3.1" />
<PackageReference Include="Markdown.Avalonia.Tight" Version="11.0.0-c1" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.0.0-preview3" />
<PackageReference Include="Markdown.Avalonia.Tight" Version="11.0.0-d1" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.0.1" />
<PackageReference Include="Octopus.Octodiff" Version="2.0.261" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />

View File

@ -103,8 +103,9 @@ public class SimpleContextDragBehavior : Behavior<Control>
private void AssociatedObject_PointerPressed(object? sender, PointerPressedEventArgs e)
{
IFocusManager? focusManager = TopLevel.GetTopLevel(AssociatedObject)?.FocusManager;
PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties;
if (!properties.IsLeftButtonPressed || FocusManager.Instance?.Current is TextBox)
if (!properties.IsLeftButtonPressed || focusManager?.GetFocusedElement() is TextBox)
return;
if (e.Source is not Control control || AssociatedObject?.DataContext != control.DataContext)
return;
@ -130,8 +131,9 @@ public class SimpleContextDragBehavior : Behavior<Control>
private async void AssociatedObject_PointerMoved(object? sender, PointerEventArgs e)
{
IFocusManager? focusManager = TopLevel.GetTopLevel(AssociatedObject)?.FocusManager;
PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties;
if (!properties.IsLeftButtonPressed || FocusManager.Instance?.Current is TextBox)
if (!properties.IsLeftButtonPressed || focusManager?.GetFocusedElement() is TextBox)
return;
if (_triggerEvent is null)

View File

@ -1,5 +1,4 @@
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
@ -16,6 +15,6 @@ public partial class StringPropertyInputView : ReactiveUserControl<FloatProperty
private void OnRoutedKeyUp(object? sender, KeyEventArgs e)
{
if (e.Key == Key.Enter || e.Key == Key.Escape)
FocusManager.Instance!.Focus(null);
Focus();
}
}

View File

@ -8,7 +8,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.ProfileEditor.MenuBar.MenuBarView"
x:DataType="menuBar:MenuBarViewModel">
<Menu VerticalAlignment="Top" MenuClosed="MenuBase_OnMenuClosed">
<Menu VerticalAlignment="Top" Closed="MenuBase_OnMenuClosed">
<MenuItem Header="_File">
<MenuItem Header="New">
<MenuItem.Icon>

View File

@ -110,14 +110,14 @@
</shared:SelectionRectangle.Background>
</shared:SelectionRectangle>
<Border Name="SurfaceBounds"
<Rectangle Name="SurfaceBounds"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Width="{Binding MaxTextureSize}"
Height="{Binding MaxTextureSize}"
BorderThickness="2"
BorderBrush="{DynamicResource SystemAccentColorLight1}"
BorderDashArray="6,2"
StrokeThickness="2"
Stroke="{DynamicResource SystemAccentColorLight1}"
StrokeDashArray="6,2"
Opacity="0.5" />
</Grid>
</paz:ZoomBorder>

View File

@ -5,7 +5,6 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.PanAndZoom;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.ReactiveUI;
@ -30,7 +29,7 @@ public partial class SurfaceEditorView : ReactiveUserControl<SurfaceEditorViewMo
private void ZoomBorder_OnZoomChanged(object sender, ZoomChangedEventArgs e)
{
UpdateZoomBorderBackground();
SurfaceBounds.BorderThickness = new Thickness(2 / ContainerZoomBorder.ZoomX);
SurfaceBounds.StrokeThickness = 2 / ContainerZoomBorder.ZoomX;
}
private void SelectionRectangle_OnSelectionUpdated(object? sender, SelectionRectangleEventArgs e)

View File

@ -3,17 +3,22 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.ReactiveUI;
using Avalonia.Rendering;
using Avalonia.Threading;
using Avalonia.VisualTree;
namespace Artemis.UI.Screens.VisualScripting.Pins;
public class PinView : ReactiveUserControl<PinViewModel>
{
private Canvas? _container;
private readonly DispatcherTimer _updateTimer;
private bool _dragging;
private Canvas? _container;
private Border? _pinPoint;
private PinViewRenderLoopTaks _renderLoopTask;
public PinView()
{
_updateTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(16), DispatcherPriority.Render, UpdatePosition);
}
protected void InitializePin(Border pinPoint)
{
@ -21,7 +26,6 @@ public class PinView : ReactiveUserControl<PinViewModel>
_pinPoint.PointerMoved += PinPointOnPointerMoved;
_pinPoint.PointerReleased += PinPointOnPointerReleased;
_pinPoint.PropertyChanged += PinPointOnPropertyChanged;
_renderLoopTask = new PinViewRenderLoopTaks(this);
}
private void PinPointOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
@ -74,19 +78,17 @@ public class PinView : ReactiveUserControl<PinViewModel>
/// <inheritdoc />
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
_container = this.FindAncestorOfType<Canvas>();
AvaloniaLocator.Current.GetRequiredService<IRenderLoop>().Add(_renderLoopTask);
_updateTimer.Start();
}
/// <inheritdoc />
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnDetachedFromVisualTree(e);
AvaloniaLocator.Current.GetRequiredService<IRenderLoop>().Remove(_renderLoopTask);
_updateTimer.Stop();
}
public void UpdatePosition()
public void UpdatePosition(object? sender, EventArgs eventArgs)
{
if (_container == null || _pinPoint == null || ViewModel == null)
return;
@ -97,25 +99,4 @@ public class PinView : ReactiveUserControl<PinViewModel>
}
#endregion
}
public class PinViewRenderLoopTaks : IRenderLoopTask
{
private readonly PinView _pinView;
public PinViewRenderLoopTaks(PinView pinView)
{
_pinView = pinView;
}
public void Update(TimeSpan time)
{
_pinView.UpdatePosition();
}
public void Render()
{
}
public bool NeedsUpdate => true;
}

View File

@ -8,9 +8,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-rc1.1" />
<PackageReference Include="DryIoc.dll" Version="5.4.0" />
<PackageReference Include="NoStringEvaluating" Version="2.5.2" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />