fix comment order and not being able to move around comment nodes
This commit is contained in:
@@ -16,7 +16,7 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// Helper class for <see cref="ResizableSurfaceNode"/> that handles mouse interactions resizing the node itself.
|
||||
/// </summary>
|
||||
protected class ResizeBorder : Control
|
||||
public class ResizeBorder : ContainerControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Distance to each of the 4 node edges that the cursor has to be so the user can resize along the direction of the edge.
|
||||
@@ -24,10 +24,14 @@ namespace FlaxEditor.Surface
|
||||
private const float BorderWidth = 15f;
|
||||
|
||||
private readonly VisjectSurface Surface;
|
||||
private readonly ResizableSurfaceNode ResizableNode;
|
||||
private Float2 _surfaceMouseLocation;
|
||||
private Float2 startResizingSize;
|
||||
|
||||
/// <summary>
|
||||
/// The resizable node that this <see cref="ResizeBorder"/> controls.
|
||||
/// </summary>
|
||||
public readonly ResizableSurfaceNode ResizableNode;
|
||||
|
||||
/// <summary>
|
||||
/// True if the mouse is at the border of the resizable node and not further away from the border than <see cref="BorderWidth"/>.
|
||||
/// </summary>
|
||||
@@ -63,7 +67,6 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public ResizeBorder(VisjectSurface surface, ResizableSurfaceNode resizableNode)
|
||||
{
|
||||
@@ -100,7 +103,7 @@ namespace FlaxEditor.Surface
|
||||
ResizeDirection = new Float2(Mathf.Abs(rawResizeDirection.X) >= nodeHalfSizeNoBorder.X ? Mathf.Sign(rawResizeDirection.X) : 0,
|
||||
Mathf.Abs(rawResizeDirection.Y) >= nodeHalfSizeNoBorder.Y ? Mathf.Sign(rawResizeDirection.Y) : 0);
|
||||
|
||||
IsMouseOverResizeBorder = false;// onBorder && !inNode;
|
||||
IsMouseOverResizeBorder = onBorder && !inNode;
|
||||
}
|
||||
|
||||
private Float2 GetControlDelta(Control control, ref Float2 start, ref Float2 end)
|
||||
@@ -186,6 +189,13 @@ namespace FlaxEditor.Surface
|
||||
base.OnMouseMove(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseEnter(Float2 location)
|
||||
{
|
||||
Cursor = CursorType.Default;
|
||||
base.OnMouseEnter(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
@@ -243,7 +253,7 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// Represents the border control used for resizing the associated element.
|
||||
/// </summary>
|
||||
protected ResizeBorder ResizeBorderControl;
|
||||
public ResizeBorder ResizeBorderControl;
|
||||
|
||||
/// <summary>
|
||||
/// Index of the Float2 value in the node values list to store node size.
|
||||
@@ -270,6 +280,7 @@ namespace FlaxEditor.Surface
|
||||
Parent = Surface.SurfaceRoot,
|
||||
};
|
||||
|
||||
Parent = ResizeBorderControl;
|
||||
ResizeBorderControl.MatchResizableNode(Size, Location);
|
||||
}
|
||||
|
||||
@@ -280,13 +291,7 @@ namespace FlaxEditor.Surface
|
||||
base.OnLocationChanged();
|
||||
}
|
||||
|
||||
///// <inheritdoc />
|
||||
//public override bool CanSelect(ref Float2 location)
|
||||
//{
|
||||
// return base.CanSelect(ref location);
|
||||
//}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <inheritdoc />
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
// Reapply the curve node size
|
||||
@@ -314,9 +319,14 @@ namespace FlaxEditor.Surface
|
||||
base.Draw();
|
||||
|
||||
if (Surface.CanEdit && (ResizeBorderControl.IsResizing || ResizeBorderControl.IsMouseOverResizeBorder))
|
||||
{
|
||||
Render2D.DrawRectangle(new Rectangle(Float2.Zero, Size), Style.Current.Foreground, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnDestroy()
|
||||
{
|
||||
ResizeBorderControl.Parent = null;
|
||||
base.OnDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,16 +81,12 @@ namespace FlaxEditor.Surface
|
||||
if (Values.Length < 4)
|
||||
{
|
||||
if (IndexInParent > 0)
|
||||
{
|
||||
IndexInParent = 0;
|
||||
ResizeBorderControl.IndexInParent = - 1;
|
||||
}
|
||||
OrderValue = IndexInParent;
|
||||
}
|
||||
else if (OrderValue != -1)
|
||||
{
|
||||
IndexInParent = OrderValue;
|
||||
ResizeBorderControl.IndexInParent = OrderValue - 1;
|
||||
ResizeBorderControl.IndexInParent = OrderValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +99,8 @@ namespace FlaxEditor.Surface
|
||||
Color = ColorValue = Color.FromHSV(new Random().NextFloat(0, 360), 0.7f, 0.25f, 0.8f);
|
||||
|
||||
if (OrderValue == -1)
|
||||
OrderValue = Context.CommentCount - 1;
|
||||
IndexInParent = OrderValue;
|
||||
OrderValue = Context.CommentCount;
|
||||
ResizeBorderControl.IndexInParent = OrderValue;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -333,25 +329,25 @@ namespace FlaxEditor.Surface
|
||||
{
|
||||
cmOrder.ContextMenu.AddButton("Bring Forward", () =>
|
||||
{
|
||||
if (IndexInParent < Context.CommentCount - 1)
|
||||
IndexInParent++;
|
||||
OrderValue = IndexInParent;
|
||||
if (ResizeBorderControl.IndexInParent < Context.CommentCount - 1)
|
||||
ResizeBorderControl.IndexInParent++;
|
||||
OrderValue = ResizeBorderControl.IndexInParent;
|
||||
});
|
||||
cmOrder.ContextMenu.AddButton("Bring to Front", () =>
|
||||
{
|
||||
IndexInParent = Context.CommentCount - 1;
|
||||
OrderValue = IndexInParent;
|
||||
ResizeBorderControl.IndexInParent = Context.CommentCount - 1;
|
||||
OrderValue = ResizeBorderControl.IndexInParent;
|
||||
});
|
||||
cmOrder.ContextMenu.AddButton("Send Backward", () =>
|
||||
{
|
||||
if (IndexInParent > 0)
|
||||
IndexInParent--;
|
||||
OrderValue = IndexInParent;
|
||||
if (ResizeBorderControl.IndexInParent > 0)
|
||||
ResizeBorderControl.IndexInParent--;
|
||||
OrderValue = ResizeBorderControl.IndexInParent;
|
||||
});
|
||||
cmOrder.ContextMenu.AddButton("Send to Back", () =>
|
||||
{
|
||||
IndexInParent = 0;
|
||||
OrderValue = IndexInParent;
|
||||
ResizeBorderControl.IndexInParent = 0;
|
||||
OrderValue = ResizeBorderControl.IndexInParent;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,10 @@ namespace FlaxEditor.Surface
|
||||
{
|
||||
var child = _children[i];
|
||||
|
||||
if (child is SurfaceComment && child.Visible)
|
||||
if (child is ResizableSurfaceNode.ResizeBorder border && border.ResizableNode is SurfaceComment comment2 && comment2.Visible)
|
||||
{
|
||||
Render2D.PushTransform(ref child._cachedTransform);
|
||||
child.Draw();
|
||||
Render2D.PushTransform(ref comment2._cachedTransform);
|
||||
comment2.Draw();
|
||||
Render2D.PopTransform();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +80,9 @@ namespace FlaxEditor.Surface
|
||||
var result = new List<SurfaceComment>();
|
||||
for (int i = 0; i < RootControl.Children.Count; i++)
|
||||
{
|
||||
if (RootControl.Children[i] is SurfaceComment comment)
|
||||
result.Add(comment);
|
||||
var child = RootControl.Children[i];
|
||||
if (child is ResizableSurfaceNode.ResizeBorder border && border.ResizableNode is SurfaceComment comment2)
|
||||
result.Add(comment2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -101,7 +102,8 @@ namespace FlaxEditor.Surface
|
||||
int count = 0;
|
||||
for (int i = 0; i < RootControl.Children.Count; i++)
|
||||
{
|
||||
if (RootControl.Children[i] is SurfaceComment)
|
||||
var child = RootControl.Children[i];
|
||||
if (child is ResizableSurfaceNode.ResizeBorder border && border.ResizableNode is SurfaceComment)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
|
||||
Reference in New Issue
Block a user