mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 01:42:02 +00:00
Bitmap brush - Fixed samples being taken out of bounds
Effects UI - Fixed effects list not always hiding on click Effects UI - Fixed transition origin not always updating
This commit is contained in:
parent
480fae02b9
commit
8eed347de5
@ -117,7 +117,7 @@ namespace Artemis.Core.RGB.NET
|
|||||||
{
|
{
|
||||||
var x = left + horizontalSteps * horizontalStep;
|
var x = left + horizontalSteps * horizontalStep;
|
||||||
var y = top + verticalSteps * verticalStep;
|
var y = top + verticalSteps * verticalStep;
|
||||||
if (x < 0 || x > bitmapWidth || y < 0 || y > bitmapHeight)
|
if (x < 0 || x >= bitmapWidth || y < 0 || y >= bitmapHeight)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var color = pixmap.GetPixelColor(x, y);
|
var color = pixmap.GetPixelColor(x, y);
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance local:EffectsViewModel}">
|
d:DataContext="{d:DesignInstance local:EffectsViewModel}">
|
||||||
<Grid Background="{DynamicResource MaterialDesignCardBackground}">
|
<Grid Background="{DynamicResource MaterialDesignCardBackground}">
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Top" Margin="16"
|
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Top" Margin="16"
|
||||||
Visibility="{Binding HasLayerEffectDescriptors, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}">
|
Visibility="{Binding HasLayerEffectDescriptors, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}">
|
||||||
<materialDesign:PackIcon Kind="AutoAwesome" Width="80" Height="80" HorizontalAlignment="Center" />
|
<materialDesign:PackIcon Kind="AutoAwesome" Width="80" Height="80" HorizontalAlignment="Center" />
|
||||||
@ -24,14 +23,16 @@
|
|||||||
Think of things like blur, black & white but also audio visualization etc.
|
Think of things like blur, black & white but also audio visualization etc.
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
<ListBox ItemsSource="{Binding LayerEffectDescriptors}" SelectedItem="{Binding SelectedLayerEffectDescriptor}" HorizontalContentAlignment="Stretch"
|
<ListBox ItemsSource="{Binding LayerEffectDescriptors}" SelectedItem="{Binding SelectedLayerEffectDescriptor}" HorizontalContentAlignment="Stretch"
|
||||||
Visibility="{Binding HasLayerEffectDescriptors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
|
Visibility="{Binding HasLayerEffectDescriptors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
|
||||||
|
<ListBox.ItemContainerStyle>
|
||||||
|
<Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
|
||||||
|
<Setter Property="behaviors:MouseBehaviour.MouseUpCommand" Value="{x:Static materialDesign:Transitioner.MoveFirstCommand}" />
|
||||||
|
</Style>
|
||||||
|
</ListBox.ItemContainerStyle>
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate DataType="{x:Type layerEffect:LayerEffectDescriptor}">
|
<DataTemplate DataType="{x:Type layerEffect:LayerEffectDescriptor}">
|
||||||
<Border Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}" VerticalAlignment="Stretch"
|
<Border Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}" VerticalAlignment="Stretch">
|
||||||
behaviors:MouseBehaviour.MouseUpCommand="{x:Static materialDesign:Transitioner.MoveFirstCommand}">
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using System.Linq;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Artemis.Core.Plugins.Abstract;
|
using Artemis.Core.Plugins.Abstract;
|
||||||
using Artemis.Core.Plugins.LayerEffect;
|
using Artemis.Core.Plugins.LayerEffect;
|
||||||
using Artemis.Core.Services.Interfaces;
|
using Artemis.Core.Services.Interfaces;
|
||||||
@ -17,6 +19,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
|||||||
_layerService = layerService;
|
_layerService = layerService;
|
||||||
LayerPropertiesViewModel = layerPropertiesViewModel;
|
LayerPropertiesViewModel = layerPropertiesViewModel;
|
||||||
LayerEffectDescriptors = new BindableCollection<LayerEffectDescriptor>();
|
LayerEffectDescriptors = new BindableCollection<LayerEffectDescriptor>();
|
||||||
|
PropertyChanged += HandleSelectedLayerEffectChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LayerPropertiesViewModel LayerPropertiesViewModel { get; }
|
public LayerPropertiesViewModel LayerPropertiesViewModel { get; }
|
||||||
@ -24,27 +27,30 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
|||||||
public BindableCollection<LayerEffectDescriptor> LayerEffectDescriptors { get; set; }
|
public BindableCollection<LayerEffectDescriptor> LayerEffectDescriptors { get; set; }
|
||||||
public bool HasLayerEffectDescriptors => LayerEffectDescriptors.Any();
|
public bool HasLayerEffectDescriptors => LayerEffectDescriptors.Any();
|
||||||
|
|
||||||
public LayerEffectDescriptor SelectedLayerEffectDescriptor
|
public LayerEffectDescriptor SelectedLayerEffectDescriptor { get; set; }
|
||||||
{
|
|
||||||
get => null;
|
|
||||||
set => AddLayerEffect(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PopulateDescriptors()
|
public void PopulateDescriptors()
|
||||||
{
|
{
|
||||||
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerEffectProvider>();
|
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerEffectProvider>();
|
||||||
|
var descriptors = layerBrushProviders.SelectMany(l => l.LayerEffectDescriptors).ToList();
|
||||||
|
LayerEffectDescriptors.AddRange(descriptors.Except(LayerEffectDescriptors));
|
||||||
|
LayerEffectDescriptors.RemoveRange(LayerEffectDescriptors.Except(descriptors));
|
||||||
|
|
||||||
if (LayerEffectDescriptors.Any())
|
SelectedLayerEffectDescriptor = null;
|
||||||
LayerEffectDescriptors.Clear();
|
|
||||||
LayerEffectDescriptors.AddRange(layerBrushProviders.SelectMany(l => l.LayerEffectDescriptors));
|
|
||||||
|
|
||||||
NotifyOfPropertyChange(nameof(HasLayerEffectDescriptors));
|
NotifyOfPropertyChange(nameof(HasLayerEffectDescriptors));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddLayerEffect(LayerEffectDescriptor value)
|
private void HandleSelectedLayerEffectChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (LayerPropertiesViewModel.SelectedLayer != null && value != null)
|
if (e.PropertyName == nameof(SelectedLayerEffectDescriptor) && SelectedLayerEffectDescriptor != null)
|
||||||
_layerService.AddLayerEffect(LayerPropertiesViewModel.SelectedLayer, value);
|
{
|
||||||
|
// Jump off the UI thread and let the fancy animation run
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(500);
|
||||||
|
return _layerService.AddLayerEffect(LayerPropertiesViewModel.SelectedLayer, SelectedLayerEffectDescriptor);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,22 +125,33 @@
|
|||||||
|
|
||||||
<!-- Properties tree -->
|
<!-- Properties tree -->
|
||||||
<materialDesign:DialogHost Identifier="PropertyTreeDialogHost" DialogTheme="Inherit" CloseOnClickAway="True" Grid.Row="1">
|
<materialDesign:DialogHost Identifier="PropertyTreeDialogHost" DialogTheme="Inherit" CloseOnClickAway="True" Grid.Row="1">
|
||||||
<materialDesign:Transitioner SelectedIndex="{Binding PropertyTreeIndex}" DefaultTransitionOrigin="0.9, 1" AutoApplyTransitionOrigins="True">
|
<materialDesign:Transitioner x:Name="PropertyTreeTransitioner" SelectedIndex="{Binding PropertyTreeIndex}" DefaultTransitionOrigin="0.9, 0.9" AutoApplyTransitionOrigins="True">
|
||||||
|
|
||||||
<ScrollViewer x:Name="PropertyTreeScrollViewer"
|
<ScrollViewer x:Name="PropertyTreeScrollViewer"
|
||||||
HorizontalScrollBarVisibility="Hidden"
|
HorizontalScrollBarVisibility="Hidden"
|
||||||
VerticalScrollBarVisibility="Hidden"
|
VerticalScrollBarVisibility="Hidden"
|
||||||
ScrollChanged="TimelineScrollChanged">
|
ScrollChanged="TimelineScrollChanged">
|
||||||
<Border BorderThickness="0,0,1,0" BorderBrush="{DynamicResource MaterialDesignDivider}">
|
<Border BorderThickness="0,0,1,0" BorderBrush="{DynamicResource MaterialDesignDivider}">
|
||||||
<ContentControl s:View.Model="{Binding TreeViewModel}" />
|
<Grid>
|
||||||
|
<ContentControl s:View.Model="{Binding TreeViewModel}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
</Border>
|
</Border>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
<materialDesign:TransitionerSlide>
|
<materialDesign:TransitionerSlide>
|
||||||
<materialDesign:TransitionerSlide.BackwardWipe>
|
<materialDesign:TransitionerSlide.BackwardWipe>
|
||||||
<materialDesign:CircleWipe />
|
<materialDesign:CircleWipe />
|
||||||
</materialDesign:TransitionerSlide.BackwardWipe>
|
</materialDesign:TransitionerSlide.BackwardWipe>
|
||||||
<ContentControl s:View.Model="{Binding EffectsViewModel}" />
|
<Grid>
|
||||||
|
<ContentControl s:View.Model="{Binding EffectsViewModel}" />
|
||||||
|
<!-- Transitions only work when the command comes from inside the transitioner but we want the button outside,
|
||||||
|
by setting the command target to this hidden button we cercumvent that -->
|
||||||
|
<Button x:Name="TransitionCommandAnchor"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Width="110"
|
||||||
|
Height="1"
|
||||||
|
Visibility="Hidden" />
|
||||||
|
</Grid>
|
||||||
</materialDesign:TransitionerSlide>
|
</materialDesign:TransitionerSlide>
|
||||||
</materialDesign:Transitioner>
|
</materialDesign:Transitioner>
|
||||||
</materialDesign:DialogHost>
|
</materialDesign:DialogHost>
|
||||||
@ -243,12 +254,29 @@
|
|||||||
Margin="0 -2"
|
Margin="0 -2"
|
||||||
Padding="10 0"
|
Padding="10 0"
|
||||||
Height="20"
|
Height="20"
|
||||||
Width="82"
|
Width="110"
|
||||||
ToolTip="Change the property's data binding"
|
ToolTip="Select an effect to add"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Command="{s:Action ToggleAddEffect}">
|
Visibility="{Binding PropertyTreeVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
|
||||||
|
Command="{x:Static materialDesign:Transitioner.MoveLastCommand}"
|
||||||
|
CommandTarget="{Binding ElementName=TransitionCommandAnchor}">
|
||||||
<TextBlock FontSize="10">
|
<TextBlock FontSize="10">
|
||||||
<Run Text="ADD EFFECT" />
|
ADD EFFECT
|
||||||
|
</TextBlock>
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Column="1"
|
||||||
|
Style="{StaticResource MaterialDesignFlatMidBgButton}"
|
||||||
|
Margin="0 -2"
|
||||||
|
Padding="10 0"
|
||||||
|
Height="20"
|
||||||
|
Width="110"
|
||||||
|
ToolTip="Show the layer/folder properties"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Visibility="{Binding PropertyTreeVisible, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}"
|
||||||
|
Command="{x:Static materialDesign:Transitioner.MoveFirstCommand}"
|
||||||
|
CommandTarget="{Binding ElementName=TransitionCommandAnchor}">
|
||||||
|
<TextBlock FontSize="10">
|
||||||
|
SHOW PROPERTIES
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
@ -15,8 +15,6 @@ using Artemis.UI.Ninject.Factories;
|
|||||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects;
|
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects;
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
|
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree;
|
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree;
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree;
|
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem;
|
|
||||||
using Artemis.UI.Shared.Events;
|
using Artemis.UI.Shared.Events;
|
||||||
using Artemis.UI.Shared.Services.Interfaces;
|
using Artemis.UI.Shared.Services.Interfaces;
|
||||||
using GongSolutions.Wpf.DragDrop;
|
using GongSolutions.Wpf.DragDrop;
|
||||||
@ -29,7 +27,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
{
|
{
|
||||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||||
private LayerPropertyGroupViewModel _brushPropertyGroup;
|
private LayerPropertyGroupViewModel _brushPropertyGroup;
|
||||||
private DateTime _lastToggle;
|
|
||||||
|
|
||||||
public LayerPropertiesViewModel(IProfileEditorService profileEditorService, ICoreService coreService, ISettingsService settingsService,
|
public LayerPropertiesViewModel(IProfileEditorService profileEditorService, ICoreService coreService, ISettingsService settingsService,
|
||||||
ILayerPropertyVmFactory layerPropertyVmFactory)
|
ILayerPropertyVmFactory layerPropertyVmFactory)
|
||||||
@ -41,6 +38,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
SettingsService = settingsService;
|
SettingsService = settingsService;
|
||||||
|
|
||||||
LayerPropertyGroups = new BindableCollection<LayerPropertyGroupViewModel>();
|
LayerPropertyGroups = new BindableCollection<LayerPropertyGroupViewModel>();
|
||||||
|
PropertyChanged += HandlePropertyTreeIndexChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IProfileEditorService ProfileEditorService { get; }
|
public IProfileEditorService ProfileEditorService { get; }
|
||||||
@ -58,6 +56,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int PropertyTreeIndex { get; set; }
|
public int PropertyTreeIndex { get; set; }
|
||||||
|
public bool PropertyTreeVisible => PropertyTreeIndex == 0;
|
||||||
public Layer SelectedLayer { get; set; }
|
public Layer SelectedLayer { get; set; }
|
||||||
public Folder SelectedFolder { get; set; }
|
public Folder SelectedFolder { get; set; }
|
||||||
|
|
||||||
@ -65,22 +64,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
public TreeViewModel TreeViewModel { get; set; }
|
public TreeViewModel TreeViewModel { get; set; }
|
||||||
public EffectsViewModel EffectsViewModel { get; set; }
|
public EffectsViewModel EffectsViewModel { get; set; }
|
||||||
public TimelineViewModel TimelineViewModel { get; set; }
|
public TimelineViewModel TimelineViewModel { get; set; }
|
||||||
|
|
||||||
#region Effects
|
|
||||||
|
|
||||||
public void ToggleAddEffect()
|
|
||||||
{
|
|
||||||
if (DateTime.Now - _lastToggle < TimeSpan.FromMilliseconds(500))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_lastToggle = DateTime.Now;
|
|
||||||
PropertyTreeIndex = PropertyTreeIndex == 0 ? 1 : 0;
|
|
||||||
if (PropertyTreeIndex == 1)
|
|
||||||
EffectsViewModel.PopulateDescriptors();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
protected override void OnInitialActivate()
|
protected override void OnInitialActivate()
|
||||||
{
|
{
|
||||||
PopulateProperties(ProfileEditorService.SelectedProfileElement);
|
PopulateProperties(ProfileEditorService.SelectedProfileElement);
|
||||||
@ -107,6 +91,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
base.OnDeactivate();
|
base.OnDeactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandlePropertyTreeIndexChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName == nameof(PropertyTreeIndex) && PropertyTreeIndex == 1)
|
||||||
|
EffectsViewModel.PopulateDescriptors();
|
||||||
|
}
|
||||||
|
|
||||||
private void ProfileEditorServiceOnProfileElementSelected(object sender, ProfileElementEventArgs e)
|
private void ProfileEditorServiceOnProfileElementSelected(object sender, ProfileElementEventArgs e)
|
||||||
{
|
{
|
||||||
PopulateProperties(e.ProfileElement);
|
PopulateProperties(e.ProfileElement);
|
||||||
@ -292,7 +282,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
|
|
||||||
if (source == target || target?.GroupType != LayerEffectRoot || source?.GroupType != LayerEffectRoot)
|
if (source == target || target?.GroupType != LayerEffectRoot || source?.GroupType != LayerEffectRoot)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
|
dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
|
||||||
dropInfo.Effects = DragDropEffects.Move;
|
dropInfo.Effects = DragDropEffects.Move;
|
||||||
}
|
}
|
||||||
@ -338,7 +328,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
var order = 1;
|
var order = 1;
|
||||||
foreach (var groupViewModel in LayerPropertyGroups.Where(p => p.GroupType == LayerEffectRoot))
|
foreach (var groupViewModel in LayerPropertyGroups.Where(p => p.GroupType == LayerEffectRoot))
|
||||||
{
|
{
|
||||||
|
|
||||||
groupViewModel.UpdateOrder(order);
|
groupViewModel.UpdateOrder(order);
|
||||||
order++;
|
order++;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user