mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-30 09:58:25 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
38 lines
979 B
C#
38 lines
979 B
C#
namespace Editor;
|
|
|
|
[CustomEditor( typeof( Rect ) )]
|
|
[CustomEditor( typeof( RectInt ) )]
|
|
public class RectControlWidget : ControlWidget
|
|
{
|
|
SerializedObject obj;
|
|
|
|
public RectControlWidget( SerializedProperty property ) : base( property )
|
|
{
|
|
property.TryGetAsObject( out obj );
|
|
|
|
Layout = Layout.Row();
|
|
Layout.Spacing = 2;
|
|
|
|
TryAddField( "Left", Theme.Red, "X" );
|
|
TryAddField( "Top", Theme.Blue, "Y" );
|
|
TryAddField( "Width", Theme.Green, "W" );
|
|
TryAddField( "Height", Theme.Yellow, "H" );
|
|
}
|
|
|
|
private void TryAddField( string propertyName, Color color, string label )
|
|
{
|
|
var prop = obj.GetProperty( propertyName );
|
|
if ( prop is null ) return;
|
|
|
|
var control = Layout.Add( new FloatControlWidget( prop ) { HighlightColor = color, Label = label } );
|
|
control.MinimumWidth = Theme.RowHeight;
|
|
control.HorizontalSizeMode = SizeMode.CanGrow | SizeMode.Expand;
|
|
control.MakeRanged( SerializedProperty );
|
|
}
|
|
|
|
protected override void OnPaint()
|
|
{
|
|
// nothing
|
|
}
|
|
}
|