Unigine::EngineWindow Class
Header: | #include <UnigineWindowManager.h> |
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
EngineWindowViewportPtr window = EngineWindowViewport::create("New 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->setTitle("Main window");
// set a window position and size
window->setPosition(Math::ivec2(60, 60));
window->setSize(Math::ivec2(580, 300));
// set window properties
window->setCanBeNested(false);
window->setCanCreateGroup(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
EngineWindowViewportPtr settings = EngineWindowViewport::create("Settings", 512, 256);
EngineWindowViewportPtr parameters = EngineWindowViewport::create("Parameters", 512, 256);
// grouped windows
EngineWindowGroupPtr settings_and_parameters = WindowManager::stackWindows(settings, parameters, EngineWindowGroup::GROUP_TYPE_TAB);
To render the engine window, use the show() function.
See Also#
- A set of SDK samples (samples/Api/WindowManager) demonstrating various usage aspects.
EngineWindow Class
Enums
HITTEST#
CALLBACK_INDEX#
FLAGS#
AREA#
TYPE#
Name | 说明/描 述 |
---|---|
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. |
Members
Ptr<Gui> getGui ( ) const#
Returns the parent Gui for a window. If the window is nested, this Gui differs from SelfGui.Return value
Gui instance.Ptr<Gui> getSelfGui ( ) const#
Returns Gui instance for a window. This Gui remains unchanged during the whole lifecycle of the window.Return value
Gui instance.int getDisplayIndex ( ) const#
Returns the number of the display, on which the window is currently displayed. For separate windows, this index is requested from the system proxy; for nested windows, the index is provided based on the location of the client center point.Return value
The number of the display, on which the window is currently displayed.bool isNested ( ) const#
Returns a value indicating if the object is a nested window or group of windows.Return value
true for a nested window or group of windows, otherwise false.bool isSeparate ( ) const#
Returns a value indicating if the object is a separate window or group of windows.Return value
true for a separate window or group of windows, otherwise false.void setPosition ( const Math::ivec2 & position ) #
Sets the position of the top left corner of the window in the screen coordinates. In case of several displays, the position is relative to the main display.Arguments
- const Math::ivec2 & position - The window screen position (coordinates of the top left corner).
Math::ivec2 getPosition ( ) const#
Returns the position of the top left corner of the window in the screen coordinates. In case of several displays, the position is relative to the main display.Return value
The window screen position (coordinates of the top left corner).void setClientPosition ( const Math::ivec2 & position ) #
Sets the position of the top left corner of the client (the window content area without the top bar and borders) in the screen coordinates. In case of several displays, the position is relative to the main display.Arguments
- const Math::ivec2 & position - The screen position of the client (coordinates of the top left corner).
Math::ivec2 getClientPosition ( ) const#
Returns the position of the top left corner of the client (the window content area without the top bar and borders) in the screen coordinates. In case of several displays, the position is relative to the main display. For a nested window, the window position is returned.Return value
The screen position of the client (coordinates of the top left corner).Math::ivec2 getClientLocalPosition ( ) const#
Returns the position of the top left corner of the client (the window content area without the top bar and borders) relative to the window position.Return value
The screen position of the client (coordinates of the top left corner) relative to the window position.void moveToCenter ( ) #
Positions the window so that the client center coincides with the center of the current display.void setSize ( const Math::ivec2 & size ) #
Sets the engine window size (i.e. including the sizing border).Arguments
- const Math::ivec2 & size - The engine window size.
Math::ivec2 getSize ( ) const#
Returns the engine window size (i.e. including the sizing border).Return value
The engine window size.Math::ivec2 getClientSize ( ) const#
Returns the size of the window client (content) area.Return value
The size of the client area.void setMinSize ( const Math::ivec2 & size ) #
Sets the minimum possible window size when resizing the window. If the value is more than the current maximum size, use the setMinAndMaxSize() method, to change both values at once. Otherwise the value will be clamped to the current maximum size.Arguments
- const Math::ivec2 & size - The minimum possible size of the window.
Math::ivec2 getMinSize ( ) const#
Returns the minimum possible window size when resizing the window.Return value
The minimum possible size of the window.void setMaxSize ( const Math::ivec2 & size ) #
Sets the maximum possible window size when resizing the window. If the value is less than the current minimum size, use the setMinAndMaxSize() method, to change both values at once. Otherwise the value will be clamped to the current minimum size.Arguments
- const Math::ivec2 & size - The maximum possible size of the window.
Math::ivec2 getMaxSize ( ) const#
Returns the maximum possible window size when resizing the window.Return value
The maximum possible size of the window.void setMinAndMaxSize ( const Math::ivec2 & min_size, const Math::ivec2 & max_size ) #
Sets the minimum and maximum possible window size when resizing the window.Arguments
- const Math::ivec2 & min_size - The minimum possible size of the window.
- const Math::ivec2 & max_size - The maximum possible size of the window.
void setTitle ( const char * title ) #
Sets the text of the title for the window. For a separate window, the title is set via system proxy in the title bar only; for a nested window, it is also set in the tab of the parent group.Arguments
- const char * title - The title of the window.
const char * getTitle ( ) const#
Returns the text of the title for the window. For a separate window, the icon is set via system proxy in the title bar only; for a nested window, it is also set in the tab of the parent group.Return value
The title for the engine window.int setIcon ( const Ptr<Image> & image ) #
Sets the icon for the window.Arguments
Return value
1 if the specified icon is successfully set for the window, otherwise 0.Ptr<Image> getIcon ( ) const#
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 setOpacity ( float opacity ) #
Sets the opacity for the window.Arguments
- float opacity - Opacity for the window.
float getOpacity ( ) const#
Returns the current opacity for the window.Return value
The opacity for the window.void setBordersEnabled ( bool enabled ) #
Enables and disables the borders for the window.Arguments
- bool enabled - true to enable the borders for the window, otherwise false.
bool isBordersEnabled ( ) const#
Returns the value indicating if the borders are enabled for the window.Return value
true if the borders are enabled for the window, otherwise false.void setBorderSize ( int size ) #
Sets the engine window border 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.
Arguments
- int size - The engine window border size.
int getBorderSize ( ) const#
Returns the engine window border 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, for a nested window it will return 0.
Return value
The engine window border size.void setResizable ( bool resizable ) #
Enables and disables the possibility to resize the engine window by the mouse.Arguments
- bool resizable - true to make the engine window resizable by the mouse, otherwise false.
bool isResizable ( ) const#
Returns the value indicating if the engine window is resizable by the mouse.Return value
true if the engine window is resizable by the mouse, otherwise false.void show ( ) #
Enables rendering of the engine window.bool isShown ( ) const#
Returns a value indicating if a widget is rendered.Return value
true if the engine window is rendered, otherwise false.void hide ( ) #
Disables rendering of the engine window.bool isHidden ( ) const#
Returns a value indicating if a widget is hidden.Return value
true if the engine window isn't rendered, otherwise false.void setFocus ( ) #
Sets the focus to the window.bool isFocused ( ) const#
Returns the value indicating if the window is currently in focus. For a separate or parent window, the returned value coinsides with the value returned by isSystemFocused().Return value
true if the engine window is in focus, otherwise false.void setSystemFocus ( ) #
Sets the focus to the engine window.bool isSystemFocused ( ) const#
Returns the value indicating if the engine window is currently in focus.Return value
true if the engine window is in focus, otherwise false.void minimize ( ) #
Minimizes the engine window to an iconic representation.bool isMinimized ( ) const#
Returns the value indicating if the engine window is minimized to tray.Return value
true if the engine window is minimized, otherwise false.void maximize ( ) #
Makes the engine window as large as possible.bool isMaximized ( ) const#
Returns the value indicating if the engine window is maximized.Return value
true if the engine window is maximized, otherwise false.void restore ( ) #
Restores the size and position of the minimized or maximized engine window via the system proxy.EngineWindow::HITTEST getHitTestResult ( const Math::ivec2 & global_pos ) #
Returns a value indicating in which area of the engine window the mouse is located.Arguments
- const Math::ivec2 & global_pos - Global coordinates of the hit-test point.
Return value
Value indicating the window area, one of the HITTEST_* values.const char * getHitTestResultName ( EngineWindow::HITTEST hit_test ) const#
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).int getOrder ( ) const#
Returns the order of the window. This value allows comparing which window is closer to the viewer (a relatively smaller value).Return value
The order of the window.void toTop ( ) #
Makes the window appear on top of all other windows.void setAlwaysOnTop ( bool top ) #
Sets the window to always be rendered above the other windows.Arguments
- bool top - true to render the window always on top; otherwise, false.
bool isAlwaysOnTop ( ) const#
Returns the value indicating if the window is always rendered above the other windows.Return value
true if the window is always on top; otherwise, false.Ptr<EngineWindowGroup> getParentGroup ( ) const#
Returns the group into which the current window is nested, or nullptr if it is a separate window.Return value
The group into which the current window is nested, or nullptr if it is a separate window.Ptr<EngineWindowGroup> getGlobalParentGroup ( ) const#
Returns the top group of the hierarchy into which the current window is nested, or nullptr if it is a separate window.Return value
The top group of the hierarchy into which the current window is nested, or nullptr if it is a separate window.bool isGlobalChildOf ( const Ptr<EngineWindowGroup> & group ) #
Returns the value specifying if the current window is a part of a hierarchy of the specified window.Arguments
- const Ptr<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.int getNumDroppedItems ( ) const#
Returns the total number of files and/or folders dropped to the window.Return value
The number of dropped files and/or folders.const char * getDroppedItem ( int index ) const#
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.unsigned long long getID ( ) const#
Returns the ID of the engine window, which is unchanged during the whole lifecycle of the window.Return value
ID of the engine window, if the window is external.void screenshot ( const char * path ) #
Creates a screenshot after the rendering stage is completed.Arguments
- const char * path - Path to save the screenshot.
void setHoldEngine ( bool engine ) #
Sets the value indicating if the engine can stop operating (quit automatically) while this window is open.Arguments
- bool engine - true if the engine can't stop operating while this window is open, otherwise false.
bool isHoldEngine ( ) const#
Sets the value indicating if the engine can stop operating (quit automatically) while this window is open.Return value
true if the engine can't stop operating while this window is open, otherwise false.void setIgnoreSystemClose ( bool close ) #
Sets the value indicating if this window can be closed using the OS methods (ALT+F4 or cross in the top-right corner of the window).Arguments
- bool close - If true, the window can't be closed using the OS methods.
bool isIgnoreSystemClose ( ) const#
Returns the value indicating if this window can be closed using the OS methods (ALT+F4 or cross in the top-right corner of the window).Return value
If true, the window can't be closed using the OS methods.void setModal ( const Ptr<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
- const Ptr<EngineWindow> & parent_window - Parent window.
bool isModal ( ) const#
Checks if the window is modal. 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.Return value
true if the window is modal; otherwise, false.bool isModalParent ( ) const#
Checks if this window is parent for any modal 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.Return value
true if the window is parent for any modal window; otherwise, false.Ptr<EngineWindow> getModalParent ( ) const#
Returns the modal parent of the 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.Return value
The modal parent of the window.void addModalWindow ( const Ptr<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
- const Ptr<EngineWindow> & window - Window to be added as modal.
void removeModalWindow ( const Ptr<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
- const Ptr<EngineWindow> & window - Engine window.
int getNumModalWindows ( ) const#
Returns the total number of modal windows for 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.Return value
The total number of modal windows.Ptr<EngineWindow> getModalWindow ( int index ) const#
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.EngineWindow::TYPE getType ( ) const#
Returns the type of the engine window.Return value
The type of the engine window.const char * getTypeName ( ) const#
Returns the name of the engine window type as a string.Return value
The string representation of the engine window type.void setTitleBarEnabled ( bool enabled ) #
Enables and disables the title bar for the window.- 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.
Arguments
- bool enabled - true to enable the title bar for the engine window, otherwise false.
bool isTitleBarEnabled ( ) const#
Returns the value indicating if the title bar is enabled for the window.- 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, for a nested window it will return false.
Return value
true if the title bar is enabled for the engine window, otherwise false.void setTitleBarHeight ( int height ) #
Sets the height of the window title bar.- 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.
Arguments
- int height - The engine window title bar height.
int getTitleBarHeight ( ) const#
Returns the height of the window title bar.- 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, for a nested window it will return 0.
Return value
The engine window title bar height.void setSystemStyle ( bool style ) #
Sets the system style for the engine window.Arguments
- bool style - true to set the default system style for the engine window, false to set the engine-style window.
bool isSystemStyle ( ) const#
Returns the value indicating if the default system style is set for the engine window.Return value
true if the default system style is set for the engine window; false if the engine style is set for the window.void setEngineStyle ( bool style ) #
Sets the engine style for the engine window.Arguments
- bool style - true to set the engine style for the engine window, false to set the default system style.
bool isEngineStyle ( ) const#
Returns the value indicating if the engine style is set for the engine window.Return value
true if the engine style is set for the engine window; false if the default system style is set for the window.void setSizingBorderSize ( int size ) #
Sets the size of the border in the widget that is manipulated to resize the window.- This method should not be applied to a system-style window with enabled borders, as the system settings cannot be changed.
- This method should not be applied to nested windows.
Arguments
- int size - The size of the border that is manipulated to resize the window, in pixels.
int getSizingBorderSize ( ) const#
Returns the size of the border in the widget that is manipulated to resize the window.- This method should be applied to an engine-style window, for an unmodified system-style window (i.e. with the enabled border size), the system value is applied.
- This method should be applied to a separate or parent window, for a nested window it will return 0.
Return value
The size of the border in the widget that is manipulated to resize the window, in pixels.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).void setCanBeNested ( bool nested ) #
Sets the value indicating if the engine window can be used as a nested window.Arguments
- bool nested - true to enable usage of the engine window as a nested window, otherwise false.
bool isCanBeNested ( ) const#
Returns the value indicating if the engine window can be used as a nested window.Return value
true if usage of the engine window as a nested window is enabled, otherwise false.void setCanCreateGroup ( bool group ) #
Sets the value indicating if the engine window can become a group.Arguments
- bool group - true to enable usage of the engine window as a group, otherwise false.
bool isCanCreateGroup ( ) const#
Returns the value indicating if the engine window can become a group.Return value
true if usage of the engine window as a group is enabled, otherwise false.bool isHiddenByTab ( ) const#
Returns the value indicating if the window is overlapped by any other tab (either by switching to another tab or resizing this window to have zero client area).Return value
true if the window is overlapped by any other tab, otherwise false.bool getIntersection ( const Math::ivec2 & global_mouse_pos ) const#
Returns the value indicating if the mouse is hovering over the window.Arguments
- const Math::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 ( const Math::ivec2 & global_mouse_pos ) const#
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
WindowManager::getMainWindow()->getClientIntersection(Input::getMousePosition());
Arguments
- const Math::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 ( const Math::ivec2 & global_mouse_pos ) const#
Returns the area over which the mouse hovers, one of the nine areas into which the window is segmented.Arguments
- const Math::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.const char * get9AreaName ( EngineWindow::AREA area ) const#
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).Math::ivec2 globalToLocalUnitPosition ( const Math::ivec2 & global_pos ) const#
Transforms the global screen coordinates in pixels into units relative to the window client area.Arguments
- const Math::ivec2 & global_pos - The position in global coordinates.
Return value
The coordinates in units relative to the window client area.Math::ivec2 localUnitToGlobalPosition ( const Math::ivec2 & unit_pos ) const#
Transforms the position in units relative to the window client area into the global screen coordinates in pixels.Arguments
- const Math::ivec2 & unit_pos - The coordinates in units relative to the window client area.
Return value
The position in global coordinates.Math::ivec2 getRenderSize ( ) const#
Returns the engine window frame size in pixels.Return value
The engine window frame size in pixels.Math::ivec2 getClientRenderSize ( ) const#
Returns the client area size in pixels.Return value
The client area size in pixels.Math::ivec2 getMinRenderSize ( ) const#
Returns the minimum window size in pixels.Return value
The minimum window size in pixels.Math::ivec2 getMaxRenderSize ( ) const#
Returns the maximum window size in pixels.Return value
The maximum window size in pixels.int getDpi ( ) const#
Returns the current DPI level for the window.Return value
The current DPI level for the window.float getDpiScale ( ) const#
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.Math::ivec2 toRenderSize ( const Math::ivec2 & unit_size ) #
Transforms the unit value to the pixel value.Arguments
- const Math::ivec2 & unit_size - Size in units.
Return value
Size in pixels.Math::ivec2 toUnitSize ( const Math::ivec2 & render_size ) #
Transforms the pixel value to the unit value.Arguments
- const Math::ivec2 & render_size - Size in pixels.