mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-01 10:13:30 +00:00
Hooked up rotation and opacity
This commit is contained in:
parent
ae330c3769
commit
5069be4af4
@ -15,7 +15,7 @@ namespace Artemis.Core.Models.Profile.KeyframeEngines
|
|||||||
var nextKeyframe = (Keyframe<int>) NextKeyframe;
|
var nextKeyframe = (Keyframe<int>) NextKeyframe;
|
||||||
|
|
||||||
var diff = nextKeyframe.Value - currentKeyframe.Value;
|
var diff = nextKeyframe.Value - currentKeyframe.Value;
|
||||||
return currentKeyframe.Value + diff * KeyframeProgressEased;
|
return (int) Math.Round(currentKeyframe.Value + diff * KeyframeProgressEased, MidpointRounding.AwayFromZero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,12 +132,12 @@ namespace Artemis.Core.Models.Profile
|
|||||||
public LayerProperty<SKSize> SizeProperty { get; private set; }
|
public LayerProperty<SKSize> SizeProperty { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The rotation property of this layer, also found in <see cref="Properties" />
|
/// The rotation property of this layer range 0 - 360, also found in <see cref="Properties" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LayerProperty<int> RotationProperty { get; private set; }
|
public LayerProperty<int> RotationProperty { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The opacity property of this layer, also found in <see cref="Properties" />
|
/// The opacity property of this layer range 0 - 100, also found in <see cref="Properties" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LayerProperty<float> OpacityProperty { get; private set; }
|
public LayerProperty<float> OpacityProperty { get; private set; }
|
||||||
|
|
||||||
@ -158,9 +158,19 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
canvas.Save();
|
canvas.Save();
|
||||||
canvas.ClipPath(Path);
|
canvas.ClipPath(Path);
|
||||||
|
|
||||||
|
// Apply transformations
|
||||||
|
var rotation = RotationProperty.CurrentValue;
|
||||||
|
var anchor = AnchorPointProperty.CurrentValue;
|
||||||
|
if (rotation != 0)
|
||||||
|
canvas.RotateDegrees(rotation, anchor.X * AbsoluteRectangle.Width + LayerShape.RenderRectangle.Left, anchor.Y * AbsoluteRectangle.Height + LayerShape.RenderRectangle.Top);
|
||||||
|
|
||||||
// Placeholder
|
// Placeholder
|
||||||
if (LayerShape?.RenderPath != null)
|
if (LayerShape?.RenderPath != null)
|
||||||
canvas.DrawPath(LayerShape.RenderPath, new SKPaint {Color = new SKColor(255, 0, 0)});
|
{
|
||||||
|
canvas.DrawPath(LayerShape.RenderPath, new SKPaint {Color = new SKColor(255, 0, 0, (byte) (2.55 * OpacityProperty.CurrentValue))});
|
||||||
|
}
|
||||||
|
|
||||||
LayerBrush?.Render(canvas);
|
LayerBrush?.Render(canvas);
|
||||||
canvas.Restore();
|
canvas.Restore();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,14 +17,17 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
|||||||
{
|
{
|
||||||
var width = Layer.AbsoluteRectangle.Width;
|
var width = Layer.AbsoluteRectangle.Width;
|
||||||
var height = Layer.AbsoluteRectangle.Height;
|
var height = Layer.AbsoluteRectangle.Height;
|
||||||
var rect = SKRect.Create(shapePosition.X * width, shapePosition.Y * height, shapeSize.Width * width, shapeSize.Height * height);
|
var rect = SKRect.Create(
|
||||||
|
Layer.Rectangle.Left + shapePosition.X * width,
|
||||||
|
Layer.Rectangle.Top + shapePosition.Y * height,
|
||||||
|
shapeSize.Width * width,
|
||||||
|
shapeSize.Height * height
|
||||||
|
);
|
||||||
var path = new SKPath();
|
var path = new SKPath();
|
||||||
path.AddOval(rect);
|
path.AddOval(rect);
|
||||||
path.Transform(SKMatrix.MakeTranslation(Layer.Rectangle.Left, Layer.Rectangle.Top));
|
|
||||||
|
|
||||||
RenderPath = path;
|
RenderPath = path;
|
||||||
RenderRectangle = path.GetRect();
|
RenderRectangle = rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ApplyToEntity()
|
public override void ApplyToEntity()
|
||||||
|
|||||||
@ -17,13 +17,17 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
|||||||
{
|
{
|
||||||
var width = Layer.AbsoluteRectangle.Width;
|
var width = Layer.AbsoluteRectangle.Width;
|
||||||
var height = Layer.AbsoluteRectangle.Height;
|
var height = Layer.AbsoluteRectangle.Height;
|
||||||
var rect = SKRect.Create(shapePosition.X * width, shapePosition.Y * height, shapeSize.Width * width, shapeSize.Height * height);
|
var rect = SKRect.Create(
|
||||||
|
Layer.Rectangle.Left + shapePosition.X * width,
|
||||||
|
Layer.Rectangle.Top + shapePosition.Y * height,
|
||||||
|
shapeSize.Width * width,
|
||||||
|
shapeSize.Height * height
|
||||||
|
);
|
||||||
var path = new SKPath();
|
var path = new SKPath();
|
||||||
path.AddRect(rect);
|
path.AddRect(rect);
|
||||||
path.Transform(SKMatrix.MakeTranslation(Layer.Rectangle.Left, Layer.Rectangle.Top));
|
|
||||||
|
|
||||||
RenderPath = path;
|
RenderPath = path;
|
||||||
RenderRectangle = path.GetRect();
|
RenderRectangle = rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ApplyToEntity()
|
public override void ApplyToEntity()
|
||||||
|
|||||||
@ -83,7 +83,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
}
|
}
|
||||||
|
|
||||||
var layerGeometry = group.GetOutlinedPathGeometry();
|
var layerGeometry = group.GetOutlinedPathGeometry();
|
||||||
|
|
||||||
var opacityGeometry = Geometry.Combine(Geometry.Empty, layerGeometry, GeometryCombineMode.Exclude, new TranslateTransform());
|
var opacityGeometry = Geometry.Combine(Geometry.Empty, layerGeometry, GeometryCombineMode.Exclude, new TranslateTransform());
|
||||||
layerGeometry.Freeze();
|
layerGeometry.Freeze();
|
||||||
opacityGeometry.Freeze();
|
opacityGeometry.Freeze();
|
||||||
@ -120,6 +119,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply transformation like done by the core during layer rendering
|
||||||
|
var anchor = Layer.LayerShape.GetUnscaledAnchor();
|
||||||
|
shapeGeometry.Transform = new RotateTransform(Layer.RotationProperty.CurrentValue, anchor.X, anchor.Y);
|
||||||
|
|
||||||
shapeGeometry.Freeze();
|
shapeGeometry.Freeze();
|
||||||
ShapeGeometry = shapeGeometry;
|
ShapeGeometry = shapeGeometry;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
{
|
{
|
||||||
CanvasViewModels = new ObservableCollection<CanvasViewModel>();
|
CanvasViewModels = new ObservableCollection<CanvasViewModel>();
|
||||||
DeviceViewModels = new ObservableCollection<ProfileDeviceViewModel>();
|
DeviceViewModels = new ObservableCollection<ProfileDeviceViewModel>();
|
||||||
PanZoomViewModel = new PanZoomViewModel();
|
PanZoomViewModel = new PanZoomViewModel {LimitToZero = false};
|
||||||
});
|
});
|
||||||
|
|
||||||
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
|
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
|
||||||
|
|||||||
@ -10,112 +10,119 @@
|
|||||||
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">
|
||||||
<!-- The rectangle around the shape that allows modification -->
|
<Canvas >
|
||||||
<Rectangle Width="{Binding ShapeSkRect.Width}"
|
<!-- The rectangle around the shape that allows modification -->
|
||||||
Height="{Binding ShapeSkRect.Height}"
|
<Canvas.RenderTransform>
|
||||||
Canvas.Left="{Binding ShapeSkRect.Left}"
|
<RotateTransform Angle="{Binding RotationAngle}" CenterX="{Binding AnchorSkPoint.X}" CenterY="{Binding AnchorSkPoint.Y}" />
|
||||||
Canvas.Top="{Binding ShapeSkRect.Top}"
|
</Canvas.RenderTransform>
|
||||||
Fill="Transparent"
|
<Rectangle Width="{Binding ShapeSkRect.Width}"
|
||||||
Stroke="{DynamicResource PrimaryHueMidBrush}"
|
Height="{Binding ShapeSkRect.Height}"
|
||||||
StrokeThickness="1"
|
Canvas.Left="{Binding ShapeSkRect.Left}"
|
||||||
StrokeDashArray="2 2"
|
Canvas.Top="{Binding ShapeSkRect.Top}"
|
||||||
Cursor="Hand"
|
Fill="Transparent"
|
||||||
MouseDown="{s:Action ShapeEditMouseDown}"
|
Stroke="{DynamicResource PrimaryHueMidBrush}"
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
StrokeThickness="1"
|
||||||
MouseMove="{s:Action Move}" />
|
StrokeDashArray="2 2"
|
||||||
|
Cursor="Hand"
|
||||||
|
MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
|
MouseMove="{s:Action Move}" />
|
||||||
|
|
||||||
<!-- Anchor point -->
|
<!-- Top left display -->
|
||||||
<Ellipse MouseDown="{s:Action ShapeEditMouseDown}"
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
<!-- Top left rotate handle -->
|
||||||
MouseMove="{s:Action AnchorMove}"
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
Width="6" Height="6" Fill="{DynamicResource SecondaryAccentBrush}" Canvas.Left="{Binding AnchorSkPoint.X}" Canvas.Top="{Binding AnchorSkPoint.Y}" Margin="-3,-3,0,0" Cursor="SizeAll" />
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
|
MouseMove="{s:Action TopLeftRotate}"
|
||||||
|
Width="15" Height="15" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-12,-12,0,0"
|
||||||
|
Cursor="/Resources/aero_rotate_tl.cur" />
|
||||||
|
<!-- Top left resize handle -->
|
||||||
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
|
MouseMove="{s:Action TopLeftResize}"
|
||||||
|
Width="6" Height="6" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-3,-3,0,0" Cursor="SizeNWSE" />
|
||||||
|
|
||||||
<!-- Top left display -->
|
<!-- Top center display -->
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.MidX}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
<!-- Top left rotate 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 TopLeftRotate}"
|
MouseMove="{s:Action TopCenterResize}"
|
||||||
Width="15" Height="15" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-12,-12,0,0"
|
Width="10" Height="10" Canvas.Left="{Binding ShapeSkRect.MidX}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-5,-5,0,0" Cursor="SizeNS" />
|
||||||
Cursor="/Resources/aero_rotate_tl.cur" />
|
|
||||||
<!-- Top left resize handle -->
|
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
|
||||||
MouseMove="{s:Action TopLeftResize}"
|
|
||||||
Width="6" Height="6" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-3,-3,0,0" Cursor="SizeNWSE" />
|
|
||||||
|
|
||||||
<!-- Top center display -->
|
<!-- Top right display -->
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.MidX}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
<!-- Top center resize 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 TopCenterResize}"
|
MouseMove="{s:Action TopRightRotate}"
|
||||||
Width="10" Height="10" Canvas.Left="{Binding ShapeSkRect.MidX}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-5,-5,0,0" Cursor="SizeNS" />
|
Width="15" Height="15" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-3,-12,0,0"
|
||||||
|
Cursor="/Resources/aero_rotate_tr.cur" />
|
||||||
|
<!-- Top right resize handle -->
|
||||||
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
|
MouseMove="{s:Action TopRightResize}"
|
||||||
|
Width="6" Height="6" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-3,-3,0,0" Cursor="SizeNESW" />
|
||||||
|
|
||||||
<!-- Top right display -->
|
<!-- Center right display -->
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.MidY}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
<!-- Top right rotate 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 TopRightRotate}"
|
MouseMove="{s:Action CenterRightResize}"
|
||||||
Width="15" Height="15" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-3,-12,0,0"
|
Width="10" Height="10" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.MidY}" Fill="Transparent" Margin="-5,-5,0,0" Cursor="SizeWE" />
|
||||||
Cursor="/Resources/aero_rotate_tr.cur" />
|
|
||||||
<!-- Top right resize handle -->
|
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
|
||||||
MouseMove="{s:Action TopRightResize}"
|
|
||||||
Width="6" Height="6" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Top}" Fill="Transparent" Margin="-3,-3,0,0" Cursor="SizeNESW" />
|
|
||||||
|
|
||||||
<!-- Center right display -->
|
<!-- Bottom right display -->
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.MidY}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
<!-- Center right resize 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 CenterRightResize}"
|
MouseMove="{s:Action BottomRightRotate}"
|
||||||
Width="10" Height="10" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.MidY}" Fill="Transparent" Margin="-5,-5,0,0" Cursor="SizeWE" />
|
Width="15" Height="15" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-3,-3,0,0"
|
||||||
|
Cursor="/Resources/aero_rotate_br.cur" />
|
||||||
|
<!-- Bottom right resize handle -->
|
||||||
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
|
MouseMove="{s:Action BottomRightResize}"
|
||||||
|
Width="6" Height="6" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-3,-3,0,0" Cursor="SizeNWSE" />
|
||||||
|
|
||||||
<!-- Bottom right display -->
|
<!-- Bottom center display -->
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.MidX}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
<!-- Bottom right rotate 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 BottomRightRotate}"
|
MouseMove="{s:Action BottomCenterResize}"
|
||||||
Width="15" Height="15" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-3,-3,0,0"
|
Width="10" Height="10" Canvas.Left="{Binding ShapeSkRect.MidX}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-5,-5,0,0" Cursor="SizeNS" />
|
||||||
Cursor="/Resources/aero_rotate_br.cur" />
|
|
||||||
<!-- Bottom right resize handle -->
|
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
|
||||||
MouseMove="{s:Action BottomRightResize}"
|
|
||||||
Width="6" Height="6" Canvas.Left="{Binding ShapeSkRect.Right}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-3,-3,0,0" Cursor="SizeNWSE" />
|
|
||||||
|
|
||||||
<!-- Bottom center display -->
|
<!-- Bottom left display -->
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.MidX}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
<!-- Bottom center resize handle -->
|
<!-- Bottom left rotate 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 BottomLeftRotate}"
|
||||||
Width="10" Height="10" Canvas.Left="{Binding ShapeSkRect.MidX}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-5,-5,0,0" Cursor="SizeNS" />
|
Width="15" Height="15" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-12,-3,0,0"
|
||||||
|
Cursor="/Resources/aero_rotate_bl.cur" />
|
||||||
|
<!-- Bottom left resize handle -->
|
||||||
|
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
||||||
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
|
MouseMove="{s:Action BottomLeftResize}"
|
||||||
|
Width="6" Height="6" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-3, -3, 0,0" Cursor="SizeNESW" />
|
||||||
|
|
||||||
<!-- Bottom left display -->
|
<!-- Center left display -->
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.MidY}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
||||||
<!-- Bottom left rotate 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 BottomLeftRotate}"
|
MouseMove="{s:Action CenterLeftResize}"
|
||||||
Width="15" Height="15" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-12,-3,0,0"
|
Width="10" Height="10" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.MidY}" Fill="Transparent" Margin="-5,-5,0,0" Cursor="SizeWE" />
|
||||||
Cursor="/Resources/aero_rotate_bl.cur" />
|
</Canvas>
|
||||||
<!-- Bottom left resize handle -->
|
<Canvas>
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
<!-- Anchor point -->
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
<Ellipse MouseDown="{s:Action AnchorEditMouseDown}"
|
||||||
MouseMove="{s:Action BottomLeftResize}"
|
MouseUp="{s:Action ShapeEditMouseUp}"
|
||||||
Width="6" Height="6" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.Bottom}" Fill="Transparent" Margin="-3, -3, 0,0" Cursor="SizeNESW" />
|
MouseMove="{s:Action AnchorMove}"
|
||||||
|
Width="6" Height="6" Fill="{DynamicResource SecondaryAccentBrush}" Canvas.Left="{Binding AnchorSkPoint.X}" Canvas.Top="{Binding AnchorSkPoint.Y}" Margin="-3,-3,0,0"
|
||||||
<!-- Center left display -->
|
Cursor="SizeAll" />
|
||||||
<Rectangle Width="4" Height="4" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.MidY}" Fill="{DynamicResource SecondaryAccentBrush}" Margin="-2,-2,0,0" />
|
</Canvas>
|
||||||
<!-- Center left resize handle -->
|
|
||||||
<Rectangle MouseDown="{s:Action ShapeEditMouseDown}"
|
|
||||||
MouseUp="{s:Action ShapeEditMouseUp}"
|
|
||||||
MouseMove="{s:Action CenterLeftResize}"
|
|
||||||
Width="10" Height="10" Canvas.Left="{Binding ShapeSkRect.Left}" Canvas.Top="{Binding ShapeSkRect.MidY}" Fill="Transparent" Margin="-5,-5,0,0" Cursor="SizeWE" />
|
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -29,6 +29,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
public SKRect ShapeSkRect { get; set; }
|
public SKRect ShapeSkRect { get; set; }
|
||||||
public SKPoint AnchorSkPoint { get; set; }
|
public SKPoint AnchorSkPoint { get; set; }
|
||||||
|
public int RotationAngle { get; set; }
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
@ -38,6 +39,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
{
|
{
|
||||||
ShapeSkRect = layer.LayerShape.GetUnscaledRectangle();
|
ShapeSkRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
AnchorSkPoint = layer.LayerShape.GetUnscaledAnchor();
|
AnchorSkPoint = layer.LayerShape.GetUnscaledAnchor();
|
||||||
|
RotationAngle = layer.RotationProperty.CurrentValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,15 +66,29 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AnchorEditMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (_isDragging)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Use the regular mousedown
|
||||||
|
ShapeEditMouseDown(sender, e);
|
||||||
|
// Override the drag offset
|
||||||
|
var dragStartPosition = GetRelativePosition(sender, e);
|
||||||
|
_dragOffsetX = AnchorSkPoint.X - dragStartPosition.X;
|
||||||
|
_dragOffsetY = AnchorSkPoint.Y - dragStartPosition.Y;
|
||||||
|
_dragStart = dragStartPosition;
|
||||||
|
}
|
||||||
|
|
||||||
public void ShapeEditMouseUp(object sender, MouseButtonEventArgs e)
|
public void ShapeEditMouseUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
((IInputElement) sender).ReleaseMouseCapture();
|
|
||||||
ProfileEditorService.UpdateSelectedProfileElement();
|
ProfileEditorService.UpdateSelectedProfileElement();
|
||||||
|
|
||||||
_isDragging = false;
|
_isDragging = false;
|
||||||
_draggingHorizontally = false;
|
_draggingHorizontally = false;
|
||||||
_draggingVertically = false;
|
_draggingVertically = false;
|
||||||
|
|
||||||
|
((IInputElement) sender).ReleaseMouseCapture();
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +98,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var position = GetRelativePosition(sender, e);
|
var position = GetRelativePosition(sender, e);
|
||||||
layer.LayerShape.SetFromUnscaledAnchor(new SKPoint((float) position.X, (float) position.Y), ProfileEditorService.CurrentTime);
|
var x = (float) (position.X + _dragOffsetX);
|
||||||
|
var y = (float) (position.Y + _dragOffsetY);
|
||||||
|
layer.LayerShape.SetFromUnscaledAnchor(new SKPoint(x, y), ProfileEditorService.CurrentTime);
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,8 +154,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
skRect.Left = (float) Math.Min(position.X, skRect.Bottom);
|
skRect.Left = (float) Math.Min(position.X, skRect.Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
ApplyShapeResize(skRect);
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TopCenterResize(object sender, MouseEventArgs e)
|
public void TopCenterResize(object sender, MouseEventArgs e)
|
||||||
@ -149,8 +166,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
skRect.Top = (float) Math.Min(position.Y, skRect.Bottom);
|
skRect.Top = (float) Math.Min(position.Y, skRect.Bottom);
|
||||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
ApplyShapeResize(skRect);
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TopRightRotate(object sender, MouseEventArgs e)
|
public void TopRightRotate(object sender, MouseEventArgs e)
|
||||||
@ -175,8 +191,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
skRect.Right = (float) Math.Max(position.X, skRect.Left);
|
skRect.Right = (float) Math.Max(position.X, skRect.Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
ApplyShapeResize(skRect);
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CenterRightResize(object sender, MouseEventArgs e)
|
public void CenterRightResize(object sender, MouseEventArgs e)
|
||||||
@ -188,14 +203,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
skRect.Right = (float) Math.Max(position.X, skRect.Left);
|
skRect.Right = (float) Math.Max(position.X, skRect.Left);
|
||||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
ApplyShapeResize(skRect);
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point GetRelativePosition(object sender, MouseEventArgs mouseEventArgs)
|
|
||||||
{
|
|
||||||
var parent = VisualTreeHelper.GetParent((DependencyObject) sender);
|
|
||||||
return mouseEventArgs.GetPosition((IInputElement) parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BottomRightRotate(object sender, MouseEventArgs e)
|
public void BottomRightRotate(object sender, MouseEventArgs e)
|
||||||
@ -220,8 +228,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
skRect.Right = (float) Math.Max(position.X, skRect.Left);
|
skRect.Right = (float) Math.Max(position.X, skRect.Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
ApplyShapeResize(skRect);
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BottomCenterResize(object sender, MouseEventArgs e)
|
public void BottomCenterResize(object sender, MouseEventArgs e)
|
||||||
@ -233,8 +240,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
skRect.Bottom = (float) Math.Max(position.Y, skRect.Top);
|
skRect.Bottom = (float) Math.Max(position.Y, skRect.Top);
|
||||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
ApplyShapeResize(skRect);
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BottomLeftRotate(object sender, MouseEventArgs e)
|
public void BottomLeftRotate(object sender, MouseEventArgs e)
|
||||||
@ -259,8 +265,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
skRect.Left = (float) Math.Min(position.X, skRect.Right);
|
skRect.Left = (float) Math.Min(position.X, skRect.Right);
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
ApplyShapeResize(skRect);
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CenterLeftResize(object sender, MouseEventArgs e)
|
public void CenterLeftResize(object sender, MouseEventArgs e)
|
||||||
@ -272,7 +277,31 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
var skRect = layer.LayerShape.GetUnscaledRectangle();
|
||||||
skRect.Left = (float) Math.Min(position.X, skRect.Right);
|
skRect.Left = (float) Math.Min(position.X, skRect.Right);
|
||||||
layer.LayerShape.SetFromUnscaledRectangle(skRect, ProfileEditorService.CurrentTime);
|
ApplyShapeResize(skRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point GetRelativePosition(object sender, MouseEventArgs mouseEventArgs)
|
||||||
|
{
|
||||||
|
var parent = VisualTreeHelper.GetParent((DependencyObject) sender);
|
||||||
|
return mouseEventArgs.GetPosition((IInputElement) parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyShapeResize(SKRect newRect)
|
||||||
|
{
|
||||||
|
if (!(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Store the original position to create an offset for the anchor
|
||||||
|
var original = layer.PositionProperty.CurrentValue;
|
||||||
|
layer.LayerShape.SetFromUnscaledRectangle(newRect, ProfileEditorService.CurrentTime);
|
||||||
|
var updated = layer.PositionProperty.CurrentValue;
|
||||||
|
// Apply the offset to the anchor so it stays in at same spot
|
||||||
|
layer.AnchorPointProperty.SetCurrentValue(new SKPoint(
|
||||||
|
layer.AnchorPointProperty.CurrentValue.X + (original.X - updated.X),
|
||||||
|
layer.AnchorPointProperty.CurrentValue.Y + (original.Y - updated.Y)
|
||||||
|
), ProfileEditorService.CurrentTime);
|
||||||
|
|
||||||
|
// Update the preview
|
||||||
ProfileEditorService.UpdateProfilePreview();
|
ProfileEditorService.UpdateProfilePreview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ namespace Artemis.UI.Screens.Shared
|
|||||||
public double PanY { get; set; }
|
public double PanY { get; set; }
|
||||||
public double CanvasWidth { get; set; }
|
public double CanvasWidth { get; set; }
|
||||||
public double CanvasHeight { get; set; }
|
public double CanvasHeight { get; set; }
|
||||||
|
public bool LimitToZero { get; set; }
|
||||||
|
|
||||||
public Rect BackgroundViewport => new Rect(PanX, PanY, 20, 20);
|
public Rect BackgroundViewport => new Rect(PanX, PanY, 20, 20);
|
||||||
|
|
||||||
@ -61,8 +62,16 @@ namespace Artemis.UI.Screens.Shared
|
|||||||
var position = e.GetPosition((IInputElement) sender);
|
var position = e.GetPosition((IInputElement) sender);
|
||||||
var delta = LastPanPosition - position;
|
var delta = LastPanPosition - position;
|
||||||
|
|
||||||
PanX = Math.Min(0, PanX - delta.Value.X);
|
if (LimitToZero)
|
||||||
PanY = Math.Min(0, PanY - delta.Value.Y);
|
{
|
||||||
|
PanX = Math.Min(0, PanX - delta.Value.X);
|
||||||
|
PanY = Math.Min(0, PanY - delta.Value.Y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PanX -= delta.Value.X;
|
||||||
|
PanY -= delta.Value.Y;
|
||||||
|
}
|
||||||
|
|
||||||
LastPanPosition = position;
|
LastPanPosition = position;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user