mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile editor - Updated timeline repeat for segments
UI - Added missing Stylet base calls Profile editor - Removed redundant min width on timeline rails Profile editor - Fixed timeline zooming Profile editor - Added missing tooltips
This commit is contained in:
parent
ce0024a14d
commit
9f951ca33f
@ -29,6 +29,8 @@ namespace Artemis.UI.Screens.Modules.Tabs
|
||||
{
|
||||
Items.Clear();
|
||||
Items.AddRange(Module.ActivationRequirements.Select(_moduleVmFactory.CreateActivationRequirementViewModel));
|
||||
|
||||
base.OnActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@
|
||||
xmlns:utilities="clr-namespace:Artemis.UI.Utilities"
|
||||
xmlns:layerProperties="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties"
|
||||
xmlns:controls="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Controls"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.LayerPropertiesView"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
@ -112,12 +113,35 @@
|
||||
<Button Style="{StaticResource MaterialDesignIconForegroundButton}" ToolTip="Next frame" Command="{s:Action GoToNextFrame}" Focusable="False">
|
||||
<materialDesign:PackIcon Kind="SkipNext" />
|
||||
</Button>
|
||||
<ToggleButton Style="{StaticResource MaterialDesignFlatToggleButton}"
|
||||
ToolTip="Repeat after last keyframe"
|
||||
IsChecked="{Binding RepeatAfterLastKeyframe}"
|
||||
Focusable="False">
|
||||
<materialDesign:PackIcon Kind="Repeat" Height="24" Width="24" />
|
||||
</ToggleButton>
|
||||
<shared:LockableToggleButton Style="{StaticResource MaterialDesignFlatToggleButton}"
|
||||
IsChecked="{Binding Repeating}"
|
||||
IsLocked="True"
|
||||
Focusable="False"
|
||||
Click="{s:Action CycleRepeating}">
|
||||
<shared:LockableToggleButton.ToolTip>
|
||||
<StackPanel>
|
||||
<StackPanel Visibility="{Binding Repeating, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" >
|
||||
<TextBlock Text="Repeat entire timeline"
|
||||
Visibility="{Binding RepeatTimeline, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
|
||||
<TextBlock Text="Repeat segment"
|
||||
Visibility="{Binding RepeatSegment, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
<TextBlock Visibility="{Binding Repeating, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}">Don't repeat the timeline</TextBlock>
|
||||
<TextBlock>This setting only applies to the editor and <Run Text="does not" FontWeight="Bold"/> affect the repeat mode during profile use</TextBlock>
|
||||
</StackPanel>
|
||||
</shared:LockableToggleButton.ToolTip>
|
||||
<Grid>
|
||||
<materialDesign:PackIcon Kind="Repeat"
|
||||
Height="24"
|
||||
Width="24"
|
||||
Visibility="{Binding RepeatTimeline, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
|
||||
<materialDesign:PackIcon Kind="RepeatOne"
|
||||
Height="24"
|
||||
Width="24"
|
||||
Visibility="{Binding RepeatSegment, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
|
||||
</Grid>
|
||||
|
||||
</shared:LockableToggleButton>
|
||||
</StackPanel>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}"
|
||||
@ -337,7 +361,7 @@
|
||||
Padding="10 0"
|
||||
Height="20"
|
||||
Width="110"
|
||||
ToolTip="Select an effect to add"
|
||||
ToolTip="Add a new segment to the timeline"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{Binding PropertyTreeVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
|
||||
IsEnabled="{Binding SelectedProfileElement, Converter={StaticResource NullToBooleanConverter}}">
|
||||
|
||||
@ -25,8 +25,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||
private LayerPropertyGroupViewModel _brushPropertyGroup;
|
||||
private bool _playing;
|
||||
private bool _repeating;
|
||||
private bool _repeatSegment;
|
||||
private bool _repeatTimeline = true;
|
||||
private int _propertyTreeIndex;
|
||||
private bool _repeatAfterLastKeyframe;
|
||||
private int _rightSideIndex;
|
||||
private RenderProfileElement _selectedProfileElement;
|
||||
|
||||
@ -89,10 +91,22 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
set => SetAndNotify(ref _playing, value);
|
||||
}
|
||||
|
||||
public bool RepeatAfterLastKeyframe
|
||||
public bool Repeating
|
||||
{
|
||||
get => _repeatAfterLastKeyframe;
|
||||
set => SetAndNotify(ref _repeatAfterLastKeyframe, value);
|
||||
get => _repeating;
|
||||
set => SetAndNotify(ref _repeating, value);
|
||||
}
|
||||
|
||||
public bool RepeatSegment
|
||||
{
|
||||
get => _repeatSegment;
|
||||
set => SetAndNotify(ref _repeatSegment, value);
|
||||
}
|
||||
|
||||
public bool RepeatTimeline
|
||||
{
|
||||
get => _repeatTimeline;
|
||||
set => SetAndNotify(ref _repeatTimeline, value);
|
||||
}
|
||||
|
||||
public string FormattedCurrentTime => $"{Math.Floor(ProfileEditorService.CurrentTime.TotalSeconds):00}.{ProfileEditorService.CurrentTime.Milliseconds:000}";
|
||||
@ -486,6 +500,27 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
ProfileEditorService.CurrentTime = TimeSpan.FromMilliseconds(newTime);
|
||||
}
|
||||
|
||||
public void CycleRepeating()
|
||||
{
|
||||
if (!Repeating)
|
||||
{
|
||||
RepeatTimeline = true;
|
||||
RepeatSegment = false;
|
||||
Repeating = true;
|
||||
}
|
||||
else if (RepeatTimeline)
|
||||
{
|
||||
RepeatTimeline = false;
|
||||
RepeatSegment = true;
|
||||
}
|
||||
else if (RepeatSegment)
|
||||
{
|
||||
RepeatTimeline = true;
|
||||
RepeatSegment = false;
|
||||
Repeating = false;
|
||||
}
|
||||
}
|
||||
|
||||
private TimeSpan CalculateEndTime()
|
||||
{
|
||||
var keyframeViewModels = LayerPropertyGroups.SelectMany(g => g.GetAllKeyframeViewModels(false)).ToList();
|
||||
@ -497,19 +532,50 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
return keyframeViewModels.Max(k => k.Position).Add(TimeSpan.FromSeconds(10));
|
||||
}
|
||||
|
||||
private TimeSpan GetCurrentSegmentStart()
|
||||
{
|
||||
var current = ProfileEditorService.CurrentTime;
|
||||
if (current < StartTimelineSegmentViewModel.SegmentEnd)
|
||||
return StartTimelineSegmentViewModel.SegmentStart;
|
||||
if (current < MainTimelineSegmentViewModel.SegmentEnd)
|
||||
return MainTimelineSegmentViewModel.SegmentStart;
|
||||
if (current < EndTimelineSegmentViewModel.SegmentEnd)
|
||||
return EndTimelineSegmentViewModel.SegmentStart;
|
||||
|
||||
return TimeSpan.Zero;
|
||||
}
|
||||
|
||||
private TimeSpan GetCurrentSegmentEnd()
|
||||
{
|
||||
var current = ProfileEditorService.CurrentTime;
|
||||
if (current < StartTimelineSegmentViewModel.SegmentEnd)
|
||||
return StartTimelineSegmentViewModel.SegmentEnd;
|
||||
if (current < MainTimelineSegmentViewModel.SegmentEnd)
|
||||
return MainTimelineSegmentViewModel.SegmentEnd;
|
||||
if (current < EndTimelineSegmentViewModel.SegmentEnd)
|
||||
return EndTimelineSegmentViewModel.SegmentEnd;
|
||||
|
||||
return TimeSpan.Zero;
|
||||
}
|
||||
|
||||
private void CoreServiceOnFrameRendering(object sender, FrameRenderingEventArgs e)
|
||||
{
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
var newTime = ProfileEditorService.CurrentTime.Add(TimeSpan.FromSeconds(e.DeltaTime));
|
||||
if (RepeatAfterLastKeyframe)
|
||||
if (Repeating && RepeatTimeline)
|
||||
{
|
||||
if (newTime > CalculateEndTime().Subtract(TimeSpan.FromSeconds(10)))
|
||||
if (newTime > SelectedProfileElement.TimelineLength)
|
||||
newTime = TimeSpan.Zero;
|
||||
}
|
||||
else if (newTime > CalculateEndTime())
|
||||
else if (Repeating && RepeatSegment)
|
||||
{
|
||||
newTime = CalculateEndTime();
|
||||
if (newTime > GetCurrentSegmentEnd())
|
||||
newTime = GetCurrentSegmentStart();
|
||||
}
|
||||
else if (newTime > SelectedProfileElement.TimelineLength)
|
||||
{
|
||||
newTime = SelectedProfileElement.TimelineLength;
|
||||
Pause();
|
||||
}
|
||||
|
||||
|
||||
@ -3,13 +3,11 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:timeline="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
MinWidth="{Binding Width}"
|
||||
HorizontalAlignment="Stretch">
|
||||
<Border Height="25" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource MaterialDesignDivider}">
|
||||
<ItemsControl ItemsSource="{Binding Items}"
|
||||
|
||||
@ -22,7 +22,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
LayerProperty.KeyframesToggled += LayerPropertyOnKeyframesToggled;
|
||||
LayerProperty.KeyframeAdded += LayerPropertyOnKeyframeAdded;
|
||||
LayerProperty.KeyframeRemoved += LayerPropertyOnKeyframeRemoved;
|
||||
_profileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
UpdateKeyframes();
|
||||
}
|
||||
|
||||
@ -69,7 +68,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
LayerProperty.KeyframesToggled -= LayerPropertyOnKeyframesToggled;
|
||||
LayerProperty.KeyframeAdded -= LayerPropertyOnKeyframeAdded;
|
||||
LayerProperty.KeyframeRemoved -= LayerPropertyOnKeyframeRemoved;
|
||||
_profileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
}
|
||||
|
||||
private void LayerPropertyOnKeyframesToggled(object sender, LayerPropertyEventArgs<T> e)
|
||||
@ -87,11 +85,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
UpdateKeyframes();
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
|
||||
{
|
||||
Width = GetAllKeyframeViewModels().Max(k => k.Position.TotalSeconds * _profileEditorService.PixelsPerSecond + 25);
|
||||
}
|
||||
|
||||
private void UpdateKeyframes()
|
||||
{
|
||||
// Only show keyframes if they are enabled
|
||||
|
||||
@ -18,6 +18,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
private bool _showRepeatButton;
|
||||
private bool _showSegmentName;
|
||||
private TimeSpan _segmentLength;
|
||||
private TimeSpan _segmentStart;
|
||||
private TimeSpan _segmentEnd;
|
||||
private double _segmentWidth;
|
||||
private bool _segmentEnabled;
|
||||
private double _segmentStartPosition;
|
||||
@ -59,6 +61,18 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
set => SetAndNotify(ref _segmentLength, value);
|
||||
}
|
||||
|
||||
public TimeSpan SegmentStart
|
||||
{
|
||||
get => _segmentStart;
|
||||
set => SetAndNotify(ref _segmentStart, value);
|
||||
}
|
||||
|
||||
public TimeSpan SegmentEnd
|
||||
{
|
||||
get => _segmentEnd;
|
||||
set => SetAndNotify(ref _segmentEnd, value);
|
||||
}
|
||||
|
||||
public double SegmentWidth
|
||||
{
|
||||
get => _segmentWidth;
|
||||
@ -134,6 +148,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
if (SelectedProfileElement == null)
|
||||
{
|
||||
SegmentLength = TimeSpan.Zero;
|
||||
SegmentStart = TimeSpan.Zero;
|
||||
SegmentEnd = TimeSpan.Zero;
|
||||
SegmentStartPosition = 0;
|
||||
SegmentWidth = 0;
|
||||
SegmentEnabled = false;
|
||||
@ -143,21 +159,22 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
if (Segment == SegmentViewModelType.Start)
|
||||
{
|
||||
SegmentLength = SelectedProfileElement.StartSegmentLength;
|
||||
SegmentStartPosition = 0;
|
||||
SegmentStart = TimeSpan.Zero;
|
||||
}
|
||||
else if (Segment == SegmentViewModelType.Main)
|
||||
{
|
||||
SegmentLength = SelectedProfileElement.MainSegmentLength;
|
||||
SegmentStartPosition = ProfileEditorService.PixelsPerSecond * SelectedProfileElement.StartSegmentLength.TotalSeconds;
|
||||
SegmentStart = SelectedProfileElement.StartSegmentLength;
|
||||
}
|
||||
else if (Segment == SegmentViewModelType.End)
|
||||
{
|
||||
SegmentLength = SelectedProfileElement.EndSegmentLength;
|
||||
SegmentStartPosition = ProfileEditorService.PixelsPerSecond * (SelectedProfileElement.StartSegmentLength.TotalSeconds +
|
||||
SelectedProfileElement.MainSegmentLength.TotalSeconds);
|
||||
SegmentStart = SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength;
|
||||
}
|
||||
|
||||
SegmentWidth = ProfileEditorService.PixelsPerSecond * SegmentLength.TotalSeconds;
|
||||
SegmentEnd = SegmentStart + SegmentLength;
|
||||
SegmentStartPosition = SegmentStart.TotalSeconds * ProfileEditorService.PixelsPerSecond;
|
||||
SegmentWidth = SegmentLength.TotalSeconds * ProfileEditorService.PixelsPerSecond;
|
||||
SegmentEnabled = SegmentLength != TimeSpan.Zero;
|
||||
|
||||
UpdateHeader();
|
||||
|
||||
@ -68,9 +68,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
private void Update()
|
||||
{
|
||||
StartSegmentEndPosition = LayerPropertiesViewModel.StartTimelineSegmentViewModel.SegmentWidth;
|
||||
MainSegmentEndPosition = StartSegmentEndPosition + LayerPropertiesViewModel.MainTimelineSegmentViewModel.SegmentWidth;
|
||||
EndSegmentEndPosition = MainSegmentEndPosition + LayerPropertiesViewModel.EndTimelineSegmentViewModel.SegmentWidth;
|
||||
StartSegmentEndPosition = LayerPropertiesViewModel.StartTimelineSegmentViewModel.SegmentEnd.TotalSeconds * _profileEditorService.PixelsPerSecond;
|
||||
MainSegmentEndPosition = LayerPropertiesViewModel.MainTimelineSegmentViewModel.SegmentEnd.TotalSeconds * _profileEditorService.PixelsPerSecond;
|
||||
EndSegmentEndPosition = LayerPropertiesViewModel.EndTimelineSegmentViewModel.SegmentEnd.TotalSeconds * _profileEditorService.PixelsPerSecond;
|
||||
|
||||
TotalTimelineWidth = EndSegmentEndPosition;
|
||||
}
|
||||
|
||||
@ -140,6 +140,7 @@
|
||||
</ComboBox.ItemsPanel>
|
||||
</ComboBox>
|
||||
<Button Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
ToolTip="Add a new profile"
|
||||
Margin="5 0"
|
||||
Grid.Column="1"
|
||||
Width="26"
|
||||
@ -149,6 +150,7 @@
|
||||
<materialDesign:PackIcon Kind="Add" Height="14" Width="14" />
|
||||
</Button>
|
||||
<Button Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}"
|
||||
ToolTip="Delete the current profile"
|
||||
Margin="5 0"
|
||||
Grid.Column="2"
|
||||
Width="26"
|
||||
@ -158,6 +160,7 @@
|
||||
<materialDesign:PackIcon Kind="TrashCanOutline" Height="14" Width="14" />
|
||||
</Button>
|
||||
<Button Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
ToolTip="Export the current profile"
|
||||
Margin="5 0"
|
||||
Grid.Column="3"
|
||||
Width="26"
|
||||
@ -167,6 +170,7 @@
|
||||
<materialDesign:PackIcon Kind="Export" Height="14" Width="14" />
|
||||
</Button>
|
||||
<Button Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
ToolTip="Import an existing profile"
|
||||
Margin="5 0 0 0"
|
||||
Grid.Column="4"
|
||||
Width="26"
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<ListBoxItem ToolTip="Pan over different parts of the surface">
|
||||
<materialDesign:PackIcon Kind="HandLeft" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Edit shape in layer" IsEnabled="{Binding CanSelectEditTool}">
|
||||
<ListBoxItem ToolTip="Edit shape in layer (hold SHIFT for incremental changes and X/Y snapping)" IsEnabled="{Binding CanSelectEditTool}">
|
||||
<materialDesign:PackIcon Kind="Edit" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Change layer selection (hold SHIFT to add to existing selection)">
|
||||
|
||||
@ -230,6 +230,8 @@ namespace Artemis.UI.Screens
|
||||
SidebarViewModel.PropertyChanged += SidebarViewModelOnPropertyChanged;
|
||||
|
||||
_titleUpdateTimer.Start();
|
||||
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
|
||||
@ -81,6 +81,8 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
||||
_pluginService.PluginDisabled += PluginServiceOnPluginToggled;
|
||||
|
||||
PopulateModules();
|
||||
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
@ -89,6 +91,8 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
||||
_updateTimer.Elapsed -= OnUpdateTimerOnElapsed;
|
||||
_pluginService.PluginEnabled -= PluginServiceOnPluginToggled;
|
||||
_pluginService.PluginDisabled -= PluginServiceOnPluginToggled;
|
||||
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
private void OnUpdateTimerOnElapsed(object sender, ElapsedEventArgs args)
|
||||
|
||||
@ -32,6 +32,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
foreach (var deviceSettingsViewModel in instances)
|
||||
Items.Add(deviceSettingsViewModel);
|
||||
});
|
||||
|
||||
base.OnActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,6 +214,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.General
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
Task.Run(ApplyAutorun);
|
||||
base.OnInitialActivate();
|
||||
}
|
||||
|
||||
private void ApplyAutorun()
|
||||
|
||||
@ -33,6 +33,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
Items.Add(pluginSettingsViewModel);
|
||||
});
|
||||
|
||||
base.OnActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user