add node shadow
- rectangular shadow (can be disabled...) - ... for example for nodes with more complex shapes like reroute
This commit is contained in:
@@ -1059,6 +1059,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
internal class RerouteNode : SurfaceNode, IConnectionInstigator
|
||||
{
|
||||
internal static readonly Float2 DefaultSize = new Float2(FlaxEditor.Surface.Constants.BoxRowHeight);
|
||||
internal override bool DrawBasicShadow => false;
|
||||
private Rectangle _localBounds;
|
||||
private InputBox _input;
|
||||
private OutputBox _output;
|
||||
@@ -1187,6 +1188,11 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
icon = type.IsVoid ? style.Icons.ArrowClose : style.Icons.BoxClose;
|
||||
else
|
||||
icon = type.IsVoid ? style.Icons.ArrowOpen : style.Icons.BoxOpen;
|
||||
|
||||
// Shadow
|
||||
var shadowRect = _localBounds.MakeOffsetted(ShadowOffset);
|
||||
Render2D.DrawSprite(icon, shadowRect, Color.Black.AlphaMultiplied(0.125f));
|
||||
|
||||
Render2D.DrawSprite(icon, _localBounds, connectionColor);
|
||||
|
||||
base.Draw();
|
||||
|
||||
@@ -40,6 +40,13 @@ namespace FlaxEditor.Surface
|
||||
[HideInEditor]
|
||||
public class SurfaceNode : SurfaceControl
|
||||
{
|
||||
internal const float ShadowOffset = 2.25f;
|
||||
|
||||
/// <summary>
|
||||
/// If true, draws a basic rectangle shadow behind the node. Disable to hide shadow or if the node is drawing a custom shadow.
|
||||
/// </summary>
|
||||
internal virtual bool DrawBasicShadow => true;
|
||||
|
||||
/// <summary>
|
||||
/// The box to draw a highlight around. Drawing will be skipped if null.
|
||||
/// </summary>
|
||||
@@ -1047,8 +1054,16 @@ namespace FlaxEditor.Surface
|
||||
{
|
||||
var style = Style.Current;
|
||||
|
||||
// Background
|
||||
var backgroundRect = new Rectangle(Float2.Zero, Size);
|
||||
|
||||
// Shadow
|
||||
if (DrawBasicShadow)
|
||||
{
|
||||
var shadowRect = backgroundRect.MakeOffsetted(ShadowOffset);
|
||||
Render2D.FillRectangle(shadowRect, Color.Black.AlphaMultiplied(0.125f));
|
||||
}
|
||||
|
||||
// Background
|
||||
Render2D.FillRectangle(backgroundRect, BackgroundColor);
|
||||
|
||||
// Breakpoint hit
|
||||
@@ -1085,6 +1100,7 @@ namespace FlaxEditor.Surface
|
||||
var colorTop = Color.Orange;
|
||||
var colorBottom = Color.OrangeRed;
|
||||
Render2D.DrawRectangle(backgroundRect, colorTop, colorTop, colorBottom, colorBottom);
|
||||
Render2D.DrawRectangle(backgroundRect, colorTop, colorTop, colorBottom, colorBottom, 2.5f);
|
||||
}
|
||||
|
||||
// Breakpoint dot
|
||||
|
||||
@@ -253,6 +253,16 @@ namespace FlaxEngine
|
||||
return new Rectangle(Location + new Float2(x, y), Size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make offseted rectangle
|
||||
/// </summary>
|
||||
/// <param name="offset">Offset (will be applied to X- and Y- axis).</param>
|
||||
/// <returns>Offseted rectangle.</returns>
|
||||
public Rectangle MakeOffsetted(float offset)
|
||||
{
|
||||
return new Rectangle(Location + new Float2(offset, offset), Size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make offseted rectangle
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user