mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 01:42:02 +00:00
Some attempts at proper anchor movement..
This commit is contained in:
parent
d79437b3fd
commit
41fbbbd87a
@ -160,18 +160,22 @@ namespace Artemis.Core.Models.Profile
|
|||||||
canvas.ClipPath(Path);
|
canvas.ClipPath(Path);
|
||||||
|
|
||||||
// Apply transformations
|
// Apply transformations
|
||||||
var anchor = AnchorPointProperty.CurrentValue;
|
|
||||||
var position = PositionProperty.CurrentValue;
|
var position = PositionProperty.CurrentValue;
|
||||||
var size = SizeProperty.CurrentValue;
|
var size = SizeProperty.CurrentValue;
|
||||||
var rotation = RotationProperty.CurrentValue;
|
var rotation = RotationProperty.CurrentValue;
|
||||||
// Scale the anchor and make it originate from the center of the untranslated layer shape
|
|
||||||
anchor.X = anchor.X * AbsoluteRectangle.Width + LayerShape.RenderRectangle.MidX;
|
|
||||||
anchor.Y = anchor.Y * AbsoluteRectangle.Height + LayerShape.RenderRectangle.MidY;
|
|
||||||
|
|
||||||
canvas.Translate(position.X * AbsoluteRectangle.Width, position.Y * AbsoluteRectangle.Height);
|
var anchor = GetLayerAnchor(true);
|
||||||
|
var relativeAnchor = GetLayerAnchor(false);
|
||||||
|
|
||||||
|
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
||||||
|
var x = position.X * Rectangle.Width - LayerShape.RenderRectangle.Width / 2 - relativeAnchor.X;
|
||||||
|
var y = position.Y * Rectangle.Height - LayerShape.RenderRectangle.Height / 2 - relativeAnchor.Y;
|
||||||
|
|
||||||
|
|
||||||
canvas.RotateDegrees(rotation, anchor.X, anchor.Y);
|
canvas.RotateDegrees(rotation, anchor.X, anchor.Y);
|
||||||
canvas.Scale(size.Width, size.Height, anchor.X, anchor.Y);
|
canvas.Scale(size.Width, size.Height, anchor.X, anchor.Y);
|
||||||
|
canvas.Translate(x, y);
|
||||||
|
|
||||||
// Placeholder
|
// Placeholder
|
||||||
if (LayerShape?.RenderPath != null)
|
if (LayerShape?.RenderPath != null)
|
||||||
{
|
{
|
||||||
@ -192,6 +196,22 @@ namespace Artemis.Core.Models.Profile
|
|||||||
canvas.Restore();
|
canvas.Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SKPoint GetLayerAnchor(bool absolute)
|
||||||
|
{
|
||||||
|
if (!absolute)
|
||||||
|
{
|
||||||
|
var anchor = AnchorPointProperty.CurrentValue;
|
||||||
|
anchor.X = anchor.X * Rectangle.Width;
|
||||||
|
anchor.Y = anchor.Y * Rectangle.Height;
|
||||||
|
return new SKPoint(anchor.X, anchor.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
var position = PositionProperty.CurrentValue;
|
||||||
|
position.X = position.X * Rectangle.Width;
|
||||||
|
position.Y = position.Y * Rectangle.Height;
|
||||||
|
return new SKPoint(position.X + LayerShape.RenderRectangle.Left, position.Y + LayerShape.RenderRectangle.Top);
|
||||||
|
}
|
||||||
|
|
||||||
internal override void ApplyToEntity()
|
internal override void ApplyToEntity()
|
||||||
{
|
{
|
||||||
// Properties
|
// Properties
|
||||||
|
|||||||
@ -58,10 +58,10 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
|||||||
return SKRect.Empty;
|
return SKRect.Empty;
|
||||||
|
|
||||||
return SKRect.Create(
|
return SKRect.Create(
|
||||||
Layer.AbsoluteRectangle.Left + Layer.AbsoluteRectangle.Width * ScaledRectangle.Left,
|
Layer.Rectangle.Left + Layer.Rectangle.Width * ScaledRectangle.Left,
|
||||||
Layer.AbsoluteRectangle.Top + Layer.AbsoluteRectangle.Height * ScaledRectangle.Top,
|
Layer.Rectangle.Top + Layer.Rectangle.Height * ScaledRectangle.Top,
|
||||||
Layer.AbsoluteRectangle.Width * ScaledRectangle.Width,
|
Layer.Rectangle.Width * ScaledRectangle.Width,
|
||||||
Layer.AbsoluteRectangle.Height * ScaledRectangle.Height
|
Layer.Rectangle.Height * ScaledRectangle.Height
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,8 +75,8 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
|||||||
}
|
}
|
||||||
|
|
||||||
Layer.AnchorPointProperty.SetCurrentValue(new SKPoint(
|
Layer.AnchorPointProperty.SetCurrentValue(new SKPoint(
|
||||||
100f / Layer.AbsoluteRectangle.Width * (anchor.X - Layer.AbsoluteRectangle.Left - Layer.PositionProperty.CurrentValue.X) / 100f,
|
100f / Layer.Rectangle.Width * (anchor.X - Layer.Rectangle.Left - Layer.PositionProperty.CurrentValue.X) / 100f,
|
||||||
100f / Layer.AbsoluteRectangle.Height * (anchor.Y - Layer.AbsoluteRectangle.Top - Layer.PositionProperty.CurrentValue.Y) / 100f
|
100f / Layer.Rectangle.Height * (anchor.Y - Layer.Rectangle.Top - Layer.PositionProperty.CurrentValue.Y) / 100f
|
||||||
), time);
|
), time);
|
||||||
CalculateRenderProperties();
|
CalculateRenderProperties();
|
||||||
}
|
}
|
||||||
@ -87,8 +87,8 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
|||||||
return SKPoint.Empty;
|
return SKPoint.Empty;
|
||||||
|
|
||||||
return new SKPoint(
|
return new SKPoint(
|
||||||
Layer.AbsoluteRectangle.Left + Layer.AbsoluteRectangle.Width * (Layer.AnchorPointProperty.CurrentValue.X + Layer.PositionProperty.CurrentValue.X),
|
Layer.Rectangle.Left + Layer.Rectangle.Width * (Layer.AnchorPointProperty.CurrentValue.X + Layer.PositionProperty.CurrentValue.X),
|
||||||
Layer.AbsoluteRectangle.Top + Layer.AbsoluteRectangle.Height * (Layer.AnchorPointProperty.CurrentValue.Y + Layer.PositionProperty.CurrentValue.Y)
|
Layer.Rectangle.Top + Layer.Rectangle.Height * (Layer.AnchorPointProperty.CurrentValue.Y + Layer.PositionProperty.CurrentValue.Y)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,12 +5,13 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools"
|
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance {x:Type local:EditToolViewModel}}">
|
d:DataContext="{d:DesignInstance {x:Type local:EditToolViewModel}}">
|
||||||
<Canvas UseLayoutRounding="False">
|
<Canvas UseLayoutRounding="False">
|
||||||
<Canvas >
|
<Canvas>
|
||||||
<!-- The part of the layer's shape that is inside the layer -->
|
<!-- The part of the layer's shape that is inside the layer -->
|
||||||
<Path Data="{Binding ShapeGeometry, Mode=OneWay}"
|
<Path Data="{Binding ShapeGeometry, Mode=OneWay}"
|
||||||
Fill="Transparent"
|
Fill="Transparent"
|
||||||
@ -20,8 +21,7 @@
|
|||||||
Cursor="Hand"
|
Cursor="Hand"
|
||||||
MouseDown="{s:Action ShapeEditMouseDown}"
|
MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action Move}">
|
MouseMove="{s:Action Move}" />
|
||||||
</Path>
|
|
||||||
|
|
||||||
<!-- Mutation points -->
|
<!-- Mutation points -->
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding TopLeft.X}" Canvas.Top="{Binding TopLeft.Y}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding TopLeft.X}" Canvas.Top="{Binding TopLeft.Y}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
@ -34,11 +34,25 @@
|
|||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding LeftCenter.X}" Canvas.Top="{Binding LeftCenter.Y}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding LeftCenter.X}" Canvas.Top="{Binding LeftCenter.Y}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
|
|
||||||
<!-- Anchor point -->
|
<!-- Anchor point -->
|
||||||
|
<materialDesign:PackIcon Kind="Crosshairs"
|
||||||
|
Width="8"
|
||||||
|
Height="8"
|
||||||
|
Foreground="{DynamicResource SecondaryAccentBrush}"
|
||||||
|
Canvas.Left="{Binding ShapeAnchor.X}"
|
||||||
|
Canvas.Top="{Binding ShapeAnchor.Y}"
|
||||||
|
Margin="-4,-4,0,0" />
|
||||||
<Ellipse MouseDown="{s:Action AnchorEditMouseDown}"
|
<Ellipse MouseDown="{s:Action AnchorEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action AnchorMove}"
|
MouseMove="{s:Action AnchorMove}"
|
||||||
Width="6" Height="6" Fill="{DynamicResource SecondaryAccentBrush}" Canvas.Left="{Binding ShapeAnchor.X}" Canvas.Top="{Binding ShapeAnchor.Y}" Margin="-3,-3,0,0"
|
Width="8"
|
||||||
Cursor="SizeAll" />
|
Height="8"
|
||||||
|
Fill="Transparent"
|
||||||
|
Canvas.Left="{Binding ShapeAnchor.X}"
|
||||||
|
Canvas.Top="{Binding ShapeAnchor.Y}"
|
||||||
|
Margin="-4,-4,0,0"
|
||||||
|
Cursor="SizeAll">
|
||||||
|
</Ellipse>
|
||||||
|
|
||||||
</Canvas>
|
</Canvas>
|
||||||
<Canvas>
|
<Canvas>
|
||||||
<Canvas.RenderTransform>
|
<Canvas.RenderTransform>
|
||||||
@ -48,45 +62,45 @@
|
|||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action TopLeftRotate}"
|
MouseMove="{s:Action TopLeftRotate}"
|
||||||
Width="15" Height="15"
|
Width="15" Height="15"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Left}"
|
Canvas.Left="{Binding ShapeRectangle.Left}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Top}"
|
Canvas.Top="{Binding ShapeRectangle.Top}"
|
||||||
Fill="Blue"
|
Fill="Transparent"
|
||||||
Margin="-12,-12,0,0"
|
Margin="-12,-12,0,0"
|
||||||
Cursor="/Resources/aero_rotate_tl.cur" />
|
Cursor="/Resources/aero_rotate_tl.cur" />
|
||||||
<!-- Top left resize handle -->
|
<!-- Top left resize handle -->
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action TopLeftResize}"
|
MouseMove="{s:Action TopLeftResize}"
|
||||||
Width="6"
|
Width="6"
|
||||||
Height="6"
|
Height="6"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Left}"
|
Canvas.Left="{Binding ShapeRectangle.Left}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Top}"
|
Canvas.Top="{Binding ShapeRectangle.Top}"
|
||||||
Fill="Red"
|
Fill="Transparent"
|
||||||
Margin="-3,-3,0,0"
|
Margin="-3,-3,0,0"
|
||||||
Cursor="SizeNWSE" />
|
Cursor="SizeNWSE" />
|
||||||
|
|
||||||
<!-- Top center resize handle -->
|
<!-- Top center resize handle -->
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action TopCenterResize}"
|
MouseMove="{s:Action TopCenterResize}"
|
||||||
Width="10"
|
Width="10"
|
||||||
Height="10"
|
Height="10"
|
||||||
Canvas.Left="{Binding ShapeRectangle.MidX}"
|
Canvas.Left="{Binding ShapeRectangle.MidX}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Top}"
|
Canvas.Top="{Binding ShapeRectangle.Top}"
|
||||||
Fill="Red"
|
Fill="Transparent"
|
||||||
Margin="-5,-5,0,0"
|
Margin="-5,-5,0,0"
|
||||||
Cursor="SizeNS" />
|
Cursor="SizeNS" />
|
||||||
|
|
||||||
<!-- Top right rotate handle -->
|
<!-- Top right rotate handle -->
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action TopRightRotate}"
|
MouseMove="{s:Action TopRightRotate}"
|
||||||
Width="15"
|
Width="15"
|
||||||
Height="15"
|
Height="15"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Right}"
|
Canvas.Left="{Binding ShapeRectangle.Right}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Top}"
|
Canvas.Top="{Binding ShapeRectangle.Top}"
|
||||||
Fill="Blue"
|
Fill="Transparent"
|
||||||
Margin="-3,-12,0,0"
|
Margin="-3,-12,0,0"
|
||||||
Cursor="/Resources/aero_rotate_tr.cur" />
|
Cursor="/Resources/aero_rotate_tr.cur" />
|
||||||
<!-- Top right resize handle -->
|
<!-- Top right resize handle -->
|
||||||
@ -95,62 +109,62 @@
|
|||||||
MouseMove="{s:Action TopRightResize}"
|
MouseMove="{s:Action TopRightResize}"
|
||||||
Width="6"
|
Width="6"
|
||||||
Height="6"
|
Height="6"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Right}"
|
Canvas.Left="{Binding ShapeRectangle.Right}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Top}"
|
Canvas.Top="{Binding ShapeRectangle.Top}"
|
||||||
Fill="Red"
|
Fill="Transparent"
|
||||||
Margin="-3,-3,0,0"
|
Margin="-3,-3,0,0"
|
||||||
Cursor="SizeNESW" />
|
Cursor="SizeNESW" />
|
||||||
|
|
||||||
<!-- Center right resize handle -->
|
<!-- Center right resize handle -->
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action CenterRightResize}"
|
MouseMove="{s:Action CenterRightResize}"
|
||||||
Width="10"
|
Width="10"
|
||||||
Height="10"
|
Height="10"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Right}"
|
Canvas.Left="{Binding ShapeRectangle.Right}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.MidY}"
|
Canvas.Top="{Binding ShapeRectangle.MidY}"
|
||||||
Fill="Red"
|
Fill="Transparent"
|
||||||
Margin="-5,-5,0,0"
|
Margin="-5,-5,0,0"
|
||||||
Cursor="SizeWE" />
|
Cursor="SizeWE" />
|
||||||
|
|
||||||
|
|
||||||
<!-- Bottom right rotate handle -->
|
<!-- Bottom right rotate handle -->
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action BottomRightRotate}"
|
MouseMove="{s:Action BottomRightRotate}"
|
||||||
Width="15"
|
Width="15"
|
||||||
Height="15"
|
Height="15"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Right}"
|
Canvas.Left="{Binding ShapeRectangle.Right}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
||||||
Fill="Blue"
|
Fill="Transparent"
|
||||||
Margin="-3,-3,0,0"
|
Margin="-3,-3,0,0"
|
||||||
Cursor="/Resources/aero_rotate_br.cur" />
|
Cursor="/Resources/aero_rotate_br.cur" />
|
||||||
<!-- Bottom right resize handle -->
|
<!-- Bottom right resize handle -->
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action BottomRightResize}"
|
MouseMove="{s:Action BottomRightResize}"
|
||||||
Width="6"
|
Width="6"
|
||||||
Height="6"
|
Height="6"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Right}"
|
Canvas.Left="{Binding ShapeRectangle.Right}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
||||||
Fill="Red"
|
Fill="Transparent"
|
||||||
Margin="-3,-3,0,0"
|
Margin="-3,-3,0,0"
|
||||||
Cursor="SizeNWSE" />
|
Cursor="SizeNWSE" />
|
||||||
|
|
||||||
|
|
||||||
<!-- Bottom center resize handle -->
|
<!-- Bottom center resize handle -->
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action BottomCenterResize}"
|
MouseMove="{s:Action BottomCenterResize}"
|
||||||
Width="10"
|
Width="10"
|
||||||
Height="10"
|
Height="10"
|
||||||
Canvas.Left="{Binding ShapeRectangle.MidX}"
|
Canvas.Left="{Binding ShapeRectangle.MidX}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
||||||
Fill="Red"
|
Fill="Transparent"
|
||||||
Margin="-5,-5,0,0"
|
Margin="-5,-5,0,0"
|
||||||
Cursor="SizeNS" />
|
Cursor="SizeNS" />
|
||||||
|
|
||||||
|
|
||||||
<!-- Bottom left rotate handle -->
|
<!-- Bottom left rotate handle -->
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
@ -158,8 +172,8 @@
|
|||||||
Width="15"
|
Width="15"
|
||||||
Height="15"
|
Height="15"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Left}"
|
Canvas.Left="{Binding ShapeRectangle.Left}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
||||||
Fill="Blue"
|
Fill="Transparent"
|
||||||
Margin="-12,-3,0,0"
|
Margin="-12,-3,0,0"
|
||||||
Cursor="/Resources/aero_rotate_bl.cur" />
|
Cursor="/Resources/aero_rotate_bl.cur" />
|
||||||
<!-- Bottom left resize handle -->
|
<!-- Bottom left resize handle -->
|
||||||
@ -167,26 +181,26 @@
|
|||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action BottomLeftResize}"
|
MouseMove="{s:Action BottomLeftResize}"
|
||||||
Width="6"
|
Width="6"
|
||||||
Height="6"
|
Height="6"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Left}"
|
Canvas.Left="{Binding ShapeRectangle.Left}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
Canvas.Top="{Binding ShapeRectangle.Bottom}"
|
||||||
Fill="Red"
|
Fill="Transparent"
|
||||||
Margin="-3, -3, 0,0"
|
Margin="-3, -3, 0,0"
|
||||||
Cursor="SizeNESW" />
|
Cursor="SizeNESW" />
|
||||||
|
|
||||||
|
|
||||||
<!-- Center left resize handle -->
|
<!-- Center left resize handle -->
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
MouseMove="{s:Action CenterLeftResize}"
|
MouseMove="{s:Action CenterLeftResize}"
|
||||||
Width="10"
|
Width="10"
|
||||||
Height="10"
|
Height="10"
|
||||||
Canvas.Left="{Binding ShapeRectangle.Left}"
|
Canvas.Left="{Binding ShapeRectangle.Left}"
|
||||||
Canvas.Top="{Binding ShapeRectangle.MidY}"
|
Canvas.Top="{Binding ShapeRectangle.MidY}"
|
||||||
Fill="Red"
|
Fill="Transparent"
|
||||||
Margin="-5,-5,0,0"
|
Margin="-5,-5,0,0"
|
||||||
Cursor="SizeWE" />
|
Cursor="SizeWE" />
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</Canvas>
|
</Canvas>
|
||||||
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -16,10 +16,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
private readonly ILayerEditorService _layerEditorService;
|
private readonly ILayerEditorService _layerEditorService;
|
||||||
private bool _draggingHorizontally;
|
private bool _draggingHorizontally;
|
||||||
private bool _draggingVertically;
|
private bool _draggingVertically;
|
||||||
private double _dragOffsetX;
|
|
||||||
private double _dragOffsetY;
|
|
||||||
private Point _dragStart;
|
|
||||||
private bool _isDragging;
|
private bool _isDragging;
|
||||||
|
private Point _dragStart;
|
||||||
|
private Point _dragOffset;
|
||||||
|
private SKPoint _dragStartAnchor;
|
||||||
|
|
||||||
public EditToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerEditorService layerEditorService)
|
public EditToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerEditorService layerEditorService)
|
||||||
: base(profileViewModel, profileEditorService)
|
: base(profileViewModel, profileEditorService)
|
||||||
@ -38,6 +38,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
public RectangleGeometry ShapeGeometry { get; set; }
|
public RectangleGeometry ShapeGeometry { get; set; }
|
||||||
public TransformCollection ShapeTransformCollection { get; set; }
|
public TransformCollection ShapeTransformCollection { get; set; }
|
||||||
|
|
||||||
|
public SKPoint TopLeft { get; set; }
|
||||||
|
public SKPoint TopRight { get; set; }
|
||||||
|
public SKPoint BottomRight { get; set; }
|
||||||
|
public SKPoint BottomLeft { get; set; }
|
||||||
|
public SKPoint TopCenter { get; set; }
|
||||||
|
public SKPoint RightCenter { get; set; }
|
||||||
|
public SKPoint BottomCenter { get; set; }
|
||||||
|
public SKPoint LeftCenter { get; set; }
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (ProfileEditorService.SelectedProfileElement is Layer layer)
|
if (ProfileEditorService.SelectedProfileElement is Layer layer)
|
||||||
@ -71,27 +80,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SKPoint TopLeft { get; set; }
|
|
||||||
public SKPoint TopRight { get; set; }
|
|
||||||
public SKPoint BottomRight { get; set; }
|
|
||||||
public SKPoint BottomLeft { get; set; }
|
|
||||||
public SKPoint TopCenter { get; set; }
|
|
||||||
public SKPoint RightCenter { get; set; }
|
|
||||||
public SKPoint BottomCenter { get; set; }
|
|
||||||
public SKPoint LeftCenter { get; set; }
|
|
||||||
|
|
||||||
public void ShapeEditMouseDown(object sender, MouseButtonEventArgs e)
|
public void ShapeEditMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (_isDragging)
|
if (_isDragging)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
((IInputElement) sender).CaptureMouse();
|
|
||||||
if (ProfileEditorService.SelectedProfileElement is Layer layer)
|
if (ProfileEditorService.SelectedProfileElement is Layer layer)
|
||||||
{
|
{
|
||||||
|
// The path starts at 0,0 so there's no simple way to get the position relative to the top-left of the path
|
||||||
var dragStartPosition = GetRelativePosition(sender, e);
|
var dragStartPosition = GetRelativePosition(sender, e);
|
||||||
var skRect = layer.LayerShape.RenderRectangle;
|
var anchor = _layerEditorService.GetLayerAnchor(layer, true);
|
||||||
_dragOffsetX = skRect.Left - dragStartPosition.X;
|
|
||||||
_dragOffsetY = skRect.Top - dragStartPosition.Y;
|
_dragOffset = new Point(dragStartPosition.X - anchor.X - 1.45, dragStartPosition.Y - anchor.Y - 1.45);
|
||||||
_dragStart = dragStartPosition;
|
_dragStart = dragStartPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,21 +99,31 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
_draggingHorizontally = false;
|
_draggingHorizontally = false;
|
||||||
_draggingVertically = false;
|
_draggingVertically = false;
|
||||||
|
|
||||||
|
((IInputElement) sender).CaptureMouse();
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AnchorEditMouseDown(object sender, MouseButtonEventArgs e)
|
public void AnchorEditMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (_isDragging)
|
if (_isDragging)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Use the regular mousedown
|
if (ProfileEditorService.SelectedProfileElement is Layer layer)
|
||||||
ShapeEditMouseDown(sender, e);
|
{
|
||||||
// Override the drag offset
|
// The path starts at 0,0 so there's no simple way to get the position relative to the top-left of the path
|
||||||
var dragStartPosition = GetRelativePosition(sender, e);
|
var dragStartPosition = GetRelativePosition(sender, e);
|
||||||
// _dragOffsetX = AnchorSkPoint.X - dragStartPosition.X;
|
|
||||||
// _dragOffsetY = AnchorSkPoint.Y - dragStartPosition.Y;
|
_dragOffset = new Point(TopLeft.X + (dragStartPosition.X - TopLeft.X), TopLeft.Y + (dragStartPosition.Y - TopLeft.Y));
|
||||||
_dragStart = dragStartPosition;
|
_dragStartAnchor = _layerEditorService.GetLayerAnchor(layer, false);
|
||||||
|
_dragStart = dragStartPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isDragging = true;
|
||||||
|
_draggingHorizontally = false;
|
||||||
|
_draggingVertically = false;
|
||||||
|
|
||||||
|
((IInputElement) sender).CaptureMouse();
|
||||||
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShapeEditMouseUp(object sender, MouseButtonEventArgs e)
|
public void ShapeEditMouseUp(object sender, MouseButtonEventArgs e)
|
||||||
@ -134,9 +144,19 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var position = GetRelativePosition(sender, e);
|
var position = GetRelativePosition(sender, e);
|
||||||
var x = (float) (position.X + _dragOffsetX);
|
var x = (float)(position.X - _dragOffset.X + _dragStartAnchor.X);
|
||||||
var y = (float) (position.Y + _dragOffsetY);
|
var y = (float)(position.Y - _dragOffset.Y + _dragStartAnchor.Y);
|
||||||
layer.LayerShape.SetFromUnscaledAnchor(new SKPoint(x, y), ProfileEditorService.CurrentTime);
|
|
||||||
|
// Convert the desired X and Y position to a translation
|
||||||
|
var scaled = _layerEditorService.GetScaledPoint(layer, new SKPoint(x, y), false);
|
||||||
|
var currentAnchor = layer.AnchorPointProperty.CurrentValue;
|
||||||
|
var currentPos = layer.PositionProperty.CurrentValue;
|
||||||
|
|
||||||
|
layer.AnchorPointProperty.SetCurrentValue(scaled, ProfileEditorService.CurrentTime);
|
||||||
|
|
||||||
|
var positionOffsetX = (scaled.X - currentAnchor.X) * layer.SizeProperty.CurrentValue.Width;
|
||||||
|
var positionOffsetY = (scaled.Y - currentAnchor.Y) * layer.SizeProperty.CurrentValue.Height;
|
||||||
|
layer.PositionProperty.SetCurrentValue(new SKPoint(currentPos.X + positionOffsetX, currentPos.Y + positionOffsetY), ProfileEditorService.CurrentTime);
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,16 +166,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var position = GetRelativePosition(sender, e);
|
var position = GetRelativePosition(sender, e);
|
||||||
var skRect = _layerEditorService.GetShapeRenderRect(layer.LayerShape).ToSKRect();
|
var x = (float) (position.X - _dragOffset.X);
|
||||||
var x = (float) (position.X + _dragOffsetX);
|
var y = (float) (position.Y - _dragOffset.Y);
|
||||||
var y = (float) (position.Y + _dragOffsetY);
|
|
||||||
|
|
||||||
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
||||||
{
|
{
|
||||||
if (_draggingVertically)
|
if (_draggingVertically)
|
||||||
x = skRect.Left;
|
x = (float) (_dragStart.X - _dragOffset.X);
|
||||||
else if (_draggingHorizontally)
|
else if (_draggingHorizontally)
|
||||||
y = skRect.Top;
|
y = (float) (_dragStart.Y - _dragOffset.Y);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_draggingHorizontally = Math.Abs(position.X - _dragStart.X) > Math.Abs(position.Y - _dragStart.Y);
|
_draggingHorizontally = Math.Abs(position.X - _dragStart.X) > Math.Abs(position.Y - _dragStart.Y);
|
||||||
@ -164,11 +183,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the desired X and Y position to a translation
|
var scaled = _layerEditorService.GetScaledPoint(layer, new SKPoint(x, y), true);
|
||||||
var layerRect = _layerEditorService.GetLayerRenderRect(layer).ToSKRect();
|
|
||||||
var translation = layer.PositionProperty.CurrentValue;
|
|
||||||
var scaled = _layerEditorService.GetScaledPoint(layer, new SKPoint(x , y));
|
|
||||||
Console.WriteLine(scaled);
|
|
||||||
layer.PositionProperty.SetCurrentValue(scaled, ProfileEditorService.CurrentTime);
|
layer.PositionProperty.SetCurrentValue(scaled, ProfileEditorService.CurrentTime);
|
||||||
|
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
|
|||||||
@ -44,8 +44,16 @@ namespace Artemis.UI.Screens.Shared
|
|||||||
Zoom = Math.Max(0.1, Math.Min(4, Zoom));
|
Zoom = Math.Max(0.1, Math.Min(4, Zoom));
|
||||||
|
|
||||||
// Update the PanX/Y to enable zooming relative to cursor
|
// Update the PanX/Y to enable zooming relative to cursor
|
||||||
PanX = Math.Min(0, absoluteX - relative.X * Zoom);
|
if (LimitToZero)
|
||||||
PanY = Math.Min(0, absoluteY - relative.Y * Zoom);
|
{
|
||||||
|
PanX = Math.Min(0, absoluteX - relative.X * Zoom);
|
||||||
|
PanY = Math.Min(0, absoluteY - relative.Y * Zoom);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PanX = absoluteX - relative.X * Zoom;
|
||||||
|
PanY = absoluteY - relative.Y * Zoom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessMouseMove(object sender, MouseEventArgs e)
|
public void ProcessMouseMove(object sender, MouseEventArgs e)
|
||||||
|
|||||||
@ -33,6 +33,18 @@ namespace Artemis.UI.Services
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Rect GetLayerRect(Layer layer)
|
||||||
|
{
|
||||||
|
// Adjust the render rectangle for the difference in render scale
|
||||||
|
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
|
||||||
|
return new Rect(
|
||||||
|
layer.Rectangle.Left / renderScale * 1,
|
||||||
|
layer.Rectangle.Top / renderScale * 1,
|
||||||
|
Math.Max(0, layer.Rectangle.Width / renderScale * 1),
|
||||||
|
Math.Max(0, layer.Rectangle.Height / renderScale * 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public SKPath GetLayerPath(Layer layer)
|
public SKPath GetLayerPath(Layer layer)
|
||||||
{
|
{
|
||||||
@ -40,57 +52,93 @@ namespace Artemis.UI.Services
|
|||||||
var shapeRect = GetShapeRenderRect(layer.LayerShape).ToSKRect();
|
var shapeRect = GetShapeRenderRect(layer.LayerShape).ToSKRect();
|
||||||
|
|
||||||
// Apply transformation like done by the core during layer rendering
|
// Apply transformation like done by the core during layer rendering
|
||||||
var anchor = GetLayerAnchor(layer, false);
|
var anchor = GetLayerAnchor(layer, true);
|
||||||
var position = layer.PositionProperty.CurrentValue;
|
var relativeAnchor = GetLayerAnchor(layer, false);
|
||||||
var size = layer.SizeProperty.CurrentValue;
|
|
||||||
var rotation = layer.RotationProperty.CurrentValue;
|
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
||||||
|
var x = layer.PositionProperty.CurrentValue.X * layerRect.Width - shapeRect.Width / 2 - relativeAnchor.X;
|
||||||
|
var y = layer.PositionProperty.CurrentValue.Y * layerRect.Height - shapeRect.Height / 2 - relativeAnchor.Y;
|
||||||
|
|
||||||
var path = new SKPath();
|
var path = new SKPath();
|
||||||
path.AddRect(shapeRect);
|
path.AddRect(shapeRect);
|
||||||
|
path.Transform(SKMatrix.MakeTranslation(x, y));
|
||||||
path.Transform(SKMatrix.MakeScale(size.Width, size.Height, anchor.X, anchor.Y));
|
path.Transform(SKMatrix.MakeScale(layer.SizeProperty.CurrentValue.Width, layer.SizeProperty.CurrentValue.Height, anchor.X, anchor.Y));
|
||||||
path.Transform(SKMatrix.MakeRotationDegrees(rotation, anchor.X, anchor.Y));
|
path.Transform(SKMatrix.MakeRotationDegrees(layer.RotationProperty.CurrentValue, anchor.X, anchor.Y));
|
||||||
path.Transform(SKMatrix.MakeTranslation(position.X * layerRect.Width, position.Y * layerRect.Height));
|
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
public void ReverseLayerPath(Layer layer, SKPath path)
|
||||||
public SKPoint GetLayerAnchor(Layer layer, bool includeTranslate)
|
|
||||||
{
|
{
|
||||||
var layerRect = GetLayerRenderRect(layer).ToSKRect();
|
var layerRect = GetLayerRenderRect(layer).ToSKRect();
|
||||||
var shapeRect = GetShapeRenderRect(layer.LayerShape).ToSKRect();
|
var shapeRect = GetShapeRenderRect(layer.LayerShape).ToSKRect();
|
||||||
var anchor = layer.AnchorPointProperty.CurrentValue;
|
|
||||||
|
|
||||||
// Scale the anchor and make it originate from the center of the untranslated layer shape
|
// Apply transformation like done by the core during layer rendering
|
||||||
anchor.X = anchor.X * layerRect.Width + shapeRect.MidX;
|
var anchor = GetLayerAnchor(layer, true);
|
||||||
anchor.Y = anchor.Y * layerRect.Height + shapeRect.MidY;
|
var relativeAnchor = GetLayerAnchor(layer, false);
|
||||||
|
|
||||||
if (includeTranslate)
|
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
||||||
|
var x = layer.PositionProperty.CurrentValue.X * layerRect.Width - shapeRect.Width / 2 - relativeAnchor.X;
|
||||||
|
var y = layer.PositionProperty.CurrentValue.Y * layerRect.Height - shapeRect.Height / 2 - relativeAnchor.Y;
|
||||||
|
|
||||||
|
SKMatrix.MakeScale(layer.SizeProperty.CurrentValue.Width, layer.SizeProperty.CurrentValue.Height, anchor.X, anchor.Y).TryInvert(out var scale);
|
||||||
|
|
||||||
|
path.Transform(SKMatrix.MakeRotationDegrees(layer.RotationProperty.CurrentValue * -1, anchor.X, anchor.Y));
|
||||||
|
path.Transform(scale);
|
||||||
|
path.Transform(SKMatrix.MakeTranslation(x * -1, y * -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public SKPoint GetLayerAnchor(Layer layer, bool absolute)
|
||||||
|
{
|
||||||
|
var layerRect = GetLayerRect(layer);
|
||||||
|
if (absolute)
|
||||||
{
|
{
|
||||||
var position = layer.PositionProperty.CurrentValue;
|
var position = layer.PositionProperty.CurrentValue;
|
||||||
anchor.X += position.X * layerRect.Width;
|
position.X = (float) (position.X * layerRect.Width);
|
||||||
anchor.Y += position.Y * layerRect.Height;
|
position.Y = (float) (position.Y * layerRect.Height);
|
||||||
|
var shapeRect = GetShapeRenderRect(layer.LayerShape);
|
||||||
|
return new SKPoint((float) (position.X + shapeRect.Left), (float) (position.Y + shapeRect.Top));
|
||||||
}
|
}
|
||||||
|
|
||||||
return anchor;
|
var anchor = layer.AnchorPointProperty.CurrentValue;
|
||||||
|
anchor.X = (float) (anchor.X * layerRect.Width);
|
||||||
|
anchor.Y = (float) (anchor.Y * layerRect.Height);
|
||||||
|
return new SKPoint(anchor.X, anchor.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLayerAnchor(Layer layer, SKPoint point, bool absolute, TimeSpan? time)
|
||||||
|
{
|
||||||
|
var layerRect = GetLayerRect(layer);
|
||||||
|
if (absolute)
|
||||||
|
{
|
||||||
|
var shapeRect = GetShapeRenderRect(layer.LayerShape);
|
||||||
|
var position = new SKPoint((float) ((point.X - shapeRect.Left) / layerRect.Width), (float) ((point.Y - shapeRect.Top) / layerRect.Height));
|
||||||
|
layer.PositionProperty.SetCurrentValue(position, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
var anchor = new SKPoint((float) (point.X / layerRect.Width), (float) (point.Y / layerRect.Height));
|
||||||
|
layer.AnchorPointProperty.SetCurrentValue(anchor, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public TransformGroup GetLayerTransformGroup(Layer layer)
|
public TransformGroup GetLayerTransformGroup(Layer layer)
|
||||||
{
|
{
|
||||||
var layerRect = GetLayerRenderRect(layer).ToSKRect();
|
var layerRect = GetLayerRenderRect(layer).ToSKRect();
|
||||||
|
var shapeRect = GetShapeRenderRect(layer.LayerShape).ToSKRect();
|
||||||
|
|
||||||
// Apply transformation like done by the core during layer rendering
|
// Apply transformation like done by the core during layer rendering
|
||||||
var anchor = GetLayerAnchor(layer, false);
|
var anchor = GetLayerAnchor(layer, true);
|
||||||
var position = layer.PositionProperty.CurrentValue;
|
|
||||||
var size = layer.SizeProperty.CurrentValue;
|
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
||||||
var rotation = layer.RotationProperty.CurrentValue;
|
var x = layer.PositionProperty.CurrentValue.X * layerRect.Width - shapeRect.Width / 2 - GetLayerAnchor(layer, false).X;
|
||||||
|
var y = layer.PositionProperty.CurrentValue.Y * layerRect.Height - shapeRect.Height / 2 - GetLayerAnchor(layer, false).Y;
|
||||||
|
|
||||||
var transformGroup = new TransformGroup();
|
var transformGroup = new TransformGroup();
|
||||||
transformGroup.Children.Add(new ScaleTransform(size.Width, size.Height, anchor.X, anchor.Y));
|
transformGroup.Children.Add(new TranslateTransform(x, y));
|
||||||
transformGroup.Children.Add(new RotateTransform(rotation, anchor.X, anchor.Y));
|
transformGroup.Children.Add(new ScaleTransform(layer.SizeProperty.CurrentValue.Width, layer.SizeProperty.CurrentValue.Height, anchor.X, anchor.Y));
|
||||||
transformGroup.Children.Add(new TranslateTransform(position.X * layerRect.Width, position.Y * layerRect.Height));
|
transformGroup.Children.Add(new RotateTransform(layer.RotationProperty.CurrentValue, anchor.X, anchor.Y));
|
||||||
|
|
||||||
return transformGroup;
|
return transformGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,23 +167,29 @@ namespace Artemis.UI.Services
|
|||||||
// Adjust the provided rect for the difference in render scale
|
// Adjust the provided rect for the difference in render scale
|
||||||
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
|
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
|
||||||
layerShape.ScaledRectangle = SKRect.Create(
|
layerShape.ScaledRectangle = SKRect.Create(
|
||||||
100f / layerShape.Layer.AbsoluteRectangle.Width * ((float) (rect.Left * renderScale) - layerShape.Layer.AbsoluteRectangle.Left) / 100f,
|
100f / layerShape.Layer.Rectangle.Width * ((float) (rect.Left * renderScale) - layerShape.Layer.Rectangle.Left) / 100f,
|
||||||
100f / layerShape.Layer.AbsoluteRectangle.Height * ((float) (rect.Top * renderScale) - layerShape.Layer.AbsoluteRectangle.Top) / 100f,
|
100f / layerShape.Layer.Rectangle.Height * ((float) (rect.Top * renderScale) - layerShape.Layer.Rectangle.Top) / 100f,
|
||||||
100f / layerShape.Layer.AbsoluteRectangle.Width * (float) (rect.Width * renderScale) / 100f,
|
100f / layerShape.Layer.Rectangle.Width * (float) (rect.Width * renderScale) / 100f,
|
||||||
100f / layerShape.Layer.AbsoluteRectangle.Height * (float) (rect.Height * renderScale) / 100f
|
100f / layerShape.Layer.Rectangle.Height * (float) (rect.Height * renderScale) / 100f
|
||||||
);
|
);
|
||||||
layerShape.CalculateRenderProperties();
|
layerShape.CalculateRenderProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public SKPoint GetScaledPoint(Layer layer, SKPoint point)
|
public SKPoint GetScaledPoint(Layer layer, SKPoint point, bool absolute)
|
||||||
{
|
{
|
||||||
var rect = GetLayerRenderRect(layer).ToSKRect();
|
|
||||||
// Adjust the provided rect for the difference in render scale
|
|
||||||
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
|
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
|
||||||
|
if (absolute)
|
||||||
|
{
|
||||||
|
return new SKPoint(
|
||||||
|
100f / layer.Rectangle.Width * ((float) (point.X * renderScale) - layer.Rectangle.Left) / 100f,
|
||||||
|
100f / layer.Rectangle.Height * ((float) (point.Y * renderScale) - layer.Rectangle.Top) / 100f
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return new SKPoint(
|
return new SKPoint(
|
||||||
100f / layer.AbsoluteRectangle.Width * ((float) (point.X * renderScale) - rect.Left) / 100f,
|
100f / layer.Rectangle.Width * (float)(point.X * renderScale) / 100f,
|
||||||
100f / layer.AbsoluteRectangle.Height * ((float) (point.Y * renderScale) - rect.Top) / 100f
|
100f / layer.Rectangle.Height * (float)(point.Y * renderScale) / 100f
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,13 +210,17 @@ namespace Artemis.UI.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
SKPath GetLayerPath(Layer layer);
|
SKPath GetLayerPath(Layer layer);
|
||||||
|
|
||||||
|
void ReverseLayerPath(Layer layer, SKPath path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an absolute and scaled anchor for the given layer, optionally with the translation applied.
|
/// Returns an absolute and scaled anchor for the given layer, optionally with the translation applied.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="layer"></param>
|
/// <param name="layer"></param>
|
||||||
/// <param name="includeTranslate"></param>
|
/// <param name="absolute"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
SKPoint GetLayerAnchor(Layer layer, bool includeTranslate);
|
SKPoint GetLayerAnchor(Layer layer, bool absolute);
|
||||||
|
|
||||||
|
void SetLayerAnchor(Layer layer, SKPoint point, bool absolute, TimeSpan? time);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a WPF transform group that contains all the transformations required to render the provided layer.
|
/// Creates a WPF transform group that contains all the transformations required to render the provided layer.
|
||||||
@ -191,7 +249,8 @@ namespace Artemis.UI.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="layer"></param>
|
/// <param name="layer"></param>
|
||||||
/// <param name="point"></param>
|
/// <param name="point"></param>
|
||||||
|
/// <param name="absolute"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
SKPoint GetScaledPoint(Layer layer, SKPoint point);
|
SKPoint GetScaledPoint(Layer layer, SKPoint point, bool absolute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user