mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
UI - Further restructuring
This commit is contained in:
1 parent
a9c9d06354
commit
678fad95d1
53 files changed
+459
-1242
No files matched your search
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
|
||||
|
||||
namespace Artemis.UI.Services.Interfaces
|
||||
{
|
||||
@@ -11,6 +14,7 @@ namespace Artemis.UI.Services.Interfaces
|
||||
ProfileElement SelectedProfileElement { get; }
|
||||
TimeSpan CurrentTime { get; set; }
|
||||
|
||||
LayerPropertyBaseViewModel CreateLayerPropertyViewModel(BaseLayerProperty baseLayerProperty, PropertyDescriptionAttribute propertyDescription);
|
||||
void ChangeSelectedProfile(Profile profile);
|
||||
void UpdateSelectedProfile();
|
||||
void ChangeSelectedProfileElement(ProfileElement profileElement);
|
||||
@@ -18,6 +22,8 @@ namespace Artemis.UI.Services.Interfaces
|
||||
void UpdateProfilePreview();
|
||||
void UndoUpdateProfile(ProfileModule module);
|
||||
void RedoUpdateProfile(ProfileModule module);
|
||||
void StopRegularRender();
|
||||
void ResumeRegularRender();
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a new profile is selected
|
||||
@@ -48,8 +54,5 @@ namespace Artemis.UI.Services.Interfaces
|
||||
/// Occurs when the profile preview has been updated
|
||||
/// </summary>
|
||||
event EventHandler ProfilePreviewUpdated;
|
||||
|
||||
void StopRegularRender();
|
||||
void ResumeRegularRender();
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace Artemis.UI.Services
|
||||
public Point GetLayerAnchorPosition(Layer layer, SKPoint? positionOverride = null)
|
||||
{
|
||||
var layerBounds = GetLayerBounds(layer).ToSKRect();
|
||||
var positionProperty = layer.Properties.Position.CurrentValue;
|
||||
var positionProperty = layer.Transform.Position.CurrentValue;
|
||||
if (positionOverride != null)
|
||||
positionProperty = positionOverride.Value;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Artemis.UI.Services
|
||||
// the layer using the structure of the XAML while the Core has to deal with that by applying the layer
|
||||
// position to the translation
|
||||
var anchorPosition = GetLayerAnchorPosition(layer);
|
||||
var anchorProperty = layer.Properties.AnchorPoint.CurrentValue;
|
||||
var anchorProperty = layer.Transform.AnchorPoint.CurrentValue;
|
||||
|
||||
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
||||
var x = anchorPosition.X - layerBounds.MidX - anchorProperty.X * layerBounds.Width;
|
||||
@@ -67,8 +67,8 @@ namespace Artemis.UI.Services
|
||||
|
||||
var transformGroup = new TransformGroup();
|
||||
transformGroup.Children.Add(new TranslateTransform(x, y));
|
||||
transformGroup.Children.Add(new ScaleTransform(layer.Properties.Scale.CurrentValue.Width / 100f, layer.Properties.Scale.CurrentValue.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||
transformGroup.Children.Add(new RotateTransform(layer.Properties.Rotation.CurrentValue, anchorPosition.X, anchorPosition.Y));
|
||||
transformGroup.Children.Add(new ScaleTransform(layer.Transform.Scale.CurrentValue.Width / 100f, layer.Transform.Scale.CurrentValue.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||
transformGroup.Children.Add(new RotateTransform(layer.Transform.Rotation.CurrentValue, anchorPosition.X, anchorPosition.Y));
|
||||
|
||||
return transformGroup;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace Artemis.UI.Services
|
||||
if (anchorOverride != null)
|
||||
anchorPosition = anchorOverride.Value;
|
||||
|
||||
var anchorProperty = layer.Properties.AnchorPoint.CurrentValue;
|
||||
var anchorProperty = layer.Transform.AnchorPoint.CurrentValue;
|
||||
|
||||
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
||||
var x = anchorPosition.X - layerBounds.MidX - anchorProperty.X * layerBounds.Width;
|
||||
@@ -94,9 +94,9 @@ namespace Artemis.UI.Services
|
||||
if (includeTranslation)
|
||||
path.Transform(SKMatrix.MakeTranslation(x, y));
|
||||
if (includeScale)
|
||||
path.Transform(SKMatrix.MakeScale(layer.Properties.Scale.CurrentValue.Width / 100f, layer.Properties.Scale.CurrentValue.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||
path.Transform(SKMatrix.MakeScale(layer.Transform.Scale.CurrentValue.Width / 100f, layer.Transform.Scale.CurrentValue.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||
if (includeRotation)
|
||||
path.Transform(SKMatrix.MakeRotationDegrees(layer.Properties.Rotation.CurrentValue, anchorPosition.X, anchorPosition.Y));
|
||||
path.Transform(SKMatrix.MakeRotationDegrees(layer.Transform.Rotation.CurrentValue, anchorPosition.X, anchorPosition.Y));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
|
||||
namespace Artemis.UI.Services
|
||||
{
|
||||
@@ -13,15 +22,21 @@ namespace Artemis.UI.Services
|
||||
{
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly List<Type> _registeredProfileEditors;
|
||||
private TimeSpan _currentTime;
|
||||
private TimeSpan _lastUpdateTime;
|
||||
|
||||
public ProfileEditorService(ICoreService coreService, IProfileService profileService)
|
||||
public ProfileEditorService(ICoreService coreService, IProfileService profileService, IKernel kernel)
|
||||
{
|
||||
_coreService = coreService;
|
||||
_profileService = profileService;
|
||||
_kernel = kernel;
|
||||
_registeredProfileEditors = new List<Type>();
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<Type> RegisteredPropertyEditors => _registeredProfileEditors.AsReadOnly();
|
||||
|
||||
public Profile SelectedProfile { get; private set; }
|
||||
public ProfileElement SelectedProfileElement { get; private set; }
|
||||
|
||||
@@ -38,6 +53,23 @@ namespace Artemis.UI.Services
|
||||
}
|
||||
}
|
||||
|
||||
public LayerPropertyBaseViewModel CreateLayerPropertyViewModel(BaseLayerProperty baseLayerProperty, PropertyDescriptionAttribute propertyDescription)
|
||||
{
|
||||
// Go through the pain of instantiating a generic type VM now via reflection to make things a lot simpler down the line
|
||||
var genericType = baseLayerProperty.GetType().GetGenericArguments()[0];
|
||||
// Only create entries for types supported by a tree input VM
|
||||
if (!TreePropertyViewModel.IsPropertySupported(genericType))
|
||||
return null;
|
||||
var genericViewModel = typeof(LayerPropertyViewModel<>).MakeGenericType(genericType);
|
||||
var parameters = new IParameter[]
|
||||
{
|
||||
new ConstructorArgument("layerProperty", baseLayerProperty),
|
||||
new ConstructorArgument("propertyDescription", propertyDescription)
|
||||
};
|
||||
|
||||
return (LayerPropertyBaseViewModel) _kernel.Get(genericViewModel, parameters);
|
||||
}
|
||||
|
||||
public void ChangeSelectedProfile(Profile profile)
|
||||
{
|
||||
ChangeSelectedProfileElement(null);
|
||||
|
||||
Reference in new issue
Block a user