diff --git a/Source/Editor/Surface/ResizableSurfaceNode.cs b/Source/Editor/Surface/ResizableSurfaceNode.cs
index 6fa7225c5..ea9ceec82 100644
--- a/Source/Editor/Surface/ResizableSurfaceNode.cs
+++ b/Source/Editor/Surface/ResizableSurfaceNode.cs
@@ -16,7 +16,7 @@ namespace FlaxEditor.Surface
///
/// Helper class for that handles mouse interactions resizing the node itself.
///
- protected class ResizeBorder : Control
+ public class ResizeBorder : ContainerControl
{
///
/// 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;
+ ///
+ /// The resizable node that this controls.
+ ///
+ public readonly ResizableSurfaceNode ResizableNode;
+
///
/// True if the mouse is at the border of the resizable node and not further away from the border than .
///
@@ -63,7 +67,6 @@ namespace FlaxEditor.Surface
}
}
-
///
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);
}
+ ///
+ public override void OnMouseEnter(Float2 location)
+ {
+ Cursor = CursorType.Default;
+ base.OnMouseEnter(location);
+ }
+
///
public override bool OnMouseDown(Float2 location, MouseButton button)
{
@@ -243,7 +253,7 @@ namespace FlaxEditor.Surface
///
/// Represents the border control used for resizing the associated element.
///
- protected ResizeBorder ResizeBorderControl;
+ public ResizeBorder ResizeBorderControl;
///
/// 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();
}
- /////
- //public override bool CanSelect(ref Float2 location)
- //{
- // return base.CanSelect(ref location);
- //}
-
- ///
+ ///
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);
- }
+ }
+
+ ///
+ public override void OnDestroy()
+ {
+ ResizeBorderControl.Parent = null;
+ base.OnDestroy();
}
}
}
diff --git a/Source/Editor/Surface/SurfaceComment.cs b/Source/Editor/Surface/SurfaceComment.cs
index c257dddd1..73f280d48 100644
--- a/Source/Editor/Surface/SurfaceComment.cs
+++ b/Source/Editor/Surface/SurfaceComment.cs
@@ -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;
}
///
@@ -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;
});
}
}
diff --git a/Source/Editor/Surface/SurfaceRootControl.cs b/Source/Editor/Surface/SurfaceRootControl.cs
index 15d4c43cc..c7639a27d 100644
--- a/Source/Editor/Surface/SurfaceRootControl.cs
+++ b/Source/Editor/Surface/SurfaceRootControl.cs
@@ -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();
}
}
diff --git a/Source/Editor/Surface/VisjectSurfaceContext.cs b/Source/Editor/Surface/VisjectSurfaceContext.cs
index 0d10aa230..be91e02ca 100644
--- a/Source/Editor/Surface/VisjectSurfaceContext.cs
+++ b/Source/Editor/Surface/VisjectSurfaceContext.cs
@@ -80,8 +80,9 @@ namespace FlaxEditor.Surface
var result = new List();
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;