mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Added layer properties to core and hooked it up with the UI
Implemented timeline caret scrolling logic Added special treeview style for the layer properties tree
This commit is contained in:
1 parent
14065bffef
commit
59f0062c97
48 files changed
+618
-381
No files matched your search
+100
-25
@@ -1,20 +1,52 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
{
|
||||
public class LayerPropertiesViewModel : ProfileEditorPanelViewModel
|
||||
{
|
||||
public LayerPropertiesViewModel()
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
|
||||
public LayerPropertiesViewModel(IProfileEditorService profileEditorService)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
|
||||
CurrentTime = TimeSpan.Zero;
|
||||
PixelsPerSecond = 1;
|
||||
PropertyTree = new PropertyTreeViewModel(this);
|
||||
PropertyTimeline = new PropertyTimelineViewModel(this);
|
||||
|
||||
PopulateProperties();
|
||||
|
||||
_profileEditorService.SelectedProfileElementChanged += (sender, args) => PopulateProperties();
|
||||
}
|
||||
|
||||
public TimeSpan CurrentTime
|
||||
{
|
||||
get => _currentTime;
|
||||
set
|
||||
{
|
||||
_currentTime = value;
|
||||
OnCurrentTimeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int PixelsPerSecond
|
||||
{
|
||||
get => _pixelsPerSecond;
|
||||
set
|
||||
{
|
||||
_pixelsPerSecond = value;
|
||||
OnPixelsPerSecondChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan CurrentTime { get; set; }
|
||||
public int PixelsPerSecond { get; set; }
|
||||
public Thickness TimeCaretPosition
|
||||
{
|
||||
get => new Thickness(CurrentTime.TotalSeconds * PixelsPerSecond, 0, 0, 0);
|
||||
@@ -24,29 +56,72 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
public PropertyTreeViewModel PropertyTree { get; set; }
|
||||
public PropertyTimelineViewModel PropertyTimeline { get; set; }
|
||||
|
||||
private void CreateTestValues()
|
||||
private void PopulateProperties()
|
||||
{
|
||||
// var propertyRailViewModels = new List<TimelinePropertyRailViewModel>();
|
||||
// for (var i = 0; i < 20; i++)
|
||||
// propertyRailViewModels.Add(new TimelinePropertyRailViewModel());
|
||||
//
|
||||
// TimelinePropertyRailViewModels.AddRange(propertyRailViewModels);
|
||||
//
|
||||
// // Transform will be the only built-in properties so test with that
|
||||
// var testVm = new TimelinePropertiesViewModel { PropertiesName = "Transform" };
|
||||
// testVm.Properties.Add(new TimelinePropertyViewModel { PropertyName = "Anchor Point" });
|
||||
// testVm.Properties.Add(new TimelinePropertyViewModel { PropertyName = "Position" });
|
||||
// testVm.Properties.Add(new TimelinePropertyViewModel { PropertyName = "Scale" });
|
||||
// testVm.Properties.Add(new TimelinePropertyViewModel { PropertyName = "Rotation" });
|
||||
// testVm.Properties.Add(new TimelinePropertyViewModel { PropertyName = "Opacity" });
|
||||
// // Purely for testing, add a nested property
|
||||
// var subTestVm = new TimelinePropertiesViewModel() { PropertiesName = "Sub Properties" };
|
||||
// subTestVm.Properties.Add(new TimelinePropertyViewModel { PropertyName = "Sub Property 1" });
|
||||
// subTestVm.Properties.Add(new TimelinePropertyViewModel { PropertyName = "Sub Property 2" });
|
||||
// subTestVm.Properties.Add(new TimelinePropertyViewModel { PropertyName = "Sub Property 3" });
|
||||
// testVm.Properties.Add(subTestVm);
|
||||
//
|
||||
// TimelinePropertiesViewModels.Add(testVm);
|
||||
if (_profileEditorService.SelectedProfileElement is Layer selectedLayer)
|
||||
{
|
||||
// Only create VMs for top-level parents, let parents populate their own children recursively
|
||||
var propertyViewModels = selectedLayer.Properties
|
||||
.Where(p => p.Children.Any())
|
||||
.Select(p => new LayerPropertyViewModel(p, null))
|
||||
.ToList();
|
||||
|
||||
PropertyTree.PopulateProperties(propertyViewModels);
|
||||
PropertyTimeline.PopulateProperties(propertyViewModels);
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyTree.ClearProperties();
|
||||
PropertyTimeline.ClearProperties();
|
||||
}
|
||||
}
|
||||
|
||||
#region Caret movement
|
||||
|
||||
private double _caretStartMouseStartOffset;
|
||||
private bool _mouseOverCaret;
|
||||
private int _pixelsPerSecond;
|
||||
private TimeSpan _currentTime;
|
||||
|
||||
public void RightGridMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
_caretStartMouseStartOffset = e.GetPosition((IInputElement) sender).X - TimeCaretPosition.Left;
|
||||
}
|
||||
|
||||
public void CaretMouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
_mouseOverCaret = true;
|
||||
}
|
||||
|
||||
public void CaretMouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton != MouseButtonState.Pressed)
|
||||
_mouseOverCaret = false;
|
||||
}
|
||||
|
||||
public void RightGridMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (_mouseOverCaret && e.LeftButton == MouseButtonState.Pressed)
|
||||
TimeCaretPosition = new Thickness(Math.Max(0, e.GetPosition((IInputElement) sender).X), 0, 0, 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler CurrentTimeChanged;
|
||||
public event EventHandler PixelsPerSecondChanged;
|
||||
|
||||
protected virtual void OnCurrentTimeChanged()
|
||||
{
|
||||
CurrentTimeChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnPixelsPerSecondChanged()
|
||||
{
|
||||
PixelsPerSecondChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user