76 lines
2.2 KiB
C++
76 lines
2.2 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "SChildWindowTitleBar.h"
|
|
#include "SCompoundWidget.h"
|
|
#include "SConstraintCanvas.h"
|
|
|
|
class IChildWindow;
|
|
class SChildWindowTitleBar;
|
|
class SNativeChildWindow;
|
|
class SHorizontalBox;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
class ARONA_API SChildWindow : public SCompoundWidget
|
|
{
|
|
public:
|
|
SLATE_BEGIN_ARGS(SChildWindow):
|
|
_Title(),
|
|
_BorderSize(2),
|
|
_ResizeHandleSize(16)
|
|
{
|
|
}
|
|
|
|
|
|
SLATE_ARGUMENT(TSharedPtr<IChildWindow>, Content)
|
|
SLATE_ARGUMENT(FString, Title)
|
|
SLATE_ARGUMENT(FVector2D, BorderSize)
|
|
SLATE_ARGUMENT(bool, IsSingletonWindow)
|
|
SLATE_ARGUMENT(FVector2D, ResizeHandleSize)
|
|
|
|
SLATE_EVENT(FSimpleDelegate, OnClose)
|
|
SLATE_EVENT(FWindowVector2fEvent, OnWindowMove)
|
|
SLATE_EVENT(FWindowVector2fEvent, OnWindowResize)
|
|
SLATE_END_ARGS()
|
|
|
|
/** Constructs this widget with InArgs */
|
|
void Construct(const FArguments& InArgs, SConstraintCanvas::FSlot* InSlot);
|
|
|
|
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 MoveWindow(FVector2f Position); // 相对于父窗口的位置
|
|
static float GetTitleBarHeight();
|
|
void MoveWindowDelta(FVector2f Delta);
|
|
void ResizeWindow(FVector2f Size); // 相对于父窗口的大小
|
|
|
|
SConstraintCanvas::FSlot* GetSlot() const { return Slot; }
|
|
|
|
FVector2f GetWindowSize() const { return Slot->GetOffset().GetDesiredSize2f(); }
|
|
void SetOnWindowResize(FWindowVector2fEvent InOnWindowResize) { OnWindowResize = InOnWindowResize; }
|
|
FWindowVector2fEvent& GetOnWindowResize() { return OnWindowResize; }
|
|
void OnMaximize(bool bArg);
|
|
|
|
TSharedPtr<IChildWindow> Content;
|
|
private:
|
|
void OnCloseClicked();
|
|
SConstraintCanvas::FSlot* Slot = nullptr;
|
|
FSimpleDelegate OnClose;
|
|
FWindowVector2fEvent OnWindowMove;
|
|
FWindowVector2fEvent OnWindowResize;
|
|
FVector2D BorderSize;
|
|
FVector2D ResizeHandleSize;
|
|
FVector2D BeginResizePos;
|
|
FMargin LastMargin;
|
|
FMargin BeginResizeMargin;
|
|
bool IsSingletonWindow = false;
|
|
bool IsOnResize = false;
|
|
|
|
TSharedPtr<SChildWindowTitleBar> TitleBar;
|
|
};
|