Move UseFixedSize property from node archetype to flags and optimize unnecessary layouts during node loading
#3866
This commit is contained in:
@@ -71,7 +71,7 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
return;
|
return;
|
||||||
_assetSelect.Visible = !box.HasAnyConnection;
|
_assetSelect.Visible = !box.HasAnyConnection;
|
||||||
|
|
||||||
if (!Archetype.UseFixedSize)
|
if (!Archetype.Flags.HasFlag(NodeFlags.FixedSize))
|
||||||
ResizeAuto();
|
ResizeAuto();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -934,8 +934,7 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
TypeID = 27,
|
TypeID = 27,
|
||||||
Title = "Copy Node",
|
Title = "Copy Node",
|
||||||
Description = "Copies the skeleton node transformation data (in local space)",
|
Description = "Copies the skeleton node transformation data (in local space)",
|
||||||
Flags = NodeFlags.AnimGraph,
|
Flags = NodeFlags.AnimGraph | NodeFlags.FixedSize,
|
||||||
UseFixedSize = true,
|
|
||||||
Size = new Float2(260, 140),
|
Size = new Float2(260, 140),
|
||||||
DefaultValues = new object[]
|
DefaultValues = new object[]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -340,8 +340,7 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
Create = (id, context, arch, groupArch) => new ParticleEmitterNode(id, context, arch, groupArch),
|
Create = (id, context, arch, groupArch) => new ParticleEmitterNode(id, context, arch, groupArch),
|
||||||
Title = "Particle Emitter",
|
Title = "Particle Emitter",
|
||||||
Description = "Main particle emitter node. Contains a set of modules per emitter context. Modules are executed in order from top to bottom of the stack.",
|
Description = "Main particle emitter node. Contains a set of modules per emitter context. Modules are executed in order from top to bottom of the stack.",
|
||||||
Flags = NodeFlags.ParticleEmitterGraph | NodeFlags.NoRemove | NodeFlags.NoSpawnViaGUI | NodeFlags.NoSpawnViaPaste | NodeFlags.NoCloseButton,
|
Flags = NodeFlags.ParticleEmitterGraph | NodeFlags.NoRemove | NodeFlags.NoSpawnViaGUI | NodeFlags.NoSpawnViaPaste | NodeFlags.NoCloseButton | NodeFlags.FixedSize,
|
||||||
UseFixedSize = true,
|
|
||||||
Size = new Float2(300, 600),
|
Size = new Float2(300, 600),
|
||||||
DefaultValues = new object[]
|
DefaultValues = new object[]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1526,9 +1526,8 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
Title = "Color Gradient",
|
Title = "Color Gradient",
|
||||||
Create = (id, context, arch, groupArch) => new ColorGradientNode(id, context, arch, groupArch),
|
Create = (id, context, arch, groupArch) => new ColorGradientNode(id, context, arch, groupArch),
|
||||||
Description = "Linear color gradient sampler",
|
Description = "Linear color gradient sampler",
|
||||||
Flags = NodeFlags.AllGraphs,
|
Flags = NodeFlags.AllGraphs | NodeFlags.FixedSize,
|
||||||
Size = new Float2(400, 150.0f),
|
Size = new Float2(400, 150.0f),
|
||||||
UseFixedSize = true,
|
|
||||||
DefaultValues = new object[]
|
DefaultValues = new object[]
|
||||||
{
|
{
|
||||||
// Stops count
|
// Stops count
|
||||||
@@ -1846,9 +1845,8 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
Title = "Reroute",
|
Title = "Reroute",
|
||||||
Create = (id, context, arch, groupArch) => new RerouteNode(id, context, arch, groupArch),
|
Create = (id, context, arch, groupArch) => new RerouteNode(id, context, arch, groupArch),
|
||||||
Description = "Reroute a connection.",
|
Description = "Reroute a connection.",
|
||||||
Flags = NodeFlags.NoCloseButton | NodeFlags.NoSpawnViaGUI | NodeFlags.AllGraphs,
|
Flags = NodeFlags.NoCloseButton | NodeFlags.NoSpawnViaGUI | NodeFlags.AllGraphs | NodeFlags.FixedSize,
|
||||||
Size = RerouteNode.DefaultSize,
|
Size = RerouteNode.DefaultSize,
|
||||||
UseFixedSize = true,
|
|
||||||
ConnectionsHints = ConnectionsHint.All,
|
ConnectionsHints = ConnectionsHint.All,
|
||||||
IndependentBoxes = new int[] { 0 },
|
IndependentBoxes = new int[] { 0 },
|
||||||
DependentBoxes = new int[] { 1 },
|
DependentBoxes = new int[] { 1 },
|
||||||
|
|||||||
@@ -129,11 +129,6 @@ namespace FlaxEditor.Surface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public NodeFlags Flags;
|
public NodeFlags Flags;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If the node should use the <see cref="Size"/> as node size. If false, the node will auto resize based on its elements.
|
|
||||||
/// </summary>
|
|
||||||
public bool UseFixedSize = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Title text.
|
/// Title text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -78,6 +78,11 @@ namespace FlaxEditor.Surface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
VariableValuesSize = 2048,
|
VariableValuesSize = 2048,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Node has fixed size defined and should not use automatic layout.
|
||||||
|
/// </summary>
|
||||||
|
FixedSize = 4096,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Node can be used in the all visual graphs.
|
/// Node can be used in the all visual graphs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -348,10 +348,8 @@ namespace FlaxEditor.Surface
|
|||||||
if (element is Control control)
|
if (element is Control control)
|
||||||
AddChild(control);
|
AddChild(control);
|
||||||
|
|
||||||
if (!Archetype.UseFixedSize)
|
if (!IsLayoutLocked)
|
||||||
ResizeAuto();
|
UpdateSize();
|
||||||
else
|
|
||||||
Resize(Archetype.Size.X, Archetype.Size.Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -912,6 +910,14 @@ namespace FlaxEditor.Surface
|
|||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateSize()
|
||||||
|
{
|
||||||
|
if (Archetype.Flags.HasFlag(NodeFlags.FixedSize))
|
||||||
|
Resize(Archetype.Size.X, Archetype.Size.Y);
|
||||||
|
else
|
||||||
|
ResizeAuto();
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override bool ShowTooltip => base.ShowTooltip && _headerRect.Contains(ref _mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
|
protected override bool ShowTooltip => base.ShowTooltip && _headerRect.Contains(ref _mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
|
||||||
|
|
||||||
@@ -965,10 +971,7 @@ namespace FlaxEditor.Surface
|
|||||||
box.OnConnectionsChanged();
|
box.OnConnectionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Archetype.UseFixedSize)
|
UpdateSize();
|
||||||
ResizeAuto();
|
|
||||||
else
|
|
||||||
Resize(Archetype.Size.X, Archetype.Size.Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -1007,10 +1010,7 @@ namespace FlaxEditor.Surface
|
|||||||
|
|
||||||
_isDuringValuesEditing = false;
|
_isDuringValuesEditing = false;
|
||||||
|
|
||||||
if (!Archetype.UseFixedSize)
|
UpdateSize();
|
||||||
ResizeAuto();
|
|
||||||
else
|
|
||||||
Resize(Archetype.Size.X, Archetype.Size.Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1046,10 +1046,7 @@ namespace FlaxEditor.Surface
|
|||||||
|
|
||||||
_isDuringValuesEditing = false;
|
_isDuringValuesEditing = false;
|
||||||
|
|
||||||
if (!Archetype.UseFixedSize)
|
UpdateSize();
|
||||||
ResizeAuto();
|
|
||||||
else
|
|
||||||
Resize(Archetype.Size.X, Archetype.Size.Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetIsDuringValuesEditing(bool value)
|
internal void SetIsDuringValuesEditing(bool value)
|
||||||
@@ -1082,10 +1079,7 @@ namespace FlaxEditor.Surface
|
|||||||
public virtual void ConnectionTick(Box box)
|
public virtual void ConnectionTick(Box box)
|
||||||
{
|
{
|
||||||
UpdateBoxesTypes();
|
UpdateBoxesTypes();
|
||||||
if (!Archetype.UseFixedSize)
|
UpdateSize();
|
||||||
ResizeAuto();
|
|
||||||
else
|
|
||||||
Resize(Archetype.Size.X, Archetype.Size.Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user