Radial menus are in good shape
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/Widget.h"
|
||||
#include "Fonts/SlateFontInfo.h"
|
||||
#include "RadialMenu.generated.h"
|
||||
|
||||
class SRadialMenu;
|
||||
@@ -19,10 +20,10 @@ struct FRadialMenuConfig
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="RadialMenu")
|
||||
int32 NumItems = 8;
|
||||
TArray<FString> MenuItems;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="RadialMenu")
|
||||
float ItemHeight = 20.0f;
|
||||
FSlateFontInfo Font;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="RadialMenu")
|
||||
float InnerRadius = 20.0f;
|
||||
@@ -37,7 +38,7 @@ struct FRadialMenuConfig
|
||||
float LineThickness = 4.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="RadialMenu")
|
||||
FLinearColor LineColor = FLinearColor::White;
|
||||
FLinearColor ItemColor = FLinearColor::White;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="RadialMenu")
|
||||
TObjectPtr<UTexture2D> DotTexture;
|
||||
@@ -45,6 +46,12 @@ struct FRadialMenuConfig
|
||||
UPROPERTY(EditAnywhere, Category="RadialMenu")
|
||||
float DotRadius = 3.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="RadialMenu")
|
||||
TObjectPtr<UTexture2D> Teardrop;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="RadialMenu")
|
||||
float TeardropRadius = 0.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="RadialMenu")
|
||||
int32 SelectedItem = -1;
|
||||
|
||||
@@ -73,8 +80,16 @@ struct FRadialMenuItem
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
bool RightSide = false;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FVector2D TextSize = {0,0};
|
||||
|
||||
static TArray<FRadialMenuItem> Calculate(const FRadialMenuConfig &Config);
|
||||
|
||||
// Like Calculate, but only produces the unit-vector direction of
|
||||
// each spoke. Cheaper to evaluate when only the spoke directions
|
||||
// are needed (e.g. for hit-testing a pointer against the wheel).
|
||||
static TArray<FVector2D> CalculateDirections(int32 NumItems);
|
||||
|
||||
private:
|
||||
using View = TArrayView<FRadialMenuItem>;
|
||||
|
||||
@@ -112,59 +127,29 @@ class URadialMenuWidget : public UWidget
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetNumItems(int32 NewNumItems);
|
||||
void SetMenuItems(const TArray<FString>& NewMenuItems);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetItemHeight(float NewItemHeight);
|
||||
void ClearMenuItems() { SetMenuItems({}); }
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetInnerRadius(float NewInnerRadius);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetMinSpoke(float NewMinSpoke);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetSpread(float NewSpread);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetLineThickness(float NewLineThickness);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetLineColor(FLinearColor NewLineColor);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetDotTexture(UTexture2D* NewDotTexture);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetDotRadius(float NewDotRadius);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool SetSelectedItem(int32 NewSelectedItem);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetSelectedColor(FLinearColor NewSelectedColor);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetSelectedThickness(float NewSelectedThickness);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
const TArray<FRadialMenuItem> &GetItems() const { return Items; }
|
||||
void SetSelectedItem(int32 NewSelectedItem);
|
||||
|
||||
// Returns true if the selected item changed.
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool AddPointer(FVector2D Direction, float Scale);
|
||||
void AddPointer(FVector2D Direction, float Scale);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
FVector2D GetPointer() const { return PointerVector; }
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
FLinearColor GetItemColor(int N) const;
|
||||
|
||||
FString GetSelectedMenuItem() const;
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditAnywhere)
|
||||
FRadialMenuConfig Config;
|
||||
|
||||
TArray<FRadialMenuItem> Items;
|
||||
TArray<FVector2D> Directions;
|
||||
|
||||
FVector2D PointerVector = {0,0};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user