AronaSlate/Source/Arona/UI/Widget/SChildWindowTitleBar.h
2024-01-25 11:21:15 +08:00

47 lines
1.3 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "SCompoundWidget.h"
DECLARE_DELEGATE_OneParam(FWindowVector2fEvent, FVector2f);
/**
*
*/
class ARONA_API SChildWindowTitleBar : public SCompoundWidget
{
public:
DECLARE_DELEGATE_OneParam(FOnMaximize, bool);
SLATE_BEGIN_ARGS(SChildWindowTitleBar)
{
}
SLATE_ARGUMENT(FString, Title)
SLATE_EVENT(FSimpleDelegate, OnClose)
SLATE_EVENT(FWindowVector2fEvent, OnWindowMoveDelta)
SLATE_EVENT(FOnMaximize, OnMaximize)
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
virtual FReply OnMouseButtonDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent) override;
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
void ToggleMaximize();
bool IsMaximized() const { return bIsMaximized; }
private:
FReply OnCloseClicked();
bool OnMouseLeftButtonDown = false;
FOnMaximize OnMaximize;
FSimpleDelegate OnClose;
FWindowVector2fEvent OnWindowMoveDelta;
bool bIsMaximized = false;
};