Merge branch 'Visject-ImprovedInactiveBoxes' of https://github.com/Chikinsupu/FlaxEngine into Chikinsupu-Visject-ImprovedInactiveBoxes
This commit is contained in:
@@ -71,20 +71,20 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
// Layered material
|
// Layered material
|
||||||
if (GetBox(MaterialNodeBoxes.Layer).HasAnyConnection)
|
if (GetBox(MaterialNodeBoxes.Layer).HasAnyConnection)
|
||||||
{
|
{
|
||||||
GetBox(MaterialNodeBoxes.Color).Enabled = false;
|
GetBox(MaterialNodeBoxes.Color).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Mask).Enabled = false;
|
GetBox(MaterialNodeBoxes.Mask).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Emissive).Enabled = false;
|
GetBox(MaterialNodeBoxes.Emissive).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Metalness).Enabled = false;
|
GetBox(MaterialNodeBoxes.Metalness).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Specular).Enabled = false;
|
GetBox(MaterialNodeBoxes.Specular).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Roughness).Enabled = false;
|
GetBox(MaterialNodeBoxes.Roughness).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.AmbientOcclusion).Enabled = false;
|
GetBox(MaterialNodeBoxes.AmbientOcclusion).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Normal).Enabled = false;
|
GetBox(MaterialNodeBoxes.Normal).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Opacity).Enabled = false;
|
GetBox(MaterialNodeBoxes.Opacity).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Refraction).Enabled = false;
|
GetBox(MaterialNodeBoxes.Refraction).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.PositionOffset).Enabled = false;
|
GetBox(MaterialNodeBoxes.PositionOffset).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false;
|
GetBox(MaterialNodeBoxes.TessellationMultiplier).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false;
|
GetBox(MaterialNodeBoxes.WorldDisplacement).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false;
|
GetBox(MaterialNodeBoxes.SubsurfaceColor).IsActive = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,94 +102,94 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
bool isNotUnlit = info.ShadingModel != MaterialShadingModel.Unlit;
|
bool isNotUnlit = info.ShadingModel != MaterialShadingModel.Unlit;
|
||||||
bool withTess = info.TessellationMode != TessellationMethod.None;
|
bool withTess = info.TessellationMode != TessellationMethod.None;
|
||||||
|
|
||||||
GetBox(MaterialNodeBoxes.Color).Enabled = isNotUnlit;
|
GetBox(MaterialNodeBoxes.Color).IsActive = isNotUnlit;
|
||||||
GetBox(MaterialNodeBoxes.Mask).Enabled = true;
|
GetBox(MaterialNodeBoxes.Mask).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Emissive).Enabled = true;
|
GetBox(MaterialNodeBoxes.Emissive).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Metalness).Enabled = isNotUnlit;
|
GetBox(MaterialNodeBoxes.Metalness).IsActive = isNotUnlit;
|
||||||
GetBox(MaterialNodeBoxes.Specular).Enabled = isNotUnlit;
|
GetBox(MaterialNodeBoxes.Specular).IsActive = isNotUnlit;
|
||||||
GetBox(MaterialNodeBoxes.Roughness).Enabled = isNotUnlit;
|
GetBox(MaterialNodeBoxes.Roughness).IsActive = isNotUnlit;
|
||||||
GetBox(MaterialNodeBoxes.AmbientOcclusion).Enabled = isNotUnlit;
|
GetBox(MaterialNodeBoxes.AmbientOcclusion).IsActive = isNotUnlit;
|
||||||
GetBox(MaterialNodeBoxes.Normal).Enabled = isNotUnlit;
|
GetBox(MaterialNodeBoxes.Normal).IsActive = isNotUnlit;
|
||||||
GetBox(MaterialNodeBoxes.Opacity).Enabled = info.ShadingModel == MaterialShadingModel.Subsurface || info.ShadingModel == MaterialShadingModel.Foliage || info.BlendMode != MaterialBlendMode.Opaque;
|
GetBox(MaterialNodeBoxes.Opacity).IsActive = info.ShadingModel == MaterialShadingModel.Subsurface || info.ShadingModel == MaterialShadingModel.Foliage || info.BlendMode != MaterialBlendMode.Opaque;
|
||||||
GetBox(MaterialNodeBoxes.Refraction).Enabled = info.BlendMode != MaterialBlendMode.Opaque;
|
GetBox(MaterialNodeBoxes.Refraction).IsActive = info.BlendMode != MaterialBlendMode.Opaque;
|
||||||
GetBox(MaterialNodeBoxes.PositionOffset).Enabled = true;
|
GetBox(MaterialNodeBoxes.PositionOffset).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = withTess;
|
GetBox(MaterialNodeBoxes.TessellationMultiplier).IsActive = withTess;
|
||||||
GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = withTess;
|
GetBox(MaterialNodeBoxes.WorldDisplacement).IsActive = withTess;
|
||||||
GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = info.ShadingModel == MaterialShadingModel.Subsurface || info.ShadingModel == MaterialShadingModel.Foliage;
|
GetBox(MaterialNodeBoxes.SubsurfaceColor).IsActive = info.ShadingModel == MaterialShadingModel.Subsurface || info.ShadingModel == MaterialShadingModel.Foliage;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MaterialDomain.PostProcess:
|
case MaterialDomain.PostProcess:
|
||||||
{
|
{
|
||||||
GetBox(MaterialNodeBoxes.Color).Enabled = false;
|
GetBox(MaterialNodeBoxes.Color).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Mask).Enabled = false;
|
GetBox(MaterialNodeBoxes.Mask).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Emissive).Enabled = true;
|
GetBox(MaterialNodeBoxes.Emissive).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Metalness).Enabled = false;
|
GetBox(MaterialNodeBoxes.Metalness).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Specular).Enabled = false;
|
GetBox(MaterialNodeBoxes.Specular).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Roughness).Enabled = false;
|
GetBox(MaterialNodeBoxes.Roughness).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.AmbientOcclusion).Enabled = false;
|
GetBox(MaterialNodeBoxes.AmbientOcclusion).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Normal).Enabled = false;
|
GetBox(MaterialNodeBoxes.Normal).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Opacity).Enabled = true;
|
GetBox(MaterialNodeBoxes.Opacity).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Refraction).Enabled = false;
|
GetBox(MaterialNodeBoxes.Refraction).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.PositionOffset).Enabled = false;
|
GetBox(MaterialNodeBoxes.PositionOffset).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false;
|
GetBox(MaterialNodeBoxes.TessellationMultiplier).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false;
|
GetBox(MaterialNodeBoxes.WorldDisplacement).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false;
|
GetBox(MaterialNodeBoxes.SubsurfaceColor).IsActive = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MaterialDomain.Decal:
|
case MaterialDomain.Decal:
|
||||||
{
|
{
|
||||||
var mode = info.DecalBlendingMode;
|
var mode = info.DecalBlendingMode;
|
||||||
|
|
||||||
GetBox(MaterialNodeBoxes.Color).Enabled = mode == MaterialDecalBlendingMode.Translucent || mode == MaterialDecalBlendingMode.Stain;
|
GetBox(MaterialNodeBoxes.Color).IsActive = mode == MaterialDecalBlendingMode.Translucent || mode == MaterialDecalBlendingMode.Stain;
|
||||||
GetBox(MaterialNodeBoxes.Mask).Enabled = true;
|
GetBox(MaterialNodeBoxes.Mask).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Emissive).Enabled = mode == MaterialDecalBlendingMode.Translucent || mode == MaterialDecalBlendingMode.Emissive;
|
GetBox(MaterialNodeBoxes.Emissive).IsActive = mode == MaterialDecalBlendingMode.Translucent || mode == MaterialDecalBlendingMode.Emissive;
|
||||||
GetBox(MaterialNodeBoxes.Metalness).Enabled = mode == MaterialDecalBlendingMode.Translucent;
|
GetBox(MaterialNodeBoxes.Metalness).IsActive = mode == MaterialDecalBlendingMode.Translucent;
|
||||||
GetBox(MaterialNodeBoxes.Specular).Enabled = mode == MaterialDecalBlendingMode.Translucent;
|
GetBox(MaterialNodeBoxes.Specular).IsActive = mode == MaterialDecalBlendingMode.Translucent;
|
||||||
GetBox(MaterialNodeBoxes.Roughness).Enabled = mode == MaterialDecalBlendingMode.Translucent;
|
GetBox(MaterialNodeBoxes.Roughness).IsActive = mode == MaterialDecalBlendingMode.Translucent;
|
||||||
GetBox(MaterialNodeBoxes.AmbientOcclusion).Enabled = false;
|
GetBox(MaterialNodeBoxes.AmbientOcclusion).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Normal).Enabled = mode == MaterialDecalBlendingMode.Translucent || mode == MaterialDecalBlendingMode.Normal;
|
GetBox(MaterialNodeBoxes.Normal).IsActive = mode == MaterialDecalBlendingMode.Translucent || mode == MaterialDecalBlendingMode.Normal;
|
||||||
GetBox(MaterialNodeBoxes.Opacity).Enabled = true;
|
GetBox(MaterialNodeBoxes.Opacity).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Refraction).Enabled = false;
|
GetBox(MaterialNodeBoxes.Refraction).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.PositionOffset).Enabled = false;
|
GetBox(MaterialNodeBoxes.PositionOffset).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false;
|
GetBox(MaterialNodeBoxes.TessellationMultiplier).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false;
|
GetBox(MaterialNodeBoxes.WorldDisplacement).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false;
|
GetBox(MaterialNodeBoxes.SubsurfaceColor).IsActive = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MaterialDomain.GUI:
|
case MaterialDomain.GUI:
|
||||||
{
|
{
|
||||||
GetBox(MaterialNodeBoxes.Color).Enabled = false;
|
GetBox(MaterialNodeBoxes.Color).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Mask).Enabled = true;
|
GetBox(MaterialNodeBoxes.Mask).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Emissive).Enabled = true;
|
GetBox(MaterialNodeBoxes.Emissive).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Metalness).Enabled = false;
|
GetBox(MaterialNodeBoxes.Metalness).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Specular).Enabled = false;
|
GetBox(MaterialNodeBoxes.Specular).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Roughness).Enabled = false;
|
GetBox(MaterialNodeBoxes.Roughness).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.AmbientOcclusion).Enabled = false;
|
GetBox(MaterialNodeBoxes.AmbientOcclusion).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Normal).Enabled = false;
|
GetBox(MaterialNodeBoxes.Normal).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Opacity).Enabled = true;
|
GetBox(MaterialNodeBoxes.Opacity).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Refraction).Enabled = false;
|
GetBox(MaterialNodeBoxes.Refraction).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.PositionOffset).Enabled = false;
|
GetBox(MaterialNodeBoxes.PositionOffset).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false;
|
GetBox(MaterialNodeBoxes.TessellationMultiplier).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false;
|
GetBox(MaterialNodeBoxes.WorldDisplacement).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false;
|
GetBox(MaterialNodeBoxes.SubsurfaceColor).IsActive = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MaterialDomain.VolumeParticle:
|
case MaterialDomain.VolumeParticle:
|
||||||
{
|
{
|
||||||
GetBox(MaterialNodeBoxes.Color).Enabled = true;
|
GetBox(MaterialNodeBoxes.Color).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Mask).Enabled = true;
|
GetBox(MaterialNodeBoxes.Mask).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Emissive).Enabled = true;
|
GetBox(MaterialNodeBoxes.Emissive).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Metalness).Enabled = false;
|
GetBox(MaterialNodeBoxes.Metalness).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Specular).Enabled = false;
|
GetBox(MaterialNodeBoxes.Specular).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Roughness).Enabled = false;
|
GetBox(MaterialNodeBoxes.Roughness).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.AmbientOcclusion).Enabled = false;
|
GetBox(MaterialNodeBoxes.AmbientOcclusion).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Normal).Enabled = false;
|
GetBox(MaterialNodeBoxes.Normal).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.Opacity).Enabled = true;
|
GetBox(MaterialNodeBoxes.Opacity).IsActive = true;
|
||||||
GetBox(MaterialNodeBoxes.Refraction).Enabled = false;
|
GetBox(MaterialNodeBoxes.Refraction).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.PositionOffset).Enabled = false;
|
GetBox(MaterialNodeBoxes.PositionOffset).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false;
|
GetBox(MaterialNodeBoxes.TessellationMultiplier).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false;
|
GetBox(MaterialNodeBoxes.WorldDisplacement).IsActive = false;
|
||||||
GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false;
|
GetBox(MaterialNodeBoxes.SubsurfaceColor).IsActive = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: throw new ArgumentOutOfRangeException();
|
default: throw new ArgumentOutOfRangeException();
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
private void UpdateInputBox()
|
private void UpdateInputBox()
|
||||||
{
|
{
|
||||||
var facingMode = (ParticleSpriteFacingMode)Values[2];
|
var facingMode = (ParticleSpriteFacingMode)Values[2];
|
||||||
GetBox(0).Enabled = facingMode == ParticleSpriteFacingMode.CustomFacingVector || facingMode == ParticleSpriteFacingMode.FixedAxis;
|
GetBox(0).IsActive = facingMode == ParticleSpriteFacingMode.CustomFacingVector || facingMode == ParticleSpriteFacingMode.FixedAxis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ namespace FlaxEditor.Surface.Elements
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected bool _isSelected;
|
protected bool _isSelected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The is active flag for the box. Unlike <see cref="FlaxEngine.GUI.Control.Enabled"/>, inactive boxes can still be interacted with, they just will be drawn like disabled boxes
|
||||||
|
/// </summary>
|
||||||
|
protected bool _isActive = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unique box ID within single node.
|
/// Unique box ID within single node.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -180,6 +185,15 @@ namespace FlaxEditor.Surface.Elements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the active state of the box. Unlike <see cref="FlaxEngine.GUI.Control.Enabled"/>, inactive boxes can still be interacted with, they just will be drawn like disabled boxes
|
||||||
|
/// </summary>
|
||||||
|
public bool IsActive
|
||||||
|
{
|
||||||
|
get => _isActive;
|
||||||
|
set => _isActive = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected Box(SurfaceNode parentNode, NodeElementArchetype archetype, Float2 location)
|
protected Box(SurfaceNode parentNode, NodeElementArchetype archetype, Float2 location)
|
||||||
: base(parentNode, archetype, location, new Float2(Constants.BoxSize), false)
|
: base(parentNode, archetype, location, new Float2(Constants.BoxSize), false)
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ namespace FlaxEditor.Surface.Elements
|
|||||||
Box targetBox = Connections[i];
|
Box targetBox = Connections[i];
|
||||||
var endPos = targetBox.ConnectionOrigin;
|
var endPos = targetBox.ConnectionOrigin;
|
||||||
var highlight = 1 + Mathf.Max(startHighlight, targetBox.ConnectionsHighlightIntensity);
|
var highlight = 1 + Mathf.Max(startHighlight, targetBox.ConnectionsHighlightIntensity);
|
||||||
var color = _currentTypeColor * highlight;
|
var alpha = targetBox.Enabled && targetBox.IsActive ? 1.0f : 0.6f;
|
||||||
|
var color = _currentTypeColor * highlight * alpha;
|
||||||
|
|
||||||
// TODO: Figure out how to only draw the topmost connection
|
// TODO: Figure out how to only draw the topmost connection
|
||||||
if (IntersectsConnection(ref startPos, ref endPos, ref mousePosition, mouseOverDistance))
|
if (IntersectsConnection(ref startPos, ref endPos, ref mousePosition, mouseOverDistance))
|
||||||
@@ -172,7 +173,9 @@ namespace FlaxEditor.Surface.Elements
|
|||||||
// Draw all the connections
|
// Draw all the connections
|
||||||
var startPos = ConnectionOrigin;
|
var startPos = ConnectionOrigin;
|
||||||
var endPos = targetBox.ConnectionOrigin;
|
var endPos = targetBox.ConnectionOrigin;
|
||||||
DrawConnection(Surface.Style, ref startPos, ref endPos, ref _currentTypeColor, 2.5f);
|
var alpha = targetBox.Enabled && targetBox.IsActive ? 1.0f : 0.6f;
|
||||||
|
var color = _currentTypeColor * alpha;
|
||||||
|
DrawConnection(Surface.Style, ref startPos, ref endPos, ref color, 2.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ namespace FlaxEditor.Surface
|
|||||||
|
|
||||||
// Draw icon
|
// Draw icon
|
||||||
bool hasConnections = box.HasAnyConnection;
|
bool hasConnections = box.HasAnyConnection;
|
||||||
float alpha = box.Enabled ? 1.0f : 0.6f;
|
float alpha = box.Enabled && box.IsActive ? 1.0f : 0.6f;
|
||||||
Color color = box.CurrentTypeColor * alpha;
|
Color color = box.CurrentTypeColor * alpha;
|
||||||
var style = box.Surface.Style;
|
var style = box.Surface.Style;
|
||||||
SpriteHandle icon;
|
SpriteHandle icon;
|
||||||
|
|||||||
Reference in New Issue
Block a user