Files
sbox-public/engine/Sandbox.Tools/ControlWidget/MarginControlWidget.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

39 lines
1021 B
C#

using Sandbox.UI;
namespace Editor;
[CustomEditor( typeof( Margin ) )]
public class MarginControlWidget : ControlWidget
{
SerializedObject obj;
public MarginControlWidget( SerializedProperty property ) : base( property )
{
property.TryGetAsObject( out obj );
Layout = Layout.Row();
Layout.Spacing = 2;
TryAddField( "Left", Theme.Red, "border_left" );
TryAddField( "Top", Theme.Blue, "border_top" );
TryAddField( "Right", Theme.Green, "border_right" );
TryAddField( "Bottom", Theme.Yellow, "border_bottom" );
}
private void TryAddField( string propertyName, Color color, string icon )
{
var prop = obj.GetProperty( propertyName );
if ( prop is null ) return;
var control = Layout.Add( new FloatControlWidget( prop ) { HighlightColor = color, Label = null, Icon = icon } );
control.MinimumWidth = Theme.RowHeight;
control.HorizontalSizeMode = SizeMode.CanGrow | SizeMode.Expand;
control.MakeRanged( SerializedProperty );
}
protected override void OnPaint()
{
// nothing
}
}