mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Implemented basic keyframes
This commit is contained in:
1 parent
b734fa2f8f
commit
8a1759a575
41 files changed
+951
-123
No files matched your search
@@ -7,15 +7,36 @@ namespace Artemis.UI.Services.Interfaces
|
||||
{
|
||||
Profile SelectedProfile { get; }
|
||||
ProfileElement SelectedProfileElement { get; }
|
||||
TimeSpan CurrentTime { get; set; }
|
||||
|
||||
void ChangeSelectedProfile(Profile profile);
|
||||
void UpdateSelectedProfile();
|
||||
void ChangeSelectedProfileElement(ProfileElement profileElement);
|
||||
void UpdateSelectedProfileElement();
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a new profile is selected
|
||||
/// </summary>
|
||||
event EventHandler SelectedProfileChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs then the currently selected profile is updated
|
||||
/// </summary>
|
||||
event EventHandler SelectedProfileUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a new profile element is selected
|
||||
/// </summary>
|
||||
event EventHandler SelectedProfileElementChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the currently selected profile element is updated
|
||||
/// </summary>
|
||||
event EventHandler SelectedProfileElementUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the current editor time is changed
|
||||
/// </summary>
|
||||
event EventHandler CurrentTimeChanged;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ namespace Artemis.UI.Services
|
||||
public class ProfileEditorService : IProfileEditorService
|
||||
{
|
||||
private readonly IProfileService _profileService;
|
||||
private TimeSpan _currentTime;
|
||||
private TimeSpan _lastUpdateTime;
|
||||
|
||||
public ProfileEditorService(IProfileService profileService)
|
||||
{
|
||||
@@ -17,6 +19,19 @@ namespace Artemis.UI.Services
|
||||
public Profile SelectedProfile { get; private set; }
|
||||
public ProfileElement SelectedProfileElement { get; private set; }
|
||||
|
||||
public TimeSpan CurrentTime
|
||||
{
|
||||
get => _currentTime;
|
||||
set
|
||||
{
|
||||
if (_currentTime.Equals(value))
|
||||
return;
|
||||
_currentTime = value;
|
||||
UpdateProfilePreview();
|
||||
OnCurrentTimeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeSelectedProfile(Profile profile)
|
||||
{
|
||||
SelectedProfile = profile;
|
||||
@@ -41,10 +56,30 @@ namespace Artemis.UI.Services
|
||||
OnSelectedProfileElementUpdated();
|
||||
}
|
||||
|
||||
|
||||
private void UpdateProfilePreview()
|
||||
{
|
||||
var delta = CurrentTime - _lastUpdateTime;
|
||||
foreach (var layer in SelectedProfile.GetAllLayers())
|
||||
{
|
||||
// Override keyframe progress
|
||||
foreach (var baseLayerProperty in layer.Properties)
|
||||
baseLayerProperty.KeyframeEngine?.OverrideProgress(CurrentTime);
|
||||
|
||||
// Force layer shape to redraw
|
||||
layer.LayerShape?.CalculateRenderProperties(layer.PositionProperty.GetCurrentValue(), layer.SizeProperty.GetCurrentValue());
|
||||
// Update the brush with the delta (which can now be negative ^^)
|
||||
layer.Update(delta.TotalSeconds);
|
||||
}
|
||||
|
||||
_lastUpdateTime = CurrentTime;
|
||||
}
|
||||
|
||||
public event EventHandler SelectedProfileChanged;
|
||||
public event EventHandler SelectedProfileUpdated;
|
||||
public event EventHandler SelectedProfileElementChanged;
|
||||
public event EventHandler SelectedProfileElementUpdated;
|
||||
public event EventHandler CurrentTimeChanged;
|
||||
|
||||
protected virtual void OnSelectedProfileElementUpdated()
|
||||
{
|
||||
@@ -65,5 +100,10 @@ namespace Artemis.UI.Services
|
||||
{
|
||||
SelectedProfileChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnCurrentTimeChanged()
|
||||
{
|
||||
CurrentTimeChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user