mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 13:59:22 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
57 lines
983 B
C#
57 lines
983 B
C#
namespace Editor;
|
|
|
|
public class VirtualWidget
|
|
{
|
|
public Rect Rect;
|
|
public object Object;
|
|
public bool Hovered;
|
|
public bool Selected;
|
|
public bool Pressed;
|
|
public bool Dropping;
|
|
public bool Dragging;
|
|
public int Row;
|
|
public int Column;
|
|
|
|
// for tree
|
|
public float Indent;
|
|
public bool HasChildren;
|
|
public bool IsOpen;
|
|
|
|
/// <summary>
|
|
/// Generically paint a background for this item
|
|
/// </summary>
|
|
public void PaintBackground( Color background, float radius )
|
|
{
|
|
var c = background;
|
|
var r = Rect;
|
|
Paint.ClearPen();
|
|
|
|
if ( Hovered )
|
|
{
|
|
Paint.SetPen( Color.Lerp( c, Theme.Blue, 0.8f ), 1, PenStyle.Dot );
|
|
r = r.Shrink( 1 );
|
|
c = Color.Lerp( c, Theme.Blue, 0.3f );
|
|
}
|
|
|
|
if ( Selected )
|
|
{
|
|
Paint.SetPen( Theme.Blue, 1 );
|
|
c = Color.Lerp( c, Theme.Blue, 0.3f );
|
|
}
|
|
|
|
if ( c.a > 0 )
|
|
{
|
|
Paint.SetBrush( c );
|
|
Paint.DrawRect( r, radius );
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public Color GetForegroundColor()
|
|
{
|
|
return Theme.Text;
|
|
}
|
|
}
|