From fac7a618e78cc4adc8b46c3380566dc9aac75aaa Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 28 Feb 2022 23:26:18 +0100 Subject: [PATCH] Notifications - Fixed positioning in main window, Notifications - Added vertical stacking --- .../Controls/DeviceVisualizer.cs | 9 +- .../Services/Builders/NotificationBuilder.cs | 12 +-- .../Artemis.UI.Shared/Styles/Artemis.axaml | 3 +- .../Controls/GradientPickerButton.axaml | 58 ++++++----- .../Styles/Notifications.axaml | 27 ++++++ src/Avalonia/Artemis.UI/MainWindow.axaml | 17 ++-- .../Screens/Debugger/DebugView.axaml | 95 ++++++++++--------- .../Tabs/Render/RenderDebugView.axaml | 2 +- .../Screens/Device/DevicePropertiesView.axaml | 2 + .../Plugins/PluginSettingsWindowView.axaml | 1 + .../Properties/PropertyGroupViewModel.cs | 23 ++++- .../Panels/Properties/PropertyViewModel.cs | 19 +++- .../Screens/Workshop/WorkshopViewModel.cs | 3 +- 13 files changed, 178 insertions(+), 93 deletions(-) create mode 100644 src/Avalonia/Artemis.UI.Shared/Styles/Notifications.axaml diff --git a/src/Avalonia/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Avalonia/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index 9358e1e61..b5a944faf 100644 --- a/src/Avalonia/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Avalonia/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -69,7 +69,14 @@ namespace Artemis.UI.Shared.Controls // Render device and LED images if (_deviceImage != null) - drawingContext.DrawImage(_deviceImage, new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height)); + { + drawingContext.DrawImage( + _deviceImage, + new Rect(_deviceImage.Size), + new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height), + RenderOptions.GetBitmapInterpolationMode(this) + ); + } if (!ShowColors) return; diff --git a/src/Avalonia/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs b/src/Avalonia/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs index 22fa90f18..ccf3c741f 100644 --- a/src/Avalonia/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs +++ b/src/Avalonia/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs @@ -26,12 +26,7 @@ public class NotificationBuilder public NotificationBuilder(Window parent) { _parent = parent; - _infoBar = new InfoBar - { - Classes = Classes.Parse("notification-info-bar"), - VerticalAlignment = VerticalAlignment.Bottom, - HorizontalAlignment = HorizontalAlignment.Right - }; + _infoBar = new InfoBar {Classes = Classes.Parse("notification-info-bar")}; } /// @@ -121,8 +116,9 @@ public class NotificationBuilder /// public Action Show() { - if (_parent.Content is not Panel panel) - throw new ArtemisSharedUIException("Can't display a notification on a window without a panel at its root."); + IPanel? panel = _parent.Find("NotificationContainer"); + if (panel == null) + throw new ArtemisSharedUIException("Can't display a notification on a window without a NotificationContainer."); Dispatcher.UIThread.Post(() => { diff --git a/src/Avalonia/Artemis.UI.Shared/Styles/Artemis.axaml b/src/Avalonia/Artemis.UI.Shared/Styles/Artemis.axaml index 2c44880a6..b3572739e 100644 --- a/src/Avalonia/Artemis.UI.Shared/Styles/Artemis.axaml +++ b/src/Avalonia/Artemis.UI.Shared/Styles/Artemis.axaml @@ -35,9 +35,10 @@ + - + @@ -60,4 +67,11 @@ + + + \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI.Shared/Styles/Notifications.axaml b/src/Avalonia/Artemis.UI.Shared/Styles/Notifications.axaml new file mode 100644 index 000000000..bfe195ede --- /dev/null +++ b/src/Avalonia/Artemis.UI.Shared/Styles/Notifications.axaml @@ -0,0 +1,27 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/MainWindow.axaml b/src/Avalonia/Artemis.UI/MainWindow.axaml index fada19202..f10f4287f 100644 --- a/src/Avalonia/Artemis.UI/MainWindow.axaml +++ b/src/Avalonia/Artemis.UI/MainWindow.axaml @@ -7,11 +7,14 @@ x:Class="Artemis.UI.MainWindow" Icon="/Assets/Images/Logo/application.ico" Title="Artemis 2.0"> - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/Debugger/DebugView.axaml b/src/Avalonia/Artemis.UI/Screens/Debugger/DebugView.axaml index 325cd5362..a6aac23e7 100644 --- a/src/Avalonia/Artemis.UI/Screens/Debugger/DebugView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/Debugger/DebugView.axaml @@ -20,51 +20,56 @@ - - - - - - - Rendering - - - - - - - - Data Model - - - - - - - - Performance - - - - - - - - Logging - - - - - - - - - + + + + + + + + Rendering + + + + + + + + Data Model + + + + + + + + Performance + + + + + + + + Logging + + + + - + + + + + + + + + + \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugView.axaml b/src/Avalonia/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugView.axaml index e29e77355..cfb66a4e5 100644 --- a/src/Avalonia/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugView.axaml @@ -24,7 +24,7 @@ - + + + \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/Plugins/PluginSettingsWindowView.axaml b/src/Avalonia/Artemis.UI/Screens/Plugins/PluginSettingsWindowView.axaml index 7bfea49dc..f653027b5 100644 --- a/src/Avalonia/Artemis.UI/Screens/Plugins/PluginSettingsWindowView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/Plugins/PluginSettingsWindowView.axaml @@ -12,5 +12,6 @@ WindowStartupLocation="CenterOwner"> + diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertyGroupViewModel.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertyGroupViewModel.cs index 202d5f4df..edccd7921 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertyGroupViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertyGroupViewModel.cs @@ -12,11 +12,10 @@ using Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes; using Artemis.UI.Screens.ProfileEditor.Properties.Tree; using Artemis.UI.Shared; using Artemis.UI.Shared.Services.PropertyInput; -using ReactiveUI; namespace Artemis.UI.Screens.ProfileEditor.Properties; -public class PropertyGroupViewModel : ViewModelBase +public class PropertyGroupViewModel : ViewModelBase, IDisposable { private readonly ILayerPropertyVmFactory _layerPropertyVmFactory; private readonly IPropertyInputService _propertyInputService; @@ -33,7 +32,7 @@ public class PropertyGroupViewModel : ViewModelBase TreeGroupViewModel = layerPropertyVmFactory.TreeGroupViewModel(this); TimelineGroupViewModel = layerPropertyVmFactory.TimelineGroupViewModel(this); - // TODO: Centralize visibility updating or do it here and dispose + LayerPropertyGroup.VisibilityChanged += LayerPropertyGroupOnVisibilityChanged; _isVisible = !LayerPropertyGroup.IsHidden; PopulateChildren(); @@ -86,10 +85,12 @@ public class PropertyGroupViewModel : ViewModelBase return result; foreach (ViewModelBase child in Children) + { if (child is PropertyViewModel profileElementPropertyViewModel) result.AddRange(profileElementPropertyViewModel.TimelinePropertyViewModel.GetAllKeyframeViewModels()); else if (child is PropertyGroupViewModel profileElementPropertyGroupViewModel) result.AddRange(profileElementPropertyGroupViewModel.GetAllKeyframeViewModels(expandedOnly)); + } return result; } @@ -120,4 +121,20 @@ public class PropertyGroupViewModel : ViewModelBase HasChildren = Children.Any(i => i is PropertyViewModel {IsVisible: true} || i is PropertyGroupViewModel {IsVisible: true}); } + + private void LayerPropertyGroupOnVisibilityChanged(object? sender, EventArgs e) + { + IsVisible = !LayerPropertyGroup.IsHidden; + } + + /// + public void Dispose() + { + LayerPropertyGroup.VisibilityChanged -= LayerPropertyGroupOnVisibilityChanged; + foreach (ViewModelBase viewModelBase in Children) + { + if (viewModelBase is IDisposable disposable) + disposable.Dispose(); + } + } } \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertyViewModel.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertyViewModel.cs index 36cbbd55f..0dfa5ad45 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertyViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertyViewModel.cs @@ -1,13 +1,13 @@ -using Artemis.Core; +using System; +using Artemis.Core; using Artemis.UI.Ninject.Factories; using Artemis.UI.Screens.ProfileEditor.Properties.Timeline; using Artemis.UI.Screens.ProfileEditor.Properties.Tree; using Artemis.UI.Shared; -using ReactiveUI; namespace Artemis.UI.Screens.ProfileEditor.Properties; -public class PropertyViewModel : ViewModelBase +public class PropertyViewModel : ViewModelBase, IDisposable { private bool _isExpanded; private bool _isHighlighted; @@ -19,7 +19,7 @@ public class PropertyViewModel : ViewModelBase TreePropertyViewModel = propertyVmFactory.TreePropertyViewModel(LayerProperty, this); TimelinePropertyViewModel = propertyVmFactory.TimelinePropertyViewModel(LayerProperty, this); - // TODO: Centralize visibility updating or do it here and dispose + LayerProperty.VisibilityChanged += LayerPropertyOnVisibilityChanged; _isVisible = !LayerProperty.IsHidden; } @@ -44,4 +44,15 @@ public class PropertyViewModel : ViewModelBase get => _isExpanded; set => RaiseAndSetIfChanged(ref _isExpanded, value); } + + private void LayerPropertyOnVisibilityChanged(object? sender, LayerPropertyEventArgs e) + { + IsVisible = !LayerProperty.IsHidden; + } + + /// + public void Dispose() + { + LayerProperty.VisibilityChanged -= LayerPropertyOnVisibilityChanged; + } } \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/Workshop/WorkshopViewModel.cs b/src/Avalonia/Artemis.UI/Screens/Workshop/WorkshopViewModel.cs index ca36e0e4c..cb7f09681 100644 --- a/src/Avalonia/Artemis.UI/Screens/Workshop/WorkshopViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/Workshop/WorkshopViewModel.cs @@ -1,4 +1,5 @@ -using System.Reactive; +using System; +using System.Reactive; using System.Reactive.Linq; using Artemis.Core; using Artemis.UI.Shared.Services.Builders;