// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
using FlaxEditor.GUI;
using FlaxEngine.Utilities;
namespace FlaxEditor.Surface.Elements
{
///
/// Combo box for enum element.
///
///
///
/// [HideInEditor]
public class EnumValue : EnumComboBox, ISurfaceNodeElement
{
///
public SurfaceNode ParentNode { get; }
///
public NodeElementArchetype Archetype { get; }
///
/// Gets the surface.
///
public VisjectSurface Surface => ParentNode.Surface;
///
public EnumValue(SurfaceNode parentNode, NodeElementArchetype archetype)
: base(TypeUtils.GetType(archetype.Text).Type)
{
X = archetype.ActualPositionX;
Y = archetype.ActualPositionY;
Width = archetype.Size.X;
ParentNode = parentNode;
Archetype = archetype;
Value = Convert.ToInt32(ParentNode.Values[Archetype.ValueIndex]);
}
///
protected override void OnValueChanged()
{
if (Convert.ToInt32(ParentNode.Values[Archetype.ValueIndex]) != (int)Value)
{
// Edit value
ParentNode.SetValue(Archetype.ValueIndex, Value);
}
base.OnValueChanged();
}
}
}