// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "CsdkBaseBtnSlotWidget.h"
#include "CsdkBtnParam.h"
#include "Components/Widget.h"
#include "Slate/CommonBtn/SCsdkCommonBtns.h"
#include "CsdkCommonBtns.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnButtonClickedEvent,int32, index,const FCsdkBtnParam&, Param);


/**
 * 
 */
UCLASS(BlueprintType,Blueprintable)
class CSDKUI_API UCsdkCommonBtns : public UWidget
{
	GENERATED_BODY()
public:
	//~ Begin UWidget Interface
	virtual void SynchronizeProperties() override;
	//~ End UWidget Interface

	//~ Begin UVisual Interface
	virtual void ReleaseSlateResources(bool bReleaseChildren) override;
	//~ End UVisual Interface

	virtual TSharedRef<SWidget> RebuildWidget() override;

	UFUNCTION(BlueprintCallable,Category="CSDK")
	void SwitchToIndex(const int32 Index);
protected:
	FORCEINLINE void Reset();
	FReply SlateHandleClicked(const int32 Index);
public:
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="CSDK", meta=(ExposeOnSpawn))
	TEnumAsByte<EOrientation> Orientation = EOrientation::Orient_Horizontal;
	
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="CSDK", meta=(ExposeOnSpawn))
	TArray<FCsdkBtnParam> BtnParams;
	
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="CSDK", meta=(ExposeOnSpawn))
	TSubclassOf<UCsdkBaseBtnSlotWidget> BtnSlotClass = UCsdkBaseBtnSlotWidget::StaticClass();

	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="CSDK", meta=(ExposeOnSpawn))
	FMargin Padding;
	
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="CSDK", meta=(ExposeOnSpawn))
	int32 DefaultIndex = -1;

	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="CSDK|Advance", meta=(ExposeOnSpawn))
	bool bCanMutex = true;

	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="CSDK|Advance", meta=(ExposeOnSpawn, EditCondition ="bCanMutex"))
	bool bCanSelfMutex = false;

	
	UPROPERTY(BlueprintAssignable, Category="CSDK")
	FOnButtonClickedEvent OnClicked;

	UPROPERTY(BlueprintReadOnly,Category="CSDK")
	TArray<UCsdkBaseBtnSlotWidget*> BtnSlotWidgets;
protected:

	TSharedPtr<SCsdkCommonBtns> MyCsdkCommonBtns;
	
	TArray<TSharedPtr<SWidget>> BtnSlotSlate;

	int32 CurrentIndex = -1;
};
