fix box spacing and (auto calculate) node height
- Work in progress but enough progress to commit because it basically works, it's just a bit ugly - Node height is now recalculated every time a new element is added to the node - Introduced `Archetype.UseFixedSize` for special nodes like *Color Gradient* or *Curve* that must rely on hardcoded size for now because the auto sizing does not take elements like the gradient editor or curve editor into account (ideally in the future it will) - Fixed input and output box spacing (still some 1px offsets that I'm unsure where they are from, could be placebo though)
This commit is contained in:
@@ -79,7 +79,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
: base(id, context, nodeArch, groupArch)
|
||||
{
|
||||
var marginX = FlaxEditor.Surface.Constants.NodeMarginX;
|
||||
var uiStartPosY = FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize;
|
||||
var uiStartPosY = FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight;
|
||||
|
||||
var editButton = new Button(marginX, uiStartPosY, 246, 20)
|
||||
{
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
Type = NodeElementType.Input,
|
||||
Position = new Float2(
|
||||
FlaxEditor.Surface.Constants.NodeMarginX - FlaxEditor.Surface.Constants.BoxOffsetX,
|
||||
FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize + ylevel * FlaxEditor.Surface.Constants.LayoutOffsetY),
|
||||
FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight + ylevel * FlaxEditor.Surface.Constants.LayoutOffsetY),
|
||||
Text = "Pose " + _blendPoses.Count,
|
||||
Single = true,
|
||||
ValueIndex = -1,
|
||||
@@ -263,7 +263,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
private void UpdateHeight()
|
||||
{
|
||||
float nodeHeight = 10 + (Mathf.Max(_blendPoses.Count, 1) + 3) * FlaxEditor.Surface.Constants.LayoutOffsetY;
|
||||
Height = nodeHeight + FlaxEditor.Surface.Constants.NodeMarginY * 2 + FlaxEditor.Surface.Constants.NodeHeaderSize + FlaxEditor.Surface.Constants.NodeFooterSize;
|
||||
Height = nodeHeight + FlaxEditor.Surface.Constants.NodeMarginY * 2 + FlaxEditor.Surface.Constants.NodeHeaderHeight + FlaxEditor.Surface.Constants.NodeFooterSize;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -515,7 +515,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
height += decorator.Height + DecoratorsMarginY;
|
||||
width = Mathf.Max(width, decorator.Width - FlaxEditor.Surface.Constants.NodeCloseButtonSize - 2 * DecoratorsMarginX);
|
||||
}
|
||||
Size = new Float2(width + FlaxEditor.Surface.Constants.NodeMarginX * 2 + FlaxEditor.Surface.Constants.NodeCloseButtonSize, height + FlaxEditor.Surface.Constants.NodeHeaderSize + FlaxEditor.Surface.Constants.NodeFooterSize);
|
||||
Size = new Float2(width + FlaxEditor.Surface.Constants.NodeMarginX * 2 + FlaxEditor.Surface.Constants.NodeCloseButtonSize, height + FlaxEditor.Surface.Constants.NodeHeaderHeight + FlaxEditor.Surface.Constants.NodeFooterSize);
|
||||
UpdateRectangles();
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
decorator.IndexInParent = indexInParent + 1; // Push elements above the node
|
||||
}
|
||||
const float footerSize = FlaxEditor.Surface.Constants.NodeFooterSize;
|
||||
const float headerSize = FlaxEditor.Surface.Constants.NodeHeaderSize;
|
||||
const float headerSize = FlaxEditor.Surface.Constants.NodeHeaderHeight;
|
||||
const float closeButtonMargin = FlaxEditor.Surface.Constants.NodeCloseButtonMargin;
|
||||
const float closeButtonSize = FlaxEditor.Surface.Constants.NodeCloseButtonSize;
|
||||
_headerRect = new Rectangle(0, bounds.Y - Y, bounds.Width, headerSize);
|
||||
@@ -676,7 +676,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
width = Mathf.Max(width, _debugInfoSize.X + 8.0f);
|
||||
height += _debugInfoSize.Y + 8.0f;
|
||||
}
|
||||
return new Float2(width + FlaxEditor.Surface.Constants.NodeCloseButtonSize * 2 + DecoratorsMarginX * 2, height + FlaxEditor.Surface.Constants.NodeHeaderSize);
|
||||
return new Float2(width + FlaxEditor.Surface.Constants.NodeCloseButtonSize * 2 + DecoratorsMarginX * 2, height + FlaxEditor.Surface.Constants.NodeHeaderHeight);
|
||||
}
|
||||
|
||||
protected override void UpdateRectangles()
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_picker = new EnumComboBox(type)
|
||||
{
|
||||
EnumTypeValue = Values[0],
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize, 160, 16),
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight, 160, 16),
|
||||
Parent = this,
|
||||
};
|
||||
_picker.ValueChanged += () => SetValue(0, _picker.EnumTypeValue);
|
||||
@@ -218,7 +218,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_output = (OutputBox)Elements[0];
|
||||
_typePicker = new TypePickerControl
|
||||
{
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize, 160, 16),
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight, 160, 16),
|
||||
Parent = this,
|
||||
};
|
||||
_typePicker.ValueChanged += () => Set(3);
|
||||
@@ -362,7 +362,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_output = (OutputBox)Elements[0];
|
||||
_keyTypePicker = new TypePickerControl
|
||||
{
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize, 160, 16),
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight, 160, 16),
|
||||
Parent = this,
|
||||
};
|
||||
_keyTypePicker.ValueChanged += OnKeyTypeChanged;
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
public CustomCodeNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
|
||||
: base(id, context, nodeArch, groupArch)
|
||||
{
|
||||
Float2 pos = new Float2(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize), size;
|
||||
Float2 pos = new Float2(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight), size;
|
||||
if (nodeArch.TypeID == 8)
|
||||
{
|
||||
pos += new Float2(60, 0);
|
||||
|
||||
@@ -461,7 +461,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <summary>
|
||||
/// The particle module node elements offset applied to controls to reduce default surface node header thickness.
|
||||
/// </summary>
|
||||
private const float NodeElementsOffset = 16.0f - Surface.Constants.NodeHeaderSize;
|
||||
private const float NodeElementsOffset = 16.0f - Surface.Constants.NodeHeaderHeight;
|
||||
|
||||
private const NodeFlags DefaultModuleFlags = NodeFlags.ParticleEmitterGraph | NodeFlags.NoSpawnViaGUI | NodeFlags.NoMove;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <summary>
|
||||
/// The header height.
|
||||
/// </summary>
|
||||
public const float HeaderHeight = FlaxEditor.Surface.Constants.NodeHeaderSize;
|
||||
public const float HeaderHeight = FlaxEditor.Surface.Constants.NodeHeaderHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the module.
|
||||
@@ -199,7 +199,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
DrawChildren();
|
||||
|
||||
// Options border
|
||||
var optionsAreaStart = FlaxEditor.Surface.Constants.NodeHeaderSize + 3.0f;
|
||||
var optionsAreaStart = FlaxEditor.Surface.Constants.NodeHeaderHeight + 3.0f;
|
||||
var optionsAreaHeight = 7 * FlaxEditor.Surface.Constants.LayoutOffsetY + 6.0f;
|
||||
Render2D.DrawRectangle(new Rectangle(1, optionsAreaStart, Width - 2, optionsAreaHeight), style.BackgroundSelected);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
_textureGroupPicker = new ComboBox
|
||||
{
|
||||
Location = new Float2(FlaxEditor.Surface.Constants.NodeMarginX + 50, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize + FlaxEditor.Surface.Constants.LayoutOffsetY * 5),
|
||||
Location = new Float2(FlaxEditor.Surface.Constants.NodeMarginX + 50, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight + FlaxEditor.Surface.Constants.LayoutOffsetY * 5),
|
||||
Width = 100,
|
||||
Parent = this,
|
||||
};
|
||||
|
||||
@@ -467,6 +467,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
Create = (id, context, arch, groupArch) => new CurveNode<T>(id, context, arch, groupArch),
|
||||
Description = "An animation spline represented by a set of keyframes, each representing an endpoint of a Bezier curve.",
|
||||
Flags = NodeFlags.AllGraphs,
|
||||
UseFixedSize = true,
|
||||
Size = new Float2(400, 180.0f),
|
||||
DefaultValues = new object[]
|
||||
{
|
||||
@@ -828,7 +829,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_picker = new TypePickerControl
|
||||
{
|
||||
Type = ScriptType.FlaxObject,
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX + 20, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize, 160, 16),
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX + 20, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight, 160, 16),
|
||||
Parent = this,
|
||||
};
|
||||
_picker.ValueChanged += () => SetValue(0, _picker.ValueTypeName);
|
||||
@@ -897,7 +898,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_picker = new TypePickerControl
|
||||
{
|
||||
Type = ScriptType.Object,
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize, 140, 16),
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight, 140, 16),
|
||||
Parent = this,
|
||||
};
|
||||
_picker.ValueChanged += () => SetValue(0, _picker.ValueTypeName);
|
||||
@@ -948,7 +949,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_picker = new TypePickerControl
|
||||
{
|
||||
Type = ScriptType.FlaxObject,
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX + 20, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize, 160, 16),
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX + 20, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight, 160, 16),
|
||||
Parent = this,
|
||||
};
|
||||
_picker.ValueChanged += () => SetValue(0, _picker.ValueTypeName);
|
||||
@@ -999,7 +1000,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_picker = new TypePickerControl
|
||||
{
|
||||
Type = type,
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX + 20, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize, 160, 16),
|
||||
Bounds = new Rectangle(FlaxEditor.Surface.Constants.NodeMarginX + 20, FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderHeight, 160, 16),
|
||||
Parent = this,
|
||||
};
|
||||
_picker.ValueChanged += () => SetValue(0, _picker.ValueTypeName);
|
||||
@@ -1510,6 +1511,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
Description = "Linear color gradient sampler",
|
||||
Flags = NodeFlags.AllGraphs,
|
||||
Size = new Float2(400, 150.0f),
|
||||
UseFixedSize = true,
|
||||
DefaultValues = new object[]
|
||||
{
|
||||
// Stops count
|
||||
@@ -1829,6 +1831,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
Description = "Reroute a connection.",
|
||||
Flags = NodeFlags.NoCloseButton | NodeFlags.NoSpawnViaGUI | NodeFlags.AllGraphs,
|
||||
Size = RerouteNode.DefaultSize,
|
||||
UseFixedSize = true,
|
||||
ConnectionsHints = ConnectionsHint.All,
|
||||
IndependentBoxes = new int[] { 0 },
|
||||
DependentBoxes = new int[] { 1 },
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// The node header height.
|
||||
/// </summary>
|
||||
public const float NodeHeaderSize = 20.0f;
|
||||
public const float NodeHeaderHeight = 20.0f;
|
||||
|
||||
public const float NodeHeaderTextScale = 0.65f;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// The node left margin.
|
||||
/// </summary>
|
||||
public const float NodeMarginX = 5.0f;
|
||||
public const float NodeMarginX = 8.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The node right margin.
|
||||
@@ -45,7 +45,7 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// The box position offset on the x axis.
|
||||
/// </summary>
|
||||
public const float BoxOffsetX = 2.0f;
|
||||
public const float BoxOffsetX = 0.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the row that is started by a box.
|
||||
@@ -61,5 +61,15 @@ namespace FlaxEditor.Surface
|
||||
/// The node layout offset on the y axis (height of the boxes rows, etc.). It's used to make the design more consistent.
|
||||
/// </summary>
|
||||
public const float LayoutOffsetY = 22.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The offset between the box text and the box
|
||||
/// </summary>
|
||||
public const float BoxTextOffset = 4.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the rectangle used to draw the box text.
|
||||
/// </summary>
|
||||
public const float BoxTextRectWidth = 1410.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1442,7 +1442,7 @@ namespace FlaxEditor.Surface.Elements
|
||||
|
||||
// Draw text
|
||||
var style = Style.Current;
|
||||
var rect = new Rectangle(Width + 4, 0, 1410, Height);
|
||||
var rect = new Rectangle(Width + Constants.BoxTextOffset, 0, Constants.BoxTextRectWidth, Height);
|
||||
Render2D.DrawText(style.FontSmall, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace FlaxEditor.Surface.Elements
|
||||
|
||||
// Draw text
|
||||
var style = Style.Current;
|
||||
var rect = new Rectangle(-100, 0, 100 - 2, Height);
|
||||
var rect = new Rectangle(-Constants.BoxTextRectWidth - Constants.BoxTextOffset, 0, Constants.BoxTextRectWidth, Height);
|
||||
Render2D.DrawText(style.FontSmall, Text, rect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Far, TextAlignment.Center);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,8 @@ namespace FlaxEditor.Surface
|
||||
/// </summary>
|
||||
public NodeFlags Flags;
|
||||
|
||||
public bool UseFixedSize = false;
|
||||
|
||||
/// <summary>
|
||||
/// Title text.
|
||||
/// </summary>
|
||||
|
||||
@@ -78,12 +78,12 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// Gets the actual element position on the y axis.
|
||||
/// </summary>
|
||||
public float ActualPositionY => Position.Y + Constants.NodeMarginY + Constants.NodeHeaderSize;
|
||||
public float ActualPositionY => Position.Y + Constants.NodeMarginY + Constants.NodeHeaderHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actual element position.
|
||||
/// </summary>
|
||||
public Float2 ActualPosition => new Float2(Position.X + Constants.NodeMarginX, Position.Y + Constants.NodeMarginY + Constants.NodeHeaderSize);
|
||||
public Float2 ActualPosition => new Float2(Position.X + Constants.NodeMarginX, Position.Y + Constants.NodeMarginY + Constants.NodeHeaderHeight);
|
||||
|
||||
/// <summary>
|
||||
/// Node element archetypes factory object. Helps to build surface nodes archetypes.
|
||||
@@ -107,7 +107,7 @@ namespace FlaxEditor.Surface
|
||||
Type = NodeElementType.Input,
|
||||
Position = new Float2(
|
||||
Constants.NodeMarginX - Constants.BoxOffsetX,
|
||||
Constants.NodeMarginY + Constants.NodeHeaderSize + yLevel * Constants.LayoutOffsetY),
|
||||
Constants.NodeMarginY + Constants.NodeHeaderHeight + yLevel * Constants.LayoutOffsetY),
|
||||
Text = text,
|
||||
Single = single,
|
||||
ValueIndex = valueIndex,
|
||||
@@ -133,7 +133,7 @@ namespace FlaxEditor.Surface
|
||||
Type = NodeElementType.Input,
|
||||
Position = new Float2(
|
||||
Constants.NodeMarginX - Constants.BoxOffsetX,
|
||||
Constants.NodeMarginY + Constants.NodeHeaderSize + yLevel * Constants.LayoutOffsetY),
|
||||
Constants.NodeMarginY + Constants.NodeHeaderHeight + yLevel * Constants.LayoutOffsetY),
|
||||
Text = text,
|
||||
Single = single,
|
||||
ValueIndex = valueIndex,
|
||||
@@ -158,7 +158,7 @@ namespace FlaxEditor.Surface
|
||||
Type = NodeElementType.Output,
|
||||
Position = new Float2(
|
||||
Constants.NodeMarginX - Constants.BoxRowHeight + Constants.BoxOffsetX,
|
||||
Constants.NodeMarginY + Constants.NodeHeaderSize + yLevel * Constants.LayoutOffsetY),
|
||||
Constants.NodeMarginY + Constants.NodeHeaderHeight + yLevel * Constants.LayoutOffsetY),
|
||||
Text = text,
|
||||
Single = single,
|
||||
ValueIndex = -1,
|
||||
@@ -182,8 +182,8 @@ namespace FlaxEditor.Surface
|
||||
{
|
||||
Type = NodeElementType.Output,
|
||||
Position = new Float2(
|
||||
Constants.NodeMarginX - Constants.BoxRowHeight + Constants.BoxOffsetX,
|
||||
Constants.NodeMarginY + Constants.NodeHeaderSize + yLevel * Constants.LayoutOffsetY),
|
||||
Constants.NodeMarginX - Constants.BoxSize + Constants.BoxOffsetX,
|
||||
Constants.NodeMarginY + Constants.NodeHeaderHeight + yLevel * Constants.LayoutOffsetY),
|
||||
Text = text,
|
||||
Single = single,
|
||||
ValueIndex = -1,
|
||||
@@ -228,7 +228,7 @@ namespace FlaxEditor.Surface
|
||||
return new NodeElementArchetype
|
||||
{
|
||||
Type = NodeElementType.IntegerValue,
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderSize + y),
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderHeight + y),
|
||||
Text = null,
|
||||
Single = false,
|
||||
ValueIndex = valueIndex,
|
||||
@@ -254,7 +254,7 @@ namespace FlaxEditor.Surface
|
||||
return new NodeElementArchetype
|
||||
{
|
||||
Type = NodeElementType.UnsignedIntegerValue,
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderSize + y),
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderHeight + y),
|
||||
Text = null,
|
||||
Single = false,
|
||||
ValueIndex = valueIndex,
|
||||
@@ -280,7 +280,7 @@ namespace FlaxEditor.Surface
|
||||
return new NodeElementArchetype
|
||||
{
|
||||
Type = NodeElementType.FloatValue,
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderSize + y),
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderHeight + y),
|
||||
Text = null,
|
||||
Single = false,
|
||||
ValueIndex = valueIndex,
|
||||
@@ -359,7 +359,7 @@ namespace FlaxEditor.Surface
|
||||
return new NodeElementArchetype
|
||||
{
|
||||
Type = NodeElementType.ColorValue,
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderSize + y),
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderHeight + y),
|
||||
Text = null,
|
||||
Single = false,
|
||||
ValueIndex = valueIndex,
|
||||
@@ -530,7 +530,7 @@ namespace FlaxEditor.Surface
|
||||
return new NodeElementArchetype
|
||||
{
|
||||
Type = NodeElementType.TextBox,
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderSize + y),
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderHeight + y),
|
||||
Size = new Float2(width, height),
|
||||
Single = false,
|
||||
ValueIndex = valueIndex,
|
||||
@@ -595,7 +595,7 @@ namespace FlaxEditor.Surface
|
||||
return new NodeElementArchetype
|
||||
{
|
||||
Type = NodeElementType.BoxValue,
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderSize + y),
|
||||
Position = new Float2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderHeight + y),
|
||||
Text = null,
|
||||
Single = false,
|
||||
ValueIndex = valueIndex,
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace FlaxEditor.Surface
|
||||
var width = _rootNode.Width;
|
||||
var rootPos = _rootNode.Location;
|
||||
var pos = rootPos;
|
||||
pos.Y += Constants.NodeHeaderSize + 1.0f + 7 * Constants.LayoutOffsetY + 6.0f + 4.0f;
|
||||
pos.Y += Constants.NodeHeaderHeight + 1.0f + 7 * Constants.LayoutOffsetY + 6.0f + 4.0f;
|
||||
|
||||
for (int i = 0; i < _rootNode.Headers.Length; i++)
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace FlaxEditor.Surface
|
||||
|
||||
var modulesStart = pos - rootPos;
|
||||
var modules = modulesGroups.FirstOrDefault(x => x.Key == header.ModuleType);
|
||||
pos.Y += Constants.NodeHeaderSize + 2.0f;
|
||||
pos.Y += Constants.NodeHeaderHeight + 2.0f;
|
||||
if (modules != null)
|
||||
{
|
||||
foreach (var module in modules)
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace FlaxEditor.Surface
|
||||
{
|
||||
_renameTextBox = new TextBox(false, 0, 0, Width)
|
||||
{
|
||||
Height = Constants.NodeHeaderSize,
|
||||
Height = Constants.NodeHeaderHeight,
|
||||
Visible = false,
|
||||
Parent = this,
|
||||
EndEditOnClick = false, // We have to handle this ourselves, otherwise the textbox instantly loses focus when double-clicking the header
|
||||
@@ -158,7 +158,7 @@ namespace FlaxEditor.Surface
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateRectangles()
|
||||
{
|
||||
const float headerSize = Constants.NodeHeaderSize;
|
||||
const float headerSize = Constants.NodeHeaderHeight;
|
||||
const float buttonMargin = Constants.NodeCloseButtonMargin;
|
||||
const float buttonSize = Constants.NodeCloseButtonSize;
|
||||
_headerRect = new Rectangle(0, 0, Width, headerSize);
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace FlaxEditor.Surface
|
||||
/// <param name="nodeArch">The node archetype.</param>
|
||||
/// <param name="groupArch">The group archetype.</param>
|
||||
public SurfaceNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
|
||||
: base(context, nodeArch.Size.X + Constants.NodeMarginX * 2, nodeArch.Size.Y + Constants.NodeMarginY * 2 + Constants.NodeHeaderSize + Constants.NodeFooterSize)
|
||||
: base(context, nodeArch.Size.X + Constants.NodeMarginX * 2, nodeArch.Size.Y + Constants.NodeMarginY * 2 + Constants.NodeHeaderHeight + Constants.NodeFooterSize)
|
||||
{
|
||||
Title = nodeArch.Title;
|
||||
ID = id;
|
||||
@@ -173,7 +173,7 @@ namespace FlaxEditor.Surface
|
||||
/// <returns>The node control total size.</returns>
|
||||
protected virtual Float2 CalculateNodeSize(float width, float height)
|
||||
{
|
||||
return new Float2(width + Constants.NodeMarginX * 2, height + Constants.NodeMarginY * 2 + Constants.NodeHeaderSize + Constants.NodeFooterSize);
|
||||
return new Float2(width + Constants.NodeMarginX * 2, height + Constants.NodeMarginY * 2 + Constants.NodeHeaderHeight + Constants.NodeFooterSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -227,25 +227,28 @@ namespace FlaxEditor.Surface
|
||||
var child = Children[i];
|
||||
if (!child.Visible)
|
||||
continue;
|
||||
// Input boxes
|
||||
if (child is InputBox inputBox)
|
||||
{
|
||||
var boxWidth = boxLabelFont.MeasureText(inputBox.Text).X + 20;
|
||||
if (inputBox.DefaultValueEditor != null)
|
||||
boxWidth += inputBox.DefaultValueEditor.Width + 4;
|
||||
leftWidth = Mathf.Max(leftWidth, boxWidth);
|
||||
leftHeight = Mathf.Max(leftHeight, inputBox.Archetype.Position.Y - Constants.NodeMarginY - Constants.NodeHeaderSize + 20.0f);
|
||||
leftHeight = Mathf.Max(leftHeight, inputBox.Archetype.Position.Y - Constants.NodeMarginY - Constants.NodeHeaderHeight + 20.0f);
|
||||
}
|
||||
// Output boxes
|
||||
else if (child is OutputBox outputBox)
|
||||
{
|
||||
rightWidth = Mathf.Max(rightWidth, boxLabelFont.MeasureText(outputBox.Text).X + 20);
|
||||
rightHeight = Mathf.Max(rightHeight, outputBox.Archetype.Position.Y - Constants.NodeMarginY - Constants.NodeHeaderSize + 20.0f);
|
||||
rightHeight = Mathf.Max(rightHeight, outputBox.Archetype.Position.Y - Constants.NodeMarginY - Constants.NodeHeaderHeight + 20.0f);
|
||||
}
|
||||
// Other controls in the node
|
||||
else if (child is Control control)
|
||||
{
|
||||
if (control.AnchorPreset == AnchorPresets.TopLeft)
|
||||
{
|
||||
width = Mathf.Max(width, control.Right + 4 - Constants.NodeMarginX);
|
||||
height = Mathf.Max(height, control.Bottom + 4 - Constants.NodeMarginY - Constants.NodeHeaderSize);
|
||||
height = Mathf.Max(height, control.Bottom + 4 - Constants.NodeMarginY - Constants.NodeHeaderHeight);
|
||||
}
|
||||
else if (!_headerRect.Intersects(control.Bounds))
|
||||
{
|
||||
@@ -337,6 +340,10 @@ namespace FlaxEditor.Surface
|
||||
Elements.Add(element);
|
||||
if (element is Control control)
|
||||
AddChild(control);
|
||||
|
||||
// TODO: Perform this at a better time instead of every time an element gets added.
|
||||
if (!Archetype.UseFixedSize)
|
||||
ResizeAuto();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -377,7 +384,7 @@ namespace FlaxEditor.Surface
|
||||
// Sync properties for exiting box
|
||||
box.Text = text;
|
||||
box.CurrentType = type;
|
||||
box.Y = Constants.NodeMarginY + Constants.NodeHeaderSize + yLevel * Constants.LayoutOffsetY;
|
||||
box.Y = Constants.NodeMarginY + Constants.NodeHeaderHeight + yLevel * Constants.LayoutOffsetY;
|
||||
}
|
||||
|
||||
// Update box
|
||||
@@ -1040,7 +1047,7 @@ namespace FlaxEditor.Surface
|
||||
protected override void UpdateRectangles()
|
||||
{
|
||||
const float footerSize = Constants.NodeFooterSize;
|
||||
const float headerSize = Constants.NodeHeaderSize;
|
||||
const float headerSize = Constants.NodeHeaderHeight;
|
||||
const float closeButtonMargin = Constants.NodeCloseButtonMargin;
|
||||
const float closeButtonSize = Constants.NodeCloseButtonSize;
|
||||
_headerRect = new Rectangle(0, 0, Width, headerSize);
|
||||
|
||||
Reference in New Issue
Block a user