|
Window Framework v1.2.4
Window Framework for Unity UI Toolkit
|
A mouse manipulator that provides resizing functionality for WindowFrame elements in Unity's UI Toolkit. More...
Public Member Functions | |
| WindowFrameResizer () | |
| Initializes a new instance of the WindowFrameResizer with left-click activation. | |
Protected Member Functions | |
| void | OnMouseMove (MouseMoveEvent e) |
| Handles mouse move events to update window size during resize operations. | |
| void | OnMouseUp (MouseUpEvent e) |
| Handles mouse up events to complete window resizing operations. | |
| override void | RegisterCallbacksOnTarget () |
| Registers mouse event callbacks on the target element. | |
| override void | UnregisterCallbacksFromTarget () |
| Unregisters mouse event callbacks from the target element. | |
Private Member Functions | |
| Vector2 | GetClampedWindowSize (float rootX, float rootY, VisualElement targetWindow) |
| Calculates and enforces size constraints for window resizing operations. | |
| void | OnMouseDown (MouseDownEvent e) |
| Handles mouse down events to initiate window resizing operations. | |
Private Attributes | |
| bool | _active |
| Indicates whether the resize operation is currently active. | |
| float | _clickXOffset |
| The horizontal offset between the mouse click position and the window's right edge. | |
| float | _clickYOffset |
| The vertical offset between the mouse click position and the window's bottom edge. | |
Static Private Attributes | |
| const float | MinHeight = 15f |
| The absolute minimum height that any window can be resized to, in pixels. | |
| const float | MinWidth = 15f |
| The absolute minimum width that any window can be resized to, in pixels. | |
This manipulator enables users to resize windows by dragging from a resize handle or corner. It enforces minimum and maximum size constraints while keeping windows within screen boundaries. The resizer integrates with the WindowFrame system to respect resize permissions and size limits.
Key Features:
| GWG.WindowFramework.Manipulators.WindowFrameResizer.WindowFrameResizer | ( | ) |
The constructor configures the manipulator to activate only on left mouse button clicks. This prevents conflicts with other mouse operations like context menus (right-click) or middle-click actions.
The manipulator will automatically register its event callbacks when added to a target element.
|
private |
| rootX | The requested X position of the mouse cursor |
| rootY | The requested Y position of the mouse cursor |
| targetWindow | The VisualElement being resized (typically a WindowFrame) |
This method implements comprehensive size constraint logic:
Size Calculation:
Constraint Enforcement (in order of priority):
The method ensures windows remain usable and visible while respecting both framework constraints and user-defined size limits.
|
private |
| e | The mouse down event data containing click position and button information |
This method performs the following operations when a valid resize operation begins:
The method will exit early if the target WindowFrame has AllowResize set to false. Click offsets are calculated to maintain consistent resize behavior regardless of exactly where on the resize handle the user clicks.
|
protected |
| e | The mouse move event data containing current mouse position |
This method continuously updates the window size while a resize operation is active:
The size calculation uses the stored click offsets to provide smooth, predictable resizing behavior. All size constraints and screen boundaries are enforced through the clamping function.
|
protected |
| e | The mouse up event data |
This method finalizes the resize operation when the user releases the mouse button:
After this method completes, the window retains its new size and normal mouse interaction is restored. The resize operation is fully complete.
|
protected |
This method is called automatically by the UI Toolkit when the manipulator is added to a target element. It registers callbacks for:
The callbacks are registered in the capture phase to ensure proper event handling even if other elements might intercept the events.
|
protected |
This method is called automatically by the UI Toolkit when the manipulator is removed from a target element or when the element is destroyed.
Proper unregistration prevents memory leaks and ensures clean disposal of event handlers when the manipulator is no longer needed.
|
private |
Set to true when a resize drag begins and false when it ends. Used to track the state of the resize operation and control event handling.
|
private |
Calculated during OnMouseDown to maintain consistent resize behavior. This offset ensures that the resize operation feels natural and responsive regardless of where exactly on the resize handle the user clicks.
|
private |
Calculated during OnMouseDown to maintain consistent resize behavior. This offset ensures that the resize operation feels natural and responsive regardless of where exactly on the resize handle the user clicks.
|
staticprivate |
This constant ensures windows remain usable and visible even at minimum size. The value is enforced in addition to any minHeight style property set on the window. A 15-pixel minimum ensures basic window chrome remains visible.
|
staticprivate |
This constant ensures windows remain usable and visible even at minimum size. The value is enforced in addition to any minWidth style property set on the window. A 15-pixel minimum ensures basic window chrome remains visible.