feat(ui): text style via CommonTextStyle por variante (padrao Hyper) + align + auto-size
FUIStyleButtonVariant.Font (FSlateFontInfo) -> TSubclassOf<UCommonTextStyle> TextStyle (idiomatico CommonUI, como BP_Style_Text_* do Hyper; theme-driven via DT_UI_Styles por variante). ButtonText volta a UCommonTextBlock; RefreshUIStyle: SetStyle(variante.TextStyle) + cor do FUIStyle por cima (FUIStyle manda na cor por tema). Mantidos TextAlign (ETextJustify L/C/R via SetJustification + slot do Overlay) e bAutoSizeText (TextScaleBox ScaleToFit/None) — ortogonais ao CommonTextStyle. ButtonTextValue default 'Button Text' agora no header. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,9 +3,12 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Fonts/SlateFontInfo.h"
|
#include "Fonts/SlateFontInfo.h"
|
||||||
#include "Layout/Margin.h"
|
#include "Layout/Margin.h"
|
||||||
|
#include "Templates/SubclassOf.h"
|
||||||
#include "UIStyleTypes.h"
|
#include "UIStyleTypes.h"
|
||||||
#include "UIStyleTokens.generated.h"
|
#include "UIStyleTokens.generated.h"
|
||||||
|
|
||||||
|
class UCommonTextStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tokens de estilo da UI organizados em 3 camadas (design tokens):
|
* Tokens de estilo da UI organizados em 3 camadas (design tokens):
|
||||||
*
|
*
|
||||||
@@ -193,6 +196,15 @@ struct ZMMO_API FUIStyleButtonVariant
|
|||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "UI Style|Button")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "UI Style|Button")
|
||||||
FLinearColor TextColor = FLinearColor::White;
|
FLinearColor TextColor = FLinearColor::White;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estilo de texto desta variante (padrão Hyper/CommonUI: CommonTextStyle).
|
||||||
|
* Define fonte/tamanho/peso. A COR é sobreposta pelo TextColor acima
|
||||||
|
* (FUIStyle manda na cor por tema). Permite Primary/Secondary/Danger/Ghost
|
||||||
|
* com tipografias diferentes. Preenchido em DT_UI_Styles por tema.
|
||||||
|
*/
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "UI Style|Button")
|
||||||
|
TSubclassOf<UCommonTextStyle> TextStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
#include "Components/TextBlock.h"
|
#include "Components/TextBlock.h"
|
||||||
#include "Components/Image.h"
|
#include "Components/Image.h"
|
||||||
#include "Components/SizeBox.h"
|
#include "Components/SizeBox.h"
|
||||||
|
#include "Components/ScaleBox.h"
|
||||||
#include "Components/OverlaySlot.h"
|
#include "Components/OverlaySlot.h"
|
||||||
|
#include "CommonTextBlock.h"
|
||||||
#include "CommonActionWidget.h"
|
#include "CommonActionWidget.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -169,7 +171,36 @@ void UUIButton_Base::RefreshUIStyle()
|
|||||||
}
|
}
|
||||||
if (ButtonText)
|
if (ButtonText)
|
||||||
{
|
{
|
||||||
|
// Tipografia: CommonTextStyle da variante (padrão Hyper/CommonUI).
|
||||||
|
if (VariantStyle.TextStyle)
|
||||||
|
{
|
||||||
|
ButtonText->SetStyle(VariantStyle.TextStyle);
|
||||||
|
}
|
||||||
|
// Cor: FUIStyle manda na cor por tema (sobrepõe o CommonTextStyle).
|
||||||
ButtonText->SetColorAndOpacity(FSlateColor(VariantStyle.TextColor));
|
ButtonText->SetColorAndOpacity(FSlateColor(VariantStyle.TextColor));
|
||||||
|
|
||||||
|
// Alinhamento L/C/R dentro da largura do botão.
|
||||||
|
ButtonText->SetJustification(TextAlign);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Texto adapta ao tamanho do botão (ScaleToFit) ou usa tamanho fixo.
|
||||||
|
if (TextScaleBox)
|
||||||
|
{
|
||||||
|
TextScaleBox->SetStretch(bAutoSizeText ? EStretch::ScaleToFit : EStretch::None);
|
||||||
|
|
||||||
|
// Posiciona o bloco de texto L/C/R dentro do botão (slot do Overlay).
|
||||||
|
if (UOverlaySlot* OS = Cast<UOverlaySlot>(TextScaleBox->Slot))
|
||||||
|
{
|
||||||
|
EHorizontalAlignment H = HAlign_Center;
|
||||||
|
switch (TextAlign)
|
||||||
|
{
|
||||||
|
case ETextJustify::Left: H = HAlign_Left; break;
|
||||||
|
case ETextJustify::Right: H = HAlign_Right; break;
|
||||||
|
default: H = HAlign_Center; break;
|
||||||
|
}
|
||||||
|
OS->SetHorizontalAlignment(H);
|
||||||
|
OS->SetVerticalAlignment(VAlign_Center);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BP_ApplyUIStyle(ActiveStyle.Button, VariantStyle);
|
BP_ApplyUIStyle(ActiveStyle.Button, VariantStyle);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ class UBorder;
|
|||||||
class UTextBlock;
|
class UTextBlock;
|
||||||
class UImage;
|
class UImage;
|
||||||
class USizeBox;
|
class USizeBox;
|
||||||
|
class UScaleBox;
|
||||||
|
class UCommonTextBlock;
|
||||||
class UCommonActionWidget;
|
class UCommonActionWidget;
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnUIButtonActivatedByTimeout);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnUIButtonActivatedByTimeout);
|
||||||
@@ -49,7 +51,16 @@ public:
|
|||||||
|
|
||||||
// ---- Text Style ----
|
// ---- Text Style ----
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Text Style")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Text Style")
|
||||||
FText ButtonTextValue;
|
FText ButtonTextValue = FText::FromString(TEXT("Button Text"));
|
||||||
|
|
||||||
|
/** Alinhamento do texto dentro do botão (esquerda/centro/direita). */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Text Style")
|
||||||
|
TEnumAsByte<ETextJustify::Type> TextAlign = ETextJustify::Center;
|
||||||
|
|
||||||
|
/** true = texto escala p/ caber no tamanho do botão (ScaleBox ScaleToFit);
|
||||||
|
* false = usa o tamanho fixo da fonte da variante. */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Text Style")
|
||||||
|
bool bAutoSizeText = true;
|
||||||
|
|
||||||
// ---- Number Text ----
|
// ---- Number Text ----
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Number Text")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Number Text")
|
||||||
@@ -151,7 +162,11 @@ protected:
|
|||||||
TObjectPtr<USizeBox> SizeBox_Master;
|
TObjectPtr<USizeBox> SizeBox_Master;
|
||||||
|
|
||||||
UPROPERTY(meta = (BindWidgetOptional))
|
UPROPERTY(meta = (BindWidgetOptional))
|
||||||
TObjectPtr<UTextBlock> ButtonText;
|
TObjectPtr<UCommonTextBlock> ButtonText;
|
||||||
|
|
||||||
|
/** Envolve o ButtonText: escala o texto p/ caber no botão (bAutoSizeText). */
|
||||||
|
UPROPERTY(meta = (BindWidgetOptional))
|
||||||
|
TObjectPtr<UScaleBox> TextScaleBox;
|
||||||
|
|
||||||
UPROPERTY(meta = (BindWidgetOptional))
|
UPROPERTY(meta = (BindWidgetOptional))
|
||||||
TObjectPtr<UTextBlock> Number_Text;
|
TObjectPtr<UTextBlock> Number_Text;
|
||||||
|
|||||||
Reference in New Issue
Block a user