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

#pragma once

#include "CoreMinimal.h"
#include "Widget/CommonBtn/CsdkBtnParam.h"
#include "CsdkSlateDelegate.h"
#include "Widgets/SCompoundWidget.h"

/**
 * 
 */
class CSDKUI_API SCsdkCommonBtns : public SCompoundWidget
{
public:
	SLATE_BEGIN_ARGS(SCsdkCommonBtns)
	{}

	SLATE_ARGUMENT( EOrientation, Orientation)

	SLATE_ARGUMENT( int32, BtnNum)

	SLATE_ARGUMENT(TArray<TSharedPtr<SWidget>>, SlotWidgets)

	SLATE_EVENT(FCsdkSCommonBtnClicked, OnClicked)

	/** Spacing between button's border and the content. */
	SLATE_ATTRIBUTE( FMargin, Padding )

	//SLATE_EVENT()

	SLATE_END_ARGS()

	

	/** Constructs this widget with InArgs */
	void Construct(const FArguments& InArgs);


	void SetOrientation(EOrientation InOrientation)
	{
		Orientation = InOrientation;
	}

	void SetPadding(const TAttribute<FMargin>& InPadding);

private:
	FReply OnButtonClicked(int32 Index);

private:
	TSharedPtr<SWidget> CreateWidgets();
	TSharedPtr<SWidget> CreateHorizontalBox();
	TSharedPtr<SWidget> CreateVerticalBox();
	TSharedRef<class SCsdkBaseBtn> CreateBtn(int32 Index);
protected:
	EOrientation Orientation = EOrientation::Orient_Horizontal;
	int32 BtnNum = 0;
	TArray<TSharedPtr<SWidget>> SlotWidgets;
	FCsdkSCommonBtnClicked OnClicked;
	TAttribute<FMargin> Padding;
	TSharedPtr<SBoxPanel> BoxPanel;
};
