From 3a4eaada2c5a0765b67c82bd3993293e57ab40c5 Mon Sep 17 00:00:00 2001 From: indigo-san Date: Sun, 10 Sep 2023 17:13:02 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A6=81=E7=B4=A0=E3=81=AE=E3=83=9C?= =?UTF-8?q?=E3=83=BC=E3=83=80=E3=83=BC=E3=82=92=E5=B8=B8=E3=81=AB=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Beutl/ViewModels/ElementViewModel.cs | 7 +++++++ src/Beutl/Views/ElementView.axaml | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Beutl/ViewModels/ElementViewModel.cs b/src/Beutl/ViewModels/ElementViewModel.cs index c885889be..9f1477900 100644 --- a/src/Beutl/ViewModels/ElementViewModel.cs +++ b/src/Beutl/ViewModels/ElementViewModel.cs @@ -11,6 +11,8 @@ using Beutl.Services; using Beutl.Utilities; +using FluentAvalonia.UI.Media; + using Reactive.Bindings; using Reactive.Bindings.Extensions; @@ -65,6 +67,9 @@ public ElementViewModel(Element element, TimelineViewModel timeline) .ToReactiveProperty() .AddTo(_disposables); + RestBorderColor = Color.Select(v => (Avalonia.Media.Color)((Color2)v).LightenPercent(-0.15f)) + .ToReadOnlyReactivePropertySlim()!; + TextColor = Color.Select(GetTextColor) .ToReadOnlyReactivePropertySlim() .AddTo(_disposables); @@ -148,6 +153,8 @@ public ElementViewModel(Element element, TimelineViewModel timeline) public ReactiveProperty Color { get; } + public ReadOnlyReactivePropertySlim RestBorderColor { get; } + public ReadOnlyReactivePropertySlim TextColor { get; } public ReactiveCommand?> Split { get; } = new(); diff --git a/src/Beutl/Views/ElementView.axaml b/src/Beutl/Views/ElementView.axaml index 728e00aa4..52fac7409 100644 --- a/src/Beutl/Views/ElementView.axaml +++ b/src/Beutl/Views/ElementView.axaml @@ -26,12 +26,14 @@ Margin="{Binding BorderMargin.Value}" HorizontalAlignment="Left" Background="{Binding Color.Value, Converter={StaticResource ColorToBrushConverter}}" - BorderBrush="{DynamicResource TextControlForeground}" + BorderThickness="1" Classes.selected="{Binding IsSelected.Value}"> + From 0c6d1c7a243f333afeff43bb18df9ebef38779bd Mon Sep 17 00:00:00 2001 From: indigo-san Date: Sun, 10 Sep 2023 17:16:01 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E9=81=B8=E6=8A=9E=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=82=8B=E8=A6=81=E7=B4=A0=E3=81=AE=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=AE=E7=B8=81=E3=81=8C=E9=80=94=E5=88=87=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=81=AE=E3=82=92=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Beutl/Views/ElementView.axaml.cs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Beutl/Views/ElementView.axaml.cs b/src/Beutl/Views/ElementView.axaml.cs index 3e6c8ab03..26edfee28 100644 --- a/src/Beutl/Views/ElementView.axaml.cs +++ b/src/Beutl/Views/ElementView.axaml.cs @@ -16,6 +16,8 @@ using FluentAvalonia.UI.Controls; +using Reactive.Bindings.Extensions; + using Setter = Avalonia.Styling.Setter; namespace Beutl.Views; @@ -139,8 +141,15 @@ await Dispatcher.UIThread.InvokeAsync(async () => }); }; - _disposable1 = obj.Model.GetObservable(Element.IsEnabledProperty) - .Subscribe(b => Dispatcher.UIThread.InvokeAsync(() => border.Opacity = b ? 1 : 0.5)); + obj.Model.GetObservable(Element.IsEnabledProperty) + .ObserveOnUIDispatcher() + .Subscribe(b => border.Opacity = b ? 1 : 0.5) + .DisposeWith(_disposables); + + obj.IsSelected + .ObserveOnUIDispatcher() + .Subscribe(v => ZIndex = v ? 5 : 0) + .DisposeWith(_disposables); } protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) @@ -541,7 +550,6 @@ protected override void OnAttached() if (AssociatedObject != null) { AssociatedObject.AddHandler(PointerPressedEvent, OnPointerPressed, RoutingStrategies.Tunnel); - AssociatedObject.AddHandler(PointerReleasedEvent, OnPointerReleased, RoutingStrategies.Tunnel); AssociatedObject.border.AddHandler(PointerPressedEvent, OnBorderPointerPressed); AssociatedObject.border.AddHandler(PointerReleasedEvent, OnBorderPointerReleased); } @@ -553,7 +561,6 @@ protected override void OnDetaching() if (AssociatedObject != null) { AssociatedObject.AddHandler(PointerPressedEvent, OnPointerPressed, RoutingStrategies.Tunnel); - AssociatedObject.AddHandler(PointerReleasedEvent, OnPointerReleased, RoutingStrategies.Tunnel); AssociatedObject.border.RemoveHandler(PointerPressedEvent, OnBorderPointerPressed); AssociatedObject.border.RemoveHandler(PointerReleasedEvent, OnBorderPointerReleased); } @@ -563,7 +570,6 @@ private void OnPointerPressed(object? sender, PointerPressedEventArgs e) { if (AssociatedObject is { } obj) { - obj.ZIndex = 5; if (!obj.textBox.IsFocused) { obj.Focus(); @@ -571,14 +577,6 @@ private void OnPointerPressed(object? sender, PointerPressedEventArgs e) } } - private void OnPointerReleased(object? sender, PointerReleasedEventArgs e) - { - if (AssociatedObject is { } obj) - { - obj.ZIndex = 0; - } - } - private void OnBorderPointerPressed(object? sender, PointerPressedEventArgs e) { if (AssociatedObject is { _timeline: { } } obj) From 5fd336dfed985b3c28189ee04bca8e2c0d0c8c97 Mon Sep 17 00:00:00 2001 From: indigo-san Date: Tue, 12 Sep 2023 23:40:44 +0900 Subject: [PATCH 3/3] Fix ElementView.axaml.cs --- src/Beutl/Views/ElementView.axaml.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Beutl/Views/ElementView.axaml.cs b/src/Beutl/Views/ElementView.axaml.cs index 26edfee28..8e3eb0eb6 100644 --- a/src/Beutl/Views/ElementView.axaml.cs +++ b/src/Beutl/Views/ElementView.axaml.cs @@ -31,9 +31,9 @@ namespace Beutl.Views; public sealed partial class ElementView : UserControl { + private readonly CompositeDisposable _disposables = new(); private Timeline? _timeline; private TimeSpan _pointerPosition; - private IDisposable? _disposable1; private static ColorPickerFlyout? s_colorPickerFlyout; public ElementView() @@ -72,8 +72,7 @@ protected override void OnKeyDown(KeyEventArgs e) private void OnDataContextDetached(ElementViewModel obj) { obj.AnimationRequested = (_, _) => Task.CompletedTask; - _disposable1?.Dispose(); - _disposable1 = null; + _disposables.Clear(); } private void OnDataContextAttached(ElementViewModel obj)