mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +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 y = top + verticalSteps * verticalStep;
|
||||
if (x < 0 || x > bitmapWidth || y < 0 || y > bitmapHeight)
|
||||
if (x < 0 || x >= bitmapWidth || y < 0 || y >= bitmapHeight)
|
||||
continue;
|
||||
|
||||
var color = pixmap.GetPixelColor(x, y);
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:EffectsViewModel}">
|
||||
<Grid Background="{DynamicResource MaterialDesignCardBackground}">
|
||||
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Top" Margin="16"
|
||||
Visibility="{Binding HasLayerEffectDescriptors, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}">
|
||||
<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.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<ListBox ItemsSource="{Binding LayerEffectDescriptors}" SelectedItem="{Binding SelectedLayerEffectDescriptor}" HorizontalContentAlignment="Stretch"
|
||||
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>
|
||||
<DataTemplate DataType="{x:Type layerEffect:LayerEffectDescriptor}">
|
||||
<Border Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}" VerticalAlignment="Stretch"
|
||||
behaviors:MouseBehaviour.MouseUpCommand="{x:Static materialDesign:Transitioner.MoveFirstCommand}">
|
||||
<Border Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}" VerticalAlignment="Stretch">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<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.LayerEffect;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
@ -17,6 +19,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
||||
_layerService = layerService;
|
||||
LayerPropertiesViewModel = layerPropertiesViewModel;
|
||||
LayerEffectDescriptors = new BindableCollection<LayerEffectDescriptor>();
|
||||
PropertyChanged += HandleSelectedLayerEffectChanged;
|
||||
}
|
||||
|
||||
public LayerPropertiesViewModel LayerPropertiesViewModel { get; }
|
||||
@ -24,27 +27,30 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
||||
public BindableCollection<LayerEffectDescriptor> LayerEffectDescriptors { get; set; }
|
||||
public bool HasLayerEffectDescriptors => LayerEffectDescriptors.Any();
|
||||
|
||||
public LayerEffectDescriptor SelectedLayerEffectDescriptor
|
||||
{
|
||||
get => null;
|
||||
set => AddLayerEffect(value);
|
||||
}
|
||||
public LayerEffectDescriptor SelectedLayerEffectDescriptor { get; set; }
|
||||
|
||||
public void PopulateDescriptors()
|
||||
{
|
||||
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())
|
||||
LayerEffectDescriptors.Clear();
|
||||
LayerEffectDescriptors.AddRange(layerBrushProviders.SelectMany(l => l.LayerEffectDescriptors));
|
||||
|
||||
SelectedLayerEffectDescriptor = null;
|
||||
NotifyOfPropertyChange(nameof(HasLayerEffectDescriptors));
|
||||
}
|
||||
|
||||
private void AddLayerEffect(LayerEffectDescriptor value)
|
||||
private void HandleSelectedLayerEffectChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (LayerPropertiesViewModel.SelectedLayer != null && value != null)
|
||||
_layerService.AddLayerEffect(LayerPropertiesViewModel.SelectedLayer, value);
|
||||
if (e.PropertyName == nameof(SelectedLayerEffectDescriptor) && SelectedLayerEffectDescriptor != null)
|
||||
{
|
||||
// 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 -->
|
||||
<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"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
ScrollChanged="TimelineScrollChanged">
|
||||
<Border BorderThickness="0,0,1,0" BorderBrush="{DynamicResource MaterialDesignDivider}">
|
||||
<ContentControl s:View.Model="{Binding TreeViewModel}" />
|
||||
<Grid>
|
||||
<ContentControl s:View.Model="{Binding TreeViewModel}" />
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</ScrollViewer>
|
||||
|
||||
<materialDesign:TransitionerSlide>
|
||||
<materialDesign:TransitionerSlide.BackwardWipe>
|
||||
<materialDesign:CircleWipe />
|
||||
</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:Transitioner>
|
||||
</materialDesign:DialogHost>
|
||||
@ -243,12 +254,29 @@
|
||||
Margin="0 -2"
|
||||
Padding="10 0"
|
||||
Height="20"
|
||||
Width="82"
|
||||
ToolTip="Change the property's data binding"
|
||||
Width="110"
|
||||
ToolTip="Select an effect to add"
|
||||
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">
|
||||
<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>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
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.Timeline;
|
||||
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.Services.Interfaces;
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
@ -29,7 +27,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
{
|
||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||
private LayerPropertyGroupViewModel _brushPropertyGroup;
|
||||
private DateTime _lastToggle;
|
||||
|
||||
public LayerPropertiesViewModel(IProfileEditorService profileEditorService, ICoreService coreService, ISettingsService settingsService,
|
||||
ILayerPropertyVmFactory layerPropertyVmFactory)
|
||||
@ -41,6 +38,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
SettingsService = settingsService;
|
||||
|
||||
LayerPropertyGroups = new BindableCollection<LayerPropertyGroupViewModel>();
|
||||
PropertyChanged += HandlePropertyTreeIndexChanged;
|
||||
}
|
||||
|
||||
public IProfileEditorService ProfileEditorService { get; }
|
||||
@ -58,6 +56,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
}
|
||||
|
||||
public int PropertyTreeIndex { get; set; }
|
||||
public bool PropertyTreeVisible => PropertyTreeIndex == 0;
|
||||
public Layer SelectedLayer { get; set; }
|
||||
public Folder SelectedFolder { get; set; }
|
||||
|
||||
@ -65,22 +64,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
public TreeViewModel TreeViewModel { get; set; }
|
||||
public EffectsViewModel EffectsViewModel { 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()
|
||||
{
|
||||
PopulateProperties(ProfileEditorService.SelectedProfileElement);
|
||||
@ -107,6 +91,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
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)
|
||||
{
|
||||
PopulateProperties(e.ProfileElement);
|
||||
@ -292,7 +282,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
|
||||
if (source == target || target?.GroupType != LayerEffectRoot || source?.GroupType != LayerEffectRoot)
|
||||
return;
|
||||
|
||||
|
||||
dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
|
||||
dropInfo.Effects = DragDropEffects.Move;
|
||||
}
|
||||
@ -338,7 +328,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
var order = 1;
|
||||
foreach (var groupViewModel in LayerPropertyGroups.Where(p => p.GroupType == LayerEffectRoot))
|
||||
{
|
||||
|
||||
groupViewModel.UpdateOrder(order);
|
||||
order++;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user