1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Editor - Tweaked profile tree visuals

Editor - Add current profile name display, added smooth zooming
This commit is contained in:
Robert 2022-01-08 17:20:32 +01:00
parent 9bbab5f9f8
commit 33c54eaeb0
9 changed files with 108 additions and 46 deletions

View File

@ -201,7 +201,12 @@
</member> </member>
<member name="F:Artemis.UI.Shared.Controls.SelectionRectangle.BorderThicknessProperty"> <member name="F:Artemis.UI.Shared.Controls.SelectionRectangle.BorderThicknessProperty">
<summary> <summary>
Defines the <see cref="P:Artemis.UI.Shared.Controls.SelectionRectangle.BorderBrush" /> property. Defines the <see cref="P:Artemis.UI.Shared.Controls.SelectionRectangle.BorderThickness" /> property.
</summary>
</member>
<member name="F:Artemis.UI.Shared.Controls.SelectionRectangle.BorderRadiusProperty">
<summary>
Defines the <see cref="P:Artemis.UI.Shared.Controls.SelectionRectangle.BorderRadius" /> property.
</summary> </summary>
</member> </member>
<member name="F:Artemis.UI.Shared.Controls.SelectionRectangle.InputElementProperty"> <member name="F:Artemis.UI.Shared.Controls.SelectionRectangle.InputElementProperty">
@ -227,6 +232,11 @@
Gets or sets the width of the control's border Gets or sets the width of the control's border
</summary> </summary>
</member> </member>
<member name="P:Artemis.UI.Shared.Controls.SelectionRectangle.BorderRadius">
<summary>
Gets or sets the radius of the control's border
</summary>
</member>
<member name="P:Artemis.UI.Shared.Controls.SelectionRectangle.InputElement"> <member name="P:Artemis.UI.Shared.Controls.SelectionRectangle.InputElement">
<summary> <summary>
Gets or sets the element that captures input for the selection rectangle. Gets or sets the element that captures input for the selection rectangle.

View File

@ -26,11 +26,17 @@ namespace Artemis.UI.Shared.Controls
AvaloniaProperty.Register<SelectionRectangle, IBrush>(nameof(BorderBrush), new SolidColorBrush(Colors.CadetBlue)); AvaloniaProperty.Register<SelectionRectangle, IBrush>(nameof(BorderBrush), new SolidColorBrush(Colors.CadetBlue));
/// <summary> /// <summary>
/// Defines the <see cref="BorderBrush" /> property. /// Defines the <see cref="BorderThickness" /> property.
/// </summary> /// </summary>
public static readonly StyledProperty<double> BorderThicknessProperty = public static readonly StyledProperty<double> BorderThicknessProperty =
AvaloniaProperty.Register<SelectionRectangle, double>(nameof(BorderThickness), 1); AvaloniaProperty.Register<SelectionRectangle, double>(nameof(BorderThickness), 1);
/// <summary>
/// Defines the <see cref="BorderRadius" /> property.
/// </summary>
public static readonly StyledProperty<double> BorderRadiusProperty =
AvaloniaProperty.Register<SelectionRectangle, double>(nameof(BorderRadius), 0);
/// <summary> /// <summary>
/// Defines the <see cref="InputElement" /> property. /// Defines the <see cref="InputElement" /> property.
/// </summary> /// </summary>
@ -75,6 +81,15 @@ namespace Artemis.UI.Shared.Controls
set => SetValue(BorderThicknessProperty, value); set => SetValue(BorderThicknessProperty, value);
} }
/// <summary>
/// Gets or sets the radius of the control's border
/// </summary>
public double BorderRadius
{
get => GetValue(BorderRadiusProperty);
set => SetValue(BorderRadiusProperty, value);
}
/// <summary> /// <summary>
/// Gets or sets the element that captures input for the selection rectangle. /// Gets or sets the element that captures input for the selection rectangle.
/// </summary> /// </summary>
@ -181,7 +196,7 @@ namespace Artemis.UI.Shared.Controls
public override void Render(DrawingContext drawingContext) public override void Render(DrawingContext drawingContext)
{ {
if (_displayRect != null) if (_displayRect != null)
drawingContext.DrawRectangle(Background, new Pen(BorderBrush, BorderThickness), _displayRect.Value, 4, 4); drawingContext.DrawRectangle(Background, new Pen(BorderBrush, BorderThickness), _displayRect.Value, BorderRadius, BorderRadius);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -64,7 +64,7 @@
ColumnDefinitions="Auto, *" ColumnDefinitions="Auto, *"
Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource TreeViewItemLeftMarginConverter}}"> Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource TreeViewItemLeftMarginConverter}}">
<Panel Name="PART_ExpandCollapseChevronContainer" <Panel Name="PART_ExpandCollapseChevronContainer"
Margin="{StaticResource TreeViewItemExpandCollapseChevronMargin}"> Margin="8 0 4 0">
<ToggleButton Name="PART_ExpandCollapseChevron" <ToggleButton Name="PART_ExpandCollapseChevron"
Classes="ExpandCollapseChevron" Classes="ExpandCollapseChevron"
Focusable="False" Focusable="False"
@ -90,6 +90,10 @@
</Setter> </Setter>
</Style> </Style>
<Style Selector="Border#TreeViewItemLayoutRoot Panel.PART_ExpandCollapseChevronContainer">
<Setter Property="Margin" Value="0"></Setter>
</Style>
<!-- <Style Selector="TreeView.no-right-margin TreeViewItem /template/ Border#TreeViewItemLayoutRoot"> --> <!-- <Style Selector="TreeView.no-right-margin TreeViewItem /template/ Border#TreeViewItemLayoutRoot"> -->
<!-- <Setter Property="Margin" Value="2 2 0 2"/> --> <!-- <Setter Property="Margin" Value="2 2 0 2"/> -->
<!-- </Style> --> <!-- </Style> -->

View File

@ -13,16 +13,17 @@
Foreground="White" Foreground="White"
Background="#E74C4C" Background="#E74C4C"
BorderBrush="#E74C4C" BorderBrush="#E74C4C"
Margin="0 0 5 0"
Command="{Binding ShowBrokenStateExceptions}"> Command="{Binding ShowBrokenStateExceptions}">
<avalonia:MaterialIcon Kind="AlertCircle" /> <avalonia:MaterialIcon Kind="AlertCircle" />
</Button> </Button>
<avalonia:MaterialIcon Grid.Column="1" <avalonia:MaterialIcon Grid.Column="1"
Kind="Folder" Kind="Folder"
Margin="5 0" Margin="0 0 5 0"
IsVisible="{Binding !IsExpanded, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" /> IsVisible="{Binding !IsExpanded, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
<avalonia:MaterialIcon Grid.Column="1" <avalonia:MaterialIcon Grid.Column="1"
Kind="FolderOpen" Kind="FolderOpen"
Margin="5 0" Margin="0 0 5 0"
IsVisible="{Binding IsExpanded, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" /> IsVisible="{Binding IsExpanded, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
<TextBlock Grid.Column="2" Text="{Binding Folder.Name}" VerticalAlignment="Center" /> <TextBlock Grid.Column="2" Text="{Binding Folder.Name}" VerticalAlignment="Center" />
<ToggleButton Grid.Column="3" <ToggleButton Grid.Column="3"

View File

@ -11,10 +11,11 @@
IsVisible="{Binding ProfileElement.BrokenState, Converter={x:Static ObjectConverters.IsNotNull}}" IsVisible="{Binding ProfileElement.BrokenState, Converter={x:Static ObjectConverters.IsNotNull}}"
Classes="icon-button icon-button-small" Classes="icon-button icon-button-small"
Foreground="#E74C4C" Foreground="#E74C4C"
Margin="0 0 5 0"
Command="{Binding ShowBrokenStateExceptions}"> Command="{Binding ShowBrokenStateExceptions}">
<avalonia:MaterialIcon Kind="AlertCircle" /> <avalonia:MaterialIcon Kind="AlertCircle" />
</Button> </Button>
<avalonia:MaterialIcon Grid.Column="1" Kind="{Binding Layer.LayerBrush.Descriptor.Icon}" Margin="5 0" /> <avalonia:MaterialIcon Grid.Column="1" Kind="{Binding Layer.LayerBrush.Descriptor.Icon}" Margin="0 0 5 0" />
<TextBlock Grid.Column="2" Text="{Binding Layer.Name}" VerticalAlignment="Center" /> <TextBlock Grid.Column="2" Text="{Binding Layer.Name}" VerticalAlignment="Center" />
<ToggleButton Grid.Column="3" <ToggleButton Grid.Column="3"
Classes="icon-button icon-button-small" Classes="icon-button icon-button-small"

View File

@ -7,9 +7,9 @@
xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared" xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.ProfileEditor.VisualEditor.VisualEditorView"> x:Class="Artemis.UI.Screens.ProfileEditor.VisualEditor.VisualEditorView">
<Grid>
<paz:ZoomBorder Name="ZoomBorder" <paz:ZoomBorder Name="ZoomBorder"
Stretch="None" Stretch="None"
ZoomSpeed="1.2"
ClipToBounds="True" ClipToBounds="True"
Focusable="True" Focusable="True"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
@ -18,6 +18,11 @@
ZoomChanged="ZoomBorder_OnZoomChanged"> ZoomChanged="ZoomBorder_OnZoomChanged">
<Grid Name="ContainerGrid" <Grid Name="ContainerGrid"
Background="Transparent"> Background="Transparent">
<Grid.Transitions>
<Transitions>
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.2" Easing="CubicEaseOut"/>
</Transitions>
</Grid.Transitions>
<ItemsControl Items="{Binding Devices}" ClipToBounds="False"> <ItemsControl Items="{Binding Devices}" ClipToBounds="False">
<ItemsControl.Styles> <ItemsControl.Styles>
<Style Selector="ContentPresenter"> <Style Selector="ContentPresenter">
@ -38,4 +43,14 @@
</ItemsControl> </ItemsControl>
</Grid> </Grid>
</paz:ZoomBorder> </paz:ZoomBorder>
<Border CornerRadius="0 0 8 0" VerticalAlignment="Top" HorizontalAlignment="Left">
<Border.Background>
<SolidColorBrush Color="{DynamicResource CardStrokeColorDefaultSolid}" Opacity="0.65"></SolidColorBrush>
</Border.Background>
<StackPanel Orientation="Horizontal" Margin="8">
<controls:ProfileConfigurationIcon ConfigurationIcon="{Binding ProfileConfiguration.Icon}" Margin="0 0 5 0"></controls:ProfileConfigurationIcon>
<TextBlock Text="{Binding ProfileConfiguration.Name}"/>
</StackPanel>
</Border>
</Grid>
</UserControl> </UserControl>

View File

@ -1,17 +1,28 @@
using System.Collections.ObjectModel; using System;
using System.Collections.ObjectModel;
using System.Reactive.Disposables;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.UI.Services;
using Artemis.UI.Services.ProfileEditor; using Artemis.UI.Services.ProfileEditor;
using Artemis.UI.Shared; using Artemis.UI.Shared;
using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor namespace Artemis.UI.Screens.ProfileEditor.VisualEditor
{ {
public class VisualEditorViewModel : ActivatableViewModelBase public class VisualEditorViewModel : ActivatableViewModelBase
{ {
private ProfileConfiguration? _profileConfiguration;
public VisualEditorViewModel(IProfileEditorService profileEditorService, IRgbService rgbService) public VisualEditorViewModel(IProfileEditorService profileEditorService, IRgbService rgbService)
{ {
Devices = new ObservableCollection<ArtemisDevice>(rgbService.EnabledDevices); Devices = new ObservableCollection<ArtemisDevice>(rgbService.EnabledDevices);
this.WhenActivated(d => profileEditorService.ProfileConfiguration.Subscribe(configuration => ProfileConfiguration = configuration).DisposeWith(d));
}
public ProfileConfiguration? ProfileConfiguration
{
get => _profileConfiguration;
set => this.RaiseAndSetIfChanged(ref _profileConfiguration, value);
} }
public ObservableCollection<ArtemisDevice> Devices { get; } public ObservableCollection<ArtemisDevice> Devices { get; }

View File

@ -26,10 +26,10 @@
Classes.selection-border-selected="{Binding Highlighted}" Classes.selection-border-selected="{Binding Highlighted}"
BorderThickness="1"> BorderThickness="1">
<Border.BorderBrush> <Border.BorderBrush>
<SolidColorBrush Color="{DynamicResource SystemAccentColor}"></SolidColorBrush> <SolidColorBrush Color="{DynamicResource SystemAccentColorLight2}"></SolidColorBrush>
</Border.BorderBrush> </Border.BorderBrush>
<Border.Background> <Border.Background>
<SolidColorBrush Color="{DynamicResource SystemAccentColor}" Opacity="0.2"></SolidColorBrush> <SolidColorBrush Color="{DynamicResource SystemAccentColorLight2}" Opacity="0.2"></SolidColorBrush>
</Border.Background> </Border.Background>
</Border> </Border>
</Grid> </Grid>

View File

@ -11,7 +11,6 @@
<Border Classes="router-container"> <Border Classes="router-container">
<paz:ZoomBorder Name="ZoomBorder" <paz:ZoomBorder Name="ZoomBorder"
Stretch="None" Stretch="None"
ZoomSpeed="1.2"
ClipToBounds="True" ClipToBounds="True"
Focusable="True" Focusable="True"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
@ -22,6 +21,11 @@
PointerMoved="ZoomBorder_OnPointerMoved" PointerMoved="ZoomBorder_OnPointerMoved"
PointerReleased="ZoomBorder_OnPointerReleased"> PointerReleased="ZoomBorder_OnPointerReleased">
<Grid Name="ContainerGrid" Background="Transparent"> <Grid Name="ContainerGrid" Background="Transparent">
<Grid.Transitions>
<Transitions>
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.2" Easing="CubicEaseOut"/>
</Transitions>
</Grid.Transitions>
<ItemsControl Items="{Binding SurfaceDeviceViewModels}" ClipToBounds="False"> <ItemsControl Items="{Binding SurfaceDeviceViewModels}" ClipToBounds="False">
<ItemsControl.Styles> <ItemsControl.Styles>
<Style Selector="ContentPresenter"> <Style Selector="ContentPresenter">
@ -89,9 +93,10 @@
<controls:SelectionRectangle Name="SelectionRectangle" <controls:SelectionRectangle Name="SelectionRectangle"
InputElement="{Binding #ZoomBorder}" InputElement="{Binding #ZoomBorder}"
SelectionUpdated="SelectionRectangle_OnSelectionUpdated" SelectionUpdated="SelectionRectangle_OnSelectionUpdated"
BorderBrush="{DynamicResource SystemAccentColor}"> BorderBrush="{DynamicResource SystemAccentColor}"
BorderRadius="8">
<controls:SelectionRectangle.Background> <controls:SelectionRectangle.Background>
<SolidColorBrush Color="{DynamicResource SystemAccentColor}" Opacity="0.2"></SolidColorBrush> <SolidColorBrush Color="{DynamicResource SystemAccentColorLight1}" Opacity="0.2"></SolidColorBrush>
</controls:SelectionRectangle.Background> </controls:SelectionRectangle.Background>
</controls:SelectionRectangle> </controls:SelectionRectangle>
@ -101,7 +106,7 @@
Width="{Binding MaxTextureSize}" Width="{Binding MaxTextureSize}"
Height="{Binding MaxTextureSize}" Height="{Binding MaxTextureSize}"
BorderThickness="2" BorderThickness="2"
BorderBrush="{DynamicResource SystemAccentColorDark3}" BorderBrush="{DynamicResource SystemAccentColorLight3}"
CornerRadius="8" /> CornerRadius="8" />
</Grid> </Grid>
</paz:ZoomBorder> </paz:ZoomBorder>