mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Nodes - Added static color node
This commit is contained in:
1 parent
28534cb57a
commit
69b881b044
12 files changed
+203
-67
No files matched your search
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Avalonia.Data.Converters;
|
||||
using FluentAvalonia.UI.Media;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.UI.Shared.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// Converts <see cref="SKColor" /> into <see cref="Color2" />.
|
||||
/// </summary>
|
||||
public class SKColorToColor2Converter : IValueConverter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is SKColor skColor)
|
||||
return new Color2(skColor.Red, skColor.Green, skColor.Blue, skColor.Alpha);
|
||||
return new Color2();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Color2 color2)
|
||||
return new SKColor(color2.R, color2.G, color2.B, color2.A);
|
||||
return SKColor.Empty;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@
|
||||
<StyleInclude Source="/Styles/Border.axaml" />
|
||||
<StyleInclude Source="/Styles/Button.axaml" />
|
||||
<StyleInclude Source="/Styles/Condensed.axaml" />
|
||||
<StyleInclude Source="/Styles/ColorPickerButton.axaml" />
|
||||
<StyleInclude Source="/Styles/TextBlock.axaml" />
|
||||
<StyleInclude Source="/Styles/Sidebar.axaml" />
|
||||
<StyleInclude Source="/Styles/InfoBar.axaml" />
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<Styles xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia">
|
||||
<Design.PreviewWith>
|
||||
<Border Padding="20">
|
||||
<Grid Height="24" ColumnDefinitions="*">
|
||||
<TextBox Classes="condensed"
|
||||
Text="#FFFF0000"
|
||||
Padding="2 2 30 2">
|
||||
</TextBox>
|
||||
<controls:ColorPickerButton Classes="contained-color-picker-button"
|
||||
ShowAcceptDismissButtons="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
|
||||
<!-- Add Styles Here -->
|
||||
<Style Selector="controls|ColorPickerButton.contained-color-picker-button">
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Margin" Value="4 0" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="MinHeight" Value="00" />
|
||||
<Setter Property="MinWidth" Value="0" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<controls:Button Name="MainButton"
|
||||
Padding="0"
|
||||
BorderThickness="0"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<Border BorderBrush="{DynamicResource ColorPickerButtonOutline}"
|
||||
BorderThickness="1"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
MinWidth="18" MinHeight="18"
|
||||
Background="{TemplateBinding Color, Converter={StaticResource ColorBrushConv}}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<controls:ColorPicker Name="ColorPicker" IsVisible="False" />
|
||||
</Border>
|
||||
</controls:Button>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style Selector="controls|ColorPickerButton.contained-color-picker-button /template/ Viewbox">
|
||||
<Setter Property="IsVisible" Value="False"></Setter>
|
||||
</Style>
|
||||
</Styles>
|
||||
Reference in new issue
Block a user