Workspace#
Fully qualified name: omni::ui::Workspace
Classes Summary#
- AppWindow
Singleton that tracks the current application window.
- AppWindowGuard
Guard that pushes the current application window to class AppWindow when created and pops when destroyed.
-
class Workspace#
Workspace object provides access to the windows in Kit.
TODO: It’s more like a namespace because all the methods are static. But the idea is to have it as a singleton, and it will allow using it as the abstract factory for many systems (Kit full and Kit mini for example).
Public Functions
-
Workspace() = delete#
Public Static Functions
-
static float getDpiScale()#
Returns current DPI Scale.
-
static std::vector<std::shared_ptr<WindowHandle>> getWindows()#
Returns the list of windows ordered from back to front.
If the window is a Omni::UI window, it can be upcasted.
- static std::shared_ptr<WindowHandle> getWindow(
- const std::string &title,
Find Window by name.
- static std::shared_ptr<WindowHandle> getWindowFromCallback(
- const windowmanager::IWindowCallback *callback,
Find Window by window callback.
- const std::shared_ptr<WindowHandle> &member,
Get all the windows that docked with the given widow.
-
static uint32_t getSelectedWindowIndex(uint32_t dockId)#
Get currently selected window inedx from the given dock id.
-
static void clear()#
Undock all.
-
static float getMainWindowWidth()#
Get the width in points of the current main window.
Returns 0 if no main window is found.
-
static float getMainWindowHeight()#
Get the height in points of the current main window.
Returns 0 if no main window is found.
- static std::vector<std::shared_ptr<WindowHandle>> getDockedWindows(
- uint32_t dockId,
Get all the windows of the given dock ID.
-
static uint32_t getParentDockId(uint32_t dockId)#
Return the parent Dock Node ID.
- Parameters:
dockId – the child Dock Node ID to get parent
- static bool getDockNodeChildrenId(
- uint32_t dockId,
- uint32_t &first,
- uint32_t &second,
Get two dock children of the given dock ID.
- Parameters:
dockId – the given dock ID
first – output. the first child dock ID
second – output. the second child dock ID
- Returns:
true if the given dock ID has children
-
static WindowHandle::DockPosition getDockPosition(uint32_t dockId)#
Returns the position of the given dock ID.
Left/Right/Top/Bottom
-
static float getDockIdWidth(uint32_t dockId)#
Returns the width of the docking node.
- Parameters:
dockId – the given dock ID
-
static float getDockIdHeight(uint32_t dockId)#
Returns the height of the docking node.
It’s different from the window height because it considers dock tab bar.
- Parameters:
dockId – the given dock ID
-
static void setDockIdWidth(uint32_t dockId, float width)#
Set the width of the dock node.
It also sets the width of parent nodes if necessary and modifies the width of siblings.
- Parameters:
dockId – the given dock ID
width – the given width
-
static void setDockIdHeight(uint32_t dockId, float height)#
Set the height of the dock node.
It also sets the height of parent nodes if necessary and modifies the height of siblings.
- Parameters:
dockId – the given dock ID
height – the given height
-
static bool showWindow(const std::string &title, bool show = true)#
Makes the window visible or create the window with the callback provided with set_show_window_fn.
- Parameters:
title – the given window title
show – true to show, false to hide
- Returns:
true if the window is already created, otherwise it’s necessary to wait one frame
- std::function<void(const std::shared_ptr<WindowHandle> &window)> windowCreatedCallbackFn,
Addd the callback that is triggered when a new window is created.
- static void setShowWindowFn(
- const std::string &title,
- std::function<void(bool)> showWindowFn,
Add the callback to create a window with the given title.
When the callback’s argument is true, it’s necessary to create the window. Otherwise remove.
-
static std::vector<std::string> getShowWindowTitles()#
Get all window titles that have a show window callback.
- static uint32_t setWindowVisibilityChangedCallback(
- std::function<void(const std::string &title, bool visible)> windowVisibilityChangedCallbackFn,
Add the callback that is triggered when a window’s visibility changed.
-
static void removeWindowVisibilityChangedCallback(uint32_t id)#
Remove the callback that is triggered when a window’s visibility changed.
- static void onWindowVisibilityChanged(
- const std::string &title,
- bool visible,
Call it from inside each windows’ setVisibilityChangedFn to triggered VisibilityChangedCallback.
- static void setWindowFirstInteractionCallback(
- std::function<void(const std::string &title, const std::string &ownerModule)> callbackFn,
Set a callback to be fired the first time the user clicks inside any ui.Window.
Used by the omni.ui Python extension-usage telemetry hook. The callback receives the Window title and the Python module name that constructed the Window (may be empty if unattributable). The Python side resolves the module to an extension id via the extension manager. Invoked at most once per Window lifetime. nullptr disables the hook.
- static void onWindowFirstInteraction(
- const std::string &title,
- const std::string &ownerModule,
Internal: invoked by Window::_draw the first time a mouse click is observed inside a Window.
Forwards to the registered first-interaction callback if any.
-
class AppWindow#
Singleton that tracks the current application window.
-
Workspace() = delete#