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"
|
static 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 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) |
|
User widget class that represents a draggable window widget. It allows users to create draggable windows with optional resizing and maximizing features.
◆ UDraggableWindow()
UDraggableWindow::UDraggableWindow |
( |
const FObjectInitializer & | ObjectInitializer | ) |
|
◆ 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. |
◆ 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. |
◆ CenterWindowToScreen()
void UDraggableWindow::CenterWindowToScreen |
( |
| ) |
|
Center this window to screen. Will not work if window is maximized.
◆ CloseWindow()
void UDraggableWindow::CloseWindow |
( |
| ) |
|
Closes the draggable window.
This method is used to close the draggable window. It performs the following steps:
- Calls the K2_OnCloseWindow() function.
- Calls the OnCloseWindow() function.
- Clears the children of the ChildWidgetCanvas if it is valid.
- Removes the draggable window from its parent.
◆ 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.
◆ 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.
◆ 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 |
◆ K2_OnContentWidgetAdded()
void UDraggableWindow::K2_OnContentWidgetAdded |
( |
const UUserWidget * | AddedUserWidget | ) |
|
|
protected |
◆ 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 |
◆ K2_OnWindowMaximizeToggled()
void UDraggableWindow::K2_OnWindowMaximizeToggled |
( |
| ) |
|
|
protected |
◆ K2_StartMinimized()
void UDraggableWindow::K2_StartMinimized |
( |
| ) |
|
|
protected |
◆ NativeConstruct()
void UDraggableWindow::NativeConstruct |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ 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.
◆ SetPosition()
void UDraggableWindow::SetPosition |
( |
const FVector2D | NewPosition | ) |
|
Set the position of the window to the specified coordinates.
- Parameters
-
NewPosition | The 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.
◆ SetWindowTitle()
void UDraggableWindow::SetWindowTitle |
( |
const FText & | NewTitle | ) |
|
|
inline |
Sets the title of the window.
- Parameters
-
NewTitle | The new title of the window. |
◆ ToggleMaximize()
bool UDraggableWindow::ToggleMaximize |
( |
| ) |
|
Maximizes or restores this window.
- Returns
- [bool] True if the window was maximized or restored.
◆ 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.
◆ 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
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: