mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Layer brushes - Added RGB.NET-based layer brushes
Layer brushes - Added sample RGB.NET-based color brush Layer properties - Save on gradient edit dialog close Layer properties - Fix layer brush keyframes not working after changing layer brush
This commit is contained in:
1 parent
493790f6bd
commit
cdb91021a2
31 files changed
+550
-146
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract
|
||||
|
||||
public List<LayerPropertyBaseViewModel> Children { get; set; }
|
||||
|
||||
public abstract List<BaseLayerPropertyKeyframe> GetKeyframes(bool visibleOnly);
|
||||
public abstract List<BaseLayerPropertyKeyframe> GetKeyframes(bool expandedOnly);
|
||||
public abstract void Dispose();
|
||||
}
|
||||
}
|
||||
+17
-12
@@ -2,12 +2,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Events;
|
||||
@@ -85,7 +87,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
NotifyOfPropertyChange(() => TimeCaretPosition);
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e)
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(TimeCaretPosition));
|
||||
}
|
||||
@@ -128,17 +130,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, layer.General, (PropertyGroupDescriptionAttribute) generalAttribute));
|
||||
LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, layer.Transform, (PropertyGroupDescriptionAttribute) transformAttribute));
|
||||
|
||||
if (layer.LayerBrush != null)
|
||||
{
|
||||
// Add the rout group of the brush
|
||||
// The root group of the brush has no attribute so let's pull one out of our sleeve
|
||||
var brushDescription = new PropertyGroupDescriptionAttribute
|
||||
{
|
||||
Name = layer.LayerBrush.Descriptor.DisplayName,
|
||||
Description = layer.LayerBrush.Descriptor.Description
|
||||
};
|
||||
LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, layer.LayerBrush.BaseProperties, brushDescription));
|
||||
}
|
||||
ApplyLayerBrush();
|
||||
}
|
||||
else
|
||||
SelectedLayer = null;
|
||||
@@ -149,6 +141,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
|
||||
private void SelectedLayerOnLayerBrushUpdated(object sender, EventArgs e)
|
||||
{
|
||||
ApplyLayerBrush();
|
||||
}
|
||||
|
||||
public void ApplyLayerBrush()
|
||||
{
|
||||
var hideRenderRelatedProperties = SelectedLayer.LayerBrush != null && SelectedLayer.LayerBrush.BrushType == LayerBrushType.RgbNet;
|
||||
SelectedLayer.General.ShapeType.IsHidden = hideRenderRelatedProperties;
|
||||
SelectedLayer.General.FillType.IsHidden = hideRenderRelatedProperties;
|
||||
SelectedLayer.General.BlendMode.IsHidden = hideRenderRelatedProperties;
|
||||
SelectedLayer.Transform.IsHidden = hideRenderRelatedProperties;
|
||||
|
||||
// Get rid of the old layer properties group
|
||||
if (LayerPropertyGroups.Count == 3)
|
||||
{
|
||||
@@ -167,6 +170,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
};
|
||||
LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, SelectedLayer.LayerBrush.BaseProperties, brushDescription));
|
||||
}
|
||||
|
||||
TimelineViewModel.UpdateKeyframes();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
+5
-5
@@ -67,14 +67,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
}
|
||||
}
|
||||
|
||||
public override List<BaseLayerPropertyKeyframe> GetKeyframes(bool visibleOnly)
|
||||
public override List<BaseLayerPropertyKeyframe> GetKeyframes(bool expandedOnly)
|
||||
{
|
||||
var result = new List<BaseLayerPropertyKeyframe>();
|
||||
if (visibleOnly && !IsExpanded)
|
||||
if (expandedOnly && !IsExpanded || LayerPropertyGroup.IsHidden)
|
||||
return result;
|
||||
|
||||
|
||||
foreach (var layerPropertyBaseViewModel in Children)
|
||||
result.AddRange(layerPropertyBaseViewModel.GetKeyframes(visibleOnly));
|
||||
result.AddRange(layerPropertyBaseViewModel.GetKeyframes(expandedOnly));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
return result;
|
||||
}
|
||||
|
||||
private void LayerPropertyGroupOnVisibilityChanged(object? sender, EventArgs e)
|
||||
private void LayerPropertyGroupOnVisibilityChanged(object sender, EventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(IsVisible));
|
||||
}
|
||||
|
||||
+6
-4
@@ -45,9 +45,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
public TreePropertyViewModel<T> TreePropertyViewModel { get; set; }
|
||||
public TimelinePropertyViewModel<T> TimelinePropertyViewModel { get; set; }
|
||||
|
||||
public override List<BaseLayerPropertyKeyframe> GetKeyframes(bool visibleOnly)
|
||||
public override List<BaseLayerPropertyKeyframe> GetKeyframes(bool expandedOnly)
|
||||
{
|
||||
return LayerProperty.BaseKeyframes.ToList();
|
||||
if (LayerProperty.KeyframesEnabled && !LayerProperty.IsHidden)
|
||||
return LayerProperty.BaseKeyframes.ToList();
|
||||
return new List<BaseLayerPropertyKeyframe>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
@@ -67,9 +69,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
ProfileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
private void LayerPropertyOnVisibilityChanged(object? sender, EventArgs e)
|
||||
private void LayerPropertyOnVisibilityChanged(object sender, EventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(IsVisible));
|
||||
NotifyOfPropertyChange(nameof(IsVisible));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -9,7 +9,8 @@
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:TimelinePropertyGroupViewModel}">
|
||||
d:DataContext="{d:DesignInstance local:TimelinePropertyGroupViewModel}"
|
||||
Visibility="{Binding LayerPropertyGroupViewModel.IsVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="24" />
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
UpdateKeyframes();
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e)
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateKeyframes();
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
UpdateKeyframes();
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e)
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
|
||||
{
|
||||
foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels)
|
||||
timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond);
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyI
|
||||
Validate();
|
||||
}
|
||||
|
||||
private void ApplyInputValue()
|
||||
protected void ApplyInputValue()
|
||||
{
|
||||
// Force the validator to run
|
||||
if (Validator != null)
|
||||
|
||||
+6
-4
@@ -5,16 +5,18 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared"
|
||||
xmlns:propertyInput="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyInput"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="25" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance propertyInput:ColorGradientPropertyInputViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="0 0 5 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.PropertyDescription.InputPrefix}" />
|
||||
<controls:GradientPicker Width="132"
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
ColorGradient="{Binding InputValue}"
|
||||
DialogHost="PropertyTreeDialogHost"/>
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
ColorGradient="{Binding InputValue}"
|
||||
DialogClosed="{s:Action DialogClosed}"
|
||||
DialogHost="PropertyTreeDialogHost" />
|
||||
<TextBlock Margin="5 0 0 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.PropertyDescription.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
+7
-1
@@ -1,4 +1,5 @@
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyInput.Abstract;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyInput
|
||||
@@ -8,5 +9,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyI
|
||||
public ColorGradientPropertyInputViewModel(LayerPropertyViewModel<ColorGradient> layerPropertyViewModel) : base(layerPropertyViewModel)
|
||||
{
|
||||
}
|
||||
|
||||
public void DialogClosed(object sender, EventArgs e)
|
||||
{
|
||||
ApplyInputValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
@@ -16,7 +16,6 @@ using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools;
|
||||
using Artemis.UI.Screens.Shared;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
@@ -30,6 +29,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private int _activeToolIndex;
|
||||
private VisualizationToolViewModel _activeToolViewModel;
|
||||
private Layer _previousSelectedLayer;
|
||||
private int _previousTool;
|
||||
|
||||
public ProfileViewModel(IProfileEditorService profileEditorService,
|
||||
@@ -119,6 +119,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
}
|
||||
|
||||
public List<ArtemisLed> GetLedsInRectangle(Rect selectedRect)
|
||||
{
|
||||
return Devices.SelectMany(d => d.Leds)
|
||||
.Where(led => led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1).IntersectsWith(selectedRect))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
OnlyShowSelectedShape = _settingsService.GetSetting("ProfileEditor.OnlyShowSelectedShape", true);
|
||||
@@ -132,7 +139,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
base.OnInitialActivate();
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
HighlightSelectedLayer.SettingChanged -= HighlightSelectedLayerOnSettingChanged;
|
||||
@@ -189,6 +196,23 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
HighlightedLeds.AddRange(layer.Leds);
|
||||
}
|
||||
|
||||
private void UpdateCanSelectEditTool()
|
||||
{
|
||||
if (_profileEditorService.SelectedProfileElement is Layer layer)
|
||||
{
|
||||
CanApplyToLayer = true;
|
||||
CanSelectEditTool = (layer.LayerBrush == null || layer.LayerBrush.BrushType == LayerBrushType.Regular) && layer.Leds.Any();
|
||||
}
|
||||
else
|
||||
{
|
||||
CanApplyToLayer = false;
|
||||
CanSelectEditTool = false;
|
||||
}
|
||||
|
||||
if (CanSelectEditTool == false && ActiveToolIndex == 1)
|
||||
ActivateToolByIndex(2);
|
||||
}
|
||||
|
||||
#region Buttons
|
||||
|
||||
private void ActivateToolByIndex(int value)
|
||||
@@ -300,22 +324,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
private void OnProfileElementSelected(object sender, EventArgs e)
|
||||
{
|
||||
UpdateLedsDimStatus();
|
||||
if (_previousSelectedLayer != null)
|
||||
_previousSelectedLayer.LayerBrushUpdated -= SelectedLayerOnLayerBrushUpdated;
|
||||
if (_profileEditorService.SelectedProfileElement is Layer layer)
|
||||
{
|
||||
CanApplyToLayer = true;
|
||||
CanSelectEditTool = layer.Leds.Any();
|
||||
_previousSelectedLayer = layer;
|
||||
_previousSelectedLayer.LayerBrushUpdated += SelectedLayerOnLayerBrushUpdated;
|
||||
}
|
||||
else
|
||||
{
|
||||
CanApplyToLayer = false;
|
||||
CanSelectEditTool = false;
|
||||
}
|
||||
if (CanSelectEditTool == false && ActiveToolIndex == 1)
|
||||
ActivateToolByIndex(2);
|
||||
_previousSelectedLayer = null;
|
||||
|
||||
UpdateLedsDimStatus();
|
||||
UpdateCanSelectEditTool();
|
||||
}
|
||||
|
||||
|
||||
private void SelectedLayerOnLayerBrushUpdated(object? sender, EventArgs e)
|
||||
{
|
||||
UpdateCanSelectEditTool();
|
||||
}
|
||||
|
||||
private void OnSelectedProfileElementUpdated(object sender, EventArgs e)
|
||||
{
|
||||
@@ -331,6 +357,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
CanApplyToLayer = false;
|
||||
CanSelectEditTool = false;
|
||||
}
|
||||
|
||||
if (CanSelectEditTool == false && ActiveToolIndex == 1)
|
||||
ActivateToolByIndex(2);
|
||||
}
|
||||
@@ -376,12 +403,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public List<ArtemisLed> GetLedsInRectangle(Rect selectedRect)
|
||||
{
|
||||
return Devices.SelectMany(d => d.Leds)
|
||||
.Where(led => led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1).IntersectsWith(selectedRect))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user