|
@@ -1,9 +1,13 @@
|
|
using PixiEditor.ChangeableDocument.Actions;
|
|
using PixiEditor.ChangeableDocument.Actions;
|
|
using PixiEditor.ChangeableDocument.Actions.Generated;
|
|
using PixiEditor.ChangeableDocument.Actions.Generated;
|
|
|
|
+using PixiEditor.ChangeableDocument.Changeables.Graph.Interfaces.Shapes;
|
|
|
|
+using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
|
|
using PixiEditor.DrawingApi.Core.ColorsImpl;
|
|
using PixiEditor.DrawingApi.Core.ColorsImpl;
|
|
using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
|
|
using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
|
|
using PixiEditor.Extensions.CommonApi.Palettes;
|
|
using PixiEditor.Extensions.CommonApi.Palettes;
|
|
|
|
+using PixiEditor.Helpers.Extensions;
|
|
using PixiEditor.Models.Handlers;
|
|
using PixiEditor.Models.Handlers;
|
|
|
|
+using PixiEditor.Models.Handlers.Toolbars;
|
|
using PixiEditor.Models.Handlers.Tools;
|
|
using PixiEditor.Models.Handlers.Tools;
|
|
using PixiEditor.Models.Tools;
|
|
using PixiEditor.Models.Tools;
|
|
using PixiEditor.Numerics;
|
|
using PixiEditor.Numerics;
|
|
@@ -15,7 +19,7 @@ internal abstract class LineExecutor<T> : UpdateableChangeExecutor where T : ILi
|
|
public override ExecutorType Type => ExecutorType.ToolLinked;
|
|
public override ExecutorType Type => ExecutorType.ToolLinked;
|
|
|
|
|
|
protected VecI startPos;
|
|
protected VecI startPos;
|
|
- protected Color StrokeColor => colorsVM!.PrimaryColor;
|
|
|
|
|
|
+ protected Color StrokeColor => toolbar!.StrokeColor.ToColor();
|
|
protected int StrokeWidth => toolViewModel!.ToolSize;
|
|
protected int StrokeWidth => toolViewModel!.ToolSize;
|
|
protected Guid memberGuid;
|
|
protected Guid memberGuid;
|
|
protected bool drawOnMask;
|
|
protected bool drawOnMask;
|
|
@@ -25,12 +29,14 @@ internal abstract class LineExecutor<T> : UpdateableChangeExecutor where T : ILi
|
|
private bool transforming = false;
|
|
private bool transforming = false;
|
|
private T? toolViewModel;
|
|
private T? toolViewModel;
|
|
private IColorsHandler? colorsVM;
|
|
private IColorsHandler? colorsVM;
|
|
|
|
+ private ILineToolbar? toolbar;
|
|
|
|
|
|
public override ExecutionState Start()
|
|
public override ExecutionState Start()
|
|
{
|
|
{
|
|
colorsVM = GetHandler<IColorsHandler>();
|
|
colorsVM = GetHandler<IColorsHandler>();
|
|
toolViewModel = GetHandler<T>();
|
|
toolViewModel = GetHandler<T>();
|
|
IStructureMemberHandler? member = document?.SelectedStructureMember;
|
|
IStructureMemberHandler? member = document?.SelectedStructureMember;
|
|
|
|
+ toolbar = (ILineToolbar?)toolViewModel?.Toolbar;
|
|
if (colorsVM is null || toolViewModel is null || member is null)
|
|
if (colorsVM is null || toolViewModel is null || member is null)
|
|
return ExecutionState.Error;
|
|
return ExecutionState.Error;
|
|
|
|
|
|
@@ -40,12 +46,38 @@ internal abstract class LineExecutor<T> : UpdateableChangeExecutor where T : ILi
|
|
if (!drawOnMask && member is not ILayerHandler)
|
|
if (!drawOnMask && member is not ILayerHandler)
|
|
return ExecutionState.Error;
|
|
return ExecutionState.Error;
|
|
|
|
|
|
- startPos = controller!.LastPixelPosition;
|
|
|
|
memberGuid = member.Id;
|
|
memberGuid = member.Id;
|
|
|
|
|
|
|
|
+ if (controller.LeftMousePressed || member is not IVectorLayerHandler)
|
|
|
|
+ {
|
|
|
|
+ startPos = controller!.LastPixelPosition;
|
|
|
|
+ OnColorChanged(colorsVM.PrimaryColor, true);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ transforming = true;
|
|
|
|
+ var node = (VectorLayerNode)internals.Tracker.Document.FindMember(member.Id);
|
|
|
|
+ IReadOnlyLineData data = node.ShapeData as IReadOnlyLineData;
|
|
|
|
+
|
|
|
|
+ if(data is null)
|
|
|
|
+ {
|
|
|
|
+ document.TransformHandler.HideTransform();
|
|
|
|
+ return ExecutionState.Error;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ toolbar.StrokeColor = data.StrokeColor.ToColor();
|
|
|
|
+
|
|
|
|
+ if (!InitShapeData(node.ShapeData as IReadOnlyLineData))
|
|
|
|
+ {
|
|
|
|
+ document.TransformHandler.HideTransform();
|
|
|
|
+ return ExecutionState.Error;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
return ExecutionState.Success;
|
|
return ExecutionState.Success;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected abstract bool InitShapeData(IReadOnlyLineData? data);
|
|
protected abstract IAction DrawLine(VecI pos);
|
|
protected abstract IAction DrawLine(VecI pos);
|
|
protected abstract IAction TransformOverlayMoved(VecD start, VecD end);
|
|
protected abstract IAction TransformOverlayMoved(VecD start, VecD end);
|
|
protected abstract IAction SettingsChange();
|
|
protected abstract IAction SettingsChange();
|
|
@@ -94,6 +126,7 @@ internal abstract class LineExecutor<T> : UpdateableChangeExecutor where T : ILi
|
|
if (!primary)
|
|
if (!primary)
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
+ toolbar!.StrokeColor = color.ToColor();
|
|
var colorChangedAction = SettingsChange();
|
|
var colorChangedAction = SettingsChange();
|
|
internals!.ActionAccumulator.AddActions(colorChangedAction);
|
|
internals!.ActionAccumulator.AddActions(colorChangedAction);
|
|
}
|
|
}
|