Operating System Simulator Plugin  3.5.1
Unreal Engine plugin that simulates an Operating System Environment
Loading...
Searching...
No Matches
UDraggableWindow Class Reference

User widget class that represents a draggable window widget. It allows users to create draggable windows with optional resizing and maximizing features. More...

#include "DraggableWindow.h"

Inheritance diagram for UDraggableWindow:
[legend]
Collaboration diagram for UDraggableWindow:
[legend]

Public Member Functions

 UDraggableWindow (const FObjectInitializer &ObjectInitializer)
 
void SetWindowTitle (const FText &NewTitle)
 Sets the title of the window.
 
void CloseWindow ()
 Closes the draggable window.
 
TOptional< FVector2D > GetWindowPosition () const
 Get the position of the draggable window.
 
void AddContentWidgetClass (TSubclassOf< class UUserWidget > InWidgetClass, const bool bClearPrevious=true)
 
void AddContentWidget (class UUserWidget *InWidget, const bool bClearPrevious=true)
 
bool ToggleMaximize ()
 
void CenterWindowToScreen ()
 
bool UpdateWindowSize (const FVector2D &InNewSize)
 
bool GetChildWidget (UUserWidget *&OutChildWidget) const
 
void SetPosition (const FVector2D NewPosition)
 Set the position of the window to the specified coordinates.
 
FORCEINLINE bool IsMaximized () const
 Returns whether the window is currently maximized.
 

Static Public Member Functions

static UDraggableWindowCreateDraggableWindow (const UObject *WorldContextObject, TSubclassOf< UDraggableWindow > WindowClass, TSubclassOf< UUserWidget > ChildWidgetClass, const FVector2D StartSize=FVector2D(640.f, 480.f), const FVector2D ResizeWidth=FVector2D(640.f, 480.f), const FVector2D ResizeHeight=FVector2D(0.f, 0.f), const bool bCenterToScreen=true, const bool bCanDrag=true, const bool bCanResize=true, const EOperatingSystemWindowStartupState WindowStartupState=EOperatingSystemWindowStartupState::Default)
 
static UDraggableWindowCreateDraggableWindowFromWidget (const UObject *WorldContextObject, TSubclassOf< UDraggableWindow > WindowClass, UUserWidget *NewChildWidget, const FVector2D StartSize=FVector2D(640.f, 480.f), const FVector2D ResizeWidth=FVector2D(640.f, 480.f), const FVector2D ResizeHeight=FVector2D(0.f, 0.f), const bool bCenterToScreen=true, const bool bCanDrag=true, const bool bCanResize=true, const EOperatingSystemWindowStartupState WindowStartupState=EOperatingSystemWindowStartupState::Default)
 

Protected Member Functions

virtual void NativeConstruct () override
 
virtual FReply NativeOnMouseMove (const FGeometry &InGeometry, const FPointerEvent &InMouseEvent) override
 
virtual FReply NativeOnMouseButtonUp (const FGeometry &InGeometry, const FPointerEvent &InMouseEvent) override
 
virtual void OnCloseWindow ()
 This virtual function is called when the window is being closed. It can be overridden by derived classes to provide custom behavior when the window is closed.
 
void K2_OnCloseWindow ()
 
void K2_OnSetWindowTitle (const FText &NewWindowTitle)
 
void K2_OnContentWidgetAdded (const UUserWidget *AddedUserWidget)
 
void K2_OnDragStart (const FPointerEvent &InMouseEvent)
 
void K2_OnResizeStart (const FPointerEvent &InMouseEvent)
 
void K2_StartMinimized ()
 
void K2_OnWindowMaximizeToggled ()
 

Protected Attributes

uint8 bEnableDrag: 1
 
uint8 bEnableResizing: 1
 
uint8 bEnableMaximizing: 1
 
float MaximizeTaskbarOffset
 
float ResizeMinWidth
 
float ResizeMaxWidth
 
float ResizeMinHeight
 
float ResizeMaxHeight
 
FKey DragKey
 
UBorder * WindowTitleBorderWidget
 A pointer to a UBorder widget that represents the window title border.
 
UCanvasPanel * ChildWidgetCanvas
 Pointer to a UCanvasPanel object representing the child widget canvas of the draggable window.
 
UBorder * ResizeAreaWidget
 Represents the resize area widget of the draggable window widget.
 
UCanvasPanelSlot * ParentSlot
 A canvas panel slot is responsible for defining the layout and positioning of a widget within a canvas panel. The ParentSlot variable is used to access and manipulate the properties of the canvas panel slot associated with the parent widget.
 
UUserWidget * ChildWidget
 Represents a child widget of a draggable window.
 
uint8 bIsMaximized: 1
 Flag indicating if the draggable window is maximized.
 
FVector2D LastMousePosition
 The last recorded mouse position.
 
FVector2D PreResizeAlignment
 A 2D vector that represents the alignment of a draggable window before resizing.
 
FVector2D PreResizeOffset
 
FVector2D PreDragSize
 PreDragSize is a variable of type FVector2D. It represents the size of the draggable window before it is dragged.
 
FVector2D StartSize
 Represents the starting size of the draggable window.
 
int32 CurrentZOrder
 The current Z-order of the window.
 
FAnchors PreFullscreenAnchors
 
FMargin PreFullscreenMargin
 
EOperatingSystemWindowStartupState StartupState
 Enum representing the startup state of an operating system window.
 

Detailed Description

User widget class that represents a draggable window widget. It allows users to create draggable windows with optional resizing and maximizing features.

Constructor & Destructor Documentation

◆ UDraggableWindow()

UDraggableWindow::UDraggableWindow ( const FObjectInitializer & ObjectInitializer)

Member Function Documentation

◆ AddContentWidget()

void UDraggableWindow::AddContentWidget ( class UUserWidget * InWidget,
const bool bClearPrevious = true )

Adds a content to this window.

See:

AddContentWidgetClass().
Parameters
InWidget[class UUserWidget*] Reference to an existing content.
bClearPrevious[const bool] Should we clear all existing children from Child Widget Canvas? Recommended to keep this on.
Here is the caller graph for this function:

◆ AddContentWidgetClass()

void UDraggableWindow::AddContentWidgetClass ( TSubclassOf< class UUserWidget > InWidgetClass,
const bool bClearPrevious = true )

Adds a content to this window. A new widget is created from the given class.

See:

AddContentWidget().
Parameters
InWidgetClass[TSubclassOf<class UUserWidget>] Widget class to use as content for this window.
bClearPrevious[const bool] Should we clear all existing children from Child Widget Canvas? Recommended to keep this on.
Here is the call graph for this function:

◆ CenterWindowToScreen()

void UDraggableWindow::CenterWindowToScreen ( )

Center this window to screen. Will not work if window is maximized.

Here is the caller graph for this function:

◆ CloseWindow()

void UDraggableWindow::CloseWindow ( )

Closes the draggable window.

This method is used to close the draggable window. It performs the following steps:

  1. Calls the K2_OnCloseWindow() function.
  2. Calls the OnCloseWindow() function.
  3. Clears the children of the ChildWidgetCanvas if it is valid.
  4. Removes the draggable window from its parent.
Here is the call graph for this function:

◆ CreateDraggableWindow()

UDraggableWindow * UDraggableWindow::CreateDraggableWindow ( const UObject * WorldContextObject,
TSubclassOf< UDraggableWindow > WindowClass,
TSubclassOf< UUserWidget > ChildWidgetClass,
const FVector2D StartSize = FVector2D(640.f, 480.f),
const FVector2D ResizeWidth = FVector2D(640.f, 480.f),
const FVector2D ResizeHeight = FVector2D(0.f, 0.f),
const bool bCenterToScreen = true,
const bool bCanDrag = true,
const bool bCanResize = true,
const EOperatingSystemWindowStartupState WindowStartupState = EOperatingSystemWindowStartupState::Default )
static

public static UDraggableWindow::CreateDraggableWindow Creates a draggable window widget instance from given widget class. You can optionally add a child widget also which will be the content for this window.

Parameters
WorldContextObject[const UObject*] World context object.
WindowClass[TSubclassOf<UDraggableWindow>] Window widget class to create.
ChildWidgetClass[TSubclassOf<UUserWidget>] [OPTIONAL] Child content class to add to the newly created window widget.
StartSize[const FVector2D] What size should we start the window.
ResizeWidth[const FVector2D] Min (X) and Max (Y) width of this window.
ResizeHeight[const FVector2D] Min (X) and Max (Y) height of this window.
bCenterToScreen[const bool] Should we center the window to the player screen.
bCanDrag[const bool] Determines if the window can be dragged.
bCanResize[const bool] Determines if the window can be resized (You must have a Border widget with Is Variable set to true and variable name set to ResizeAreaWidget).
WindowStartupState[const EOperatingSystemWindowStartupState] Window state to apply.
Returns
[UDraggableWindow*] Newly created window widget.
Here is the call graph for this function:

◆ CreateDraggableWindowFromWidget()

UDraggableWindow * UDraggableWindow::CreateDraggableWindowFromWidget ( const UObject * WorldContextObject,
TSubclassOf< UDraggableWindow > WindowClass,
UUserWidget * NewChildWidget,
const FVector2D StartSize = FVector2D(640.f, 480.f),
const FVector2D ResizeWidth = FVector2D(640.f, 480.f),
const FVector2D ResizeHeight = FVector2D(0.f, 0.f),
const bool bCenterToScreen = true,
const bool bCanDrag = true,
const bool bCanResize = true,
const EOperatingSystemWindowStartupState WindowStartupState = EOperatingSystemWindowStartupState::Default )
static

public static UDraggableWindow::CreateDraggableWindowFromWidget Creates a draggable window widget instance from given widget class. You can optionally add a child widget also which will be the content for this window.

Parameters
WorldContextObject[const UObject*] World context object.
WindowClass[TSubclassOf<UDraggableWindow>] Window widget class to create.
NewChildWidget[UUserWidget*] [OPTIONAL] Child content to add to the newly created window widget.
StartSize[const FVector2D] What size should we start the window.
ResizeWidth[const FVector2D] Min (X) and Max (Y) width of this window.
ResizeHeight[const FVector2D] Min (X) and Max (Y) height of this window.
bCenterToScreen[const bool] Should we center the window to the player screen.
bCanDrag[const bool] Determines if the window can be dragged.
bCanResize[const bool] Determines if the window can be resized (You must have a Border widget with Is Variable set to true and variable name set to ResizeAreaWidget).
WindowStartupState[const EOperatingSystemWindowStartupState] Window state to apply.
Returns
[UDraggableWindow*] Newly created window widget.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChildWidget()

bool UDraggableWindow::GetChildWidget ( UUserWidget *& OutChildWidget) const

Returns the child widget (if any) of this draggable window. If the Return Value is true, then OutChildWidget will be valid.

Parameters
OutChildWidget[UUserWidget*&] Reference to the child widget created by this window.
Returns
[bool] True if a valid child widget is available.

◆ GetWindowPosition()

TOptional< FVector2D > UDraggableWindow::GetWindowPosition ( ) const

Get the position of the draggable window.

This method retrieves the position of the draggable window. It checks if the ParentSlot is valid, and if so, it calls GetPosition() on the ParentSlot to get the window position. If the ParentSlot is not valid, it returns an empty TOptional<FVector2D> object.

Returns
The position of the draggable window, or an empty TOptional<FVector2D> object if the ParentSlot is not valid.

◆ IsMaximized()

FORCEINLINE bool UDraggableWindow::IsMaximized ( ) const
inline

Returns whether the window is currently maximized.

Returns
True if the window is maximized, false otherwise.

◆ K2_OnCloseWindow()

void UDraggableWindow::K2_OnCloseWindow ( )
protected

protected UDraggableWindow::K2_OnCloseWindow Event called when this window is closed. C++ implementation calls RemoveFromParent automatically.

Here is the caller graph for this function:

◆ K2_OnContentWidgetAdded()

void UDraggableWindow::K2_OnContentWidgetAdded ( const UUserWidget * AddedUserWidget)
protected

protected UDraggableWindow::K2_OnContentWidgetAdded Event called when a new content is added to this window.

Parameters
AddedUserWidget[const UUserWidget*] Reference to the content that is being added.

◆ K2_OnDragStart()

void UDraggableWindow::K2_OnDragStart ( const FPointerEvent & InMouseEvent)
protected

protected UDraggableWindow::K2_OnDragStart Event called when resizing is started. Only called if Enable Drag is true.

Parameters
InMouseEvent[const FPointerEvent&] Mouse or touch action.

◆ K2_OnResizeStart()

void UDraggableWindow::K2_OnResizeStart ( const FPointerEvent & InMouseEvent)
protected

protected UDraggableWindow::K2_OnResizeStart Event called when resizing is started. Only called if Enable Resizing is true.

Parameters
InMouseEvent[const FPointerEvent&] Mouse or touch action.

◆ K2_OnSetWindowTitle()

void UDraggableWindow::K2_OnSetWindowTitle ( const FText & NewWindowTitle)
protected

protected UDraggableWindow::K2_OnSetWindowTitle Event called when a new title is set for this window.

Parameters
NewWindowTitle[const FText &] New title.

◆ K2_OnWindowMaximizeToggled()

void UDraggableWindow::K2_OnWindowMaximizeToggled ( )
protected

protected UDraggableWindow::K2_OnWindowMaximizeToggled Event called when this window is maximized or restored.

Here is the caller graph for this function:

◆ K2_StartMinimized()

void UDraggableWindow::K2_StartMinimized ( )
protected

protected UDraggableWindow::K2_StartMinimized Event called when the window starts minimized.

◆ NativeConstruct()

void UDraggableWindow::NativeConstruct ( )
overrideprotectedvirtual
Here is the call graph for this function:

◆ NativeOnMouseButtonUp()

FReply UDraggableWindow::NativeOnMouseButtonUp ( const FGeometry & InGeometry,
const FPointerEvent & InMouseEvent )
overrideprotectedvirtual

◆ NativeOnMouseMove()

FReply UDraggableWindow::NativeOnMouseMove ( const FGeometry & InGeometry,
const FPointerEvent & InMouseEvent )
overrideprotectedvirtual

◆ OnCloseWindow()

virtual void UDraggableWindow::OnCloseWindow ( )
inlineprotectedvirtual

This virtual function is called when the window is being closed. It can be overridden by derived classes to provide custom behavior when the window is closed.

Here is the caller graph for this function:

◆ SetPosition()

void UDraggableWindow::SetPosition ( const FVector2D NewPosition)

Set the position of the window to the specified coordinates.

Parameters
NewPositionThe new position of the window as a 2D vector (FVector2D).
Note
If the draggable window has a valid parent slot, the position of the parent slot will also be set to the new position.
If the draggable window is currently maximized, calling this method will toggle the maximize state.
If the draggable window is set to start in the center of the screen, calling this method will disable that behavior.
Here is the call graph for this function:

◆ SetWindowTitle()

void UDraggableWindow::SetWindowTitle ( const FText & NewTitle)
inline

Sets the title of the window.

Parameters
NewTitleThe new title of the window.

◆ ToggleMaximize()

bool UDraggableWindow::ToggleMaximize ( )

Maximizes or restores this window.

Returns
[bool] True if the window was maximized or restored.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateWindowSize()

bool UDraggableWindow::UpdateWindowSize ( const FVector2D & InNewSize)

Updates the size of the draggable window.

Parameters
InNewSize[const FVector2D&] New size to change to.
Returns
[bool] True if the size was changed successfully.
Here is the caller graph for this function:

Member Data Documentation

◆ bEnableDrag

uint8 UDraggableWindow::bEnableDrag
protected

◆ bEnableMaximizing

uint8 UDraggableWindow::bEnableMaximizing
protected

◆ bEnableResizing

uint8 UDraggableWindow::bEnableResizing
protected

◆ bIsMaximized

uint8 UDraggableWindow::bIsMaximized
protected

Flag indicating if the draggable window is maximized.

This flag is used to determine if the draggable window is currently maximized. It is a boolean flag with a width of 1 bit. When the flag is set to true (1), it means that the draggable window is maximized. When the flag is set to false (0), it means that the draggable window is not maximized.

Note
This flag is a transient property, meaning that it is not serialized or persisted. It is only used during runtime.
This flag is read-only from outside the draggable window widget. It can only be modified internally.

◆ ChildWidget

UUserWidget* UDraggableWindow::ChildWidget
protected

Represents a child widget of a draggable window.

This variable is of type UUserWidget*. It represents a child widget that can be attached to a draggable window. The child widget will be displayed within the draggable window and can be manipulated along with it.

◆ ChildWidgetCanvas

UCanvasPanel* UDraggableWindow::ChildWidgetCanvas
protected

Pointer to a UCanvasPanel object representing the child widget canvas of the draggable window.

Note
The ChildWidgetCanvas is expected to be bound to a UCanvasPanel widget in the Blueprints.

◆ CurrentZOrder

int32 UDraggableWindow::CurrentZOrder
protected

The current Z-order of the window.

The Z-order determines the position of the window relative to other windows in the stacking order. A higher Z-order means the window will be displayed above windows with lower Z-orders.

Note
The Z-order can be positive or negative.
A value of 0 indicates that the window is at the default Z-order.

◆ DragKey

FKey UDraggableWindow::DragKey
protected

◆ LastMousePosition

FVector2D UDraggableWindow::LastMousePosition
protected

The last recorded mouse position.

This variable stores the last known position of the mouse on the screen. It is of type FVector2D, which represents a 2D vector with X and Y coordinates. The X coordinate represents the horizontal position of the mouse, and the Y coordinate represents the vertical position of the mouse.

To access this variable, use the appropriate getter and setter methods provided by the class or structure that contains it. The methods should be named in accordance with the coding conventions and naming conventions followed in the application.

Note
This variable is typically updated by the application's input handling system, which tracks the mouse movements and updates this variable accordingly.

◆ MaximizeTaskbarOffset

float UDraggableWindow::MaximizeTaskbarOffset
protected

◆ ParentSlot

UCanvasPanelSlot* UDraggableWindow::ParentSlot
protected

A canvas panel slot is responsible for defining the layout and positioning of a widget within a canvas panel. The ParentSlot variable is used to access and manipulate the properties of the canvas panel slot associated with the parent widget.

Note
This variable is expected to be initialized and assigned a valid value before accessing or using it.

◆ PreDragSize

FVector2D UDraggableWindow::PreDragSize
protected

PreDragSize is a variable of type FVector2D. It represents the size of the draggable window before it is dragged.

PreDragSize is typically updated whenever the size of the draggable window changes, but before it is actually dragged. It is useful for keeping track of the previous size of the window.

◆ PreFullscreenAnchors

FAnchors UDraggableWindow::PreFullscreenAnchors
protected

The PreFullscreenAnchors variable is of type FAnchors and is used to store the original anchors of a draggable window before it enters fullscreen mode.

◆ PreFullscreenMargin

FMargin UDraggableWindow::PreFullscreenMargin
protected

This variable is of type FMargin, which is a struct that represents a rectangle's margin. It is used to store the top, left, bottom, and right margins of the window before it enters full screen mode.

◆ PreResizeAlignment

FVector2D UDraggableWindow::PreResizeAlignment
protected

A 2D vector that represents the alignment of a draggable window before resizing.

This vector stores the alignment of a draggable window before it is resized. It is used to determine the original position of the window before resizing it.

◆ PreResizeOffset

FVector2D UDraggableWindow::PreResizeOffset
protected

Offset value used for pre-resizing calculations.

◆ ResizeAreaWidget

UBorder* UDraggableWindow::ResizeAreaWidget
protected

Represents the resize area widget of the draggable window widget.

The resize area widget is used to specify the area where the user can click and drag to resize the window. If this widget is null, resizing will not be enabled for the window.

◆ ResizeMaxHeight

float UDraggableWindow::ResizeMaxHeight
protected

◆ ResizeMaxWidth

float UDraggableWindow::ResizeMaxWidth
protected

◆ ResizeMinHeight

float UDraggableWindow::ResizeMinHeight
protected

◆ ResizeMinWidth

float UDraggableWindow::ResizeMinWidth
protected

◆ StartSize

FVector2D UDraggableWindow::StartSize
protected

Represents the starting size of the draggable window.

This variable is of type FVector2D, which is a structure that holds a 2D vector. The vector represents the width and height of the window.

The StartSize variable is used to define the initial size of the draggable window when it is created. It determines the width and height of the window before any user interaction or resizing occurs.

See also
CreateDraggableWindowFromWidget

◆ StartupState

EOperatingSystemWindowStartupState UDraggableWindow::StartupState
protected

Enum representing the startup state of an operating system window.

The EOperatingSystemWindowStartupState enumeration represents the possible startup states for an operating system window. It is used to define how a window should behave when it is initially displayed.

See also
CreateDraggableWindowFromWidget

◆ WindowTitleBorderWidget

UBorder* UDraggableWindow::WindowTitleBorderWidget
protected

A pointer to a UBorder widget that represents the window title border.

This variable is used in the DraggableWindow class to reference the UBorder widget that represents the window title border. The UBorder widget is a visual element that can be customized to display the title of the window and provide a draggable area for the window.

Note
The meta specifiers (BindWidgetOptional) indicate that this widget is optional and can be assigned in the Blueprint. If the widget is not assigned, the pointer will be nullptr.
See also
DraggableWindow

The documentation for this class was generated from the following files: