EngineWindow Class
This base class operates with engine windows: their components, relations with other windows, size, position, visual representation and other features.
When you create a window viewport or a window group, the engine window is created.
The image below demonstrates the window components that can be controlled by the EngineWindow class methods.
To create the engine window, use one of the EngineWindowViewportor EngineWindowGroupclass constructors. For example:
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 (system or engine), change the window state (whether it is shown/hidden, minimized/maximized, focused, etc.), manage window intersections and events.
Setting Up Position and Size#
In UNIGINE, the window size and position coordinates are measured in both units and pixels:
- The size and position in units don't depend on the DPI scale and always remain the same. You can change the window and client area size via setSize and setClientSize , adjust the minimum and maximum size and set the window and client position via the corresponding methods. All of them work with units.
-
The size and position in pixels are calculated by multiplying the size in units by the current DPI scale. You can get it using one of the RenderSize-related methods/properties (e.g., getRenderSize , and so on). When the DPI scale is 100%, 1 unit corresponds to 1 pixel.
NoticeDPI scaling is applied only when the auto_dpi_scalingflag is enabled. You can check the current flag value via the console or by using WindowManager.isAutoDpiScaling .
To determine how the OS handles the DPI scale, specify the DPI awareness mode.
You should consider this information when resizing textures, calculating mouse intersections, etc. The window size and position should be set individually, depending on the situation.
- Use one of the toRenderSize or toUnitSize to convert the size.
- Use globalToLocalUnitPosition to transform the coordinates in pixels into units or localUnitToGlobalPosition to do the opposite.
In the following example, the positions of the window and client area (in units) change to the mouse cursor when you press the P or C respectively:
Adjusting Visual Representation#
The window visual representation includes all available window parameters such as title and title bar, icon, borders, opacity, and window style (the engine or system one).
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.
The ability to customize the window style makes it possible to create a standard set of window settings for different systems and frameworks.
Setting Up Order#
In the following example, the order of the window under the cursor changes when you press the specific button: T to make the window appear on top of all other windows, A to always render the window above the other windows.
Changing Behavior#
With the set of behavior-related functions, you can do the following:
- Force the engine to stop operating while the engine window is opened.
- Ignore or allow using the OS methods for windows closing.
- Specify whether the window is resizable.
- Specify the sizing border size.
- Control rendering of the engine window - show, hide, focus, minimize, maximize, restore, or close.
Working with Modal Windows#
The following example demonstrates how to create modal windows and add modal children to the main window. Additionally, the main window includes a message that informs the user whether they can close the window or not.
EngineWindow Class
Members
Gui getGui() const#
Return value
Current Gui instance.int getDisplayIndex() const#
Return value
Current number of the display, on which the window is currently displayed.int isNested() const#
Return value
Current this is a nested window or group of windowsint isSeparate() const#
Return value
Current this is a separate window or group of windowsGui getSelfGui() const#
Return value
Current Gui instance.void setPosition ( ivec2 position ) #
Arguments
- ivec2 position - The window screen position (coordinates of the top left corner).
ivec2 getPosition() const#
Return value
Current window screen position (coordinates of the top left corner).void setClientPosition ( ivec2 position ) #
Arguments
- ivec2 position - The screen position of the client (coordinates of the top left corner).
ivec2 getClientPosition() const#
Return value
Current screen position of the client (coordinates of the top left corner).ivec2 getClientLocalPosition() const#
Return value
Current screen position of the client (coordinates of the top left corner) relative to the window position.void setSize ( ivec2 size ) #
Arguments
- ivec2 size - The engine window size in units (including the sizing border).
ivec2 getSize() const#
Return value
Current engine window size in units (including the sizing border).void setClientSize ( ivec2 size ) #
Arguments
- ivec2 size - The
ivec2 getClientSize() const#
Return value
Currentvoid setMinSize ( ivec2 size ) #
Arguments
- ivec2 size - The minimum possible size of the window.
ivec2 getMinSize() const#
Return value
Current minimum possible size of the window.void setMaxSize ( ivec2 size ) #
Arguments
- ivec2 size - The maximum possible size of the window.
ivec2 getMaxSize() const#
Return value
Current maximum possible size of the window.void setTitle ( string title ) #
Arguments
- string title - The title of the window.
const char * getTitle() const#
Return value
Current title of the window.void setOpacity ( float opacity ) #
Arguments
- float opacity - The opacity for the window.
float getOpacity() const#
Return value
Current opacity for the window.void setBordersEnabled ( int enabled ) #
Arguments
- int enabled - The borders for the window
int isBordersEnabled() const#
Return value
Current borders for the windowvoid setBorderSize ( int size ) #
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method should be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Arguments
- int size - The engine window border size.
int getBorderSize() const#
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method should be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Return value
Current engine window border size.void setResizable ( int resizable ) #
Arguments
- int resizable - The the option of making the engine window resizable by the mouse
int isResizable() const#
Return value
Current the option of making the engine window resizable by the mouseint isShown() const#
Return value
Current the engine window is renderedint isHidden() const#
Return value
Current the engine window isn't renderedint isFocused() const#
Return value
Current the engine window is in focusint isMinimized() const#
Return value
Current the engine window is minimizedint isMaximized() const#
Return value
Current the engine window is maximizedint getOrder() const#
Return value
Current order of the window.EngineWindowGroup getParentGroup() const#
Return value
Current group into which the current window is nested, or NULL if it is a separate window.EngineWindowGroup getGlobalParentGroup() const#
Return value
Current top group of the hierarchy into which the current window is nested, or NULL if it is a separate window.int getNumDroppedItems() const#
Return value
Current number of dropped files and/or folders.int getNumModalWindows() const#
Return value
Current total number of modal windows.getModalParent() const#
Return value
Current modal parent of the window.bool isModalParent() const#
Return value
true if the window is parent for any modal window; otherwise false.bool isModal() const#
Return value
true if the window is modal; otherwise false.void setIgnoreSystemClose ( bool close ) #
Arguments
- bool close - Set true to enable ignoring OS methods for closing the window; false - to disable it.
bool isIgnoreSystemClose() const#
Return value
true if ignoring OS methods for closing the window is enabled; otherwise false.void setHoldEngine ( bool engine ) #
Arguments
- bool engine - Set true to enable the engine can't stop operating while this window is open; false - to disable it.
bool isHoldEngine() const#
Return value
true if the engine can't stop operating while this window is open; otherwise false.getID() const#
Return value
Current ID of the engine window, if the window is external.void setAlwaysOnTop ( bool top ) #
Arguments
- bool top - Set true to enable the window is always on top; false - to disable it.
bool isAlwaysOnTop() const#
Return value
true if the window is always on top; otherwise false.bool isHiddenByTab() const#
Return value
true if the window is overlapped by any other tab; otherwise false.void setCanCreateGroup ( bool group ) #
Arguments
- bool group - Set true to enable usage of the engine window as a group; false - to disable it.
bool isCanCreateGroup() const#
Return value
true if usage of the engine window as a group is enabled; otherwise false.void setCanBeNested ( bool nested ) #
Arguments
- bool nested - Set true to enable usage of the engine window as a nested window; false - to disable it.
bool isCanBeNested() const#
Return value
true if usage of the engine window as a nested window is enabled; otherwise false.bool isSystemFocused() const#
Return value
true if the engine window is in focus; otherwise false.void setSizingBorderSize ( int size ) #
- This method should not be applied to a system-style window with enabled borders, as the system settings cannot be changed (for an unmodified system-style window (i.e. with the enabled border size), the system value is applied).
- This method should not be applied to nested windows (it will return 0).
Arguments
- int size - The size of the border in the widget that is manipulated to resize the window, in pixels.
int getSizingBorderSize() const#
- This method should not be applied to a system-style window with enabled borders, as the system settings cannot be changed (for an unmodified system-style window (i.e. with the enabled border size), the system value is applied).
- This method should not be applied to nested windows (it will return 0).
Return value
Current size of the border in the widget that is manipulated to resize the window, in pixels.void setEngineStyle ( bool style ) #
Arguments
- bool style - Set true to enable the engine style for the engine window; false - to disable it.
bool isEngineStyle() const#
Return value
true if the engine style for the engine window is enabled; otherwise false.void setSystemStyle ( bool style ) #
Arguments
- bool style - Set true to enable the default system style for the engine window; false - to disable it.
bool isSystemStyle() const#
Return value
true if the default system style for the engine window is enabled; otherwise false.void setTitleBarHeight ( int height ) #
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method can be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Arguments
- int height - The engine window title bar height.
int getTitleBarHeight() const#
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method can be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Return value
Current engine window title bar height.void setTitleBarEnabled ( bool enabled ) #
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method should be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Arguments
- bool enabled - Set true to enable the title bar for the engine window; false - to disable it.
bool isTitleBarEnabled() const#
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method should be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Return value
true if the title bar for the engine window is enabled; otherwise false.const char * getTypeName() const#
Return value
Current string representation of the engine window type.getType() const#
Return value
Current type of the engine window.float getDpiScale() const#
Return value
Current DPI scale applied to the elements inside the window.int getDpi() const#
Return value
Current DPI level for the window.getMaxRenderSize() const#
Return value
Current maximum window size in pixels.getMinRenderSize() const#
Return value
Current minimum window size in pixels.getClientRenderSize() const#
Return value
Current client area size in pixels.getRenderSize() const#
Return value
Current engine window frame size in pixels.getEventUnstack() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventStack() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventUnstackMove() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventItemDrop() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventClose() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventRestored() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventMaximized() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventMinimized() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventHidden() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventShown() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventMouseLeave() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventMouseEnter() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventUnfocused() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventFocused() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventResized() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventMoved() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventFuncSwap() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventFuncEndRender() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventFuncEndRenderGui() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventFuncBeginRenderGui() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventFuncRender() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventFuncBeginRender() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventFuncUpdate() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.getEventWindowEvent() const#
The event handler signature is as follows: myhandler()Usage Example
Return value
Event reference.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.int 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.int 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 ENGINE_WINDOW_HITTEST_* values.string getHitTestResultName ( int hit_test ) #
Returns the string representation of the hit test result value.Arguments
- int hit_test - Value indicating the window area, one of the ENGINE_WINDOW_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.int 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
1 if the current window is globally a child of the specified one, otherwise 0.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).int 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
1 if the mouse hovers over the current window, otherwise 0.int getClientIntersection ( ivec2 global_mouse_pos ) #
Arguments
- ivec2 global_mouse_pos - Global screen coordinates of the mouse relative to the main display.
Return value
1 if the mouse hovers over the client area of the window, otherwise 0.int 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 ( int area ) #
Returns the name of the screen segment as a string.Arguments
- int 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.The information on this page is valid for UNIGINE 2.20 SDK.