mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile editor - Updated brush select design
Profile editor - Show brush icon in profile tree
This commit is contained in:
parent
728805301a
commit
c99a3aaf3b
@ -7,8 +7,8 @@ using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
using Artemis.Core.Models.Profile.LayerShapes;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
using Artemis.Core.Plugins.LayerEffect.Abstract;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
|
||||
@ -5,21 +5,53 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:propertyInput="clr-namespace:Artemis.UI.PropertyInput"
|
||||
xmlns:layerBrush="clr-namespace:Artemis.Core.Plugins.LayerBrush;assembly=Artemis.Core"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type propertyInput:BrushPropertyInputViewModel}}">
|
||||
<UserControl.Resources>
|
||||
<ControlTemplate x:Key="SimpleTemplate">
|
||||
<StackPanel d:DataContext="{d:DesignInstance {x:Type layerBrush:LayerBrushDescriptor}}" Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="{Binding Icon}" Height="13" Width="13" Margin="0 1 3 0" />
|
||||
<TextBlock Text="{Binding DisplayName}" />
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="ExtendedTemplate">
|
||||
<Grid d:DataContext="{d:DesignInstance {x:Type layerBrush:LayerBrushDescriptor}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<materialDesign:PackIcon Grid.Row="0" Grid.RowSpan="2" Kind="{Binding Icon}" Height="20" Width="20" Margin="-5 -2 10 0" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding DisplayName}" TextWrapping="Wrap" MaxWidth="350"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Description}" TextWrapping="Wrap" MaxWidth="350" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
<DataTemplate x:Key="DescriptorTemplate">
|
||||
<Control x:Name="TemplateControl" Focusable="False" Template="{StaticResource ExtendedTemplate}" />
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ComboBoxItem}}, Path=IsSelected}" Value="{x:Null}">
|
||||
<Setter TargetName="TemplateControl" Property="Template" Value="{StaticResource SimpleTemplate}" />
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
</UserControl.Resources>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Width="10" Text="{Binding LayerProperty.PropertyDescription.InputPrefix}" />
|
||||
<ComboBox Width="132"
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
Height="15"
|
||||
materialDesign:ComboBoxAssist.ClassicMode="True"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Path=ComboboxValues}"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Description"
|
||||
SelectedValue="{Binding Path=InputValue}" />
|
||||
ItemsSource="{Binding Path=Descriptors}"
|
||||
SelectedValue="{Binding Path=SelectedDescriptor}"
|
||||
ItemTemplate="{StaticResource DescriptorTemplate}" />
|
||||
<TextBlock Width="10" Text="{Binding LayerProperty.PropertyDescription.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -8,8 +8,6 @@ using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Shared.PropertyInput;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.PropertyInput
|
||||
{
|
||||
@ -23,37 +21,32 @@ namespace Artemis.UI.PropertyInput
|
||||
{
|
||||
_layerService = layerService;
|
||||
_pluginService = pluginService;
|
||||
ComboboxValues = new BindableCollection<ValueDescription>();
|
||||
|
||||
_pluginService.PluginLoaded += PluginServiceOnPluginLoaded;
|
||||
_pluginService.PluginEnabled += PluginServiceOnPluginLoaded;
|
||||
_pluginService.PluginDisabled += PluginServiceOnPluginLoaded;
|
||||
UpdateEnumValues();
|
||||
}
|
||||
|
||||
public BindableCollection<ValueDescription> ComboboxValues { get; }
|
||||
public List<LayerBrushDescriptor> Descriptors { get; set; }
|
||||
|
||||
public LayerBrushDescriptor SelectedDescriptor
|
||||
{
|
||||
get => Descriptors.FirstOrDefault(d => d.LayerBrushProvider.PluginInfo.Guid == InputValue?.BrushPluginGuid && d.LayerBrushType.Name == InputValue?.BrushType);
|
||||
set => SetBrushByDescriptor(value);
|
||||
}
|
||||
|
||||
public void UpdateEnumValues()
|
||||
{
|
||||
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
|
||||
var descriptors = layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors).ToList();
|
||||
|
||||
var enumValues = new List<ValueDescription>();
|
||||
foreach (var layerBrushDescriptor in descriptors)
|
||||
{
|
||||
var brushName = layerBrushDescriptor.LayerBrushType.Name;
|
||||
var brushGuid = layerBrushDescriptor.LayerBrushProvider.PluginInfo.Guid;
|
||||
if (InputValue != null && InputValue.BrushType == brushName && InputValue.BrushPluginGuid == brushGuid)
|
||||
enumValues.Add(new ValueDescription {Description = layerBrushDescriptor.DisplayName, Value = InputValue});
|
||||
else
|
||||
enumValues.Add(new ValueDescription {Description = layerBrushDescriptor.DisplayName, Value = new LayerBrushReference {BrushType = brushName, BrushPluginGuid = brushGuid}});
|
||||
}
|
||||
|
||||
ComboboxValues.Clear();
|
||||
ComboboxValues.AddRange(enumValues);
|
||||
Descriptors = layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors).ToList();
|
||||
NotifyOfPropertyChange(nameof(SelectedDescriptor));
|
||||
}
|
||||
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
_pluginService.PluginLoaded -= PluginServiceOnPluginLoaded;
|
||||
_pluginService.PluginEnabled -= PluginServiceOnPluginLoaded;
|
||||
_pluginService.PluginDisabled -= PluginServiceOnPluginLoaded;
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
@ -62,6 +55,11 @@ namespace Artemis.UI.PropertyInput
|
||||
_layerService.InstantiateLayerBrush(LayerProperty.Layer);
|
||||
}
|
||||
|
||||
private void SetBrushByDescriptor(LayerBrushDescriptor value)
|
||||
{
|
||||
InputValue = new LayerBrushReference {BrushPluginGuid = value.LayerBrushProvider.PluginInfo.Guid, BrushType = value.LayerBrushType.Name};
|
||||
}
|
||||
|
||||
private void PluginServiceOnPluginLoaded(object sender, PluginEventArgs e)
|
||||
{
|
||||
UpdateEnumValues();
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
Height="15"
|
||||
materialDesign:ComboBoxAssist.ClassicMode="True"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Path=EnumValues}"
|
||||
|
||||
@ -26,8 +26,14 @@
|
||||
</ContextMenu>
|
||||
</StackPanel.ContextMenu>
|
||||
<StackPanel Orientation="Horizontal" Margin="10">
|
||||
<materialDesign:PackIcon Kind="Layers" />
|
||||
<TextBlock Text="{Binding ProfileElement.Name}" Margin="10 0 0 0" />
|
||||
<materialDesign:PackIcon Kind="Layers" Width="16" />
|
||||
<materialDesign:PackIcon Kind="{Binding Layer.LayerBrush.Descriptor.Icon}"
|
||||
Width="16"
|
||||
Margin="5 0 0 0"
|
||||
ToolTip="{Binding Layer.LayerBrush.Descriptor.DisplayName, Mode=OneWay}"
|
||||
Visibility="{Binding ShowIcons, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
|
||||
Background="Transparent"/>
|
||||
<TextBlock Text="{Binding Layer.Name}" Margin="5 0 0 0" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -19,6 +19,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
||||
{
|
||||
}
|
||||
|
||||
public Layer Layer => ProfileElement as Layer;
|
||||
public bool ShowIcons => Layer?.LayerBrush != null;
|
||||
public override bool SupportsChildren => false;
|
||||
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,7 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
||||
{
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
AddLayerBrushDescriptor<ColorBrush>("Color", "A color with an (optional) gradient", "Brush");
|
||||
AddLayerBrushDescriptor<ColorBrush>("Color", "A brush supporting solid colors and multiple types of gradients", "Brush");
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user