Unigine.EngineWindow Class
This base class is used to manage engine windows: their components, relations with other windows, size, position, and other features. The EngineWindow class doesn't provide creating of a window viewport or a window group: you can create them using constructors of the corresponding classes inherited from the EngineWindow class.
The image below demonstrates the window components that can be controlled by the EngineWindow class methods.
Here are some window examples:
A system-style window
|
A window (either system or engine style),
borders and title bar disabled |
An engine-style window, borders disabled
|
An engine-style window, borders enabled
|
The system and engine style windows have the same component layout except the sizing border: in the engine style, it is in the visual part of the window.
To create the engine window, you should use one of the EngineWindowViewport class constructors. For example:
// create an engine window of the specified size with the specified name
EngineWindowViewport window = new EngineWindowViewport("Window", 580, 300);
Then, by using methods of the EngineWindow class, you can specify the window appearance (for example, set a title, an icon, change opacity, add borders, and so on), and properties (whether the window can be nested, or whether it can become a group), define its style (sytem or engine), change the window state (whether it is shown/hidden, minimized/maximized, focused, etc.), manage window intersections and callbacks.
// set an icon and a new title for the window
window.SetIcon(icon);
window.Title = "Vertical Group";
// set a window position and size
window.Position = new ivec2(60, 60);
window.Size = new ivec2(580, 300);
// set window properties
window.CanBeNested = false;
window.CanCreateGroup = false;
// show the window
window.Show();
The created window can remain a separate one, or it can be grouped with the other window(s). The window group is created and managed by means of the EngineWindowGroup class. By using methods of the Enginewindow class, you can specify whether the window can be added to the group, get the parent of the window or remove it from the group.
// separate windows
EngineWindowViewport settings = new EngineWindowViewport("Settings", 512, 256);
EngineWindowViewport parameters = new EngineWindowViewport("Parameters", 512, 256);
// grouped windows
EngineWindow settings_and_parameters = WindowManager.StackWindows(settings, parameters, EngineWindowGroup.GROUP_TYPE.TAB);
To render the engine window, use the Show() function.
EngineWindow Class
Enums
HITTEST#
CALLBACK_INDEX#
FLAGS#
AREA#
TYPE#
Name | Description |
---|---|
ENGINE_WINDOW = 0 | Engine window. |
ENGINE_WINDOW_VIEWPORT = 1 | Engine viewport window. |
ENGINE_WINDOW_GROUP = 2 | Engine window group. |
NUM_ENGINE_WINDOWS = 3 | Total number of engine windows. |
Properties
Gui Gui#
int DisplayIndex#
bool IsNested#
bool IsSeparate#
Gui SelfGui#
ivec2 Position#
ivec2 ClientPosition#
ivec2 ClientLocalPosition#
ivec2 Size#
ivec2 ClientSize#
ivec2 MinSize#
ivec2 MaxSize#
string Title#
float Opacity#
bool BordersEnabled#
int BorderSize#
bool Resizable#
bool IsShown#
bool IsHidden#
bool IsFocused#
bool IsMinimized#
bool IsMaximized#
int Order#
EngineWindowGroup ParentGroup#
EngineWindowGroup GlobalParentGroup#
int NumDroppedItems#
int NumModalWindows#
EngineWindow ModalParent#
bool IsModalParent#
bool IsModal#
bool IgnoreSystemClose#
bool HoldEngine#
ulong ID#
bool AlwaysOnTop#
bool IsHiddenByTab#
bool CanCreateGroup#
bool CanBeNested#
bool IsSystemFocused#
int SizingBorderSize#
bool EngineStyle#
bool SystemStyle#
int TitleBarHeight#
bool TitleBarEnabled#
string TypeName#
EngineWindow.TYPE Type#
float DpiScale#
int Dpi#
ivec2 MaxRenderSize#
ivec2 MinRenderSize#
ivec2 ClientRenderSize#
ivec2 RenderSize#
Members
void MoveToCenter ( ) #
Positions the window so that the client center coincides with the center of the current display.void SetMinAndMaxSize ( ivec2 min_size, ivec2 max_size ) #
Sets the minimum and maximum possible window size when resizing the window.Arguments
- ivec2 min_size - The minimum possible size of the window.
- ivec2 max_size - The maximum possible size of the window.
int SetIcon ( Image image ) #
Sets the icon for the window.Arguments
- Image image - The icon for the window.
Return value
1 if the specified icon is successfully set for the window, otherwise 0.Image GetIcon ( ) #
Returns the icon for the engine window.Return value
The icon for the window.1 if the icon for the window is returned successfully, otherwise 0.void Show ( ) #
Enables rendering of the engine window.void Hide ( ) #
Disables rendering of the engine window.void SetFocus ( ) #
Sets the focus to the window.void SetSystemFocus ( ) #
Sets the focus to the engine window.void Minimize ( ) #
Minimizes the engine window to an iconic representation.void Maximize ( ) #
Makes the engine window as large as possible.void Restore ( ) #
Restores the size and position of the minimized or maximized engine window via the system proxy.EngineWindow.HITTEST GetHitTestResult ( ivec2 global_pos ) #
Returns a value indicating in which area of the engine window the mouse is located.Arguments
- ivec2 global_pos - Global coordinates of the hit-test point.
Return value
Value indicating the window area, one of the HITTEST.* values.string GetHitTestResultName ( EngineWindow.HITTEST hit_test ) #
Returns the string representation of the hit test result value.Arguments
- EngineWindow.HITTEST hit_test - Value indicating the window area, one of the HITTEST.* values.
Return value
The string representation of the hit test result value (e.g., HITTEST_RESIZE_RIGHT is RESIZE RIGHT).void ToTop ( ) #
Makes the window appear on top of all other windows.bool IsGlobalChildOf ( EngineWindowGroup group ) #
Returns the value specifying if the current window is a part of a hierarchy of the specified window.Arguments
- EngineWindowGroup group - Window to be checked.
Return value
true if the current window is globally a child of the specified one, otherwise false.void UpdateGuiHierarchy ( ) #
Updates the hierarchy for all widgets — the widgets are arranged, expanded to the required sizes and then their positions are updated. Updating the hierarchy may be required, for example, for getting the screen position immediately after the widget has been added to the hierarchy. For a separate window, the hierarchy in self gui is updated; for a nested window, the hierarchy in self gui of the global parent group is updated.string GetDroppedItem ( int index ) #
Returns the absolute path to the file or folder dropped to the window.Arguments
- int index - Index of the dropped file or folder.
Return value
Absolute path to the dropped file or folder.void Screenshot ( string path ) #
Creates a screenshot after the rendering stage is completed.Arguments
- string path - Path to save the screenshot.
void SetModal ( EngineWindow parent_window ) #
Sets the current window modal to the specified parent window. Both the parent and the child windows must be separate. The concept of modal assumes that if a window has modal children, it cannot be closed. Any other interaction with a parent window is possible.Arguments
- EngineWindow parent_window - Parent window.
void AddModalWindow ( EngineWindow window ) #
Adds the argument window as modal to the current window. Both the parent and the child windows must be separate. The concept of modal assumes that if a window has modal children, it cannot be closed. Any other interaction with a parent window is possible.Arguments
- EngineWindow window - Window to be added as modal.
void RemoveModalWindow ( EngineWindow window ) #
Removes the argument modal window from this window. The concept of modal assumes that if a window has modal children, it cannot be closed. Any other interaction with a parent window is possible.Arguments
- EngineWindow window - Engine window.
EngineWindow GetModalWindow ( int index ) #
Returns the modal window for this window by its index. The concept of modal assumes that if a window has modal children, it cannot be closed. Any other interaction with a parent window is possible.Arguments
- int index - Index of the modal window.
Return value
Modal window.void Unstack ( ) #
Removes the current window from a parent group.void Close ( ) #
Deletes the window if this window is not a modal parent or a member of a fixed group. If a window is a member of a fixed group, it cannot be closed (i.e. deleted).bool GetIntersection ( ivec2 global_mouse_pos ) #
Returns the value indicating if the mouse is hovering over the window.Arguments
- ivec2 global_mouse_pos - Global screen coordinates of the mouse relative to the main display.
Return value
true if the mouse hovers over the current window, otherwise false.bool GetClientIntersection ( ivec2 global_mouse_pos ) #
Returns the value indicating if the mouse is hovering over the client area of the window.//checks if the mouse is hovering over the main window
EngineWindow main_window = WindowManager.MainWindow;
main_window.GetClientIntersection(Input.MousePosition);
Arguments
- ivec2 global_mouse_pos - Global screen coordinates of the mouse relative to the main display.
Return value
true if the mouse hovers over the client area of the window, otherwise false.EngineWindow.AREA GetClient9Area ( ivec2 global_mouse_pos ) #
Returns the area over which the mouse hovers, one of the nine areas into which the window is segmented.Arguments
- ivec2 global_mouse_pos - Global screen coordinates of the mouse relative to the main display.
Return value
One of the nine segments the screen area is split into.string Get9AreaName ( EngineWindow.AREA area ) #
Returns the name of the screen segment as a string.Arguments
- EngineWindow.AREA area - One of the nine segments the screen area is split into.
Return value
The string representation of the segment value (e.g., AREA_TOP_LEFT is TOP LEFT).ivec2 GlobalToLocalUnitPosition ( ivec2 global_pos ) #
Transforms the global screen coordinates in pixels into units relative to the window client area.Arguments
- ivec2 global_pos - The position in global coordinates.
Return value
The coordinates in units relative to the window client area.ivec2 LocalUnitToGlobalPosition ( ivec2 unit_pos ) #
Transforms the position in units relative to the window client area into the global screen coordinates in pixels.Arguments
- ivec2 unit_pos - The coordinates in units relative to the window client area.
Return value
The position in global coordinates.ivec2 GetRenderSize ( ) #
Returns the engine window frame size in pixels.Return value
The engine window frame size in pixels.ivec2 GetClientRenderSize ( ) #
Returns the client area size in pixels.Return value
The client area size in pixels.ivec2 GetMinRenderSize ( ) #
Returns the minimum window size in pixels.Return value
The minimum window size in pixels.ivec2 GetMaxRenderSize ( ) #
Returns the maximum window size in pixels.Return value
The maximum window size in pixels.int GetDpi ( ) #
Returns the current DPI level for the window.Return value
The current DPI level for the window.float GetDpiScale ( ) #
Returns the current DPI scale applied to the elements inside the window.Return value
The current DPI scale applied to the elements inside the window.int ToRenderSize ( int unit_size ) #
Transforms the unit value to the pixel value.Arguments
- int unit_size - Size in units.
Return value
Size in pixels.int ToUnitSize ( int render_size ) #
Transforms the pixel value to the unit value.Arguments
- int render_size - Size in pixels.
Return value
Size in units.ivec2 ToRenderSize ( ivec2 unit_size ) #
Transforms the unit value to the pixel value.Arguments
- ivec2 unit_size - Size in units.
Return value
Size in pixels.ivec2 ToUnitSize ( ivec2 render_size ) #
Transforms the pixel value to the unit value.Arguments
- ivec2 render_size - Size in pixels.