mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Added keyframe creation outside the timeline
Added existing shape moving
This commit is contained in:
1 parent
ce2f05b135
commit
e9677f2070
22 files changed
+178
-148
No files matched your search
@@ -9,15 +9,20 @@
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type local:EditToolViewModel}}">
|
||||
<Canvas>
|
||||
<Canvas UseLayoutRounding="False">
|
||||
<!-- The rectangle around the shape that allows modification -->
|
||||
<Rectangle Width="{Binding ShapeSkRect.Width}"
|
||||
Height="{Binding ShapeSkRect.Height}"
|
||||
Canvas.Left="{Binding ShapeSkRect.Left}"
|
||||
Canvas.Top="{Binding ShapeSkRect.Top}"
|
||||
Fill="Transparent"
|
||||
Stroke="{DynamicResource PrimaryHueMidBrush}"
|
||||
StrokeThickness="1"
|
||||
StrokeDashArray="2 2" />
|
||||
StrokeDashArray="2 2"
|
||||
Cursor="Hand"
|
||||
MouseDown="{s:Action ShapeEditMouseDown}"
|
||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||
MouseMove="{s:Action Move}"/>
|
||||
|
||||
<!-- Top left display -->
|
||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||
|
||||
+45
-29
@@ -10,7 +10,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
public class EditToolViewModel : VisualizationToolViewModel
|
||||
{
|
||||
private bool _mouseDown;
|
||||
private bool _isDragging;
|
||||
private double _dragOffsetY;
|
||||
private double _dragOffsetX;
|
||||
|
||||
public EditToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
|
||||
{
|
||||
@@ -19,7 +21,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
|
||||
profileEditorService.SelectedProfileChanged += (sender, args) => Update();
|
||||
profileEditorService.SelectedProfileElementUpdated += (sender, args) => Update();
|
||||
profileEditorService.CurrentTimeChanged += (sender, args) => Update();
|
||||
profileEditorService.ProfilePreviewUpdated += (sender, args) => Update();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -34,41 +36,64 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
|
||||
public void ShapeEditMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (_isDragging)
|
||||
return;
|
||||
|
||||
((IInputElement) sender).CaptureMouse();
|
||||
_mouseDown = true;
|
||||
if (ProfileEditorService.SelectedProfileElement is Layer layer)
|
||||
{
|
||||
var dragStartPosition = GetRelativePosition(sender, e);
|
||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||
_dragOffsetX = skRect.Left - dragStartPosition.X;
|
||||
_dragOffsetY = skRect.Top - dragStartPosition.Y;
|
||||
}
|
||||
|
||||
_isDragging = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
public void ShapeEditMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
((IInputElement) sender).ReleaseMouseCapture();
|
||||
_mouseDown = false;
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
|
||||
_isDragging = false;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
public void Move(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||
return;
|
||||
|
||||
var position = GetRelativePosition(sender, e);
|
||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||
layer.LayerShape.SetFromUnscaledRectangle(
|
||||
SKRect.Create((float) (position.X + _dragOffsetX), (float) (position.Y + _dragOffsetY), skRect.Width, skRect.Height),
|
||||
ProfileEditorService.CurrentTime
|
||||
);
|
||||
ProfileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
public void TopLeftRotate(object sender, MouseEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public void TopLeftResize(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void TopCenterResize(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!_mouseDown)
|
||||
return;
|
||||
if (!(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||
return;
|
||||
|
||||
var position = GetRelativePosition(sender, e);
|
||||
|
||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||
skRect.Top = (float) Math.Min(position.Y, skRect.Bottom);
|
||||
layer.LayerShape.SetFromUnscaledRectangle(skRect);
|
||||
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
||||
ProfileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
public void TopRightRotate(object sender, MouseEventArgs e)
|
||||
@@ -81,18 +106,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
|
||||
public void CenterRightResize(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!_mouseDown)
|
||||
return;
|
||||
if (!(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||
return;
|
||||
|
||||
var position = GetRelativePosition(sender, e);
|
||||
|
||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||
skRect.Right = (float) Math.Max(position.X, skRect.Left);
|
||||
layer.LayerShape.SetFromUnscaledRectangle(skRect);
|
||||
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
||||
ProfileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
private Point GetRelativePosition(object sender, MouseEventArgs mouseEventArgs)
|
||||
@@ -111,18 +133,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
|
||||
public void BottomCenterResize(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!_mouseDown)
|
||||
return;
|
||||
if (!(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||
return;
|
||||
|
||||
var position = GetRelativePosition(sender, e);
|
||||
|
||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||
skRect.Bottom = (float) Math.Max(position.Y, skRect.Top);
|
||||
layer.LayerShape.SetFromUnscaledRectangle(skRect);
|
||||
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
||||
ProfileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
public void BottomLeftRotate(object sender, MouseEventArgs e)
|
||||
@@ -135,18 +154,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
|
||||
public void CenterLeftResize(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!_mouseDown)
|
||||
return;
|
||||
if (!(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||
return;
|
||||
|
||||
var position = GetRelativePosition(sender, e);
|
||||
|
||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||
skRect.Left = (float) Math.Min(position.X, skRect.Right);
|
||||
layer.LayerShape.SetFromUnscaledRectangle(skRect);
|
||||
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
||||
ProfileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -48,7 +48,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
layer.LayerShape = new Ellipse(layer);
|
||||
|
||||
// Apply the drag rectangle
|
||||
layer.LayerShape.SetFromUnscaledRectangle(DragRectangle.ToSKRect());
|
||||
layer.LayerShape.SetFromUnscaledRectangle(DragRectangle.ToSKRect(), ProfileEditorService.CurrentTime);
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
layer.LayerShape = new Rectangle(layer);
|
||||
|
||||
// Apply the drag rectangle
|
||||
layer.LayerShape.SetFromUnscaledRectangle(DragRectangle.ToSKRect());
|
||||
layer.LayerShape.SetFromUnscaledRectangle(DragRectangle.ToSKRect(), ProfileEditorService.CurrentTime);
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
layer.AddLeds(selectedLeds);
|
||||
// Restore the saved size
|
||||
if (layer.LayerShape != null)
|
||||
layer.LayerShape.SetFromUnscaledRectangle(shapeSize);
|
||||
layer.LayerShape.SetFromUnscaledRectangle(shapeSize, ProfileEditorService.CurrentTime);
|
||||
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user