Files
sbox-public/engine/Sandbox.Tools/Widgets/VirtualWidget.cs
Garry Newman d17bebf3a7 Treeview extras (#3982)
* Add TreeNode.ClearChildren()
* Move DragDropTarget stuff to BaseItemWidget
* Add DragDropTarget.Closest (drag drop drops on closest item)
* Add OnBodyDragDrop (when drag dropped on body instead of item)
* Add VirtualWidget.ChildrenRect (for treeview, the rect containing our children)
* Add BaseItemWidget.DragDropTargetClosestThreshold (for DragDropTarget.Closest, max distance away from an item)
2026-02-03 10:41:40 +00:00

58 lines
1010 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;
public Rect ChildrenRect;
/// <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;
}
}