feat(ui): Background (rename Bg) com RoundedBox + borda na cor da variante
- Bg -> Background (nome descritivo). - RefreshUIStyle: monta o brush do Background como RoundedBox quando bRoundedBackground (default true): TintColor=BgNormal, OutlineSettings(CornerRadii=Button.CornerRadius, Color=BorderNormal, Width=Button.BorderWidth, RoundingType=FixedRadius). 'So borda com a cor' = variante com BgNormal transparente + BorderNormal na cor (data-driven, como o Hyper). bRoundedBackground=false -> caixa reta. Compila OK. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "Engine/World.h"
|
||||
#include "TimerManager.h"
|
||||
#include "Components/Border.h"
|
||||
#include "Styling/SlateBrush.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "Components/Image.h"
|
||||
#include "Components/SizeBox.h"
|
||||
@@ -165,9 +166,31 @@ void UUIButton_Base::RefreshUIStyle()
|
||||
const FUIStyle& ActiveStyle = ResolveActiveStyle(this, Fallback);
|
||||
const FUIStyleButtonVariant& VariantStyle = ResolveVariant(ActiveStyle.Button);
|
||||
|
||||
if (Bg)
|
||||
if (Background)
|
||||
{
|
||||
Bg->SetBrushColor(VariantStyle.BgNormal);
|
||||
// Fundo + borda na cor da variante. RoundedBox dá cantos arredondados
|
||||
// e a borda colorida (BorderNormal) — "só borda" = BgNormal transparente.
|
||||
FSlateBrush Brush = Background->Background;
|
||||
Brush.TintColor = FSlateColor(VariantStyle.BgNormal);
|
||||
if (bRoundedBackground)
|
||||
{
|
||||
const float R = ActiveStyle.Button.CornerRadius;
|
||||
Brush.DrawAs = ESlateBrushDrawType::RoundedBox;
|
||||
Brush.OutlineSettings = FSlateBrushOutlineSettings(
|
||||
FVector4(R, R, R, R),
|
||||
FSlateColor(VariantStyle.BorderNormal),
|
||||
ActiveStyle.Button.BorderWidth);
|
||||
Brush.OutlineSettings.RoundingType = ESlateBrushRoundingType::FixedRadius;
|
||||
}
|
||||
else
|
||||
{
|
||||
Brush.DrawAs = ESlateBrushDrawType::Box;
|
||||
Brush.OutlineSettings = FSlateBrushOutlineSettings(
|
||||
FVector4(0, 0, 0, 0),
|
||||
FSlateColor(VariantStyle.BorderNormal),
|
||||
ActiveStyle.Button.BorderWidth);
|
||||
}
|
||||
Background->SetBrush(Brush);
|
||||
}
|
||||
if (ButtonText)
|
||||
{
|
||||
|
||||
@@ -62,6 +62,11 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Text Style")
|
||||
bool bAutoSizeText = true;
|
||||
|
||||
/** Arredonda o Background (RoundedBox) e desenha a borda na cor da
|
||||
* variante. Desligado = caixa reta. Raio/largura vêm de FUIStyleButton. */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Button")
|
||||
bool bRoundedBackground = true;
|
||||
|
||||
// ---- Number Text ----
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Number Text")
|
||||
bool bShowNumberText = false;
|
||||
@@ -176,7 +181,7 @@ protected:
|
||||
|
||||
/** Fundo temável (nossa adição sobre o Hyper, p/ FUIStyle). */
|
||||
UPROPERTY(meta = (BindWidgetOptional))
|
||||
TObjectPtr<UBorder> Bg;
|
||||
TObjectPtr<UBorder> Background;
|
||||
|
||||
private:
|
||||
void StartDeactivateTimeout();
|
||||
|
||||
Reference in New Issue
Block a user