mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-10 07:18:28 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
39 lines
1021 B
C#
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
|
|
}
|
|
}
|