SchematicGraph: Render label with backdrop

#rb sara.schvartzman
#jira UE-173816
#rnx

[CL 30842689 by helge mathee in ue5-main branch]
This commit is contained in:
helge mathee
2024-01-24 09:59:08 -05:00
parent 2f96b234c3
commit 84fe4ade6f
2 changed files with 17 additions and 2 deletions

View File

@@ -238,7 +238,6 @@ int32 SSchematicGraphNode::OnPaint(const FPaintArgs& Args, const FGeometry& Allo
if(!LabelSize.IsNearlyZero())
{
NewLayerId++;
const FVector2d LabelOffset = TagCenter - LabelSize * 0.5;
FSlateDrawElement::MakeText(
@@ -283,8 +282,22 @@ int32 SSchematicGraphNode::OnPaint(const FPaintArgs& Args, const FGeometry& Allo
const FVector2d NodeBottomCenter = AllottedGeometry.GetLocalSize() * FVector2d(0.5f, 1.f) + FVector2d(0.f, 8.f);
const FVector2d NodeLabelOffset = NodeBottomCenter - NodeLabelSize * FVector2d(0.5, 0);
NewLayerId++;
static const FVector2d LabelBackgroundPadding = FVector2d(2.f);
const FVector2d LabelBackgroundSize = NodeLabelSize + LabelBackgroundPadding * 2.f;
const FVector2d LabelBackgroundOffset = NodeLabelOffset - LabelBackgroundPadding;
static const FSlateBrush* LabelBackgroundBrush = FSchematicGraphStyle::Get().GetBrush( "Schematic.Label.Background");
NewLayerId++;
FSlateDrawElement::MakeBox(
OutDrawElements,
NewLayerId,
AllottedGeometry.ToPaintGeometry(LabelBackgroundSize, FSlateLayoutTransform(LabelBackgroundOffset)),
LabelBackgroundBrush,
ESlateDrawEffect::None,
FLinearColor(0.2f, 0.2f, 0.2f, 0.8f) * FadedOutFactor
);
NewLayerId++;
FSlateDrawElement::MakeText(
OutDrawElements,
NewLayerId,

View File

@@ -37,6 +37,8 @@ public:
Set("Schematic.Dot.Large", new IMAGE_BRUSH_SVG("SchematicGraph/Schematic_Dot_Large", Icon128x128));
Set("Schematic.Dot.Group", new IMAGE_BRUSH_SVG("SchematicGraph/Schematic_Dot_Group", Icon128x128));
Set("Schematic.Label.Background", new FSlateRoundedBoxBrush(FStyleColors::White, 4.0f, FStyleColors::Transparent, 0.0f));
FSlateStyleRegistry::RegisterSlateStyle(*this);
}