// Copyright (c) 2012-2021 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 FloatValue; /// /// Initializes a new instance of the class. /// public FloatValueElement() { FloatValue = 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) { FloatValue.SetLimits((LimitAttribute)limit); } } } /// /// Sets the editor limits from member . /// /// The limit. public void SetLimits(LimitAttribute limit) { if (limit != null) { FloatValue.SetLimits(limit); } } /// /// Sets the editor limits from the other . /// /// The other. public void SetLimits(FloatValueElement other) { if (other != null) { FloatValue.SetLimits(other.FloatValue); } } /// public override Control Control => FloatValue; /// public float Value { get => FloatValue.Value; set => FloatValue.Value = value; } /// public bool IsSliding => FloatValue.IsSliding; } }