mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Add more gradient tools
This commit is contained in:
parent
46b3fdf343
commit
a874a494ff
@ -12,8 +12,8 @@
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
|
||||
Width="400"
|
||||
Height="425"
|
||||
d:DesignHeight="425"
|
||||
Height="450"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="400"
|
||||
d:DataContext="{d:DesignInstance local:GradientEditorViewModel}">
|
||||
<UserControl.Resources>
|
||||
@ -90,41 +90,66 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0">
|
||||
<Button Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||
Margin="0 8 8 8"
|
||||
Margin="0 4 8 8"
|
||||
Command="{s:Action SpreadColorStops}"
|
||||
ToolTip="Distribute Stops" IsEnabled="{Binding HasMoreThanOneStop}"
|
||||
ToolTip="Spread Stops" IsEnabled="{Binding HasMoreThanOneStop}"
|
||||
HorizontalAlignment="Left"
|
||||
Height="25">
|
||||
Height="25" Width="100">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="DistributeHorizontalCenter"/>
|
||||
<TextBlock Margin="6 0 0 0">Distribute</TextBlock>
|
||||
<TextBlock Margin="6 0 0 0">Spread</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||
Margin="0 8 8 8"
|
||||
Margin="0 4 8 8"
|
||||
Command="{s:Action RotateColorStops}"
|
||||
ToolTip="Rotate Stops" IsEnabled="{Binding HasMoreThanOneStop}"
|
||||
HorizontalAlignment="Left"
|
||||
Height="25">
|
||||
Height="25" Width="100">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="AxisZRotateCounterclockwise" />
|
||||
<TextBlock Margin="6 0 0 0">Rotate</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||
Margin="0 8 8 8"
|
||||
Margin="0 0 8 0"
|
||||
Command="{s:Action FlipColorStops}"
|
||||
IsEnabled="{Binding HasMoreThanOneStop}"
|
||||
HorizontalAlignment="Left"
|
||||
Height="25" ToolTip="Flip Stops">
|
||||
Height="25" Width="100" ToolTip="Flip Stops">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="FlipHorizontal"/>
|
||||
<TextBlock Margin="6 0 0 0">Flip</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0">
|
||||
|
||||
<Button Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||
Margin="0 0 8 0"
|
||||
Command="{s:Action ToggleSeam}"
|
||||
IsEnabled="{Binding HasMoreThanOneStop}"
|
||||
HorizontalAlignment="Left"
|
||||
Height="25" Width="100" ToolTip="Toggle Seam">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="ArrowSplitVertical"/>
|
||||
<TextBlock Margin="6 0 0 0">Seam</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||
Margin="0 0 8 0"
|
||||
Command="{s:Action ClearGradient}"
|
||||
IsEnabled="{Binding HasMoreThanOneStop}"
|
||||
HorizontalAlignment="Left"
|
||||
Height="25" Width="100" ToolTip="Clear Gradient">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="DeleteSweep"/>
|
||||
<TextBlock Margin="6 0 0 0">Clear</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Margin="0 6 0 0" FontWeight="Bold">Selected stop:</TextBlock>
|
||||
|
||||
@ -135,7 +160,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal">
|
||||
<Label HorizontalAlignment="Left" Margin="-5,0,0,0">Color:</Label>
|
||||
<Label HorizontalAlignment="Left" Margin="-5,1,0,0">Color:</Label>
|
||||
<shared:ColorPicker
|
||||
x:Name="CurrentColor"
|
||||
Width="85"
|
||||
@ -144,7 +169,7 @@
|
||||
IsEnabled="{Binding HasSelectedColorStopViewModel}" />
|
||||
|
||||
<Label HorizontalAlignment="Center">Location:</Label>
|
||||
<TextBox Width="40"
|
||||
<TextBox Width="30"
|
||||
Text="{Binding SelectedColorStopViewModel.OffsetPercent}"
|
||||
IsEnabled="{Binding HasSelectedColorStopViewModel}"
|
||||
materialDesign:HintAssist.Hint="0"
|
||||
|
||||
@ -36,6 +36,7 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
|
||||
public override void OnDialogClosed(object sender, DialogClosingEventArgs e)
|
||||
{
|
||||
ColorGradient.CollectionChanged -= ColorGradientOnCollectionChanged;
|
||||
ColorStopViewModels.CollectionChanged -= ColorStopViewModelsOnCollectionChanged;
|
||||
base.OnDialogClosed(sender, e);
|
||||
}
|
||||
|
||||
@ -127,6 +128,43 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleSeam()
|
||||
{
|
||||
if (ColorGradient.IsSeamless())
|
||||
{
|
||||
// Remove the last stop
|
||||
var stop = ColorStopViewModels.OrderBy(x => x.OffsetFloat).Last();
|
||||
|
||||
if (stop == SelectedColorStopViewModel) SelectColorStop(null);
|
||||
|
||||
ColorStopViewModels.Remove(stop);
|
||||
ColorGradient.Remove(stop.ColorStop);
|
||||
|
||||
// Distribute the stops if there is still more than one
|
||||
if (ColorGradient.Count > 1)
|
||||
SpreadColorStops();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add a stop to the end that is the same color as the first stop
|
||||
ColorGradientStop stop = new(ColorGradient.First().Color, 100);
|
||||
ColorGradient.Add(stop);
|
||||
|
||||
ColorStopViewModel viewModel = new(this, stop);
|
||||
ColorStopViewModels.Add(viewModel);
|
||||
|
||||
NotifyOfPropertyChange(nameof(HasMoreThanOneStop));
|
||||
|
||||
// Distribute the stops
|
||||
SpreadColorStops();
|
||||
}
|
||||
}
|
||||
public void ClearGradient()
|
||||
{
|
||||
ColorGradient.Clear();
|
||||
ColorStopViewModels.Clear();
|
||||
}
|
||||
|
||||
public Point GetPositionInPreview(object sender, MouseEventArgs e)
|
||||
{
|
||||
Canvas? parent = VisualTreeUtilities.FindParent<Canvas>((DependencyObject) sender, null);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user