#pragma once

#include "MenuButton.h"
#include "MenuSlider.generated.h"

UCLASS()
class UMenuSliderButton : public UMenuItemBase
{
	GENERATED_BODY()
public:
	void NativeConstruct() override ;
	void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;

	void UpdateText();

	void SetSelected(bool selected);

private:
	UFUNCTION()
	void m_OnPressed();
	void m_EndDrag();

	FReply NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override;

	friend class UMenuSlider;
	class UMenuSlider* m_parent;
	UBorder* m_dragBorder;
	UButton* m_button; 
	UTextBlock* m_text;
	UCanvasPanel* m_panel;
	FVector2D m_dragStart;
	float m_dragStartValue;
	bool m_dragging;
};

UCLASS()
class UMenuSlider : public UMenuButton
{
	GENERATED_BODY()
public:
	UMenuSlider(const FObjectInitializer& init);
	void NativeConstruct() override;
	void NativeOnMenuAction(EMenuActionBinding binding) override;

	void NativeOnSelectionChanged(bool selected, bool controller) override;

	UFUNCTION(BlueprintCallable, Category="Slider")
	void SetValue(float value);

	UPROPERTY(BlueprintReadOnly, Category = "Slider")
	float value;

	UPROPERTY(EditAnywhere, Category = "Slider")
	float stepGranularity;

private:
	friend class UMenuSliderButton;
	class USizeBorder* m_sizeBorder;
	class UMenuSliderButton* m_sliderButton;

};