Files
integration/Source/Integration/RadialMenu.h

61 lines
1.3 KiB
C
Raw Normal View History

2026-05-08 17:55:11 -04:00
//
// This class implements the layout calculatations for a radial
// menu.
//
#pragma once
#include "CoreMinimal.h"
#include "RadialMenu.generated.h"
USTRUCT(BlueprintType)
struct FRadialMenuItem
{
GENERATED_BODY()
FVector2D Point1 = {0,0};
FVector2D Point2 = {0,0};
FVector2D Point3 = {0,0};
bool RightSide = false;
};
UCLASS(BlueprintType)
class URadialMenu : public UObject
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
void Configure(int32 NItems, float ItemHeight, float InnerRadius, float MinSpoke, float Spread);
UFUNCTION(BlueprintCallable)
int32 NumItems() const { return Items.Num(); }
UFUNCTION(BlueprintCallable)
const TArray<FRadialMenuItem> GetItems() const { return Items; }
TArray<FRadialMenuItem> Items;
private:
using View = TArrayView<FRadialMenuItem>;
void CalculateSide(View V);
void FlipHorizontal(View V);
// The half-circle is divided into pie slices. Returns a direction vector
// which aims directly down the center of the pie slice.
FVector2D PieSliceToVector(double Slice, double Slices);
int32 CNItems = 0;
float CItemHeight = 0;
float CInnerRadius = 0;
float CMinSpoke = 0;
float CSpread = 0;
int32 CNumLeft = 0;
int32 CNumRight = 0;
View LeftItems;
View RightItems;
};