Editor/SFXRFloatControlWidget.cs
using Sandbox;
using Editor;
using System;
using System.Collections.Generic;
using System.Linq;
namespace SFXR.Editor;
//[CustomEditor( typeof( SFXRFloat ) )]
// public class SFXRFloatControlWidget : ControlWidget
// {
// SerializedObject Target;
// public SFXRFloatControlWidget( SerializedProperty property ) : base( property )
// {
// SetSizeMode( SizeMode.Ignore, SizeMode.Default );
// if ( !property.TryGetAsObject( out Target ) )
// return;
// Layout = Layout.Row();
// Layout.Spacing = 2;
// var value = Target.GetProperty( "Value" );
// FloatControlWidget valueWidget = new FloatControlWidget( value );
// if ( property.TryGetAttribute<RangeAttribute>( out var attribute ) )
// {
// valueWidget.Range = new Vector2( attribute.Min, attribute.Max );
// valueWidget.RangeStep = attribute.Step;
// valueWidget.HasRange = attribute.Slider;
// // if ( attribute.Slider )
// // {
// // sliderWidget = new FloatSlider( this );
// // sliderWidget.HighlightColor = Theme.Grey;
// // sliderWidget.Minimum = attribute.Min;
// // sliderWidget.Maximum = attribute.Max;
// // sliderWidget.Step = attribute.S;
// // sliderWidget.OnValueEdited = delegate
// // {
// // base.SerializedProperty.As.Float = sliderWidget.Value;
// // };
// // }
// }
// Layout.Add( valueWidget );
// var locked = Target.GetProperty( "Locked" );
// IconButton lockedButton = new IconButton( "lock_open" );
// lockedButton.OnClick = () =>
// {
// if ( Target.Targets.First() is SFXRFloat sfxrFloat )
// {
// sfxrFloat.Locked = !sfxrFloat.Locked;
// Log.Info( sfxrFloat.Locked );
// lockedButton.Icon = sfxrFloat.Locked ? "lock" : "lock_open";
// lockedButton.Update();
// }
// };
// lockedButton.ToolTip = "Lock/Unlock this value";
// Layout.Add( lockedButton );
// }
// protected override void OnPaint()
// {
// }
// }
// public class SFXRFloatControlWidget : FloatControlWidget
// {
// SerializedObject Target;
// public SFXRFloatControlWidget( SerializedProperty property ) : base( property )
// {
// if ( !property.TryGetAsObject( out Target ) )
// return;
// var locked = Target.GetProperty( "Locked" );
// IconButton lockedButton = new IconButton( "lock_open" );
// lockedButton.OnClick = () =>
// {
// // if ( Target.Targets.First() is SFXRFloat sfxrFloat )
// // {
// // sfxrFloat.Locked = !sfxrFloat.Locked;
// // Log.Info( sfxrFloat.Locked );
// // lockedButton.Icon = sfxrFloat.Locked ? "lock" : "lock_open";
// // lockedButton.Update();
// // }
// };
// lockedButton.ToolTip = "Lock/Unlock this value";
// //Layout.Add( lockedButton );
// }
// protected override void PaintControl()
// {
// if ( Target is null ) return;
// base.PaintControl();
// }
// protected override void OnPaint()
// {
// if ( Target is null ) return;
// base.OnPaint();
// }
// }