// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using System.Linq; using System.Reflection; using FlaxEditor.GUI.Input; using FlaxEngine; using FlaxEngine.GUI; namespace FlaxEditor.CustomEditors.Elements { /// /// The floating point value element. /// /// public class FloatValueElement : LayoutElement, IFloatValueEditor { /// /// The float value box. /// public readonly FloatValueBox ValueBox; /// /// [Deprecated on 26.05.2022, expires on 26.05.2024] /// [System.Obsolete("Deprecated in 1.4, use ValueBox instead")] public FloatValueBox FloatValue => ValueBox; /// /// Initializes a new instance of the class. /// public FloatValueElement() { ValueBox = new FloatValueBox(0); } /// /// Sets the editor limits from member . /// /// The member. public void SetLimits(MemberInfo member) { // Try get limit attribute for value min/max range setting and slider speed if (member != null) { var attributes = member.GetCustomAttributes(true); var limit = attributes.FirstOrDefault(x => x is LimitAttribute); if (limit != null) { ValueBox.SetLimits((LimitAttribute)limit); } } } /// /// Sets the editor limits from member . /// /// The limit. public void SetLimits(LimitAttribute limit) { if (limit != null) { ValueBox.SetLimits(limit); } } /// /// Sets the editor limits from the other . /// /// The other. public void SetLimits(FloatValueElement other) { if (other != null) { ValueBox.SetLimits(other.ValueBox); } } /// public override Control Control => ValueBox; /// public float Value { get => ValueBox.Value; set => ValueBox.Value = value; } /// public bool IsSliding => ValueBox.IsSliding; } }