mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Gradient picker - Added color randomization and condensed style
This commit is contained in:
1 parent
8806348386
commit
8faa6b7a49
6 files changed
+109
-66
No files matched your search
@@ -60,12 +60,13 @@ public class GradientPicker : TemplatedControl
|
||||
AvaloniaProperty.RegisterDirect<GradientPicker, ICommand>(nameof(DeleteStop), g => g.DeleteStop);
|
||||
|
||||
private readonly ICommand _deleteStop;
|
||||
private bool _shiftDown;
|
||||
private Button? _flipStops;
|
||||
private Border? _gradient;
|
||||
private Button? _rotateStops;
|
||||
private bool _shiftDown;
|
||||
private Button? _spreadStops;
|
||||
private Button? _toggleSeamless;
|
||||
private Button? _randomize;
|
||||
private ColorGradient? _lastColorGradient;
|
||||
private ColorPicker? _colorPicker;
|
||||
|
||||
@@ -153,6 +154,8 @@ public class GradientPicker : TemplatedControl
|
||||
_flipStops.Click -= FlipStopsOnClick;
|
||||
if (_rotateStops != null)
|
||||
_rotateStops.Click -= RotateStopsOnClick;
|
||||
if (_randomize != null)
|
||||
_randomize.Click -= RandomizeOnClick;
|
||||
|
||||
_colorPicker = e.NameScope.Find<ColorPicker>("ColorPicker");
|
||||
_gradient = e.NameScope.Find<Border>("Gradient");
|
||||
@@ -160,6 +163,7 @@ public class GradientPicker : TemplatedControl
|
||||
_toggleSeamless = e.NameScope.Find<Button>("ToggleSeamless");
|
||||
_flipStops = e.NameScope.Find<Button>("FlipStops");
|
||||
_rotateStops = e.NameScope.Find<Button>("RotateStops");
|
||||
_randomize = e.NameScope.Find<Button>("Randomize");
|
||||
|
||||
if (_gradient != null)
|
||||
_gradient.PointerPressed += GradientOnPointerPressed;
|
||||
@@ -171,10 +175,13 @@ public class GradientPicker : TemplatedControl
|
||||
_flipStops.Click += FlipStopsOnClick;
|
||||
if (_rotateStops != null)
|
||||
_rotateStops.Click += RotateStopsOnClick;
|
||||
if (_randomize != null)
|
||||
_randomize.Click += RandomizeOnClick;
|
||||
|
||||
base.OnApplyTemplate(e);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
@@ -309,4 +316,10 @@ public class GradientPicker : TemplatedControl
|
||||
|
||||
ColorGradient.RotateStops(_shiftDown);
|
||||
}
|
||||
|
||||
private void RandomizeOnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
ColorGradient.Randomize(6);
|
||||
SelectedColorStop = ColorGradient.First();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user