// Copyright (c) 2024 Codemongous LLC. All Rights Reserved.

#pragma once

#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SCompoundWidget.h"

class SButton;

/** An expander arrow that can have children which are collapsed/visible depending on the state of the arrow. */
class SSourcifyExpanderArrow : public SCompoundWidget
{
	enum class EExpansionState : uint8
	{
		Expanded = 0,
		Collapsed
	};
public:
	SLATE_BEGIN_ARGS(SSourcifyExpanderArrow)
		: _Content()
		, _ArrowText{}
		, _bIsSubSection(false) {}

	SLATE_DEFAULT_SLOT( FArguments, Content )
	SLATE_ARGUMENT(FString, ArrowText)
	SLATE_ARGUMENT(bool, bIsSubSection)
	SLATE_END_ARGS()

	void Construct(const FArguments& InArgs);

private:

	EVisibility GetExpanderVisibility() const;
	const FSlateBrush* GetExpanderImage() const;
	FReply OnExpanderClicked();
	
private:
	TSharedPtr<SButton> ExpanderArrow;
	EExpansionState ExpansionState = EExpansionState::Expanded;
	TSharedPtr<SWidget> ChildContent;
};