Skip to content

Commit ad9ccd3

Browse files
committed
Simple way for NodeUI to show that it has an error
1 parent 929f260 commit ad9ccd3

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

game/addons/tools/Code/NodeGraph/NodeUI.cs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,18 +611,51 @@ protected override void OnPaint()
611611

612612
Node.OnPaint( rect );
613613

614+
var hasError = !string.IsNullOrWhiteSpace( Node.ErrorMessage );
615+
var selectionOutline = SelectionOutline;
616+
617+
if ( hasError )
618+
{
619+
selectionOutline = Color.Red;
620+
621+
if ( !Paint.HasMouseOver )
622+
{
623+
selectionOutline = selectionOutline.Darken( 0.25f );
624+
}
625+
}
626+
614627
if ( Paint.HasSelected )
615628
{
616-
Paint.SetPen( SelectionOutline, 2.0f );
629+
Paint.SetPen( selectionOutline, 2.0f );
630+
Paint.ClearBrush();
631+
Paint.DrawRect( rect, radius );
632+
}
633+
else if ( Paint.HasMouseOver && !hasError )
634+
{
635+
Paint.SetPen( selectionOutline.Darken( 0.25f ), 1.0f );
617636
Paint.ClearBrush();
618637
Paint.DrawRect( rect, radius );
619638
}
620-
else if ( Paint.HasMouseOver )
639+
else if ( hasError )
621640
{
622-
Paint.SetPen( SelectionOutline, 1.0f );
641+
Paint.SetPen( selectionOutline, 2.0f );
623642
Paint.ClearBrush();
624643
Paint.DrawRect( rect, radius );
625644
}
645+
646+
if ( hasError )
647+
{
648+
var errorText = "ERROR!!!";
649+
var errorRect = Paint.MeasureText( rect.Align( Size, TextFlag.CenterBottom ), errorText, TextFlag.CenterBottom )
650+
.Grow( 4f, 0f, 4f, 0f );
651+
652+
Paint.SetBrush( Paint.HasMouseOver ? Color.Red : Color.Red.Darken( 0.25f ) );
653+
Paint.ClearPen();
654+
Paint.DrawRect( errorRect, 1f );
655+
656+
Paint.SetPen( Theme.TextControl );
657+
Paint.DrawText( errorRect, errorText, TextFlag.CenterBottom );
658+
}
626659
}
627660

628661
protected override void OnMousePressed( GraphicsMouseEvent e )

0 commit comments

Comments
 (0)