mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Added undo/redo to profile editor
Added shape anchor point display and movement
This commit is contained in:
1 parent
e9677f2070
commit
c97b479779
25 files changed
+386
-68
No files matched your search
@@ -81,5 +81,42 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
(float) (height * Layer.SizeProperty.CurrentValue.Height)
|
||||
);
|
||||
}
|
||||
|
||||
public void SetFromUnscaledAnchor(SKPoint anchor, TimeSpan? time)
|
||||
{
|
||||
if (!Layer.Leds.Any())
|
||||
{
|
||||
Layer.PositionProperty.SetCurrentValue(SKPoint.Empty, time);
|
||||
Layer.SizeProperty.SetCurrentValue(SKSize.Empty, time);
|
||||
return;
|
||||
}
|
||||
|
||||
var x = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.X);
|
||||
var y = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.Y);
|
||||
var width = Layer.Leds.Max(l => l.RgbLed.AbsoluteLedRectangle.Location.X + l.RgbLed.AbsoluteLedRectangle.Size.Width) - x;
|
||||
var height = Layer.Leds.Max(l => l.RgbLed.AbsoluteLedRectangle.Location.Y + l.RgbLed.AbsoluteLedRectangle.Size.Height) - y;
|
||||
|
||||
Layer.AnchorPointProperty.SetCurrentValue(new SKPoint(
|
||||
(float) (100f / width * (anchor.X - x - Layer.PositionProperty.CurrentValue.X)) / 100f,
|
||||
(float) (100f / height * (anchor.Y - y - Layer.PositionProperty.CurrentValue.Y)) / 100f
|
||||
), time);
|
||||
CalculateRenderProperties(Layer.PositionProperty.CurrentValue, Layer.SizeProperty.CurrentValue);
|
||||
}
|
||||
|
||||
public SKPoint GetUnscaledAnchor()
|
||||
{
|
||||
if (!Layer.Leds.Any())
|
||||
return SKPoint.Empty;
|
||||
|
||||
var x = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.X);
|
||||
var y = Layer.Leds.Min(l => l.RgbLed.AbsoluteLedRectangle.Location.Y);
|
||||
var width = Layer.Leds.Max(l => l.RgbLed.AbsoluteLedRectangle.Location.X + l.RgbLed.AbsoluteLedRectangle.Size.Width) - x;
|
||||
var height = Layer.Leds.Max(l => l.RgbLed.AbsoluteLedRectangle.Location.Y + l.RgbLed.AbsoluteLedRectangle.Size.Height) - y;
|
||||
|
||||
return new SKPoint(
|
||||
(float) (x + width * (Layer.AnchorPointProperty.CurrentValue.X + Layer.PositionProperty.CurrentValue.X)),
|
||||
(float) (y + height * (Layer.AnchorPointProperty.CurrentValue.Y + Layer.PositionProperty.CurrentValue.Y))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user