// Oleg Petruny proprietary.

#pragma once

#include "Blueprint/UserWidget.h"

#include "ResolutionResponsiveUserWidget.generated.h"

/**
 * Automatically scale itself for current resolution to keep UI sizes universal.
 */
UCLASS()
class UResolutionResponsiveUserWidget : public UUserWidget
{
    GENERATED_BODY()

public:
    virtual bool Initialize() override;
    virtual void BeginDestroy() override;

protected:
    void Rescale(FViewport* ViewPort, uint32 val);

    UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = ResolutionResponsiveWidget)
    void Rescale();
    virtual void Rescale_Implementation();

    UPROPERTY(EditDefaultsOnly)
    int32 defaultResolution = 1080;

    UFUNCTION(BlueprintCallable, Category = ResolutionResponsiveWidget)
    float GetScale() const;

private:
    float _scale;

    FDelegateHandle _viewportResizedEventHandle;
};
