|
@@ -4,6 +4,7 @@ using PixiEditor.ChangeableDocument.Enums;
|
|
using PixiEditor.DrawingApi.Core.ColorsImpl;
|
|
using PixiEditor.DrawingApi.Core.ColorsImpl;
|
|
using PixiEditor.DrawingApi.Core.Numerics;
|
|
using PixiEditor.DrawingApi.Core.Numerics;
|
|
using PixiEditor.Models.DocumentModels.UpdateableChangeExecutors;
|
|
using PixiEditor.Models.DocumentModels.UpdateableChangeExecutors;
|
|
|
|
+using PixiEditor.Models.DocumentModels.UpdateableChangeExecutors.Features;
|
|
using PixiEditor.Models.Handlers;
|
|
using PixiEditor.Models.Handlers;
|
|
using PixiEditor.Models.Tools;
|
|
using PixiEditor.Models.Tools;
|
|
using PixiEditor.Numerics;
|
|
using PixiEditor.Numerics;
|
|
@@ -18,7 +19,7 @@ internal class ChangeExecutionController
|
|
public VecI LastPixelPosition => lastPixelPos;
|
|
public VecI LastPixelPosition => lastPixelPos;
|
|
public VecD LastPrecisePosition => lastPrecisePos;
|
|
public VecD LastPrecisePosition => lastPrecisePos;
|
|
public bool IsBlockingChangeActive => currentSession is not null && currentSession.BlocksOtherActions;
|
|
public bool IsBlockingChangeActive => currentSession is not null && currentSession.BlocksOtherActions;
|
|
-
|
|
|
|
|
|
+
|
|
public event Action ToolSessionFinished;
|
|
public event Action ToolSessionFinished;
|
|
|
|
|
|
private readonly IDocument document;
|
|
private readonly IDocument document;
|
|
@@ -29,7 +30,7 @@ internal class ChangeExecutionController
|
|
private VecD lastPrecisePos;
|
|
private VecD lastPrecisePos;
|
|
|
|
|
|
private UpdateableChangeExecutor? currentSession = null;
|
|
private UpdateableChangeExecutor? currentSession = null;
|
|
-
|
|
|
|
|
|
+
|
|
private UpdateableChangeExecutor? _queuedExecutor = null;
|
|
private UpdateableChangeExecutor? _queuedExecutor = null;
|
|
|
|
|
|
public ChangeExecutionController(IDocument document, DocumentInternalParts internals, IServiceProvider services)
|
|
public ChangeExecutionController(IDocument document, DocumentInternalParts internals, IServiceProvider services)
|
|
@@ -39,6 +40,11 @@ internal class ChangeExecutionController
|
|
this.services = services;
|
|
this.services = services;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public bool IsChangeOfTypeActive<T>() where T : IExecutorFeature
|
|
|
|
+ {
|
|
|
|
+ return currentSession is T sessionT && sessionT.IsFeatureEnabled(sessionT);
|
|
|
|
+ }
|
|
|
|
+
|
|
public ExecutorType GetCurrentExecutorType()
|
|
public ExecutorType GetCurrentExecutorType()
|
|
{
|
|
{
|
|
if (currentSession is null)
|
|
if (currentSession is null)
|
|
@@ -53,7 +59,7 @@ internal class ChangeExecutionController
|
|
return false;
|
|
return false;
|
|
if (force)
|
|
if (force)
|
|
currentSession?.ForceStop();
|
|
currentSession?.ForceStop();
|
|
-
|
|
|
|
|
|
+
|
|
T executor = new T();
|
|
T executor = new T();
|
|
return TryStartExecutorInternal(executor);
|
|
return TryStartExecutorInternal(executor);
|
|
}
|
|
}
|
|
@@ -64,7 +70,7 @@ internal class ChangeExecutionController
|
|
return false;
|
|
return false;
|
|
if (force)
|
|
if (force)
|
|
currentSession?.ForceStop();
|
|
currentSession?.ForceStop();
|
|
-
|
|
|
|
|
|
+
|
|
return TryStartExecutorInternal(brandNewExecutor);
|
|
return TryStartExecutorInternal(brandNewExecutor);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -76,7 +82,7 @@ internal class ChangeExecutionController
|
|
private bool TryStartExecutorInternal(UpdateableChangeExecutor executor)
|
|
private bool TryStartExecutorInternal(UpdateableChangeExecutor executor)
|
|
{
|
|
{
|
|
executor.Initialize(document, internals, services, this, EndExecutor);
|
|
executor.Initialize(document, internals, services, this, EndExecutor);
|
|
-
|
|
|
|
|
|
+
|
|
if (executor.StartMode == ExecutorStartMode.OnMouseLeftButtonDown)
|
|
if (executor.StartMode == ExecutorStartMode.OnMouseLeftButtonDown)
|
|
{
|
|
{
|
|
_queuedExecutor = executor;
|
|
_queuedExecutor = executor;
|
|
@@ -85,7 +91,7 @@ internal class ChangeExecutionController
|
|
|
|
|
|
return StartExecutor(executor);
|
|
return StartExecutor(executor);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
private bool StartExecutor(UpdateableChangeExecutor brandNewExecutor)
|
|
private bool StartExecutor(UpdateableChangeExecutor brandNewExecutor)
|
|
{
|
|
{
|
|
if (brandNewExecutor.Start() == ExecutionState.Success)
|
|
if (brandNewExecutor.Start() == ExecutionState.Success)
|
|
@@ -103,7 +109,7 @@ internal class ChangeExecutionController
|
|
throw new InvalidOperationException();
|
|
throw new InvalidOperationException();
|
|
currentSession = null;
|
|
currentSession = null;
|
|
_queuedExecutor = null;
|
|
_queuedExecutor = null;
|
|
-
|
|
|
|
|
|
+
|
|
ToolSessionFinished?.Invoke();
|
|
ToolSessionFinished?.Invoke();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -113,13 +119,32 @@ internal class ChangeExecutionController
|
|
return false;
|
|
return false;
|
|
currentSession.ForceStop();
|
|
currentSession.ForceStop();
|
|
currentSession = null;
|
|
currentSession = null;
|
|
-
|
|
|
|
|
|
+
|
|
ToolSessionFinished?.Invoke();
|
|
ToolSessionFinished?.Invoke();
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- public void MidChangeUndoInlet() => currentSession?.OnMidChangeUndo();
|
|
|
|
- public void MidChangeRedoInlet() => currentSession?.OnMidChangeRedo();
|
|
|
|
|
|
+ public void MidChangeUndoInlet()
|
|
|
|
+ {
|
|
|
|
+ if (currentSession is null)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if (currentSession is IMidChangeUndoableExecutor undoableExecutor)
|
|
|
|
+ {
|
|
|
|
+ undoableExecutor.OnMidChangeUndo();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void MidChangeRedoInlet()
|
|
|
|
+ {
|
|
|
|
+ if (currentSession is null)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if (currentSession is IMidChangeUndoableExecutor undoableExecutor)
|
|
|
|
+ {
|
|
|
|
+ undoableExecutor.OnMidChangeRedo();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
public void ConvertedKeyDownInlet(Key key)
|
|
public void ConvertedKeyDownInlet(Key key)
|
|
{
|
|
{
|
|
@@ -141,6 +166,7 @@ internal class ChangeExecutionController
|
|
lastPixelPos = newPixelPos;
|
|
lastPixelPos = newPixelPos;
|
|
pixelPosChanged = true;
|
|
pixelPosChanged = true;
|
|
}
|
|
}
|
|
|
|
+
|
|
lastPrecisePos = newCanvasPos;
|
|
lastPrecisePos = newCanvasPos;
|
|
|
|
|
|
//call session events
|
|
//call session events
|
|
@@ -153,13 +179,16 @@ internal class ChangeExecutionController
|
|
}
|
|
}
|
|
|
|
|
|
public void OpacitySliderDragStartedInlet() => currentSession?.OnOpacitySliderDragStarted();
|
|
public void OpacitySliderDragStartedInlet() => currentSession?.OnOpacitySliderDragStarted();
|
|
|
|
+
|
|
public void OpacitySliderDraggedInlet(float newValue)
|
|
public void OpacitySliderDraggedInlet(float newValue)
|
|
{
|
|
{
|
|
currentSession?.OnOpacitySliderDragged(newValue);
|
|
currentSession?.OnOpacitySliderDragged(newValue);
|
|
}
|
|
}
|
|
|
|
+
|
|
public void OpacitySliderDragEndedInlet() => currentSession?.OnOpacitySliderDragEnded();
|
|
public void OpacitySliderDragEndedInlet() => currentSession?.OnOpacitySliderDragEnded();
|
|
|
|
|
|
public void SymmetryDragStartedInlet(SymmetryAxisDirection dir) => currentSession?.OnSymmetryDragStarted(dir);
|
|
public void SymmetryDragStartedInlet(SymmetryAxisDirection dir) => currentSession?.OnSymmetryDragStarted(dir);
|
|
|
|
+
|
|
public void SymmetryDraggedInlet(SymmetryAxisDragInfo info)
|
|
public void SymmetryDraggedInlet(SymmetryAxisDragInfo info)
|
|
{
|
|
{
|
|
currentSession?.OnSymmetryDragged(info);
|
|
currentSession?.OnSymmetryDragged(info);
|
|
@@ -176,7 +205,7 @@ internal class ChangeExecutionController
|
|
{
|
|
{
|
|
StartExecutor(_queuedExecutor);
|
|
StartExecutor(_queuedExecutor);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//call session event
|
|
//call session event
|
|
currentSession?.OnLeftMouseButtonDown(canvasPos);
|
|
currentSession?.OnLeftMouseButtonDown(canvasPos);
|
|
}
|
|
}
|
|
@@ -192,17 +221,26 @@ internal class ChangeExecutionController
|
|
|
|
|
|
public void TransformMovedInlet(ShapeCorners corners)
|
|
public void TransformMovedInlet(ShapeCorners corners)
|
|
{
|
|
{
|
|
- LastTransformState = corners;
|
|
|
|
- currentSession?.OnTransformMoved(corners);
|
|
|
|
|
|
+ if (currentSession is ITransformableExecutor transformableExecutor)
|
|
|
|
+ {
|
|
|
|
+ LastTransformState = corners;
|
|
|
|
+ transformableExecutor.OnTransformMoved(corners);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void MembersSelectedInlet(List<Guid> memberGuids)
|
|
public void MembersSelectedInlet(List<Guid> memberGuids)
|
|
{
|
|
{
|
|
currentSession?.OnMembersSelected(memberGuids);
|
|
currentSession?.OnMembersSelected(memberGuids);
|
|
}
|
|
}
|
|
-
|
|
|
|
- public void TransformAppliedInlet() => currentSession?.OnTransformApplied();
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ public void TransformAppliedInlet()
|
|
|
|
+ {
|
|
|
|
+ if (currentSession is ITransformableExecutor transformableExecutor)
|
|
|
|
+ {
|
|
|
|
+ transformableExecutor.OnTransformApplied();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public void SettingsChangedInlet(string name, object value)
|
|
public void SettingsChangedInlet(string name, object value)
|
|
{
|
|
{
|
|
currentSession?.OnSettingsChanged(name, value);
|
|
currentSession?.OnSettingsChanged(name, value);
|
|
@@ -210,12 +248,18 @@ internal class ChangeExecutionController
|
|
|
|
|
|
public void LineOverlayMovedInlet(VecD start, VecD end)
|
|
public void LineOverlayMovedInlet(VecD start, VecD end)
|
|
{
|
|
{
|
|
- currentSession?.OnLineOverlayMoved(start, end);
|
|
|
|
|
|
+ if (currentSession is ITransformableExecutor lineOverlayExecutor)
|
|
|
|
+ {
|
|
|
|
+ lineOverlayExecutor.OnLineOverlayMoved(start, end);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public void SelectedObjectNudgedInlet(VecI distance)
|
|
public void SelectedObjectNudgedInlet(VecI distance)
|
|
{
|
|
{
|
|
- currentSession?.OnSelectedObjectNudged(distance);
|
|
|
|
|
|
+ if (currentSession is ITransformableExecutor transformableExecutor)
|
|
|
|
+ {
|
|
|
|
+ transformableExecutor.OnSelectedObjectNudged(distance);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public void PrimaryColorChangedInlet(Color color)
|
|
public void PrimaryColorChangedInlet(Color color)
|
|
@@ -227,5 +271,4 @@ internal class ChangeExecutionController
|
|
{
|
|
{
|
|
currentSession?.OnColorChanged(color, false);
|
|
currentSession?.OnColorChanged(color, false);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|