#pragma once #include "CoreMinimal.h" #include "Blueprint/UserWidget.h" #include "MenuButtonWidget.generated.h" class UButton; class UBorder; class UTextBlock; DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnMenuButtonClicked); /** * Styled menu button (WBP_Button): DefaultButton wraps ButtonBackground/ButtonText/Highlight. * Bind to OnClicked instead of reaching into DefaultButton - callers shouldn't need to know * this is built out of a Button + two Borders + a TextBlock. Label/BackgroundColor/HighlightColor * are instance-editable, so a widget that places a WBP_Button just configures it in its Details * panel (no per-instance Blueprint graph needed). */ UCLASS(abstract) class UMenuButtonWidget : public UUserWidget { GENERATED_BODY() public: /** Fired when the button is clicked. */ UPROPERTY(BlueprintAssignable, Category = "Button") FOnMenuButtonClicked OnClicked; /** Text shown on the button. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Button") FText Label; /** ButtonBackground tint while idle. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Button|Style") FLinearColor BackgroundColor = FLinearColor(0.03f, 0.03f, 0.03f, 0.75f); /** Highlight tint shown while hovered/focused. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Button|Style") FLinearColor HighlightColor = FLinearColor(1.0f, 0.85f, 0.3f, 1.0f); /** Pushes Label/BackgroundColor/HighlightColor onto the bound widgets. Runs in the Designer too, so edits preview live. */ UFUNCTION(BlueprintCallable, Category = "Button") void RefreshStyle(); protected: virtual void NativePreConstruct() override; virtual void NativeConstruct() override; UFUNCTION() void HandleClicked(); UFUNCTION() void HandleHovered(); UFUNCTION() void HandleUnhovered(); UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true)) TObjectPtr DefaultButton; UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true)) TObjectPtr ButtonBackground; UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true)) TObjectPtr ButtonText; UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true)) TObjectPtr Highlight; };