file_path
stringlengths 32
153
| content
stringlengths 0
3.14M
|
---|---|
omniverse-code/kit/include/omni/ui/HStack.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Stack.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief Shortcut for Stack{eLeftToRight}. The widgets are placed in a row, with suitable sizes.
*
* @see Stack
*/
class OMNIUI_CLASS_API HStack : public Stack
{
OMNIUI_OBJECT(HStack)
public:
OMNIUI_API
~HStack() override;
protected:
/**
* @brief Construct a stack with the widgets placed in a row from left to right.
*/
OMNIUI_API
HStack();
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Menu.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "MenuHelper.h"
#include "Stack.h"
#include <omni/ui/windowmanager/IWindowCallbackManager.h>
namespace omni
{
namespace kit
{
struct Window;
}
}
OMNIUI_NAMESPACE_OPEN_SCOPE
class Frame;
/**
* @brief The Menu class provides a menu widget for use in menu bars, context menus, and other popup menus.
*
* It can be either a pull-down menu in a menu bar or a standalone context menu. Pull-down menus are shown by the menu
* bar when the user clicks on the respective item. Context menus are usually invoked by some special keyboard key or by
* right-clicking.
*
* TODO: Add the ability to add any widget. ATM if a random widget is added to Menu, the behaviour is undefined.
*/
class OMNIUI_CLASS_API Menu : public Stack, public MenuHelper
{
OMNIUI_OBJECT(Menu)
public:
using CallbackHelperBase = Widget;
OMNIUI_API
~Menu() override;
OMNIUI_API
void destroy() override;
/**
* @brief Reimplemented adding a widget to this Menu.
*
* @see Container::addChild
*/
OMNIUI_API
void addChild(std::shared_ptr<Widget> widget) override;
/**
* @brief Reimplemented removing all the child widgets from this Menu.
*
* @see Container::clear
*/
OMNIUI_API
void clear() override;
/**
* @brief Reimplemented the method to indicate the width hint that represents the preferred size of the widget.
*
* @see Widget::setComputedContentWidth
*/
OMNIUI_API
void setComputedContentWidth(float width) override;
/**
* @brief Reimplemented the method to indicate the height hint that represents the preferred size of the widget.
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) override;
/**
* @brief It's called when the style is changed. It should be propagated to children to make the style cached and
* available to children.
*/
OMNIUI_API
void cascadeStyle() override;
/**
* @brief Create a popup window and show the menu in it. It's usually used for context menus that are typically
* invoked by some special keyboard key or by right-clicking.
*/
OMNIUI_API
void show();
/**
* @brief Create a popup window and show the menu in it. This enable to popup the menu at specific position. X and Y
* are in points to make it easier to the Python users.
*/
OMNIUI_API
void showAt(float x, float y);
/**
* @brief Close the menu window. It only works for pop-up context menu and
* for teared off menu.
*/
OMNIUI_API
void hide();
/**
* @brief Make Menu dirty so onBuild will be executed to replace the
* children.
*/
OMNIUI_API
void invalidate();
/**
* @brief Return the menu that is currently shown.
*/
OMNIUI_API
static std::shared_ptr<Menu> getCurrent();
/**
* @brief It's true when the menu is shown on the screen.
*/
OMNIUI_PROPERTY(bool, shown, DEFAULT, false, READ, isShown, NOTIFY, setShownChangedFn, PROTECTED, WRITE, _setShown);
/**
* @brief The ability to tear the window off.
*/
OMNIUI_PROPERTY(
bool, tearable, DEFAULT, true, READ, isTearable, WRITE, setTearable, PROTECTED, NOTIFY, _setTearableChangedFn);
/**
* @brief If the window is teared off.
*/
OMNIUI_PROPERTY(bool, teared, DEFAULT, false, READ, isTeared, NOTIFY, setTearedChangedFn, PROTECTED, WRITE, _setTeared);
/**
* @brief Called to re-create new children
*/
OMNIUI_CALLBACK(OnBuild, void);
protected:
/**
* @brief Construct Menu
*
* @param text The text for the menu.
*/
OMNIUI_API
Menu(const std::string& text);
/**
* @brief Reimplemented the rendering code of the widget.
*
* Draw the content.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
void _drawMenu(float elapsedTime, bool isInSeparateWindow, bool isPopupWindow);
void _showMenuWindow(float x, float y);
/**
* @brief Creates a popup window to put the menu to using the underlying windowing system.
*/
void _createMenuWindow(bool isPopupWindow);
/**
* @brief Removes previously created popup window using the underlying windowing system. If window wasn't created,
* it does nothing.
*/
void _removeMenuWindow(bool removeCurrent);
/**
* @brief We cannot destroy window when we are right in the middle of
* rendering loop. Thus, we schedule a one-time deferred callback which will
* destroy the window.
*/
void _removeMenuWindowDeferred(bool removeCurrent);
/**
* @brief Check if the title is dirty and call the delegate to build the
* window title.
*/
void _verifyTitleFrame();
/**
* @brief Check if the is dirty and call the delegate to build the
* window title.
*/
void _verifyChildren();
void _drawContentCompatibility(float elapsedTime);
// For specific Menu Positioning. Unit: points.
bool m_useCustomPosition = false;
float m_menuPositionX = 0.0f;
float m_menuPositionY = 0.0f;
// The pointer to the popup window in the underlying windowing system.
omni::ui::windowmanager::IWindowCallbackPtr m_uiWindow;
omni::kit::IAppWindow* m_appWindow = nullptr;
// Internal unique name of the popup window. It should never be expanded to the user.
std::string m_menuUniqueId;
std::string m_popupUniqueId;
carb::events::ISubscriptionPtr m_deferredOsWindowReleaseSubs;
float m_computedWindowWidth = 0.0f;
float m_computedWindowHeight = 0.0f;
std::shared_ptr<Frame> m_title;
std::shared_ptr<Frame> m_status;
bool m_titleDirty = true;
bool m_childrenDirty = true;
Menu* m_parentMenu = nullptr;
// Internal flags for drawing in popup window.
bool m_isPopupBasedCompatibility = false;
bool m_requestToPopupCompatibility = false;
// True when the user is moving the window.
bool m_windowIsMoving = false;
float m_windowMovedDistanceX = 0.0f;
float m_windowMovedDistanceY = 0.0f;
float m_windowPosBeforeMoveX = 0.0f;
float m_windowPosBeforeMoveY = 0.0f;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Widget.h | // Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include "Callback.h"
#include "Length.h"
#include "Object.h"
#include "Property.h"
#include "StyleContainer.h"
#include <carb/input/InputTypes.h>
#include <functional>
#include <memory>
OMNIUI_NAMESPACE_OPEN_SCOPE
class Frame;
class Window;
/**
* @brief The Widget class is the base class of all user interface objects.
*
* The widget is the atom of the user interface: it receives mouse, keyboard and other events, and paints a
* representation of itself on the screen. Every widget is rectangular. A widget is clipped by its parent and by the
* widgets in front of it.
*/
class OMNIUI_CLASS_API Widget : public std::enable_shared_from_this<Widget>, protected CallbackHelper<Widget>
{
OMNIUI_OBJECT_BASE(Widget)
public:
/**
* @brief Holds the data which is sent when a drag and drop action is completed.
*/
struct MouseDropEvent
{
/**
* @brief Position where the drop was made.
*/
float x;
/**
* @brief Position where the drop was made.
*/
float y;
/**
* @brief The data that was dropped on the widget.
*
*/
std::string mimeData;
};
/**
* @brief Width/height can be dirty for different reason. To skip
* computation of children we need to know the reason why the size is
* recomputed.
*/
enum class SizeDirtyReason
{
eNone = 0,
eSizeChanged,
eChildDirty,
eParentDirty,
};
/**
* @brief We need to know the reason for the re-bake to optimize the process
* and avoid re-baking in some particular cases.
*/
enum class BakeDirtyReason
{
eNone = 0,
eChildDirty,
eContentChanged,
eEditBegan,
eEditEnded,
eLodDirty,
};
using Bool3 = bool[3];
/**
* @brief Holds widget width and height for mouse events.
*/
struct BoundingBox
{
float width;
float height;
};
/**
* @brief When WantCaptureKeyboard, omni.ui is using the keyboard input exclusively, e.g. InputText active, etc.
*/
OMNIUI_API
static constexpr uint32_t kModifierFlagWantCaptureKeyboard = (1 << 30);
OMNIUI_API
virtual ~Widget();
/**
* @brief Removes all the callbacks and circular references.
*/
OMNIUI_API
virtual void destroy();
// We assume that all the operations with all the widgets should be performed with smart pointers because we have
// parent-child relationships, and we automatically put new widgets to parents in the create method of every widget.
// If the object is copied or moved, it will break the Widget-Container hierarchy.
// No copy
Widget(const Widget&) = delete;
// No copy-assignment
Widget& operator=(const Widget&) = delete;
// No move constructor and no move-assignments are allowed because of 12.8 [class.copy]/9 and 12.8 [class.copy]/20
// of the C++ standard
/**
* @brief Execute the rendering code of the widget, that includes the work with inputs and run _drawContent() that
* can be implemented by derived clrasses.
*
* @note It's in the public section because it's not possible to put it to the protected section. If it's in the
* protected, then other widgets that have child widgets will not be able to call it.
*
* Even though access control in C++ works on a per-class basis, protected access specifier has some peculiarities.
* The language specification wants to ensure that it's not possible to access a protected member of some base
* subobject that belongs to the derived class. We are not supposed to be able to access protected members of some
* unrelated independent objects of the base type. In particular, it's not possible to access protected members of
* freestanding objects of the base type. It's only possible to access protected members of base objects that are
* embedded into derived objects as base subobjects.
*
* Example:
*
* class Widget
* {
* protected:
* virtual void draw()
* {
* }
* };
*
* class Frame : public Widget
* {
* protected:
* void draw() override
* {
* // error C2248: 'Widget::draw': cannot access protected member declared in class 'Widget'
* m_child.draw();
* }
*
* private:
* Widget m_child;
* };
*
* Also, it's not possible to use friendship because friendship is neither inherited nor transitive. It means it's
* necessary to list all the classes that can use sub-objects explicitly. And in this way, custom extensions will
* not be able to use sub-objects.
*
* @param elapsedTime The time elapsed (in seconds)
*/
OMNIUI_API
void draw(float elapsedTime);
/**
* @brief Returns the final computed width of the widget. It includes margins.
*
* @note It's in puplic section. For the explanation why please see the draw() method.
*/
OMNIUI_API
float getComputedWidth() const;
/**
* @brief Returns the final computed width of the content of the widget.
*
* @note It's in puplic section. For the explanation why please see the draw() method.
*/
OMNIUI_API
virtual float getComputedContentWidth() const;
/**
* @brief Sets the computed width. It subtract margins and calls setComputedContentWidth.
*
* @note It's in puplic section. For the explanation why please see the draw() method.
*/
OMNIUI_API
void setComputedWidth(float width);
/**
* @brief The widget provides several functions that deal with a widget's geometry. Indicates the content width hint
* that represents the preferred size of the widget. The widget is free to readjust its geometry to fit the content
* when it's necessary.
*
* @note It's in puplic section. For the explanation why please see the draw() method.
*/
OMNIUI_API
virtual void setComputedContentWidth(float width);
/**
* @brief Returns the final computed height of the widget. It includes margins.
*
* @note It's in puplic section. For the explanation why please see the draw() method.
*/
OMNIUI_API
float getComputedHeight() const;
/**
* @brief Returns the final computed height of the content of the widget.
*
* @note It's in puplic section. For the explanation why please see the draw() method.
*/
OMNIUI_API
virtual float getComputedContentHeight() const;
/**
* @brief Sets the computed height. It subtract margins and calls setComputedContentHeight.
*
* @note It's in puplic section. For the explanation why please see the draw() method.
*/
OMNIUI_API
void setComputedHeight(float height);
/**
* @brief The widget provides several functions that deal with a widget's geometry. Indicates the content height
* hint that represents the preferred size of the widget. The widget is free to readjust its geometry to fit the
* content when it's necessary.
*
* @note It's in puplic section. For the explanation why please see the draw() method.
*/
OMNIUI_API
virtual void setComputedContentHeight(float height);
/**
* @brief Returns the X Screen coordinate the widget was last draw.
* This is in Screen Pixel size
*
* It's float because we need negative numbers and precise position considering DPI scale factor.
*/
OMNIUI_API
float getScreenPositionX() const;
/**
* @brief Returns the Y Screen coordinate the widget was last draw.
* This is in Screen Pixel size
*
* It's float because we need negative numbers and precise position considering DPI scale factor.
*/
OMNIUI_API
float getScreenPositionY() const;
/**
* @brief Sets the function that will be called when the user moves the mouse inside the widget. Mouse move events
* only occur if a mouse button is pressed while the mouse is being moved.
* void onMouseMoved(float x, float y, int32_t modifier)
*
* TODO: Add "mouse tracking property". If mouse tracking is switched on, mouse move events occur even if no mouse
* button is pressed.
*/
OMNIUI_CALLBACK(MouseMoved, void, float, float, int32_t, Bool3);
/**
* @brief Sets the function that will be called when the user presses the mouse button inside the widget. The
* function should be like this:
* void onMousePressed(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)
* Where:
* 'button' is the number of the mouse button pressed.
* 'modifier' is the flag for the keyboard modifier key.
*/
OMNIUI_CALLBACK(MousePressed, void, float, float, int32_t, carb::input::KeyboardModifierFlags);
/**
* @brief Sets the function that will be called when the user releases the mouse button if this button was pressed
* inside the widget.
* void onMouseReleased(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)
*/
OMNIUI_CALLBACK(MouseReleased, void, float, float, int32_t, carb::input::KeyboardModifierFlags);
/**
* @brief Sets the function that will be called when the user presses the mouse button twice inside the widget. The
* function specification is the same as in setMousePressedFn.
* void onMouseDoubleClicked(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)
*/
OMNIUI_CALLBACK(MouseDoubleClicked, void, float, float, int32_t, carb::input::KeyboardModifierFlags);
/**
* @brief Sets the function that will be called when the user uses mouse wheel on the focused window. The
* function specification is the same as in setMousePressedFn.
* void onMouseWheel(float x, float y, carb::input::KeyboardModifierFlags modifier)
*/
OMNIUI_CALLBACK(MouseWheel, void, float, float, carb::input::KeyboardModifierFlags);
/**
* @brief Sets the function that will be called when the user use mouse enter/leave on the focused window.
* function specification is the same as in setMouseHovedFn.
* void onMouseHovered(bool hovered)
*/
OMNIUI_CALLBACK(MouseHovered, void, bool);
/**
* @brief Sets the function that will be called when the user presses the keyboard key when the mouse clicks the
* widget.
*/
OMNIUI_CALLBACK(KeyPressed, void, int32_t, carb::input::KeyboardModifierFlags, bool);
/**
* @brief Specify that this Widget is draggable, and set the callback that is attached to the drag operation.
*/
OMNIUI_CALLBACK(Drag, std::string);
/**
* @brief Specify that this Widget can accept specific drops and set the callback that is called to check if the
* drop can be accepted.
*/
OMNIUI_CALLBACK(AcceptDrop, bool, const std::string&);
/**
* @brief Specify that this Widget accepts drops and set the callback to the drop operation.
*/
OMNIUI_CALLBACK(Drop, void, const MouseDropEvent&);
/**
* @brief Called when the size of the widget is changed.
*/
OMNIUI_CALLBACK(ComputedContentSizeChanged, void);
/**
* @brief If the widgets has callback functions it will by default not capture the events if it is the top most
* widget and setup this option to true, so they don't get routed to the child widgets either
*/
OMNIUI_PROPERTY(bool, opaqueForMouseEvents, DEFAULT, false, READ, isOpaqueForMouseEvents, WRITE, setOpaqueForMouseEvents);
/**
* @brief Set the current style. The style contains a description of customizations to the widget's style
*/
OMNIUI_API
void setStyle(const StyleContainer& style);
OMNIUI_API
void setStyle(StyleContainer&& style);
/**
* @brief Recompute internal cached data that is used for styling. Unlike cascadeStyle, updateStyle is called when
* the name or type of the widget is changed.
*/
OMNIUI_API
void updateStyle();
/**
* @brief It's called when the style is changed. It should be propagated to children to make the style cached and
* available to children.
*/
OMNIUI_API
virtual void cascadeStyle();
/**
* @brief Called when the style is changed. The child classes can use it to propagate the style to children.
*/
OMNIUI_API
virtual void onStyleUpdated();
/**
* @brief The ability to skip margins. It's useful when the widget is a part of compound widget and should be of
* exactly provided size. Like Rectangle of the Button.
*/
OMNIUI_API
void useMarginFromStyle(bool use);
/**
* @brief Adjust scrolling amount to make current item visible.
*
* @param[in] centerRatio 0.0: left, 0.5: center, 1.0: right
*/
OMNIUI_API
void scrollHereX(float centerRatio = 0.f);
/**
* @brief Adjust scrolling amount to make current item visible.
*
* @param[in] centerRatio 0.0: top, 0.5: center, 1.0: bottom
*/
OMNIUI_API
void scrollHereY(float centerRatio = 0.f);
/**
* @brief Adjust scrolling amount in two axes to make current item visible.
*
* @param[in] centerRatioX 0.0: left, 0.5: center, 1.0: right
* @param[in] centerRatioY 0.0: top, 0.5: center, 1.0: bottom
*/
OMNIUI_API
void scrollHere(float centerRatioX = 0.f, float centerRatioY = 0.f);
/**
* @brief Return the application DPI factor multiplied by the widget scale.
*/
OMNIUI_API float getDpiScale() const;
/**
* @brief Next frame content width will be forced to recompute.
*/
OMNIUI_API virtual void forceWidthDirty(SizeDirtyReason reason);
/**
* @brief Next frame content height will be forced to recompute.
*/
OMNIUI_API virtual void forceHeightDirty(SizeDirtyReason reason);
/**
* @brief Next frame the content will be forced to re-bake.
*/
OMNIUI_API virtual void forceRasterDirty(BakeDirtyReason reason);
/**
* @brief Next frame content width will be forced to recompute.
*/
OMNIUI_API virtual void forceWidthDirty();
/**
* @brief Next frame content height will be forced to recompute.
*/
OMNIUI_API virtual void forceHeightDirty();
/**
* @brief Change dirty bits when the visibility is changed. It's public because other widgets have to call it.
*
* @param visible True when the widget is completely rendered. False when early exit.
* @param dirtySize True to set the size diry bits.
*/
OMNIUI_API virtual void setVisiblePreviousFrame(bool visible, bool dirtySize = true);
/**
* @brief This property holds whether the widget is visible.
*/
OMNIUI_PROPERTY(
bool, visible, DEFAULT, true, READ, isVisible, WRITE, setVisible, PROTECTED, NOTIFY, _setVisibleChangedFn);
/**
* @brief If the current zoom factor and DPI is less than this value, the widget is not visible.
*/
OMNIUI_PROPERTY(
float, visibleMin, DEFAULT, 0.0f, READ, getVisibleMin, WRITE, setVisibleMin, PROTECTED, NOTIFY, _setVisibleMinChangedFn);
/**
* @brief If the current zoom factor and DPI is bigger than this value, the widget is not visible.
*/
OMNIUI_PROPERTY(
float, visibleMax, DEFAULT, 0.0f, READ, getVisibleMax, WRITE, setVisibleMax, PROTECTED, NOTIFY, _setVisibleMaxChangedFn);
/**
* @brief This property holds whether the widget is enabled. In general an enabled widget handles keyboard and mouse
* events; a disabled widget does not. And widgets display themselves differently when they are disabled.
*/
OMNIUI_PROPERTY(bool, enabled, DEFAULT, true, READ, isEnabled, WRITE, setEnabled, NOTIFY, setEnabledChangedFn);
/**
* @brief This property holds a flag that specifies the widget has to use eSelected state of the style.
*/
OMNIUI_PROPERTY(bool, selected, DEFAULT, false, READ, isSelected, WRITE, setSelected, NOTIFY, setSelectedChangedFn);
/**
* @brief This property holds a flag that specifies the widget has to use eChecked state of the style. It's on the
* Widget level because the button can have sub-widgets that are also should be checked.
*/
OMNIUI_PROPERTY(bool, checked, DEFAULT, false, READ, isChecked, WRITE, setChecked, NOTIFY, setCheckedChangedFn);
/**
* @brief This property holds the width of the widget relative to its parent. Do not use this function to find the
* width of a screen.
*
* TODO: Widget Geometry documentation for an overview of geometry issues and layouting.
*/
OMNIUI_PROPERTY(
Length, width, DEFAULT, Fraction{ 1.0f }, READ, getWidth, WRITE, setWidth, PROTECTED, NOTIFY, _setWidthChangedFn);
/**
* @brief This property holds the height of the widget relative to its parent. Do not use this function to find the
* height of a screen.
*
* TODO: Widget Geometry documentation for an overview of geometry issues and layouting.
*/
OMNIUI_PROPERTY(
Length, height, DEFAULT, Fraction{ 1.0f }, READ, getHeight, WRITE, setHeight, PROTECTED, NOTIFY, _setHeightChangedFn);
/**
* @brief This property holds if the widget is being dragged.
*/
OMNIUI_PROPERTY(bool, dragging, DEFAULT, false, READ, isDragging, WRITE, setDragging);
/**
* @brief The name of the widget that user can set.
*/
OMNIUI_PROPERTY(std::string, name, READ, getName, WRITE, setName, NOTIFY, setNameChangedFn);
/**
* @brief By default, we use typeName to look up the style. But sometimes it's necessary to use a custom name. For
* example, when a widget is a part of another widget. (Label is a part of Button) This property can override the
* name to use in style.
*/
OMNIUI_PROPERTY(std::string,
styleTypeNameOverride,
READ,
getStyleTypeNameOverride,
WRITE,
setStyleTypeNameOverride,
NOTIFY,
setStyleTypeNameOverrideChangedFn);
/**
* @brief Protected weak pointer to the parent object. We need it to query the parent style. Parent can be a
* Container or another widget if it holds sub-widgets.
*/
OMNIUI_PROPERTY(
Widget*, parent, DEFAULT, nullptr, PROTECTED, READ_VALUE, getParent, WRITE, setParent, NOTIFY, setParentChangedFn);
/**
* @brief The local style. When the user calls `setStyle()`, it saves the given style to this property and creates a
* new style that is the result of the parent style and the given style.
*/
OMNIUI_PROPERTY(std::shared_ptr<StyleContainer>, style, READ, getStyle, WRITE, setStyle, NOTIFY, setStyleChangedFn);
/**
* @brief Set a basic tooltip for the widget, this will simply be a Label, it will follow the Tooltip style
*/
OMNIUI_PROPERTY(std::string, tooltip, READ, getTooltip, WRITE, setTooltip, PROTECTED, NOTIFY, _setTooltipPropertyChangedFn);
/**
* @brief Set dynamic tooltip that will be created dynamiclly the first time it is needed.
* the function is called inside a ui.Frame scope that the widget will be parented correctly.
*/
OMNIUI_CALLBACK(Tooltip, void);
/**
* @brief Get Payload Id for drag and drop.
*/
static constexpr const char* const getDragDropPayloadId()
{
return "OMNIUI_DRAG_AND_DROP";
}
/**
* @brief Set the X tooltip offset in points. In a normal state, the tooltip position is linked to the mouse
* position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner
* of the widget, and this property defines the relative position the tooltip should be shown.
*/
OMNIUI_PROPERTY(float,
tooltipOffsetX,
DEFAULT,
0.0f,
READ,
getTooltipOffsetX,
WRITE,
setTooltipOffsetX,
NOTIFY,
setTooltipOffsetXChangedFn);
/**
* @brief Set the Y tooltip offset in points. In a normal state, the tooltip position is linked to the mouse
* position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner
* of the widget, and this property defines the relative position the tooltip should be shown.
*/
OMNIUI_PROPERTY(float,
tooltipOffsetY,
DEFAULT,
0.0f,
READ,
getTooltipOffsetY,
WRITE,
setTooltipOffsetY,
NOTIFY,
setTooltipOffsetYChangedFn);
/**
* @brief The flag that specifies if it's necessary to bypass the whole draw cycle if the bounding box is clipped
* with a scrolling frame. It's needed to avoid the limitation of 65535 primitives in a single draw list.
*/
OMNIUI_PROPERTY(bool, skipDrawWhenClipped, DEFAULT, false, READ, isSkipDrawWhenClipped, WRITE, setSkipDrawWhenClipped);
/**
* The scale factor of the widget.
*
* The purpose of this property is to cache the scale factor of the CanvasFarame that uniformly scales its children.
*/
OMNIUI_PROPERTY(float, scale, DEFAULT, 1.0f, WRITE, setScale, PROTECTED, READ, _getScale, NOTIFY, _setScaleChangedFn);
/**
* @brief Zoom level of the parent CanvasFrame
*/
OMNIUI_PROPERTY(float,
canvasZoom,
DEFAULT,
-1.0f,
WRITE,
setCanvasZoom,
PROTECTED,
READ,
_getCanvasZoom,
NOTIFY,
_setCanvasZoomChangedFn);
/**
* @brief An optional identifier of the widget we can use to refer to it in queries.
*/
OMNIUI_PROPERTY(std::string, identifier, READ, getIdentifier, WRITE, setIdentifier, NOTIFY, setIdentifierChangedFn);
/**
* @brief When it's false, the scroll callback is called even if other window is hovered.
*/
OMNIUI_PROPERTY(bool, scrollOnlyWindowHovered, DEFAULT, false, READ, isScrollOnlyWindowHovered, WRITE, setScrollOnlyWindowHovered);
protected:
friend class Button;
friend class CanvasFrame;
friend class CollapsableFrame;
friend class ContainerStack;
friend class DockSpace;
friend class FontHelper;
friend class Frame;
friend class Inspector;
friend class MainWindow;
friend class Menu;
friend class MenuHelper;
friend class Placer;
friend class RasterHelper;
friend class Stack;
friend class Style;
friend class TreeView;
friend class Window;
OMNIUI_API
Widget();
/**
* @brief The rendering code of the widget. Should be implemented by derived classes.
*
* The difference with draw() is that the _drawContent() method should contain the code to draw the current widget.
* draw() includes the code that is common for all the widgets, like mouse input, checking visibility, etc.
*
* @param elapsedTime The time elapsed (in seconds)
*/
OMNIUI_API
virtual void _drawContent(float elapsedTime){}
/**
* @brief It returns the style that is result of merging the styles of all the parents and the local style.
*/
OMNIUI_API
const std::shared_ptr<StyleContainer>& _getResolvedStyle() const;
/**
* @brief Get the Type Name used to query the style. It can be either overrided type name or the widget type. We
* need to override type name when the widget has constructed with multiple widgets. For example Button is
* constructed with rectangle and label.
*/
OMNIUI_API
const std::string& _getStyleTypeName() const;
/**
* @brief Resolves the style property with the style object. It checks override, parent, and cascade styles.
*
* @tparam T StyleFloatProperty or StyleColorProperty
* @tparam U float or uint32_t
* @param property For example StyleFloatProperty::ePadding
* @param result the pointer to the result where the resolved property will be written
* @return true when the style contains given property
* @return false when the style doesn't have the given property
*/
template <typename T, typename U>
OMNIUI_API bool _resolveStyleProperty(T property, U* result) const;
/**
* @brief Resolves the style property with the given state.
*/
template <typename T, typename U>
OMNIUI_API bool _resolveStyleProperty(T property, StyleContainer::State state, U* result) const;
/**
* @brief Returns the current state for the styling.
*/
OMNIUI_API StyleContainer::State _getStyleState() const;
/**
* @brief Enable custom glyph char. Default is disabled - all glyph chars rendered with ImGuiCol_Text. Enable to
* make all glyph chars be rendered with ImGuiCol_CustomChar (default 0xFFFFFFFF). Recommend to enable before
* rendering the glyph chars with color defined in svg, and disable when rendering done to make sure others be
* rendered as expected.
*/
OMNIUI_API void _enableCustomChar(bool enable) const;
/**
* @brief Check if current widget or its parent has accepted drop.
*/
OMNIUI_API bool _hasAcceptedDrop() const;
/**
* m_dirtyWidth = false;
* m_dirtyHeight = false;
*/
OMNIUI_API void _undirtyWidthAndHeight(bool force = false);
/**
* @brief This function returns a boolean value indicating whether the
* parent of the widget is a CanvasFrame. CanvasFrame has the capability to
* scale its child widgets. This information is useful for certain widgets
* to determine if they should be rendered in a scalable environment.
*
* @return bool - true if the parent or any of its ancestors is a
* CanvasFrame, false otherwise.
*/
OMNIUI_API virtual bool _isParentCanvasFrame() const;
/**
* @brief This method fills an unordered set with the visible minimum and
* maximum values of the Widget and children.
*/
OMNIUI_API virtual void _fillVisibleThreshold(void* thresholds) const;
/**
* @brief Return current visibleMin/visibleMax LOD id.
*/
OMNIUI_API virtual size_t _getCurrentLod(float zoom) const;
/**
* @brief Return widget bounding box for use with mouse events. Defaults to
* [computedContentWidth, computedContentHeight]. Used by FreeShapes
* which otherwise set width and height to zero for layout.
*/
OMNIUI_API virtual BoundingBox _getInteractionBBox() const;
/**
* @brief Number of mouse buttons Widget considers
*/
static constexpr uint32_t kMouseButtonCount = 5;
// True when the mouse pointer is inside the widget area.
// TODO: Have not decided if we need this as a property. Probably when we have signals, it would be useful to have
// signal that this property is changed.
bool m_isHovered = false;
bool m_isPressed[kMouseButtonCount] = {};
bool m_isClicked[kMouseButtonCount] = {};
// If falls, the widget skips margins.
bool m_useMarginFromStyle = true;
// True when we need to recompute content width
SizeDirtyReason m_dirtyWidth = SizeDirtyReason::eSizeChanged;
// True when we need to recompute content height
SizeDirtyReason m_dirtyHeight = SizeDirtyReason::eSizeChanged;
private:
/**
* @brief Creates m_resolvedStyle, which is the parents style plus the local style. If there is no local style,
* m_resolvedStyle is empty.
*/
void _mergeStyleWithParent();
/**
* @brief called when the tooltip is needed for the first time, this will create the right widgets in the frame
*/
void _createToolTipWidgets();
/**
* @brief Called every frame when there is dragFn to setup drag area.
*/
void _performDrag();
/**
* @brief Called when there are dropFn and acceptDropFn and mouse enters the widget to check if widget accepts
* current drag.
*/
void _performAcceptDrop();
/**
* @brief Called when the user makes drop to call dropFn.
*/
void _performDrop(float x, float y);
// unit: pixels
float m_computedContentWidth = 0.0f;
float m_computedContentHeight = 0.0f;
float m_computedContentWidthOnDraw = 0.0f;
float m_computedContentHeightOnDraw = 0.0f;
// The current mouse position. We need it to decide if the mouse is moved and call m_mouseMovedFn.
// TODO: Put it to a singleton. It's not good to have it in each widget.
float m_mouseX = 0.0f;
float m_mouseY = 0.0f;
// The parent style definition with the local style definition merged. If there is no local style, this variable is
// also nullptr.
std::shared_ptr<StyleContainer> m_resolvedStyle;
size_t m_styleStateGroupIndex = SIZE_MAX;
// Margins for fast access
float m_marginWidthCache = 0.0f;
float m_marginHeightCache = 0.0f;
// position from the last call draw call;
// unit: pixels
float m_cursorPositionXCache = 0.0f;
float m_cursorPositionYCache = 0.0f;
// Offset from parent. We need it to get the position of the widget when it's hidden.
float m_cursorPositionOffsetXCache = 0.0f;
float m_cursorPositionOffsetYCache = 0.0f;
// Buffer variable to indicate if the tooltip was shown in the previous frame. We need it to be able to recreate the
// widget when we need it.
bool m_tooltipShown = false;
// Tooltip support, can be either a simple text or a function callback that can create any widgets
std::string m_tooltipString;
// the frame for the tooltip
std::shared_ptr<Frame> m_tooltipFrame;
// the timer for the tooltip
float m_tooltipTimer = 0.0f;
// Flag to scroll to the widget
bool m_scrollHereX = false;
bool m_scrollHereY = false;
float m_scrollHereXRatio = 0.0f;
float m_scrollHereYRatio = 0.0f;
// Drag and Drop
// The buffer with DnD data. We keep it because ImGui needs to have this buffer every frame.
std::string m_dragAndDropBuffer;
bool m_dragActive = false;
bool m_dropAccepted = false;
// The frame for the drag and drop tooltip
std::shared_ptr<Frame> m_dragFrame;
// Flag when visibleMin/visibleMax is explicitly set.
bool m_visibleMinSet = false;
bool m_visibleMaxSet = false;
float m_dpiAtPreviousFrame = 0.0f;
bool m_wasVisiblePreviousFrame = false;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/ValueModelHelper.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Widget.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
class AbstractValueModel;
/**
* @brief The ValueModelHelper class provides the basic functionality for value widget classes.
*
* ValueModelHelper class is the base class for every standard widget that uses a AbstractValueModel.
* ValueModelHelper is an abstract class and itself cannot be instantiated. It provides a standard interface for
* interoperating with models.
*/
class OMNIUI_CLASS_API ValueModelHelper
{
public:
OMNIUI_API
virtual ~ValueModelHelper();
/**
* @brief Called by the model when the model value is changed. The class should react to the changes.
*/
OMNIUI_API
virtual void onModelUpdated() = 0;
/**
* @brief Set the current model.
*/
OMNIUI_API
virtual void setModel(const std::shared_ptr<AbstractValueModel>& model);
/**
* @brief Returns the current model.
*/
OMNIUI_API
virtual const std::shared_ptr<AbstractValueModel>& getModel() const;
protected:
OMNIUI_API
ValueModelHelper(const std::shared_ptr<AbstractValueModel>& model);
private:
std::shared_ptr<AbstractValueModel> m_model = {};
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Length.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
enum class UnitType
{
ePixel,
ePercent,
eFraction
};
/**
* @brief OMNI.UI has several different units for expressing a length.
*
* Many widget properties take "Length" values, such as width, height, minWidth, minHeight, etc. Pixel is the absolute
* length unit. Percent and Fraction are relative length units, and they specify a length relative to the parent length.
* Relative length units are scaled with the parent.
*/
struct Length
{
/**
* @brief Construct Length
*/
Length(float v, UnitType u) : value{ v }, unit{ u }
{
}
~Length() = default;
bool operator==(const Length& b) const
{
return value == b.value && unit == b.unit;
}
bool operator!=(const Length& b) const
{
return !(b == *this);
}
/** Resolves the length value to a absolute value
* @param absoluteFactor the unit multiplier if the value is Pixel
* @param relativeFactor the unit multiplier if the value is Percent or Fraction
* @param totalFractions the number of total fractions of the parent value if the value is Fraction.
* @return the computed absolute value
*/
float resolve(float absoluteFactor, float relativeFactor, float totalFractions) const;
float value;
UnitType unit;
};
/**
* @brief Percent is the length in percents from the parent widget.
*/
struct Percent : public Length
{
/**
* @brief Construct Percent
*/
explicit Percent(float v) : Length{ v, UnitType::ePercent }
{
}
float resolve(float relativeFactor) const
{
return relativeFactor * (value / 100.0f);
}
};
/**
* @brief Pixel length is exact length in pixels.
*/
struct Pixel : public Length
{
/**
* @brief Construct Pixel
*/
explicit Pixel(float v) : Length{ v, UnitType::ePixel }
{
}
/** Resolves the length value to a absolute value
* @param absoluteFactor the unit multiplier
* @return the computed absolute value
*/
float resolve(float absoluteFactor) const
{
return value * absoluteFactor;
}
};
/**
* @brief Fraction length is made to take the space of the parent widget, divides it up into a row of boxes, and makes
* each child widget fill one box.
*/
struct Fraction : public Length
{
/**
* @brief Construct Fraction
*/
explicit Fraction(float v) : Length{ v, UnitType::eFraction }
{
}
/** Resolves the length value to a absolute value
* @param relativeFactor the unit multiplier
* @param totalFractions the number of total fractions of the parent value
* @return the computed absolute value
*/
float resolve(float relativeFactor, float totalFractions) const
{
return relativeFactor * (value / totalFractions);
}
};
inline float Length::resolve(float absoluteFactor, float relativeFactor, float totalFractions) const
{
if (unit == UnitType::ePixel)
return Pixel(value).resolve(absoluteFactor);
if (unit == UnitType::ePercent)
return Percent(value).resolve(relativeFactor);
return Fraction(value).resolve(relativeFactor, totalFractions);
}
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/ArrowHelper.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Shape.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The ArrowHelper widget provides a colored rectangle to display.
*/
class OMNIUI_CLASS_API ArrowHelper
{
public:
enum class ArrowType : uint8_t
{
eNone = 0,
eArrow
};
OMNIUI_API
virtual ~ArrowHelper();
/**
* @brief This property holds the width of the begin arrow
*/
OMNIUI_PROPERTY(float, beginArrowWidth, DEFAULT, 8.0f, READ, getBeginArrowWidth, WRITE, setBeginArrowWidth);
/**
* @brief This property holds the height of the begin arrow
*/
OMNIUI_PROPERTY(float, beginArrowHeight, DEFAULT, 8.0f, READ, getBeginArrowHeight, WRITE, setBeginArrowHeight);
/**
* @brief This property holds the type of the begin arrow can only be eNone or eRrrow.
* By default, the arrow type is eNone.
*/
OMNIUI_PROPERTY(ArrowType, beginArrowType, DEFAULT, ArrowType::eNone, READ, getBeginArrowType, WRITE, setBeginArrowType);
/**
* @brief This property holds the width of the end arrow
*/
OMNIUI_PROPERTY(float, endArrowWidth, DEFAULT, 8.0f, READ, getEndArrowWidth, WRITE, setEndArrowWidth);
/**
* @brief This property holds the height of the end arrow
*/
OMNIUI_PROPERTY(float, endArrowHeight, DEFAULT, 8.0f, READ, getEndArrowHeight, WRITE, setEndArrowHeight);
/**
* @brief This property holds the type of the end arrow can only be eNone or eRrrow.
* By default, the arrow type is eNone.
*/
OMNIUI_PROPERTY(ArrowType, endArrowType, DEFAULT, ArrowType::eNone, READ, getEndArrowType, WRITE, setEndArrowType);
protected:
/**
* @brief Constructs ArrowHelper
*/
OMNIUI_API
ArrowHelper();
/**
* @brief draw a arrow.
*
*/
OMNIUI_API
void drawArrow(float x,
float y,
float width,
float height,
float dpi,
float lineWidth,
float arrowWidth,
float arrowHeight,
uint32_t color);
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Circle.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Alignment.h"
#include "Shape.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
struct CircleStyleSnapshot;
/**
* @brief The Circle widget provides a colored circle to display.
*/
class OMNIUI_CLASS_API Circle : public Shape
{
OMNIUI_OBJECT(Circle)
public:
// TODO: this need to be moved to be a Header like Alignment
enum class SizePolicy : uint8_t
{
eStretch = 0,
eFixed
};
OMNIUI_API
~Circle() override;
/**
* @brief Reimplemented the method to indicate the width hint that represents the preferred size of the widget.
* when the circle is in fixed mode it can't be smaller than the radius
*
* @see Widget::setComputedContentWidth
*/
OMNIUI_API
void setComputedContentWidth(float width) override;
/**
* @brief Reimplemented the method to indicate the height hint that represents the preferred size of the widget.
* when the circle is in fixed mode it can't be smaller than the radius
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) override;
/**
* @brief This property holds the radius of the circle when the fill policy is eFixed or
* eFixedCrop.
* By default, the circle radius is 0.
*/
OMNIUI_PROPERTY(float, radius, DEFAULT, 0, READ, getRadius, WRITE, setRadius, NOTIFY, setRadiusChangeFn);
/**
* @brief This property holds the alignment of the circle when the fill policy is ePreserveAspectFit or
* ePreserveAspectCrop.
* By default, the circle is centered.
*/
OMNIUI_PROPERTY(Alignment, alignment, DEFAULT, Alignment::eCenter, READ, getAlignment, WRITE, setAlignment);
/**
* @brief This property is the way to draw a half or a quarter of the circle. When it's eLeft, only left side of the
* circle is rendered. When it's eLeftTop, only left top quarter is rendered.
*/
OMNIUI_PROPERTY(Alignment, arc, DEFAULT, Alignment::eCenter, READ, getArc, WRITE, setArc);
/**
* @brief Define what happens when the source image has a different size than the item.
*/
OMNIUI_PROPERTY(SizePolicy,
sizePolicy,
DEFAULT,
SizePolicy::eStretch,
READ,
getSizePolicy,
WRITE,
setSizePolicy,
NOTIFY,
setSizePolicyChangedFn);
protected:
/**
* @brief Constructs Circle
*/
OMNIUI_API
Circle();
/**
* @brief Reimplemented the rendering code of the shape.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawShape(float elapsedTime, float x, float y, float width, float height) override;
/**
* @brief Reimplemented the draw shadow of the shape.
*/
OMNIUI_API
void _drawShadow(
float elapsedTime,
float x,
float y,
float width,
float height,
uint32_t shadowColor,
float dpiScale,
ImVec2 shadowOffset,
float shadowThickness,
uint32_t shadowFlag) override;
private:
void _calCentreAndRadius(float width, float height, float dpiScale, ImVec2& center, float& radius);
// this need to become a property, stylable ?
int32_t m_numSegments = 40;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/MenuItem.h | // Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "MenuHelper.h"
#include "Widget.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief A MenuItem represents the items the Menu consists of.
*
* MenuItem can be inserted only once in the menu.
*
* TODO: In addition to a text label, MenuItem should have an optional icon drawn on the very left side, and shortcut
* key sequence such as "Ctrl+X".
*/
class OMNIUI_CLASS_API MenuItem : public Widget, public MenuHelper
{
OMNIUI_OBJECT(MenuItem)
public:
using CallbackHelperBase = Widget;
OMNIUI_API
~MenuItem() override;
/**
* @brief Reimplemented the method to indicate the width hint that represents the preferred size of the widget.
*
* @see Widget::setComputedContentWidth
*/
OMNIUI_API
void setComputedContentWidth(float width) override;
/**
* @brief Reimplemented the method to indicate the height hint that represents the preferred size of the widget.
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) override;
/**
* @brief It's called when the style is changed. It should be propagated to children to make the style cached and
* available to children.
*/
OMNIUI_API
void cascadeStyle() override;
protected:
/**
* @brief Construct MenuItem
*/
OMNIUI_API
MenuItem(const std::string& text);
/**
* @brief Reimplemented the rendering code of the widget.
*
* Draw the content.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
void _drawContentCompatibility(float elapsedTime);
std::function<void()> m_triggeredFn;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Stack.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Container.h"
#include <vector>
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The Stack class lines up child widgets horizontally, vertically or sorted in a Z-order.
*/
class OMNIUI_CLASS_API Stack : public Container
{
OMNIUI_OBJECT(Stack)
public:
OMNIUI_API
~Stack() override;
OMNIUI_API
void destroy() override;
/**
* @brief This type is used to determine the direction of the layout.
* If the Stack's orientation is eLeftToRight the widgets are placed in a horizontal row, from left to right.
* If the Stack's orientation is eRightToLeft the widgets are placed in a horizontal row, from right to left.
* If the Stack's orientation is eTopToBottom, the widgets are placed in a vertical column, from top to bottom.
* If the Stack's orientation is eBottomToTop, the widgets are placed in a vertical column, from bottom to top.
* If the Stack's orientation is eBackToFront, the widgets are placed sorted in a Z-order in top right corner.
* If the Stack's orientation is eFrontToBack, the widgets are placed sorted in a Z-order in top right corner, the
* first widget goes to front.
*/
enum class Direction
{
eLeftToRight,
eRightToLeft,
eTopToBottom,
eBottomToTop,
eBackToFront,
eFrontToBack
};
/**
* @brief Reimplemented adding a widget to this Stack. The Stack class can contain multiple widgets.
*
* @see Container::addChild
*/
OMNIUI_API
void addChild(std::shared_ptr<Widget> widget) override;
/**
* @brief Reimplemented removing all the child widgets from this Stack.
*
* @see Container::clear
*/
OMNIUI_API
void clear() override;
/**
* @brief Reimplemented the method to indicate the width hint that represents the preferred size of the widget.
* Currently this widget can't be smaller than the minimal size of the child widgets.
*
* @see Widget::setComputedContentWidth
*/
OMNIUI_API
void setComputedContentWidth(float width) override;
/**
* @brief Reimplemented the method to indicate the height hint that represents the preferred size of the widget.
* Currently this widget can't be smaller than the minimal size of the child widgets.
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) override;
/**
* @brief It's called when the style is changed. It should be propagated to children to make the style cached and
* available to children.
*/
OMNIUI_API
void cascadeStyle() override;
/**
* @brief Next frame the content will be forced to re-bake.
*/
OMNIUI_API
void forceRasterDirty(BakeDirtyReason reason) override;
/**
* @brief Change dirty bits when the visibility is changed.
*/
OMNIUI_API void setVisiblePreviousFrame(bool wasVisible, bool dirtySize = true) override;
/**
* @brief Determines if the child widgets should be clipped by the rectangle of this Stack.
*/
OMNIUI_PROPERTY(bool, contentClipping, DEFAULT, false, READ, isContentClipping, WRITE, setContentClipping);
/**
* @brief Sets a non-stretchable space in pixels between child items of this layout.
*/
OMNIUI_PROPERTY(float, spacing, DEFAULT, 0.0f, READ, getSpacing, WRITE, setSpacing);
/**
* @brief Determines the type of the layout. It can be vertical, horizontal or front-to-back.
*/
OMNIUI_PROPERTY(Direction, direction, DEFAULT, Direction::eLeftToRight, READ, getDirection, WRITE, setDirection);
/**
* @brief When children of a Z-based stack overlap mouse events are normally sent to the topmost one. Setting
* this property true will invert that behavior, sending mouse events to the bottom-most child.
*
* Default is ImGui default
*/
OMNIUI_PROPERTY(
bool, sendMouseEventsToBack, READ, isSendMouseEventsToBack, WRITE, setSendMouseEventsToBack, DEFAULT, true);
protected:
/**
* @brief Constructor.
*
* @param direction Determines the orientation of the Stack.
*
* @see Stack::Direction
*/
OMNIUI_API
Stack(Direction direction);
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
/**
* @brief Return the list of children for the Container.
*/
OMNIUI_API
const std::vector<std::shared_ptr<Widget>> _getChildren() const override;
/**
* @brief This method fills an unordered set with the visible minimum and
* maximum values of the Widget and children.
*/
OMNIUI_API
void _fillVisibleThreshold(void* thresholds) const override;
std::vector<std::shared_ptr<Widget>> m_children;
private:
/**
* @brief Evaluates the layout of one dimension (width or height) of the child widgets considering that in this
* dimension, the widgets will be placed in a row one after each other.
*
* It's called for the width if the direction eLeftToRight, and for the height, if the direction is eTopToBottom.
*
* @return Returns the total length/width of the evaluated widgets.
*/
float _evaluateConsecutiveLayout(float length, bool isWidthEvaluation);
/**
* @brief Evaluates the layout of one dimension (width or height) of the child widgets considering that in this
* dimension, the widgets will be placed at the same point at the start of the dimension.
*
* It's called for the height if the direction eLeftToRight, and for the width, if the direction is eTopToBottom.
* Also, it's called for both width and height if the direction is eBackToFront.
*
* @return Returns the total length/width of the evaluated widgets.
*/
float _evaluateSimultaneousLayout(float length, bool isWidthEvaluation);
void _forceChildDirty(std::shared_ptr<Widget>& child, bool width) const;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/AbstractField.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "FontHelper.h"
#include "ValueModelHelper.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
class Rectangle;
/**
* @brief The abstract widget that is base for any field, which is a one-line text editor.
*
* A field allows the user to enter and edit a single line of plain text. It's implemented using the model-view pattern
* and uses AbstractValueModel as the central component of the system.
*/
class OMNIUI_CLASS_API AbstractField : public Widget, public ValueModelHelper, public FontHelper
{
public:
OMNIUI_API
~AbstractField() override;
/**
* @brief Reimplemented the method to indicate the width hint that represents the preferred size of the widget.
*
* @see Widget::setComputedContentWidth
*/
OMNIUI_API
void setComputedContentWidth(float width) override;
/**
* @brief Reimplemented the method to indicate the height hint that represents the preferred size of the widget.
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) override;
/**
* @brief Reimplemented. Something happened with the style or with the parent style. We need to gerenerate the
* cache.
*/
OMNIUI_API
void onStyleUpdated() override;
/**
* @brief Reimplemented the method from ValueModelHelper that is called when the model is changed.
*
* TODO: We can avoid it if we create templated ValueModelHelper that manages data.
*/
OMNIUI_API
void onModelUpdated() override;
/**
* @brief Puts cursor to this field or removes focus if `focus` is false.
*/
OMNIUI_API
void focusKeyboard(bool focus = true);
protected:
OMNIUI_API
AbstractField(const std::shared_ptr<AbstractValueModel>& model = {});
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
/**
* @brief It's necessary to implement it to convert model to string buffer that is displayed by the field. It's
* possible to use it for setting the string format.
*/
virtual std::string _generateTextForField() = 0;
/**
* @brief Set/get the field data and the state on a very low level of the underlying system.
*/
virtual void _updateSystemText(void*) = 0;
/**
* @brief Determines the flags that are used in the underlying system widget.
*/
virtual int32_t _getSystemFlags() const = 0;
/**
* @brief Internal private callback. It's called when the internal text buffer needs to change the size.
*/
static int32_t _onInputTextActive(void*);
// The text of the model. It's cached because we can't query the model every frame because the model can be written
// in python and query filesystem or USD.
std::string m_textModelCache = {};
// Internal cache. It represents the text in the field see AbstractField::onModelUpdated() for the description why
// it's a vector.
std::vector<char> m_textBuffer;
// True if the cursor is in the field
bool m_fieldActive = false;
// The rectangle used instead of the background
std::shared_ptr<Rectangle> m_backgroundRect;
// Puts cursor to this field.
bool m_focusKeyboard = false;
// We change ID every time the user wants to defocus this field.
int m_underlyingId = 0;
// Flag that specifies that the model is changed because the user pressed a key.
bool m_isModelChangedInternally = false;
// Force set content from the model.
bool m_forceContentChange = false;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/StyleProperties.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
enum class StyleFloatProperty
{
eBorderRadius = 0,
eBorderWidth,
eFontSize,
eMargin,
eMarginWidth,
eMarginHeight,
ePadding,
eScrollbarSize,
ePaddingWidth,
ePaddingHeight,
eSecondaryPadding,
eShadowThickness,
eShadowOffsetX,
eShadowOffsetY,
eCount
};
enum class StyleEnumProperty
{
eCornerFlag = 0,
eAlignment,
eFillPolicy,
eDrawMode,
eStackDirection,
eShadowFlag,
eCount
};
enum class StyleColorProperty
{
eBackgroundColor = 0,
eBackgroundGradientColor,
eBackgroundSelectedColor,
eBorderColor,
eColor,
eSelectedColor,
eSecondaryColor,
eSecondarySelectedColor,
eSecondaryBackgroundColor,
eDebugColor,
eShadowColor,
eCount
};
enum class StyleStringProperty
{
eImageUrl = 0,
eFont,
eCount
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/FontAtlasTexture.h | // Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include <memory>
#include <string>
#include <vector>
OMNIUI_NAMESPACE_OPEN_SCOPE
class _FontAtlasTexture;
class _FontAtlasTextureRegistry;
/**
* @brief A single font. It has a texture with all the letters and a table with
* data for every character.
*/
class FontAtlasTexture
{
public:
~FontAtlasTexture();
/**
* @brief Get the pointer to the underlying system font object.
*/
OMNIUI_API
void* getFont() const;
/**
* @brief GPU reference to the buffer with the font texture.
*/
OMNIUI_API
void* getTextureId() const;
/**
* @brief True if it's the font with the given path and size.
*/
OMNIUI_API
bool isA(const char* fontName, float size) const;
private:
friend class FontAtlasTextureRegistry;
FontAtlasTexture(const char* fontPath, const char* fontName, float fontSize, bool mipMaps);
// To avoid including ImGui libs
std::unique_ptr<_FontAtlasTexture> m_prv;
};
/**
* @brief Registry for the fonts. It's the object that creates fonts. It stores
* weak pointers so if the font is not used, it destroyes.
*
* TODO: Languages
*/
class FontAtlasTextureRegistry
{
public:
OMNIUI_API
static FontAtlasTextureRegistry& instance();
// Singleton
FontAtlasTextureRegistry(FontAtlasTextureRegistry const&) = delete;
void operator=(FontAtlasTextureRegistry const&) = delete;
/**
* @brief Retrieves the FontAtlasTexture associated with the specified font
* path and size.
*
* @param fontName - The path to the font file.
* @param fontSize - The desired size of the font.
* @param mipMaps - An optional parameter indicating whether to generate
* mipmaps for the font atlas texture. Defaults to false.
*
* @return std::shared_ptr<FontAtlasTexture> - A shared pointer to the
* FontAtlasTexture object associated with the specified font and size.
*/
OMNIUI_API
std::shared_ptr<FontAtlasTexture> getAtlas(const char* fontName, float fontSize, bool mipMaps = false);
private:
friend class Inspector;
FontAtlasTextureRegistry();
/**
* @brief Returns all the fonts in the cache. We need it for tests.
*/
std::vector<std::pair<std::string, uint32_t>> _getStoredFonts() const;
/**
* @brief Create a new atlas.
*/
std::shared_ptr<FontAtlasTexture> _createAtlas(const char* font, float roundFontSize, bool mipMaps);
std::unique_ptr<_FontAtlasTextureRegistry> m_prv;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/FontHelper.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include <memory>
OMNIUI_NAMESPACE_OPEN_SCOPE
class FontAtlasTexture;
class Widget;
struct FontHelperPrivate;
/**
* @brief The helper class for the widgets that are working with fonts.
*/
class OMNIUI_CLASS_API FontHelper
{
protected:
OMNIUI_API
FontHelper();
OMNIUI_API
virtual ~FontHelper();
/**
* @brief Push the font to the underlying windowing system if the font is available. It's in protected to make it
* available to devired classes.
*/
OMNIUI_API
void _pushFont(const Widget& widget, bool overresolution = false);
/**
* @brief Push the font to the underlying windowing system if the font is available. It's in protected to make it
* available to devired classes.
*/
OMNIUI_API
void _pushFont(float fontSize);
/**
* @brief Remove the font from the underlying windowing system if the font was pushed.
*/
OMNIUI_API
void _popFont() const;
/**
* @brief Checks the style, and save the font if necessary. We don't want this object to be derived from widget, so
* we pass the widget as argument.
*
* @param widget the object we want to get the font style from.
*/
void _updateFont(const Widget& widget, bool overresolution = false);
/**
* @brief Save the font if necessary.
*/
void _updateFont(float fontSize, float scale, bool hasFontSizeStyle);
/**
* @brief Save the font if necessary.
*/
void _updateFont(const char* font, float fontSize, float scale, bool hasFontSizeStyle, bool overresolution = false);
private:
std::unique_ptr<FontHelperPrivate> m_prv;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/HGrid.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include "Grid.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief Shortcut for Grid{eLeftToRight}. The grid grows from left to right with the widgets placed.
*
* @see Grid
*/
class OMNIUI_CLASS_API HGrid : public Grid
{
OMNIUI_OBJECT(HGrid)
public:
OMNIUI_API
~HGrid() override;
protected:
/**
* @brief Construct a grid that grow from left to right with the widgets placed.
*/
OMNIUI_API
HGrid();
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Object.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include <omni/ui/ContainerScope.h>
// The OMNIUI_OBJECT macro must appear in the public section of a class definition of all the objects that use
// other services provided by UI Framework system. It implements two public methods: create and castShared.
// We need to specify the class name because we need to have the text representation of it in getTypeName.
#define OMNIUI_OBJECT_(currentType, overrideText) \
public: \
/* A little shortcut to get the current class type */ \
using This = currentType; \
\
/** Create the widget and put it as a child of the top item of ContainerStack. */ \
/* It's very useful to have the new object already attached to the layout. */ \
template <typename... Args> \
static std::shared_ptr<This> create(Args&&... args) \
{ \
/* Cannot use std::make_shared because the constructor is protected */ \
std::shared_ptr<This> ptr{ new This{ std::forward<Args>(args)... } }; \
\
ContainerStack::instance().addChildToTop(std::static_pointer_cast<Widget>(ptr)); \
\
return ptr; \
} \
/* version that accepts a destructor and passes it to the shared_ptr */ \
template<class Destructor, typename... Args> \
static std::shared_ptr<This> createWithDestructor(Destructor destructor, Args&&... args) \
{ \
/* Cannot use std::make_shared because the constructor is protected */ \
std::shared_ptr<This> ptr{ new This{ std::forward<Args>(args)... }, std::forward<Destructor>(destructor) }; \
\
ContainerStack::instance().addChildToTop(std::static_pointer_cast<Widget>(ptr)); \
\
return ptr; \
} \
\
/** Returns this as a shared pointer */ \
template <typename T = This> \
std::shared_ptr<T> castShared() \
{ \
return std::static_pointer_cast<T>(this->shared_from_this()); \
} \
\
/** Return the name of the current type. We use it to resolve the styles. */ \
virtual const std::string& getTypeName() const overrideText \
{ \
static const std::string typeName{ #currentType }; \
return typeName; \
} \
\
private:
#define OMNIUI_OBJECT(currentType) OMNIUI_OBJECT_(currentType, override)
#define OMNIUI_OBJECT_BASE(currentType) OMNIUI_OBJECT_(currentType, )
|
omniverse-code/kit/include/omni/ui/ItemModelHelper.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractItemModel.h"
#include "Widget.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
class AbstractItemModel;
/**
* @brief The ItemModelHelper class provides the basic functionality for item widget classes.
*
* TODO: It's very similar to ValueModelHelper. We need to template it. It's not templated now because we need a good
* solution for pybind11. Pybind11 doesn't like templated classes.
*/
class OMNIUI_CLASS_API ItemModelHelper
{
public:
OMNIUI_API
virtual ~ItemModelHelper();
/**
* @brief Called by the model when the model value is changed. The class should react to the changes.
*
* @param item The item in the model that is changed. If it's NULL, the root is chaged.
*/
OMNIUI_API
virtual void onModelUpdated(const std::shared_ptr<const AbstractItemModel::AbstractItem>& item) = 0;
/**
* @brief Set the current model.
*/
OMNIUI_API
virtual void setModel(const std::shared_ptr<AbstractItemModel>& model);
/**
* @brief Returns the current model.
*/
OMNIUI_API
virtual const std::shared_ptr<AbstractItemModel>& getModel() const;
protected:
OMNIUI_API
ItemModelHelper(const std::shared_ptr<AbstractItemModel>& model);
private:
std::shared_ptr<AbstractItemModel> m_model = {};
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/ZStack.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include "Stack.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief Shortcut for Stack{eBackToFront}. The widgets are placed sorted in a Z-order in top right corner with suitable
* sizes.
*
* @see Stack
*/
class OMNIUI_CLASS_API ZStack : public Stack
{
OMNIUI_OBJECT(ZStack)
public:
OMNIUI_API
~ZStack() override;
protected:
/**
* @brief Construct a stack with the widgets placed in a Z-order with sorting from background to foreground.
*/
OMNIUI_API
ZStack();
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/ComboBox.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "FontHelper.h"
#include "ItemModelHelper.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
class AbstractItemModel;
/**
* @brief The ComboBox widget is a combined button and a drop-down list.
*
* A combo box is a selection widget that displays the current item and can pop up a list of selectable items.
*
* The ComboBox is implemented using the model-view pattern. The model is the central component of this system. The root
* of the item model should contain the index of currently selected items, and the children of the root include all the
* items of the combo box.
*/
class OMNIUI_CLASS_API ComboBox : public Widget, public ItemModelHelper, public FontHelper
{
OMNIUI_OBJECT(ComboBox)
public:
OMNIUI_API
~ComboBox() override;
/**
* @brief Reimplemented the method to indicate the width hint that represents the preferred size of the widget.
* Currently this widget can't be smaller than the size of the ComboBox square.
*
* @see Widget::setComputedContentWidth
*/
OMNIUI_API
void setComputedContentWidth(float width) override;
/**
* @brief Reimplemented the method to indicate the height hint that represents the preferred size of the widget.
* Currently this widget can't be smaller than the size of the ComboBox square.
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) override;
/**
* @brief Reimplemented. Something happened with the style or with the parent style. We need to update the saved
* font.
*/
OMNIUI_API
void onStyleUpdated() override;
/**
* @brief Reimplemented the method from ItemModelHelper that is called when the model is changed.
*
* @param item The item in the model that is changed. If it's NULL, the root is chaged.
*/
OMNIUI_API
void onModelUpdated(const std::shared_ptr<const AbstractItemModel::AbstractItem>& item) override;
/**
* @brief Determines if it's necessary to hide the text of the ComboBox.
*/
OMNIUI_PROPERTY(bool, arrowOnly, DEFAULT, false, READ, isArrowOnly, WRITE, setArrowOnly);
protected:
/**
* @brief Construct ComboBox
*
* @param model The model that determines if the button is checked.
*/
OMNIUI_API
ComboBox(const std::shared_ptr<AbstractItemModel>& model = {});
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
// The cached state of the ComboBox allows to query the model only if it's changed.
int64_t m_currentIndex = 0;
std::vector<std::string> m_items;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Separator.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "FontHelper.h"
#include "MenuItem.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The Separator class provides blank space.
*
* Normally, it's used to create separator line in the UI elements
*/
class OMNIUI_CLASS_API Separator : public MenuItem, public FontHelper
{
OMNIUI_OBJECT(Separator)
public:
OMNIUI_API
~Separator() override;
/**
* @brief It's called when the style is changed. It should be propagated to children to make the style cached and
* available to children.
*/
OMNIUI_API
void cascadeStyle() override;
protected:
/**
* @brief Construct Separator
*/
OMNIUI_API
Separator(const std::string& text = "");
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
void _drawContentCompatibility(float elapsedTime);
/**
* @brief Resolves padding from style and from the underlying draw system.
*/
void _resolvePaddingCompatibility(float& paddingX, float& paddingY) const;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/OffsetLine.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "FreeShape.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The free widget is the widget that is independent of the layout. It
* draws the line stuck to the bounds of other widgets.
*/
class OMNIUI_CLASS_API OffsetLine : public FreeLine
{
OMNIUI_OBJECT(OffsetLine)
public:
/**
* @brief The offset to the direction of the line normal.
*
*/
OMNIUI_PROPERTY(float, offset, DEFAULT, 0.0f, READ, getOffset, WRITE, setOffset);
/**
* @brief The offset from the bounds of the widgets this line is stuck to.
*
*/
OMNIUI_PROPERTY(float, boundOffset, DEFAULT, 0.0f, READ, getBoundOffset, WRITE, setBoundOffset);
protected:
/**
* @brief Initialize the the shape with bounds limited to the positions of the given widgets.
*
* @param start The bound corder is in the border of this given widget.
* @param end The bound corder is in the border of this given widget.
*/
OMNIUI_API
OffsetLine(std::shared_ptr<Widget> start, std::shared_ptr<Widget> end);
/**
* @brief Reimplemented the rendering code of the shape.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/FloatSlider.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "AbstractSlider.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The slider is the classic widget for controlling a bounded value. It lets the user move a slider handle along
* a horizontal groove and translates the handle's position into a float value within the legal range.
*/
class OMNIUI_CLASS_API FloatSlider : public AbstractSlider
{
OMNIUI_OBJECT(FloatSlider)
public:
/**
* @brief Reimplemented the method from ValueModelHelper that is called when the model is changed.
*/
OMNIUI_API
void onModelUpdated() override;
/**
* @brief Get the format string for the given value. The number should be in the format of `0.0` and the length of
* the formed string should be minimal.
*/
static const char* getFormatString(double value, uint32_t maxSymbols = 5);
/**
* @brief This property holds the slider's minimum value.
*/
OMNIUI_PROPERTY(double, min, DEFAULT, 0.0f, READ, getMin, WRITE, setMin);
/**
* @brief This property holds the slider's maximum value.
*/
OMNIUI_PROPERTY(double, max, DEFAULT, 1.0f, READ, getMax, WRITE, setMax);
/**
* @brief This property controls the steping speed on the drag
*/
OMNIUI_PROPERTY(float, step, DEFAULT, 0.01f, READ, getStep, WRITE, setStep);
/**
* @brief This property overrides automatic formatting if needed
*/
OMNIUI_PROPERTY(std::string, format, DEFAULT, "", READ, getFormat, WRITE, setFormat);
/**
* @brief This property holds the slider value's float precision
*/
OMNIUI_PROPERTY(uint32_t, precision, DEFAULT, 5, READ, getPrecision, WRITE, setPrecision);
protected:
/**
* @brief Construct FloatSlider
*/
OMNIUI_API
FloatSlider(const std::shared_ptr<AbstractValueModel>& model = {});
/**
* @brief the ration calculation is requiere to draw the Widget as Gauge, it is calculated with Min/Max & Value
*/
virtual float _getValueRatio() override;
private:
/**
* @brief Reimplemented. _drawContent sets everything up including styles and fonts and calls this method.
*/
void _drawUnderlyingItem() override;
/**
* @brief It has to run a very low level function to call the widget.
*/
virtual bool _drawUnderlyingItem(double* value, double min, double max);
// The cached state of the slider.
double m_valueCache;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/RadioCollection.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Api.h"
#include "ValueModelHelper.h"
#include <functional>
#include <memory>
#include <vector>
OMNIUI_NAMESPACE_OPEN_SCOPE
class RadioButton;
/**
* @brief Radio Collection is a class that groups RadioButtons and coordinates their state.
*
* It makes sure that the choice is mutually exclusive, it means when the user selects a radio button, any previously
* selected radio button in the same collection becomes deselected.
*
* @see RadioButton
*/
class OMNIUI_CLASS_API RadioCollection : public ValueModelHelper
{
public:
OMNIUI_API
~RadioCollection();
// We need it to make sure it's created as a shared pointer.
template <typename... Args>
static std::shared_ptr<RadioCollection> create(Args&&... args)
{
/* make_shared doesn't work because the constructor is protected: */
/* auto ptr = std::make_shared<This>(std::forward<Args>(args)...); */
/* TODO: Find the way to use make_shared */
return std::shared_ptr<RadioCollection>{ new RadioCollection{ std::forward<Args>(args)... } };
}
/**
* @brief Called by the model when the model value is changed. The class should react to the changes.
*
* Reimplemented from ValueModelHelper
*/
OMNIUI_API
void onModelUpdated() override;
protected:
/**
* @brief Constructs RadioCollection
*/
OMNIUI_API
RadioCollection(const std::shared_ptr<AbstractValueModel>& model);
private:
friend class RadioButton;
/**
* @brief this methods add a radio button to the collection, generally it is called directly by the button itself
* when the collection is setup on the button
*/
OMNIUI_API
void _addRadioButton(const std::shared_ptr<RadioButton>& button);
/**
* @brief Called then the user clicks one of the buttons in this collection.
*/
OMNIUI_API
void _clicked(const RadioButton* button);
// The list of the radio button that are part of this collection.
//
// RadioButton keeps the shared pointer to this collection, and here the collection keeps the pointer to the
// RadioButton. To avoid circular dependency, we use weak pointers from this side because of the Python API. We
// never require the user to keep a Python object and do all the work that is related to the object's life. It means
// the user can create UI like this, and the created objects will not be immediately removed with Python garbage
// collector:
//
// with ui.HStack():
// ui.Label("Hello")
// ui.Label("World")
//
// The RadioCollection is not a widget, and to make sure the collection will not be removed right after it's
// created, we use shared pointers in RadioButtons and not here, which makes them the owners of the collection.
std::vector<std::weak_ptr<RadioButton>> m_radioButtons;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Style.h | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#include "Api.h"
#include "StyleContainer.h"
#include <memory>
OMNIUI_NAMESPACE_OPEN_SCOPE
class Container;
/**
* @brief A singleton that controls the global style of the session.
*/
class OMNIUI_CLASS_API Style
{
public:
/**
* @brief Get the instance of this singleton object.
*/
OMNIUI_API
static Style& getInstance();
OMNIUI_API
virtual ~Style();
// A singletom pattern
Style(Style const&) = delete;
void operator=(Style const&) = delete;
/**
* @brief Returns the default root style. It's the style that is preselected when no alternative is specified.
*/
OMNIUI_API
std::shared_ptr<StyleContainer> const& getDefaultStyle() const;
/**
* @brief Set the default root style. It's the style that is preselected when no alternative is specified.
*/
OMNIUI_API
void setDefaultStyle(std::shared_ptr<StyleContainer> const& v);
/**
* @brief Set the default root style. It's the style that is preselected when no alternative is specified.
*/
OMNIUI_API
void setDefaultStyle(StyleContainer&& style);
/**
* @brief Connect the widget to the default root style.
*/
void connectToGlobalStyle(const std::shared_ptr<Widget>& widget);
private:
Style();
std::shared_ptr<Container> m_rootStyleWidget;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Triangle.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Alignment.h"
#include "Shape.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
struct TriangleStyleSnapshot;
/**
* @brief The Triangle widget provides a colored triangle to display.
*/
class OMNIUI_CLASS_API Triangle : public Shape
{
OMNIUI_OBJECT(Triangle)
public:
OMNIUI_API
~Triangle() override;
/**
* @brief This property holds the alignment of the triangle when the fill policy is ePreserveAspectFit or
* ePreserveAspectCrop.
* By default, the triangle is centered.
*/
OMNIUI_PROPERTY(Alignment, alignment, DEFAULT, Alignment::eRightCenter, READ, getAlignment, WRITE, setAlignment);
protected:
/**
* @brief Constructs Triangle
*/
OMNIUI_API
Triangle();
/**
* @brief Reimplemented the rendering code of the shape.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawShape(float elapsedTime, float x, float y, float width, float height) override;
/**
* @brief Reimplemented the draw shadow of the shape.
*/
OMNIUI_API
void _drawShadow(
float elapsedTime,
float x,
float y,
float width,
float height,
uint32_t shadowColor,
float dpiScale,
ImVec2 shadowOffset,
float shadowThickness,
uint32_t shadowFlag) override;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/ImageWithProvider.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "Alignment.h"
#include "ImageProvider/ImageProvider.h"
#include "Widget.h"
#include <mutex>
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The Image widget displays an image.
*
* The source of the image is specified as a URL using the source property. By default, specifying the width and height
* of the item causes the image to be scaled to that size. This behavior can be changed by setting the fill_mode
* property, allowing the image to be stretched or scaled instead. The property alignment controls where to align the
* scaled image.
*/
class OMNIUI_CLASS_API ImageWithProvider : public Widget
{
OMNIUI_OBJECT(ImageWithProvider)
public:
enum class FillPolicy : uint8_t
{
eStretch = 0,
ePreserveAspectFit,
ePreserveAspectCrop
};
OMNIUI_API
~ImageWithProvider() override;
OMNIUI_API
void destroy() override;
/**
* @brief Reimplemented. Called when the style or the parent style is changed.
*/
OMNIUI_API
void onStyleUpdated() override;
/**
* @brief Force call `ImageProvider::prepareDraw` to ensure the next draw
* call the image is loaded. It can be used to load the image for a hidden
* widget or to set the rasterization resolution.
*/
OMNIUI_API
void prepareDraw(float width, float height);
/**
* @brief This property holds the alignment of the image when the fill policy is ePreserveAspectFit or
* ePreserveAspectCrop.
* By default, the image is centered.
*/
OMNIUI_PROPERTY(Alignment, alignment, DEFAULT, Alignment::eCenter, READ, getAlignment, WRITE, setAlignment);
/**
* @brief Define what happens when the source image has a different size than the item.
*/
OMNIUI_PROPERTY(FillPolicy,
fillPolicy,
DEFAULT,
FillPolicy::ePreserveAspectFit,
READ,
getFillPolicy,
WRITE,
setFillPolicy,
NOTIFY,
setFillPolicyChangedFn);
/**
* @brief Prevents image blurring when it's placed to fractional position (like x=0.5, y=0.5)
*/
OMNIUI_PROPERTY(bool, pixelAligned, DEFAULT, false, READ, getPixelAligned, WRITE, setPixelAligned);
// TODO: Image rotation
// TODO: Right now, it's useless because we load the image in the background, and when the object is created, the
// texture is not loaded. There is no way to wait for the texture. We need to add a method to force load. And we
// will be able to use texture dimensions as a read-only property. It will help us to achieve
protected:
/**
* @brief Construct image with given ImageProvider. If the ImageProvider is nullptr, it gets the image URL from
* styling.
*/
OMNIUI_API
ImageWithProvider(std::shared_ptr<ImageProvider> imageProvider);
/**
* @brief Construct image with given url. If the url is empty, it gets the image URL from styling.
*/
OMNIUI_API
ImageWithProvider(const std::string& url = {});
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
// The mutex for the texture operations, because we load the texture in the background.
std::mutex m_textureMutex;
void _populateImageProvidersFromStyles();
std::shared_ptr<ImageProvider>& _createImageProviderFromUrl(const char* url);
void _calcTextureIndex();
// Returns true if the url from the style is changed since the image is loaded.
bool _hasStyleUrlChanged() const;
// Flag to check all the textures if it's necessary to reload them.
bool m_texturesLoaded = false;
// It is the cache of preloaded textures. We need it because we can switch the texture depending on the widget style
// state. It can be a separate texture for hovered, disabled, selected, etc. widget. To switch the texture fast, we
// preload them for all the states. To be sure that the same texture is not loaded twice, we keep them in a separate
// vector, and we keep the index of the texture per style state. To know which texture is already loaded, we keep
// the map name to the texture index.
// Index of the texture per style state
std::array<size_t, static_cast<size_t>(StyleContainer::State::eCount)> m_styleStateToTextureDataIndex;
// Resolved style. We need it to know if style shade is changed. It's void*
// to indicate that it can't be used as a string andit can only be used to
// check if the style became dirty.
std::array<const void*, static_cast<size_t>(StyleContainer::State::eCount)> m_styleStateToResolvedStyle;
// Index of the texture per filename
std::unordered_map<std::string, size_t> m_imageUrlToTextureDataIndex;
bool m_updateStyleImages = true;
bool m_overrideStyleImages = false;
// Texture data for all the loaded textures
struct TextureData
{
// Removes it from the GPU.
~TextureData();
// Flag to reload the texture.
bool loadingStarted = false;
// We delete TextureData when the use count reaches zero.
size_t counter = 0;
std::shared_ptr<ImageProvider> imageProvider = nullptr;
};
std::vector<std::unique_ptr<TextureData>> m_textureDataArray;
std::vector<std::shared_ptr<ImageProvider>> m_createdImageProviders;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/Profile.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include <carb/profiler/Profile.h>
// Enable top-level Window zones by default.
#define OMNIUI_PROFILE_ENABLE
// Extra zones for recursive Widget layout and drawing functions, causes performance slowdown so disabled by default.
// Recommend using the profiler maxZoneDepth option if enabled.
// #define OMNIUI_PROFILE_VERBOSE
#ifdef OMNIUI_PROFILE_ENABLE
# define OMNIUI_PROFILE_ZONE(zoneName, ...) CARB_PROFILE_ZONE(1, zoneName, ##__VA_ARGS__)
# define OMNIUI_PROFILE_FUNCTION CARB_PROFILE_FUNCTION(1)
# define OMNIUI_PROFILE_WIDGET_FUNCTION \
CARB_PROFILE_ZONE(1, "[%s] %s '%s'", this->getTypeName().c_str(), CARB_PRETTY_FUNCTION, this->getName().c_str())
#else
# define OMNIUI_PROFILE_ZONE(...)
# define OMNIUI_PROFILE_FUNCTION
# define OMNIUI_PROFILE_WIDGET_FUNCTION
#endif
#ifdef OMNIUI_PROFILE_VERBOSE
# define OMNIUI_PROFILE_VERBOSE_ZONE OMNIUI_PROFILE_ZONE
# define OMNIUI_PROFILE_VERBOSE_FUNCTION OMNIUI_PROFILE_FUNCTION
# define OMNIUI_PROFILE_VERBOSE_WIDGET_FUNCTION OMNIUI_PROFILE_WIDGET_FUNCTION
#else
# define OMNIUI_PROFILE_VERBOSE_ZONE(...)
# define OMNIUI_PROFILE_VERBOSE_FUNCTION
# define OMNIUI_PROFILE_VERBOSE_WIDGET_FUNCTION
#endif
|
omniverse-code/kit/include/omni/ui/windowmanager/IWindowCallbackManager.h | #pragma once
#include <carb/Framework.h>
#include <carb/Interface.h>
#include <carb/events/EventsUtils.h>
#include <carb/events/IEvents.h>
#include <carb/profiler/Profile.h>
namespace omni
{
namespace kit
{
class IAppWindow;
}
namespace ui
{
namespace windowmanager
{
enum class DockPreference : uint32_t
{
eDisabled,
eMain,
eRight,
eLeft,
eRightTop,
eRightBottom,
eLeftBottom
};
/**
* Interface to implement for event listener.
*/
class IEventListener : public carb::IObject
{
public:
virtual void onDraw(float elapsedTime) = 0;
};
using IEventListenerPtr = carb::ObjectPtr<IEventListener>;
struct WindowSet;
class IWindowCallback : public carb::IObject
{
public:
virtual const char* getTitle() = 0;
virtual uint32_t getWidth() = 0;
virtual uint32_t getHeight() = 0;
virtual DockPreference getDockPreference() = 0;
virtual WindowSet* getWindowSet() = 0;
virtual omni::kit::IAppWindow* getAppWindow() = 0;
virtual void draw(float elapsedTime) = 0;
};
using IWindowCallbackPtr = carb::ObjectPtr<IWindowCallback>;
class IWindowCallbackManager
{
public:
CARB_PLUGIN_INTERFACE("omni::ui::windowmanager::IWindowCallbackManager", 0, 3)
virtual IWindowCallback* createWindowCallbackPtr(
const char* title, uint32_t width, uint32_t height, DockPreference dockPreference, IEventListener* listener) = 0;
IWindowCallbackPtr createWindowCallback(
const char* title, uint32_t width, uint32_t height, DockPreference dockPreference, IEventListener* listener)
{
return stealObject(this->createWindowCallbackPtr(title, width, height, dockPreference, listener));
}
virtual void removeWindowCallback(IWindowCallback* windowCallback) = 0;
virtual size_t getWindowCallbackCount() = 0;
virtual IWindowCallback* getWindowCallbackAt(size_t index) = 0;
inline void drawWindows(float elapsedTime);
inline IWindowCallback* findWindowCallbackByName(const char* name);
virtual WindowSet* createWindowSet() = 0;
virtual void destroyWindowSet(WindowSet* windowSet) = 0;
virtual WindowSet* getDefaultWindowSet() = 0;
virtual void attachWindowSetToAppWindow(WindowSet* windowSet, omni::kit::IAppWindow* appWindow) = 0;
virtual WindowSet* getWindowSetByAppWindow(omni::kit::IAppWindow* appWindow) = 0;
virtual omni::kit::IAppWindow* getAppWindowFromWindowSet(WindowSet* windowSet) = 0;
virtual size_t getWindowSetCount() = 0;
virtual WindowSet* getWindowSetAt(size_t index) = 0;
virtual IWindowCallback* createWindowSetCallbackPtr(WindowSet* windowSet,
const char* title,
uint32_t width,
uint32_t height,
DockPreference dockPreference,
IEventListener* listener) = 0;
IWindowCallbackPtr createWindowSetCallback(WindowSet* windowSet,
const char* title,
uint32_t width,
uint32_t height,
DockPreference dockPreference,
IEventListener* listener)
{
return stealObject(this->createWindowSetCallbackPtr(windowSet, title, width, height, dockPreference, listener));
}
IWindowCallbackPtr createAppWindowCallback(omni::kit::IAppWindow* appWindow,
const char* title,
uint32_t width,
uint32_t height,
DockPreference dockPreference,
IEventListener* listener)
{
WindowSet* windowSet = this->getWindowSetByAppWindow(appWindow);
if (!windowSet)
{
CARB_LOG_WARN("createAppWindowCallback: No window set attached to supplied app window!");
return IWindowCallbackPtr();
}
return stealObject(this->createWindowSetCallbackPtr(windowSet, title, width, height, dockPreference, listener));
}
virtual void addWindowSetCallback(WindowSet* windowSet, IWindowCallback* windowCallback) = 0;
virtual void removeWindowSetCallback(WindowSet* windowSet, IWindowCallback* windowCallback) = 0;
void removeAppWindowCallback(omni::kit::IAppWindow* appWindow, IWindowCallback* windowCallback)
{
WindowSet* windowSet = this->getWindowSetByAppWindow(appWindow);
if (!windowSet)
{
CARB_LOG_WARN("removeAppWindowCallback: No window set attached to supplied app window!");
return;
}
this->removeWindowSetCallback(windowSet, windowCallback);
}
void moveCallbackToAppWindow(IWindowCallback* windowCallback, omni::kit::IAppWindow* newAppWindow)
{
WindowSet* newWindowSet = this->getWindowSetByAppWindow(newAppWindow);
if (!newWindowSet)
{
CARB_LOG_WARN("moveCallbackToAppWindow: No window set attached to supplied app window!");
return;
}
WindowSet* oldWindowSet = windowCallback->getWindowSet();
this->removeWindowSetCallback(oldWindowSet, windowCallback);
this->addWindowSetCallback(newWindowSet, windowCallback);
}
virtual size_t getWindowSetCallbackCount(WindowSet* windowSet) = 0;
virtual IWindowCallback* getWindowSetCallbackAt(WindowSet* windowSet, size_t index) = 0;
inline void drawWindowSet(WindowSet* windowSet, float elapsedTime);
inline IWindowCallback* findWindowSetCallbackByName(WindowSet* windowSet, const char* name);
};
inline void IWindowCallbackManager::drawWindows(float elapsedTime)
{
WindowSet* windowSet = getDefaultWindowSet();
drawWindowSet(windowSet, elapsedTime);
}
inline IWindowCallback* IWindowCallbackManager::findWindowCallbackByName(const char* name)
{
WindowSet* windowSet = getDefaultWindowSet();
return findWindowSetCallbackByName(windowSet, name);
}
inline void IWindowCallbackManager::drawWindowSet(WindowSet* windowSet, float elapsedTime)
{
size_t windowCallbackCount = getWindowSetCallbackCount(windowSet);
omni::ui::windowmanager::IWindowCallback* editorMenuCallback = nullptr;
for (size_t idx = 0; idx < windowCallbackCount; ++idx)
{
omni::ui::windowmanager::IWindowCallback* windowCallback = getWindowSetCallbackAt(windowSet, idx);
if (windowCallback)
{
if (!editorMenuCallback && strcmp(windowCallback->getTitle(), "[editor_menu_hookup]") == 0)
{
// HACK, draw [editor_menu_hookup] last so MainWindow menu goes before it
editorMenuCallback = windowCallback;
continue;
}
CARB_PROFILE_ZONE(1, "'%s' ext window[new]", windowCallback->getTitle());
windowCallback->draw(elapsedTime);
}
}
if (editorMenuCallback)
{
CARB_PROFILE_ZONE(1, "[editor_menu_hookup] ext window[new]", editorMenuCallback->getTitle());
editorMenuCallback->draw(elapsedTime);
}
}
inline IWindowCallback* IWindowCallbackManager::findWindowSetCallbackByName(WindowSet* windowSet, const char* name)
{
size_t nameLen = strlen(name);
size_t windowCallbackCount = getWindowSetCallbackCount(windowSet);
for (size_t idx = 0; idx < windowCallbackCount; ++idx)
{
omni::ui::windowmanager::IWindowCallback* windowCallback = getWindowSetCallbackAt(windowSet, idx);
if (windowCallback && (strncmp(windowCallback->getTitle(), name, nameLen) == 0))
{
return windowCallback;
}
}
return nullptr;
}
} // windowmanager
} // ui
} // omni
|
omniverse-code/kit/include/omni/ui/windowmanager/WindowManagerUtils.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "IWindowCallbackManager.h"
#include <carb/settings/ISettings.h>
#include <functional>
namespace omni
{
namespace ui
{
namespace windowmanager
{
class LambdaEventListener : public IEventListener
{
public:
LambdaEventListener(const std::function<void(float)>& fn) : m_fn(fn)
{
}
void onDraw(float elapsedTime) override
{
if (m_fn)
m_fn(elapsedTime);
}
private:
std::function<void(float)> m_fn;
CARB_IOBJECT_IMPL
};
inline IWindowCallbackPtr createWindowCallback(IWindowCallbackManager* windowCallbackManager,
const char* title,
uint32_t width,
uint32_t height,
DockPreference dockPreference,
const std::function<void(float)>& onDrawFn)
{
return windowCallbackManager->createWindowCallback(
title, width, height, dockPreference, carb::stealObject(new LambdaEventListener(onDrawFn)).get());
}
inline IWindowCallbackPtr createWindowSetCallback(WindowSet* windowSet,
IWindowCallbackManager* windowCallbackManager,
const char* title,
uint32_t width,
uint32_t height,
DockPreference dockPreference,
const std::function<void(float)>& onDrawFn)
{
return windowCallbackManager->createWindowSetCallback(
windowSet, title, width, height, dockPreference, carb::stealObject(new LambdaEventListener(onDrawFn)).get());
}
inline IWindowCallbackPtr createAppWindowCallback(omni::kit::IAppWindow* appWindow,
IWindowCallbackManager* windowCallbackManager,
const char* title,
uint32_t width,
uint32_t height,
DockPreference dockPreference,
const std::function<void(float)>& onDrawFn)
{
return windowCallbackManager->createAppWindowCallback(
appWindow, title, width, height, dockPreference, carb::stealObject(new LambdaEventListener(onDrawFn)).get());
}
inline bool removeWindowCallbackFromDefaultManager(IWindowCallback* windowCallback)
{
IWindowCallbackManager* uiWindowManager = carb::getCachedInterface<IWindowCallbackManager>();
if (windowCallback && uiWindowManager)
{
uiWindowManager->removeWindowCallback(windowCallback);
return true;
}
return false;
}
}
}
}
|
omniverse-code/kit/include/omni/ui/windowmanager/WindowManagerBindingsPython.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#include "IWindowCallbackManager.h"
#include "WindowManagerUtils.h"
#include <carb/BindingsPythonUtils.h>
#include <carb/Framework.h>
DISABLE_PYBIND11_DYNAMIC_CAST(omni::ui::windowmanager::IWindowCallback)
DISABLE_PYBIND11_DYNAMIC_CAST(omni::ui::windowmanager::IWindowCallbackManager)
namespace omni
{
namespace kit
{
class IAppWindow
{
};
}
namespace ui
{
namespace windowmanager
{
struct WindowSet
{
};
class PythonEventListener : public IEventListener
{
public:
PythonEventListener(const std::function<void(float)>& fn) : m_fn(fn)
{
}
void onDraw(float dt) override
{
carb::callPythonCodeSafe(m_fn, dt);
}
private:
std::function<void(float)> m_fn;
CARB_IOBJECT_IMPL
};
inline void definePythonModule(py::module& m)
{
m.doc() = "pybind11 omni.ui.windowmanager bindings";
py::class_<WindowSet>(m, "WindowSet");
py::class_<IWindowCallback, IWindowCallbackPtr>(m, "IWindowCallback", R"(
IWindowCallback object.
)")
.def("get_title", &IWindowCallback::getTitle)
.def("get_width", &IWindowCallback::getWidth)
.def("get_height", &IWindowCallback::getHeight)
.def("get_dock_preference", &IWindowCallback::getDockPreference)
.def("get_window_set", &IWindowCallback::getWindowSet, py::return_value_policy::reference)
.def("get_app_window", &IWindowCallback::getAppWindow, py::return_value_policy::reference)
.def("draw", &IWindowCallback::draw)
/**/;
m.def("acquire_window_callback_manager_interface",
[]() { return carb::getCachedInterface<omni::ui::windowmanager::IWindowCallbackManager>(); },
py::return_value_policy::reference)
/**/;
py::class_<IWindowCallbackManager>(m, "IWindowCallbackManager")
.def("create_window_callback",
[](IWindowCallbackManager* self, const char* title, uint32_t width, uint32_t height,
DockPreference dockPreference, const std::function<void(float)>& onDrawFn) {
return self->createWindowCallback(
title, width, height, dockPreference, carb::stealObject(new PythonEventListener(onDrawFn)).get());
},
py::return_value_policy::reference)
.def("remove_window_callback", &IWindowCallbackManager::removeWindowCallback)
.def("get_window_callback_count", &IWindowCallbackManager::getWindowCallbackCount)
.def("get_window_callback_at", &IWindowCallbackManager::getWindowCallbackAt, py::return_value_policy::reference)
.def("create_window_set", &IWindowCallbackManager::createWindowSet, py::return_value_policy::reference)
.def("destroy_window_set", &IWindowCallbackManager::destroyWindowSet)
.def("get_default_window_set", &IWindowCallbackManager::getDefaultWindowSet)
.def("attach_window_set_to_app_window", &IWindowCallbackManager::attachWindowSetToAppWindow)
.def("get_window_set_by_app_window", &IWindowCallbackManager::getWindowSetByAppWindow,
py::return_value_policy::reference)
.def("get_app_window_from_window_set", &IWindowCallbackManager::getAppWindowFromWindowSet,
py::return_value_policy::reference)
.def("get_window_set_count", &IWindowCallbackManager::getWindowSetCount)
.def("get_window_set_at", &IWindowCallbackManager::getWindowSetAt, py::return_value_policy::reference)
.def("create_window_set_callback",
[](IWindowCallbackManager* self, WindowSet* windowSet, const char* title, uint32_t width, uint32_t height,
DockPreference dockPreference, const std::function<void(float)>& onDrawFn) {
return self->createWindowSetCallback(windowSet, title, width, height, dockPreference,
carb::stealObject(new PythonEventListener(onDrawFn)).get());
},
py::return_value_policy::reference)
.def("create_app_window_callback",
[](IWindowCallbackManager* self, omni::kit::IAppWindow* appWindow, const char* title, uint32_t width,
uint32_t height, DockPreference dockPreference, const std::function<void(float)>& onDrawFn) {
return self->createAppWindowCallback(appWindow, title, width, height, dockPreference,
carb::stealObject(new PythonEventListener(onDrawFn)).get());
},
py::return_value_policy::reference)
.def("add_window_set_callback", &IWindowCallbackManager::addWindowSetCallback)
.def("remove_window_set_callback", &IWindowCallbackManager::removeWindowSetCallback)
.def("remove_app_window_callback", &IWindowCallbackManager::removeAppWindowCallback)
.def("move_callback_to_app_window", &IWindowCallbackManager::moveCallbackToAppWindow)
.def("get_window_set_callback_count", &IWindowCallbackManager::getWindowSetCallbackCount)
.def("get_window_set_callback_at", &IWindowCallbackManager::getWindowSetCallbackAt,
py::return_value_policy::reference)
/**/;
}
}
}
}
|
omniverse-code/kit/include/omni/ui/ImageProvider/AssetsState.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include <carb/assets/IAssets.h>
#include <carb/filesystem/IFileSystem.h>
#include <carb/imaging/IImaging.h>
#include <carb/svg/Svg.h>
#include <carb/tokens/ITokens.h>
#include <carb/tokens/TokensUtils.h>
#include <omni/renderer/utils/AssetsManagement.h>
#include <unordered_set>
namespace omni
{
namespace ui
{
/**
* @brief Helper class to store asset-related interfaces and entities.
* The main entity is an asset pool, which is supposed to be single for the whole omni.ui.
* As omni.ui do not have solid enter/exit pattern as e.g. Carbonite plugins do, reference
* counting mechanism is implemented to make sure we don't leak resources.
* Each time reference count is 0, the asset pool is released. When reference count goes
* positive, asset pool is recreated.
*/
class AssetsState
{
public:
carb::filesystem::IFileSystem* fs = nullptr;
carb::tokens::ITokens* tokens = nullptr;
carb::assets::IAssets* assets = nullptr;
carb::imaging::IImaging* imaging = nullptr;
carb::svg::Svg* svg = nullptr;
omni::renderer::utils::AssetsManager* assetsManager = nullptr;
carb::assets::Pool assetPool = carb::assets::kInvalidPool;
bool isInitialized = false;
bool releaseHookRegistered = false;
AssetsState()
{
fs = carb::getCachedInterface<carb::filesystem::IFileSystem>();
tokens = carb::getCachedInterface<carb::tokens::ITokens>();
assets = carb::getCachedInterface<carb::assets::IAssets>();
imaging = carb::getCachedInterface<carb::imaging::IImaging>();
svg = carb::getCachedInterface<carb::svg::Svg>();
carb::getFramework()->addReleaseHook(assets, sAssetsReleased, this);
releaseHookRegistered = true;
}
~AssetsState()
{
// As this object is expected to be static, we use regular assert
assert(counter == 0);
if (carb::getFramework())
{
if (releaseHookRegistered)
carb::getFramework()->removeReleaseHook(assets, sAssetsReleased, this);
}
}
static void sAssetsReleased(void*, void* user)
{
static_cast<AssetsState*>(user)->assetsReleased();
}
void assetsReleased()
{
fs = nullptr;
tokens = nullptr;
assets = nullptr;
imaging = nullptr;
svg = nullptr;
assetPool = carb::assets::kInvalidPool;
if (assetsManager)
{
assetsManager->notifyShutdown();
}
carb::getFramework()->removeReleaseHook(nullptr, sAssetsReleased, this);
releaseHookRegistered = false;
}
carb::extras::Path getAssetPath(const std::string& sourceUrl)
{
carb::extras::Path imagePath;
if (sourceUrl.compare(0, 10, "omniverse:") == 0 || sourceUrl.compare(0, 5, "http:") == 0 || sourceUrl.compare(0, 6, "https:") == 0 ||
sourceUrl.compare(0, 5, "file:") == 0 || sourceUrl.compare(0, 2, "//") == 0 || sourceUrl[0] == '$')
{
// It's URL
imagePath = sourceUrl;
}
else if (sourceUrl[0] == '/')
{
// If the first symbol is '/', it's direct path in Linux. Windows should accept it as path in the current
// drive.
#if CARB_PLATFORM_WINDOWS
// Get drive name from app directory and append imagePath.
imagePath = carb::extras::Path{ "${drive}" }.join(sourceUrl);
#else
imagePath = sourceUrl;
#endif
}
else if (sourceUrl.length() > 2 && sourceUrl[1] == ':')
{
// If the second symbol is ':', it's direct path in Windows.
#if CARB_PLATFORM_WINDOWS
imagePath = sourceUrl;
#else
// TODO: What should we do if we have Windows path on Linux? ATM the drive is removed from the path.
imagePath = sourceUrl.substr(2);
#endif
}
else
{
// It's relative path. We consider it's relative to the application directory.
imagePath = carb::extras::Path{ "${kit}" }.join(sourceUrl);
}
imagePath = carb::tokens::resolveString(tokens, static_cast<const char*>(imagePath));
return imagePath;
}
void startup()
{
if (!isInitialized)
{
assetsManager = new omni::renderer::utils::AssetsManager;
assetPool = assets->createPool("omni.ui ImageProviders");
isInitialized = true;
}
}
void shutdown()
{
if (isInitialized)
{
// The framework could be shutting down at this point. Re-acquire IAssets to see if it matches.
if (carb::getFramework() && assets)
{
carb::AcquireInterfaceOptions aio{};
aio.sizeofThis = sizeof(aio);
aio.clientName = g_carbClientName;
aio.desc = carb::assets::IAssets::getInterfaceDesc();
aio.flags = (carb::AcquireInterfaceFlags)(carb::fAIFNoInitialize | carb::fAIFOptional);
auto newAssets = (carb::assets::IAssets*)carb::getFramework()->internalAcquireInterface(aio);
if (newAssets == assets)
{
assets->destroyPool(assetPool);
}
}
assetPool = carb::assets::kInvalidPool;
delete assetsManager;
assetsManager = nullptr;
isInitialized = false;
}
}
// We need this ref counting because omni.ui doesn't have clear shutdown routine,
// and we need a way to free asset pool resources
size_t counter = 0;
void incPoolRef()
{
++counter;
if (assetPool == carb::assets::kInvalidPool)
{
startup();
}
}
void decPoolRef()
{
if (counter > 0)
{
--counter;
if (counter == 0)
{
shutdown();
}
}
else
{
CARB_LOG_ERROR("Asset state manager: asymmetric ref counting detected!");
}
}
};
AssetsState& getAssetsState();
}
}
|
omniverse-code/kit/include/omni/ui/ImageProvider/ByteImageProvider.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "ImageProvider.h"
namespace omni
{
namespace kit
{
namespace renderer
{
class IImGuiRenderer;
}
}
namespace ui
{
class OMNIUI_CLASS_API ByteImageProvider : public ImageProvider
{
public:
OMNIUI_API
ByteImageProvider();
OMNIUI_API
virtual ~ByteImageProvider();
/**
* @brief Sets byte data that the image provider will turn into an image.
* @param bytes Data bytes.
* @param size Tuple of image size, (width, height).
* @param stride Number of bytes between rows of data bytes. Value kAutoCalculateStride could be used to
* auto-calculate stride based on format, given data bytes have no gaps.
* @param format Image format.
*/
OMNIUI_API
virtual void setBytesData(const uint8_t* bytes,
carb::Uint2 size,
size_t stride = kAutoCalculateStride,
carb::Format format = carb::Format::eRGBA8_UNORM);
OMNIUI_API
virtual void setMipMappedBytesData(const uint8_t* const* mipMapBytes,
size_t* mipMapStrides,
size_t mipMapCount,
carb::Uint2 size,
carb::Format format = carb::Format::eRGBA8_UNORM);
OMNIUI_API
virtual void setMipMappedBytesData(const uint8_t* bytes,
carb::Uint2 size,
size_t stride,
carb::Format format = carb::Format::eRGBA8_UNORM,
size_t maxMipLevels = SIZE_MAX);
OMNIUI_API
virtual void setBytesDataFromGPU(const uint8_t* bytes,
carb::Uint2 size,
size_t stride = kAutoCalculateStride,
carb::Format format = carb::Format::eRGBA8_UNORM);
OMNIUI_API
void prepareDraw(float widgetWidth, float widgetHeight) override;
protected:
friend class GpuResourcesCache;
void _updateImage(const uint8_t* const* mipMapBuffers,
size_t* mipMapStrides,
size_t mipMapCount,
carb::Uint2 size,
carb::Format format,
bool fromGpu = false);
OMNIUI_API
void _releaseImage() override;
OMNIUI_API
bool mergeTextureOptions(TextureOptions& textureOptions) const override;
OMNIUI_API
bool setTextureOptions(TextureOptions textureOptions) override;
omni::kit::renderer::TextureGpuData* m_textureGpuData = nullptr;
omni::kit::renderer::TextureGpuReference m_imageGpuDescRef = {};
omni::kit::renderer::IImGuiRenderer* m_imGuiRenderer = nullptr;
struct ObsoleteTexture;
std::unique_ptr<ObsoleteTexture> m_obsoleteTexture;
std::unique_ptr<TextureOptions> m_textureOptions;
};
}
}
|
omniverse-code/kit/include/omni/ui/ImageProvider/DynamicTextureProvider.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "ByteImageProvider.h"
namespace omni
{
namespace ui
{
class OMNIUI_CLASS_API DynamicTextureProvider : public ByteImageProvider
{
public:
/**
* @brief Construct DynamicTextureProvider.
* @param textureName Name of dynamic texture which will be updated from setBytesData.
*/
OMNIUI_API
DynamicTextureProvider(const std::string& textureName);
OMNIUI_API
virtual ~DynamicTextureProvider() override;
protected:
OMNIUI_API
bool _setManagedResource(GpuResource* gpuResource) override;
OMNIUI_API
bool mergeTextureOptions(TextureOptions& textureOptions) const override;
std::string m_textureUri;
};
}
}
|
omniverse-code/kit/include/omni/ui/ImageProvider/VectorImageProvider.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "RasterImageProvider.h"
namespace omni
{
namespace ui
{
class OMNIUI_CLASS_API VectorImageProvider : public ImageProvider
{
public:
OMNIUI_API
VectorImageProvider(std::string url = {});
OMNIUI_API
~VectorImageProvider();
/**
* @brief Sets the vector image URL. Asset loading doesn't happen immediately, but rather is started the next time
* widget is visible, in prepareDraw call.
*/
OMNIUI_API
virtual void setSourceUrl(const char* url);
/**
* @brief Returns vector image URL.
*/
OMNIUI_API
virtual std::string getSourceUrl() const;
/**
* @brief This function needs to be called every frame to make sure asset loading is moving forward, and resources
* are properly allocated.
*/
OMNIUI_API
void prepareDraw(float widgetWidth, float widgetHeight) override;
/**
* @brief Sets the maximum number of mip map levels allowed.
*/
OMNIUI_API
virtual void setMaxMipLevels(size_t maxMipLevels);
/**
* @brief Returns the maximum number of mip map levels allowed.
*/
OMNIUI_API
virtual size_t getMaxMipLevels() const;
protected:
std::string m_sourceVectorUrl;
bool m_sourceVectorUrlChanged = false;
mutable std::mutex m_sourceVectorUrlMutex;
size_t m_maxMipLevels = 3;
mutable std::mutex m_maxMipLevelsMutex;
bool _rasterizeSVG(const std::string& filePath, int width, int height);
std::string m_cacheKey;
};
}
}
|
omniverse-code/kit/include/omni/ui/ImageProvider/ImageProvider.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "../Object.h"
#include "../Property.h"
#include <carb/Types.h>
#include <carb/container/IntrusiveList.h>
#include <carb/tasking/TaskingTypes.h>
#include <omni/kit/renderer/IRenderer.h>
#include <mutex>
namespace omni
{
namespace ui
{
constexpr const size_t kAutoCalculateStride = (size_t)-1;
class OMNIUI_CLASS_API ImageProvider
{
protected:
using GpuResource = rtx::resourcemanager::RpResource;
using TextureOptions = omni::kit::renderer::IRendererTextureOptions;
public:
OMNIUI_API
ImageProvider();
OMNIUI_API
virtual ~ImageProvider();
/**
* @brief Returns reference which could be used to draw ImGui images with.
*/
OMNIUI_API
virtual void* getImGuiReference();
/**
* @brief Returns true if ImGui reference is valid, false otherwise.
*/
OMNIUI_API
virtual bool isReferenceValid()
{
return m_imGuiReference != nullptr;
}
/**
* @brief Gets image width.
*/
OMNIUI_API
size_t getWidth()
{
return m_imageSize.x;
}
/**
* @brief Gets image height.
*/
OMNIUI_API
size_t getHeight()
{
return m_imageSize.y;
}
/**
* @brief Gets tuple (width, height).
*/
OMNIUI_API
carb::Uint2 getSize()
{
return m_imageSize;
}
/**
* @brief Gets image format.
*/
OMNIUI_API
carb::Format getFormat()
{
return m_imageFormat;
}
/**
* @brief Function that should be called when the widget is being prepared to be drawn. Lazy load of image
* contents may happen there, depending on the image provider logic.
* @param widgetWidth Computed width of the widget.
* @param widgetHeight Computed height of the widget.
*/
OMNIUI_API
virtual void prepareDraw(float widgetWidth, float widgetHeight);
/**
* @brief Sets non-managed image data directly.
* @param imGuiReference Opaque pointer to the data used in the ImGuiRenderer.
* @param size Size tuple (width, height) of the image data.
* @param format Pixel format of the image data.
* @param rpRsrc The GpuResource to be associated with the image data. The GpuResource is not checked for data compatibility, can be nullptr.
*/
OMNIUI_API
void setImageData(void* imGuiReference, carb::Uint2 size, carb::Format format, GpuResource* gpuRsrc = nullptr);
/**
* @brief Sets image data directly from an GpuResource.
* @param rpRsrc The GpuResource to be used for data.
* @return A boolean value whether the image-data was set.
* On success the GpuResource will have been retained, otherwise not.
*/
OMNIUI_API
bool setImageData(GpuResource& gpuRsrc);
OMNIUI_API
bool setImageData(GpuResource& gpuRsrc, uint64_t presentationKey);
/**
* @brief Shuts down the image provider system
*/
OMNIUI_API
static void shutdown();
/**
* @brief Shuts down the image provider system
*/
OMNIUI_API
GpuResource* getManagedResource();
protected:
/**
* @brief Release the managed image data, called from setImageData
*/
OMNIUI_API
virtual void _releaseImage()
{
}
void _shutdown();
OMNIUI_API
virtual bool _setManagedResource(GpuResource* rpRsrc);
OMNIUI_API
virtual bool mergeTextureOptions(TextureOptions& textureOptions) const;
OMNIUI_API
virtual bool setTextureOptions(TextureOptions textureOptions);
void* m_imGuiReference = nullptr;
carb::Uint2 m_imageSize = {};
carb::Format m_imageFormat = carb::Format::eRGBA8_UNORM;
size_t m_imageMipCount = 1;
bool m_isShutdown = false;
omni::kit::renderer::IRenderer* m_kitRenderer = nullptr;
GpuResource* m_managedRsrc = nullptr;
uint64_t m_presentationKey = 0;
carb::tasking::SharedFuture<gpu::GfResult> m_future;
bool m_hasFuture = false;
public: // Must be public so it can be accessed outside of the class
carb::container::IntrusiveListLink<ImageProvider> m_link;
};
template <typename T, typename... Args>
static std::shared_ptr<T> create(Args&&... args)
{
std::shared_ptr<T> ptr{ new T{ std::forward<Args>(args)... } };
return ptr;
}
template <typename T, typename Deleter, typename... Args>
static std::shared_ptr<T> createWithDeleter(Deleter&& deleter, Args&&... args)
{
return std::shared_ptr<T>{ new T{ std::forward<Args>(args)... }, std::forward<Deleter>(deleter) };
}
}
}
|
omniverse-code/kit/include/omni/ui/ImageProvider/RasterImageProvider.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "ImageProvider.h"
namespace carb
{
namespace settings
{
struct ISettings;
}
}
namespace omni
{
namespace ui
{
class OMNIUI_CLASS_API RasterImageProvider : public ImageProvider
{
public:
OMNIUI_API
RasterImageProvider(std::string = {});
OMNIUI_API
~RasterImageProvider();
/**
* @brief Sets the raster image URL. Asset loading doesn't happen immediately, but rather is started the next time
* widget is visible, in prepareDraw call.
*/
OMNIUI_API
virtual void setSourceUrl(const char* url);
/**
* @brief Returns vector image URL.
*/
OMNIUI_API
virtual std::string getSourceUrl() const;
/**
* @brief This function needs to be called every frame to make sure asset loading is moving forward, and resources
* are properly allocated.
*/
OMNIUI_API
void prepareDraw(float widgetWidth, float widgetHeight) override;
/**
* @brief Sets the maximum number of mip map levels allowed.
*/
OMNIUI_API
virtual void setMaxMipLevels(size_t maxMipLevels);
/**
* @brief Returns the maximum number of mip map levels allowed.
*/
OMNIUI_API
virtual size_t getMaxMipLevels() const;
protected:
void _shutdown();
struct TextureData;
carb::settings::ISettings* m_settings = nullptr;
int32_t m_shutdownIterMax = 0;
std::string m_sourceRasterUrl;
bool m_sourceRasterUrlChanged = false;
mutable std::mutex m_sourceRasterUrlMutex;
std::unique_ptr<TextureData> m_textureData;
bool m_assetLoading = false;
std::string m_cacheKey;
size_t m_maxMipLevels = 3;
mutable std::mutex m_maxMipLevelsMutex;
time_t _getModTime(const std::string& assetPathString);
std::string _getCacheKey(const std::string& filePath);
/**
* @brief Function to trigger asset loading. Asset loading is non-blocking, so the image won't be available
* immediately after _loadAsset is called - instead the image resources will be recreated eventually in
* one of the subsequent _pollAsset calls when snapshot will be ready.
*/
void _loadAsset(const std::string& assetPathString);
/**
* @brief Function to check asset loading status. If asset snapshot is not ready, do nothing. When it is ready,
* proceed to create image resources from the loaded asset.
*/
void _pollAsset();
void _releaseAsset();
void _waitAsset();
};
}
}
|
omniverse-code/kit/include/omni/ui/bind/DocStyleContainer.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_StyleContainer \
"The StyleContainer class encapsulates the look and feel of a GUI.\n" \
"It's a place holder for the future work to support CSS style description. StyleContainer supports various properties, pseudo-states, and subcontrols that make it possible to customize the look of widgets. It can only be edited by merging with another style.\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_valid "Check if the style contains anything.\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_merge "Merges another style to this style. The given style is strongest.\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_getStyleStateGroupIndex \
"Find the style state group by type and name. It's pretty slow, so it shouldn't be used in the draw cycle.\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_getCachedTypes "Get all the types in this StyleContainer.\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_getCachedNames \
"Get all the names related to the type in this StyleContainer.\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_getCachedStates \
"Get all the available states in the given index in this StyleContainer.\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_resolveStyleProperty \
"Find the given property in the data structure using the style state group index. If the property is not found, it continues finding in cascading and parent blocks. The style state group index can be obtained with getStyleStateGroupIndex.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `T :`\n" \
" StyleFloatProperty or StyleColorProperty\n" \
"\n" \
" `U :`\n" \
" float or uint32_t\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_defaultStyle "Preset with a default style.\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_getNameToPropertyMapping \
"Get the the mapping between property and its string.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `T :`\n" \
" StyleFloatProperty, StyleEnumProperty, StyleColorProperty, StyleStringProperty or State\n"
#define OMNIUI_PYBIND_DOC_StyleContainer_getPropertyEnumeration \
"Get the Property from the string.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `T :`\n" \
" StyleFloatProperty, StyleEnumProperty, StyleColorProperty or StyleStringProperty\n"
#define OMNIUI_PYBIND_DOC_StyleContainer__parseScopeString \
"Perses a string that looks like \"Widget::name:state\", split it to the parts and return the parts.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocMainWindow.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_MainWindow \
"The MainWindow class represents Main Window for the Application, draw optional MainMenuBar and StatusBar.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_MainWindow_mainMenuBar "The main MenuBar for the application.\n"
#define OMNIUI_PYBIND_DOC_MainWindow_mainFrame "This represents Styling opportunity for the Window background.\n"
#define OMNIUI_PYBIND_DOC_MainWindow_statusBarFrame \
"The StatusBar Frame is empty by default and is meant to be filled by other part of the system.\n"
#define OMNIUI_PYBIND_DOC_MainWindow_cppStatusBarEnabled "Workaround to reserve space for C++ status bar.\n"
#define OMNIUI_PYBIND_DOC_MainWindow_showForeground "When show_foreground is True, MainWindow prevents other windows from showing.\n"
#define OMNIUI_PYBIND_DOC_MainWindow_MainWindow \
"Construct the main window, add it to the underlying windowing system, and makes it appear.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocAbstractItemModel.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_AbstractItemModel \
"The central component of the item widget. It is the application's dynamic data structure, independent of the user interface, and it directly manages the nested data. It follows closely model-view pattern. It's abstract, and it defines the standard interface to be able to interoperate with the components of the model-view architecture. It is not supposed to be instantiated directly. Instead, the user should subclass it to create a new model.\n" \
"The item model doesn't return the data itself. Instead, it returns the value model that can contain any data type and supports callbacks. Thus the client of the model can track the changes in both the item model and any value it holds.\n" \
"From any item, the item model can get both the value model and the nested items. Therefore, the model is flexible to represent anything from color to complicated tree-table construction.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_getItemChildren \
"Returns the vector of items that are nested to the given parent item.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `id :`\n" \
" The item to request children from. If it's null, the children of root will be returned.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_canItemHaveChildren \
"Returns true if the item can have children. In this way the delegate usually draws +/- icon.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `id :`\n" \
" The item to request children from. If it's null, the children of root will be returned.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_appendChildItem \
"Creates a new item from the value model and appends it to the list of the children of the given item.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_removeItem \
"Removes the item from the model.\n" \
"There is no parent here because we assume that the reimplemented model deals with its data and can figure out how to remove this item.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_getItemValueModelCount \
"Returns the number of columns this model item contains.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_getItemValueModel \
"Get the value model associated with this item.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `item :`\n" \
" The item to request the value model from. If it's null, the root value model will be returned.\n" \
"\n" \
" `index :`\n" \
" The column number to get the value model.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_beginEdit \
"Called when the user starts the editing. If it's a field, this method is called when the user activates the field and places the cursor inside.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_endEdit \
"Called when the user finishes the editing. If it's a field, this method is called when the user presses Enter or selects another field for editing. It's useful for undo/redo.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_dropAccepted \
"Called to determine if the model can perform drag and drop to the given item. If this method returns false, the widget shouldn't highlight the visual element that represents this item.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_dropAccepted01 \
"Called to determine if the model can perform drag and drop of the given string to the given item. If this method returns false, the widget shouldn't highlight the visual element that represents this item.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_drop \
"Called when the user droped one item to another.\n" \
"Small explanation why the same default value is declared in multiple places. We use the default value to be compatible with the previous API and especially with Stage 2.0. Thr signature in the old Python API is:\n" \
"def drop(self, target_item, source)\n" \
"drop(self, target_item, source)\n" \
"PyAbstractItemModel::drop\n" \
"AbstractItemModel.drop\n" \
"pybind11::class_<AbstractItemModel>.def(\"drop\")\n" \
"AbstractItemModel\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_drop01 "Called when the user droped a string to the item.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_getDragMimeData \
"Returns Multipurpose Internet Mail Extensions (MIME) for drag and drop.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_subscribe \
"Subscribe the ItemModelHelper widget to the changes of the model.\n" \
"We need to use regular pointers because we subscribe in the constructor of the widget and unsubscribe in the destructor. In constructor smart pointers are not available. We also don't allow copy and move of the widget.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_unsubscribe \
"Unsubscribe the ItemModelHelper widget from the changes of the model.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_addItemChangedFn \
"Adds the function that will be called every time the value changes.\n" \
"The id of the callback that is used to remove the callback.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_removeItemChangedFn \
"Remove the callback by its id.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `id :`\n" \
" The id that addValueChangedFn returns.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_addBeginEditFn \
"Adds the function that will be called every time the user starts the editing.\n" \
"The id of the callback that is used to remove the callback.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_removeBeginEditFn \
"Remove the callback by its id.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `id :`\n" \
" The id that addBeginEditFn returns.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_addEndEditFn \
"Adds the function that will be called every time the user finishes the editing.\n" \
"The id of the callback that is used to remove the callback.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_removeEndEditFn \
"Remove the callback by its id.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `id :`\n" \
" The id that addEndEditFn returns.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_processBeginEditCallbacks \
"Called by the widget when the user starts editing. It calls beginEdit and the callbacks.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_processEndEditCallbacks \
"Called by the widget when the user finishes editing. It calls endEdit and the callbacks.\n"
#define OMNIUI_PYBIND_DOC_AbstractItemModel_AbstractItemModel "Constructs AbstractItemModel.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocColorStore.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ColorStore \
"A singleton that stores all the UI Style color properties of omni.ui.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_ColorStore_getInstance "Get the instance of this singleton object.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindMultiDragField.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindMultiField.h"
#include "DocMultiDragField.h"
#include "DocMultiFloatDragField.h"
#include "DocMultiIntDragField.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_MultiFloatDragField \
OMNIUI_PYBIND_INIT_AbstractMultiField \
OMNIUI_PYBIND_INIT_CAST(min, setMin, double) \
OMNIUI_PYBIND_INIT_CAST(max, setMax, double) \
OMNIUI_PYBIND_INIT_CAST(step, setStep, float)
#define OMNIUI_PYBIND_INIT_MultiIntDragField \
OMNIUI_PYBIND_INIT_AbstractMultiField \
OMNIUI_PYBIND_INIT_CAST(min, setMin, int32_t) \
OMNIUI_PYBIND_INIT_CAST(max, setMax, int32_t) \
OMNIUI_PYBIND_INIT_CAST(step, setStep, float)
#define OMNIUI_PYBIND_KWARGS_DOC_MultiDragField \
"\n `min : `\n " \
OMNIUI_PYBIND_DOC_MultiDragField_min \
"\n `max : `\n " \
OMNIUI_PYBIND_DOC_MultiDragField_max \
"\n `step : `\n " \
OMNIUI_PYBIND_DOC_MultiDragField_step \
OMNIUI_PYBIND_KWARGS_DOC_AbstractMultiField
#define OMNIUI_PYBIND_KWARGS_DOC_MultiFloatDragField \
OMNIUI_PYBIND_KWARGS_DOC_MultiDragField
#define OMNIUI_PYBIND_KWARGS_DOC_MultiIntDragField \
OMNIUI_PYBIND_KWARGS_DOC_MultiDragField
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/BindAbstractField.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindUtils.h"
#include "BindWidget.h"
#include "DocAbstractField.h"
#define OMNIUI_PYBIND_INIT_AbstractField OMNIUI_PYBIND_INIT_Widget
#define OMNIUI_PYBIND_KWARGS_DOC_AbstractField OMNIUI_PYBIND_KWARGS_DOC_Widget
|
omniverse-code/kit/include/omni/ui/bind/DocStack.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Stack \
"The Stack class lines up child widgets horizontally, vertically or sorted in a Z-order.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Stack_Direction \
"This type is used to determine the direction of the layout. If the Stack's orientation is eLeftToRight the widgets are placed in a horizontal row, from left to right. If the Stack's orientation is eRightToLeft the widgets are placed in a horizontal row, from right to left. If the Stack's orientation is eTopToBottom, the widgets are placed in a vertical column, from top to bottom. If the Stack's orientation is eBottomToTop, the widgets are placed in a vertical column, from bottom to top. If the Stack's orientation is eBackToFront, the widgets are placed sorted in a Z-order in top right corner. If the Stack's orientation is eFrontToBack, the widgets are placed sorted in a Z-order in top right corner, the first widget goes to front.\n"
#define OMNIUI_PYBIND_DOC_Stack_addChild \
"Reimplemented adding a widget to this Stack. The Stack class can contain multiple widgets.\n"
#define OMNIUI_PYBIND_DOC_Stack_clear "Reimplemented removing all the child widgets from this Stack.\n"
#define OMNIUI_PYBIND_DOC_Stack_setComputedContentWidth \
"Reimplemented the method to indicate the width hint that represents the preferred size of the widget. Currently this widget can't be smaller than the minimal size of the child widgets.\n"
#define OMNIUI_PYBIND_DOC_Stack_setComputedContentHeight \
"Reimplemented the method to indicate the height hint that represents the preferred size of the widget. Currently this widget can't be smaller than the minimal size of the child widgets.\n"
#define OMNIUI_PYBIND_DOC_Stack_cascadeStyle \
"It's called when the style is changed. It should be propagated to children to make the style cached and available to children.\n"
#define OMNIUI_PYBIND_DOC_Stack_setVisiblePreviousFrame "Change dirty bits when the visibility is changed.\n"
#define OMNIUI_PYBIND_DOC_Stack_contentClipping \
"Determines if the child widgets should be clipped by the rectangle of this Stack.\n"
#define OMNIUI_PYBIND_DOC_Stack_spacing "Sets a non-stretchable space in pixels between child items of this layout.\n"
#define OMNIUI_PYBIND_DOC_Stack_direction \
"Determines the type of the layout. It can be vertical, horizontal and front-to-back.\n"
#define OMNIUI_PYBIND_DOC_Stack_sendMouseEventsToBack \
"When children of a Z-based stack overlap mouse events are normally sent to the topmost one. Setting this property true will invert that behavior, sending mouse events to the bottom-most child.\n"
#define OMNIUI_PYBIND_DOC_Stack_Stack \
"Constructor.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `direction :`\n" \
" Determines the orientation of the Stack.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocMultiIntDragField.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_MultiIntDragField \
"MultiIntDragField is the widget that has a sub widget (IntDrag) per model item.\n" \
"It's handy to use it for multi-component data, like for example, int3.\n"
#define OMNIUI_PYBIND_DOC_MultiIntDragField_MultiIntDragField \
"Constructs MultiIntDragField.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `model :`\n" \
" The widget's model. If the model is not assigned, the default model is created.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocZStack.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ZStack \
"Shortcut for Stack{eBackToFront}. The widgets are placed sorted in a Z-order in top right corner with suitable sizes.\n"
#define OMNIUI_PYBIND_DOC_ZStack_ZStack \
"Construct a stack with the widgets placed in a Z-order with sorting from background to foreground.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindFloatDrag.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindFloatSlider.h"
#include "BindUtils.h"
#include "DocFloatDrag.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_FloatDrag \
OMNIUI_PYBIND_INIT_FloatSlider
#define OMNIUI_PYBIND_KWARGS_DOC_FloatDrag \
OMNIUI_PYBIND_KWARGS_DOC_FloatSlider
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/DocSimpleNumericModel.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_SimpleNumericModel \
"A very simple value model that holds a single number. It's still an abstract class. It's necessary to reimplement\n" \
"setValue(std::string value)\n" \
"\n"
#define OMNIUI_PYBIND_DOC_SimpleNumericModel_min "This property holds the model's minimum value.\n"
#define OMNIUI_PYBIND_DOC_SimpleNumericModel_max "This property holds the model's maximum value.\n"
#define OMNIUI_PYBIND_DOC_SimpleNumericModel_getValueAsBool "Get the value as bool.\n"
#define OMNIUI_PYBIND_DOC_SimpleNumericModel_getValueAsFloat "Get the value as double.\n"
#define OMNIUI_PYBIND_DOC_SimpleNumericModel_getValueAsInt "Get the value as int64_t.\n"
#define OMNIUI_PYBIND_DOC_SimpleNumericModel_getValueAsString "Get the value as string.\n"
#define OMNIUI_PYBIND_DOC_SimpleNumericModel_setValue "Set the bool value. It will convert bool to the model's typle.\n"
#define OMNIUI_PYBIND_DOC_SimpleNumericModel_setValue01 \
"Set the double value. It will convert double to the model's typle.\n"
#define OMNIUI_PYBIND_DOC_SimpleNumericModel_setValue2 \
"Set the int64_t value. It will convert int64_t to the model's typle.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindGrid.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindStack.h"
#include "DocGrid.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Grid \
OMNIUI_PYBIND_INIT_Stack \
OMNIUI_PYBIND_INIT_CAST(column_width, setColumnWidth, float) \
OMNIUI_PYBIND_INIT_CAST(row_height, setRowHeight, float) \
OMNIUI_PYBIND_INIT_CAST(column_count, setColumnCount, uint32_t) \
OMNIUI_PYBIND_INIT_CAST(row_count, setRowCount, uint32_t) \
#define OMNIUI_PYBIND_KWARGS_DOC_Grid \
"\n `column_width : `\n " \
OMNIUI_PYBIND_DOC_Grid_columnWidth \
"\n `row_height : `\n " \
OMNIUI_PYBIND_DOC_Grid_rowHeight \
"\n `column_count : `\n " \
OMNIUI_PYBIND_DOC_Grid_columnCount \
"\n `row_count : `\n " \
OMNIUI_PYBIND_DOC_Grid_rowCount \
OMNIUI_PYBIND_KWARGS_DOC_Stack
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/BindFloatSlider.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractSlider.h"
#include "BindUtils.h"
#include "DocFloatSlider.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_FloatSlider \
OMNIUI_PYBIND_INIT_AbstractSlider \
OMNIUI_PYBIND_INIT_CAST(min, setMin, float) \
OMNIUI_PYBIND_INIT_CAST(max, setMax, float) \
OMNIUI_PYBIND_INIT_CAST(step, setStep, float) \
OMNIUI_PYBIND_INIT_CAST(format, setFormat, std::string) \
OMNIUI_PYBIND_INIT_CAST(precision, setPrecision, uint32_t)
#define OMNIUI_PYBIND_KWARGS_DOC_FloatSlider \
"\n `min : float`\n " \
OMNIUI_PYBIND_DOC_FloatSlider_min \
"\n `max : float`\n " \
OMNIUI_PYBIND_DOC_FloatSlider_max \
"\n `step : float`\n " \
OMNIUI_PYBIND_DOC_FloatSlider_step \
"\n `format : str`\n " \
OMNIUI_PYBIND_DOC_FloatSlider_format \
"\n `precision : uint32_t`\n " \
OMNIUI_PYBIND_DOC_FloatSlider_precision \
OMNIUI_PYBIND_KWARGS_DOC_AbstractSlider
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/DocAbstractMultiField.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_AbstractMultiField \
"AbstractMultiField is the abstract class that has everything to create a custom widget per model item.\n" \
"The class that wants to create multiple widgets per item needs to reimplement the method _createField.\n"
#define OMNIUI_PYBIND_DOC_AbstractMultiField_setComputedContentWidth \
"Reimplemented the method to indicate the width hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the text.\n"
#define OMNIUI_PYBIND_DOC_AbstractMultiField_setComputedContentHeight \
"Reimplemented the method to indicate the height hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the text.\n"
#define OMNIUI_PYBIND_DOC_AbstractMultiField_onStyleUpdated \
"Reimplemented. Something happened with the style or with the parent style. We need to gerenerate the cache.\n"
#define OMNIUI_PYBIND_DOC_AbstractMultiField_onModelUpdated \
"Reimplemented. Called by the model when the model value is changed.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `item :`\n" \
" The item in the model that is changed. If it's NULL, the root is chaged.\n"
#define OMNIUI_PYBIND_DOC_AbstractMultiField_columnCount "The max number of fields in a line.\n"
#define OMNIUI_PYBIND_DOC_AbstractMultiField_hSpacing \
"Sets a non-stretchable horizontal space in pixels between child fields.\n"
#define OMNIUI_PYBIND_DOC_AbstractMultiField_vSpacing \
"Sets a non-stretchable vertical space in pixels between child fields.\n"
#define OMNIUI_PYBIND_DOC_AbstractMultiField_AbstractMultiField "Constructor.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocFloatDrag.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_FloatDrag \
"The drag widget that looks like a field but it's possible to change the value with dragging.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_FloatDrag_FloatDrag "Construct FloatDrag.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocScrollingFrame.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ScrollingFrame \
"The ScrollingFrame class provides the ability to scroll onto another widget.\n" \
"ScrollingFrame is used to display the contents of a child widget within a frame. If the widget exceeds the size of the frame, the frame can provide scroll bars so that the entire area of the child widget can be viewed. The child widget must be specified with addChild().\n"
#define OMNIUI_PYBIND_DOC_ScrollingFrame_setComputedContentWidth \
"Reimplemented the method to indicate the width hint that represents the preferred size of the widget. Currently this widget can't be smaller than the minimal size of the child widgets.\n"
#define OMNIUI_PYBIND_DOC_ScrollingFrame_setComputedContentHeight \
"Reimplemented the method to indicate the height hint that represents the preferred size of the widget. Currently this widget can't be smaller than the minimal size of the child widgets.\n"
#define OMNIUI_PYBIND_DOC_ScrollingFrame_scrollX \
"The horizontal position of the scroll bar. When it's changed, the contents will be scrolled accordingly.\n"
#define OMNIUI_PYBIND_DOC_ScrollingFrame_scrollY \
"The vertical position of the scroll bar. When it's changed, the contents will be scrolled accordingly.\n"
#define OMNIUI_PYBIND_DOC_ScrollingFrame_scrollXMax "The max position of the horizontal scroll bar.\n"
#define OMNIUI_PYBIND_DOC_ScrollingFrame_scrollYMax "The max position of the vertical scroll bar.\n"
#define OMNIUI_PYBIND_DOC_ScrollingFrame_horizontalScrollBarPolicy \
"This property holds the policy for the horizontal scroll bar.\n"
#define OMNIUI_PYBIND_DOC_ScrollingFrame_verticalScrollBarPolicy \
"This property holds the policy for the vertical scroll bar.\n"
#define OMNIUI_PYBIND_DOC_ScrollingFrame_ScrollingFrame "Construct ScrollingFrame.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindLabel.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindUtils.h"
#include "BindWidget.h"
#include "DocLabel.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Label \
OMNIUI_PYBIND_INIT_Widget \
OMNIUI_PYBIND_INIT_CAST(alignment, setAlignment, Alignment) \
OMNIUI_PYBIND_INIT_CAST(word_wrap, setWordWrap, bool) \
OMNIUI_PYBIND_INIT_CAST(elided_text, setElidedText, bool) \
OMNIUI_PYBIND_INIT_CAST(elided_text_str, setElidedTextStr, std::string) \
OMNIUI_PYBIND_INIT_CAST(hide_text_after_hash, setHideTextAfterHash, bool)
// clang-format off
#define OMNIUI_PYBIND_KWARGS_DOC_Label \
"\n `alignment : `\n " \
OMNIUI_PYBIND_DOC_Label_alignment \
"\n `word_wrap : `\n " \
OMNIUI_PYBIND_DOC_Label_wordWrap \
"\n `elided_text : `\n " \
OMNIUI_PYBIND_DOC_Label_elidedText \
"\n `elided_text_str : `\n " \
OMNIUI_PYBIND_DOC_Label_elidedTextStr \
"\n `hide_text_after_hash : `\n " \
OMNIUI_PYBIND_DOC_Label_hideTextAfterHash \
OMNIUI_PYBIND_KWARGS_DOC_Widget
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/DocMenuItem.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_MenuItem \
"A MenuItem represents the items the Menu consists of.\n" \
"MenuItem can be inserted only once in the menu.\n"
#define OMNIUI_PYBIND_DOC_MenuItem_setComputedContentWidth \
"Reimplemented the method to indicate the width hint that represents the preferred size of the widget.\n"
#define OMNIUI_PYBIND_DOC_MenuItem_setComputedContentHeight \
"Reimplemented the method to indicate the height hint that represents the preferred size of the widget.\n"
#define OMNIUI_PYBIND_DOC_MenuItem_cascadeStyle \
"It's called when the style is changed. It should be propagated to children to make the style cached and available to children.\n"
#define OMNIUI_PYBIND_DOC_MenuItem_MenuItem "Construct MenuItem.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocMultiStringField.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_MultiStringField \
"MultiStringField is the widget that has a sub widget (StringField) per model item.\n" \
"It's handy to use it for string arrays.\n"
#define OMNIUI_PYBIND_DOC_MultiStringField_MultiStringField "Constructor.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindSpacer.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindUtils.h"
#include "BindWidget.h"
#include "DocSpacer.h"
#define OMNIUI_PYBIND_INIT_Spacer OMNIUI_PYBIND_INIT_Widget
#define OMNIUI_PYBIND_KWARGS_DOC_Spacer OMNIUI_PYBIND_KWARGS_DOC_Widget
|
omniverse-code/kit/include/omni/ui/bind/DocEllipse.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Ellipse \
"The Ellipse widget provides a colored ellipse to display.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Ellipse_Ellipse "Constructs Ellipse.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocCollapsableFrame.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_CollapsableFrame \
"CollapsableFrame is a frame widget that can hide or show its content. It has two states expanded and collapsed. When it's collapsed, it looks like a button. If it's expanded, it looks like a button and a frame with the content. It's handy to group properties, and temporarily hide them to get more space for something else.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_CollapsableFrame_addChild "Reimplemented. It adds a widget to m_body.\n"
#define OMNIUI_PYBIND_DOC_CollapsableFrame_setComputedContentWidth \
"Reimplemented the method to indicate the width hint that represents the preferred size of the widget. Currently this widget can't be smaller than the minimal size of the child widgets.\n"
#define OMNIUI_PYBIND_DOC_CollapsableFrame_setComputedContentHeight \
"Reimplemented the method to indicate the height hint that represents the preferred size of the widget. Currently this widget can't be smaller than the minimal size of the child widgets.\n"
#define OMNIUI_PYBIND_DOC_CollapsableFrame_BuildHeader \
"Set dynamic header that will be created dynamiclly when it is needed. The function is called inside a ui.Frame scope that the widget will be parented correctly.\n"
#define OMNIUI_PYBIND_DOC_CollapsableFrame_collapsed "The state of the CollapsableFrame.\n"
#define OMNIUI_PYBIND_DOC_CollapsableFrame_title "The header text.\n"
#define OMNIUI_PYBIND_DOC_CollapsableFrame_alignment \
"This property holds the alignment of the label in the default header. By default, the contents of the label are left-aligned and vertically-centered.\n"
#define OMNIUI_PYBIND_DOC_CollapsableFrame_CollapsableFrame \
"Constructs CollapsableFrame.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `text :`\n" \
" The text for the caption of the frame.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocFontHelper.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_FontHelper \
"The helper class for the widgets that are working with fonts.\n" \
"\n"
|
omniverse-code/kit/include/omni/ui/bind/DocInspector.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Inspector \
"Inspector is the helper to check the internal state of the widget. It's not recommended to use it for the routine UI.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Inspector_getChildren "Get the children of the given Widget.\n"
#define OMNIUI_PYBIND_DOC_Inspector_getResolvedStyle "Get the resolved style of the given Widget.\n"
#define OMNIUI_PYBIND_DOC_Inspector_beginComputedWidthMetric \
"Start counting how many times Widget::setComputedWidth is called\n"
#define OMNIUI_PYBIND_DOC_Inspector_bumpComputedWidthMetric "Increases the number Widget::setComputedWidth is called\n"
#define OMNIUI_PYBIND_DOC_Inspector_endComputedWidthMetric \
"Start counting how many times Widget::setComputedWidth is called and return the number\n"
#define OMNIUI_PYBIND_DOC_Inspector_beginComputedHeightMetric \
"Start counting how many times Widget::setComputedHeight is called\n"
#define OMNIUI_PYBIND_DOC_Inspector_bumpComputedHeightMetric \
"Increases the number Widget::setComputedHeight is called\n"
#define OMNIUI_PYBIND_DOC_Inspector_endComputedHeightMetric \
"Start counting how many times Widget::setComputedHeight is called and return the number\n"
#define OMNIUI_PYBIND_DOC_Inspector_getStoredFontAtlases \
"Provides the information about font atlases\n"
|
omniverse-code/kit/include/omni/ui/bind/DocPropertyCallback.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_PropertyCallback \
"Callback containers that is used with OMNIUI_PROPERTY macro.\n" \
"\n"
|
omniverse-code/kit/include/omni/ui/bind/DocContainerStack.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ContainerStack \
"Singleton object that holds the stack of containers. We use it to automatically add widgets to the top container when the widgets are created.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_ContainerStack_push \
"Push the container to the top of the stack. All the newly created widgets will be added to this container.\n"
#define OMNIUI_PYBIND_DOC_ContainerStack_pop "Removes the container from the stack. The previous one will be active.\n"
#define OMNIUI_PYBIND_DOC_ContainerStack_addChildToTop "Add the given widget to the top container.\n"
#define OMNIUI_PYBIND_DOC_ContainerStack_instance "The only instance of the singleton.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocHGrid.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_HGrid \
"Shortcut for Grid{eLeftToRight}. The grid grows from left to right with the widgets placed.\n"
#define OMNIUI_PYBIND_DOC_HGrid_HGrid "Construct a grid that grow from left to right with the widgets placed.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocIntDrag.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_IntDrag \
"The drag widget that looks like a field but it's possible to change the value with dragging.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_IntDrag_step \
"This property controls the steping speed on the drag, its float to enable slower speed, but of course the value on the Control are still integer.\n"
#define OMNIUI_PYBIND_DOC_IntDrag_IntDrag \
"Constructs IntDrag.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `model :`\n" \
" The widget's model. If the model is not assigned, the default model is created.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocWindowHandle.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_WindowHandle \
"WindowHandle is a handle object to control any of the windows in Kit. It can be created any time, and if it's destroyed, the source window doesn't disappear.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_getTitle "The title of the window.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_getPositionX "The position of the window in points.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_setPositionX "Set the position of the window in points.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_getPositionY "The position of the window in points.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_setPositionY "Set the position of the window in points.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_getWidth "The width of the window in points.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_setWidth "Set the width of the window in points.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_getHeight "The height of the window in points.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_setHeight "Set the height of the window in points.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_isVisible "Returns whether the window is visible.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_setVisible \
"Set the visibility of the windows. It's the way to hide the window.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_isDockTabBarVisible "Checks if the current docking space has the tab bar.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_setDockTabBarVisible \
"Sets the visibility of the current docking space tab bar. Unlike disabled, invisible tab bar can be shown with a little triangle in top left corner of the window.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_isDockTabBarEnabled \
"Checks if the current docking space is disabled. The disabled docking tab bar can't be shown by the user.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_setDockTabBarEnabled \
"Sets the visibility of the current docking space tab bar. The disabled docking tab bar can't be shown by the user.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_undock "Undock the window and make it floating.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_dockIn \
"Dock the window to the existing window. It can split the window to two parts or it can convert the window to a docking tab.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_getDockOrder "The position of the window in the dock.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_setDockOrder "Set the position of the window in the dock.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_isDocked "True if this window is docked. False otherwise.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_getDockId "Returns ID of the dock node this window is docked to.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_focus \
"Brings the window to the top. If it's a docked window, it makes the window currently visible in the dock.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_isSelectedInDock \
"Return true is the window is the current window in the docking area.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_notifyAppWindowChange \
"Notifies the UI window that the AppWindow it attached to has changed.\n"
#define OMNIUI_PYBIND_DOC_WindowHandle_WindowHandle \
"Create a handle with the given ID.\n" \
"Only Workspace can create this object.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocComboBox.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ComboBox \
"The ComboBox widget is a combined button and a drop-down list.\n" \
"A combo box is a selection widget that displays the current item and can pop up a list of selectable items.\n" \
"The ComboBox is implemented using the model-view pattern. The model is the central component of this system. The root of the item model should contain the index of currently selected items, and the children of the root include all the items of the combo box.\n"
#define OMNIUI_PYBIND_DOC_ComboBox_setComputedContentWidth \
"Reimplemented the method to indicate the width hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the ComboBox square.\n"
#define OMNIUI_PYBIND_DOC_ComboBox_setComputedContentHeight \
"Reimplemented the method to indicate the height hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the ComboBox square.\n"
#define OMNIUI_PYBIND_DOC_ComboBox_onStyleUpdated \
"Reimplemented. Something happened with the style or with the parent style. We need to update the saved font.\n"
#define OMNIUI_PYBIND_DOC_ComboBox_onModelUpdated \
"Reimplemented the method from ItemModelHelper that is called when the model is changed.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `item :`\n" \
" The item in the model that is changed. If it's NULL, the root is chaged.\n"
#define OMNIUI_PYBIND_DOC_ComboBox_arrowOnly "Determines if it's necessary to hide the text of the ComboBox.\n"
#define OMNIUI_PYBIND_DOC_ComboBox_ComboBox \
"Construct ComboBox.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `model :`\n" \
" The model that determines if the button is checked.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindAbstractValueModel.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindUtils.h"
#include "DocAbstractValueModel.h"
#include "DocSimpleBoolModel.h"
#include "DocSimpleFloatModel.h"
#include "DocSimpleIntModel.h"
#include "DocSimpleNumericModel.h"
#include "DocSimpleStringModel.h"
// Protected section is not exported
#define OMNIUI_PYBIND_DOC_AbstractValueModel__valueChanged \
"Called when any data of the model is changed. It will notify the subscribed widgets."
#define OMNIUI_PYBIND_INIT_AbstractValueModel
#define OMNIUI_PYBIND_KWARGS_DOC_AbstractValueModel
|
omniverse-code/kit/include/omni/ui/bind/DocRasterHelper.h | // Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_RasterHelper \
"The \"RasterHelper\" class is used to manage the draw lists or raster images. This class is responsible for rasterizing (or baking) the UI, which involves adding information about widgets to the cache. Once the UI has been baked, the draw list cache can be used to quickly re-render the UI without having to iterate over the widgets again. This is useful because it allows the UI to be rendered more efficiently, especially in cases where the widgets have not changed since the last time the UI was rendered. The \"RasterHelper\" class provides methods for modifying the cache and rendering the UI from the cached information.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_RasterHelper_rasterPolicy "Determine how the content of the frame should be rasterized.\n"
#define OMNIUI_PYBIND_DOC_RasterHelper_invalidateRaster "This method regenerates the raster image of the widget, even if the widget's content has not changed. This can be used with both the eOnDemand and eAuto raster policies, and is used to update the content displayed in the widget. Note that this operation may be resource-intensive, and should be used sparingly.\n"
#define OMNIUI_PYBIND_DOC_RasterHelper_RasterHelper "Constructor.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocWorkspace.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Workspace "Workspace object provides access to the windows in Kit.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getDpiScale "Returns current DPI Scale.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getWindows \
"Returns the list of windows ordered from back to front.\n" \
"If the window is a Omni::UI window, it can be upcasted.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getWindow "Find Window by name.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getWindowFromCallback "Find Window by window callback.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getDockedNeighbours "Get all the windows that docked with the given widow.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getSelectedWindowIndex \
"Get currently selected window inedx from the given dock id.\n"
#define OMNIUI_PYBIND_DOC_Workspace_clear "Undock all.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getMainWindowWidth "Get the width in points of the current main window.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getMainWindowHeight "Get the height in points of the current main window.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getDockedWindows "Get all the windows of the given dock ID.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getParentDockId \
"Return the parent Dock Node ID.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `dockId :`\n" \
" the child Dock Node ID to get parent\n"
#define OMNIUI_PYBIND_DOC_Workspace_getDockNodeChildrenId \
"Get two dock children of the given dock ID.\n" \
"true if the given dock ID has children\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `dockId :`\n" \
" the given dock ID\n" \
"\n" \
" `first :`\n" \
" output. the first child dock ID\n" \
"\n" \
" `second :`\n" \
" output. the second child dock ID\n"
#define OMNIUI_PYBIND_DOC_Workspace_getDockPosition \
"Returns the position of the given dock ID. Left/Right/Top/Bottom.\n"
#define OMNIUI_PYBIND_DOC_Workspace_getDockIdWidth \
"Returns the width of the docking node.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `dockId :`\n" \
" the given dock ID\n"
#define OMNIUI_PYBIND_DOC_Workspace_getDockIdHeight \
"Returns the height of the docking node.\n" \
"It's different from the window height because it considers dock tab bar.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `dockId :`\n" \
" the given dock ID\n"
#define OMNIUI_PYBIND_DOC_Workspace_setDockIdWidth \
"Set the width of the dock node.\n" \
"It also sets the width of parent nodes if necessary and modifies the width of siblings.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `dockId :`\n" \
" the given dock ID\n" \
"\n" \
" `width :`\n" \
" the given width\n"
#define OMNIUI_PYBIND_DOC_Workspace_setDockIdHeight \
"Set the height of the dock node.\n" \
"It also sets the height of parent nodes if necessary and modifies the height of siblings.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `dockId :`\n" \
" the given dock ID\n" \
"\n" \
" `height :`\n" \
" the given height\n"
#define OMNIUI_PYBIND_DOC_Workspace_showWindow \
"Makes the window visible or create the window with the callback provided with set_show_window_fn.\n" \
"true if the window is already created, otherwise it's necessary to wait one frame\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `title :`\n" \
" the given window title\n" \
"\n" \
" `show :`\n" \
" true to show, false to hide\n"
#define OMNIUI_PYBIND_DOC_Workspace_setWindowCreatedCallback \
"Addd the callback that is triggered when a new window is created.\n"
#define OMNIUI_PYBIND_DOC_Workspace_setWindowVisibilityChangedCallback \
"Add the callback that is triggered when window's visibility changed.\n"
#define OMNIUI_PYBIND_DOC_Workspace_removeWindowVisibilityChangedCallback \
"Remove the callback that is triggered when window's visibility changed.\n"
#define OMNIUI_PYBIND_DOC_Workspace_setShowWindowFn \
"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.\n"
#define OMNIUI_PYBIND_DOC_Workspace_RegisterWindow \
"Register Window, so it's possible to return it in getWindows. It's called by Window creator.\n"
#define OMNIUI_PYBIND_DOC_Workspace_OmitWindow "Deregister window. It's called by Window destructor.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindMainWindow.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindUtils.h"
#include "DocMainWindow.h"
#include <omni/ui/bind/Pybind.h>
// clang-format off
#define OMNIUI_PYBIND_INIT_MainWindow
#define OMNIUI_PYBIND_KWARGS_DOC_MainWindow
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/DocContainerScope301Void014.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ContainerScope \
< void > \
"Specialization. It takes existing container and puts it to the top of the stack.\n" \
"\n"
|
omniverse-code/kit/include/omni/ui/bind/BindUtils.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include <carb/logging/Log.h>
#include <omni/ui/Api.h>
#include <omni/ui/bind/BindStyleContainer.h>
#include <omni/ui/bind/Pybind.h>
#include <functional>
#define OMNIUI_BIND(x) \
void wrap##x(pybind11::module& m); \
wrap##x(m)
// Set of macros for python constructors. We need to provide a way to initialize all the properties in the Python
// constructor. And to do it we need to list all the properties from all the derived classes. To do it shortly, we use
// the following pattern in the Python init lambda:
//
// OMNIUI_PYBIND_INIT(className)
//
// It expands to the Python constructor. Here are the implementations of the macros to do it.
// Expands to the code that constructs the C++ object and its properties from pybind11 init.
//
// Omni::UI provides a property system. And this macro OMNIUI_PYBIND_INIT is the part of the property system. It's
// possible to set any property in the constructor of the Python object. It gives the ability to have declarative-like
// Python code. And we believe it allows the Python users creating complex widgets with straightforward code. The
// simplest example looks like this:
//
// ui.Image(
// image_source,
// height=160,
// alignment=ui.Alignment.CENTER,
// style={"border_radius": 8, "margin": 20},
// )
//
// We need to make sure that it's possible to initialize the properties of base class in the python constructor. It
// seems pybind11 doesn't have a way to call the python constructor of the base object. It means that the Python
// constructor of child class needs to have the code that initializes properties of the base class. To avoid duplicating
// of actual code, we put the initialization of properties to macros. And it looks like this (it's simplified):
//
// #define OMNIUI_PYBIND_INIT_Widget
// OMNIUI_PYBIND_INIT_CALL(width, setWidth, toLength)
// OMNIUI_PYBIND_INIT_CALL(height, setHeight, toLength)
// OMNIUI_PYBIND_INIT_CAST(name, setName, std::string)
//
// The initialization of child object looks like this (also simplified):
//
// #define OMNIUI_PYBIND_INIT_Button
// OMNIUI_PYBIND_INIT_Widget
// OMNIUI_PYBIND_INIT_CAST(text, setText, std::string)
//
// And to construct the python object, we can use the macro like this (also simplified):
//
// #define OMNIUI_PYBIND_INIT(className, ...)
// auto result = className::create(__VA_ARGS__);
// OMNIUI_PYBIND_INIT_##className
//
// We use className to create the object and to call the correct macro. Thus, the pybind11 constructor looks like this
// for all the widgets:
//
// .def(init([](std::string title, kwargs kwargs) { OMNIUI_PYBIND_INIT(Button, title) }))
//
#define OMNIUI_PYBIND_INIT(className, ...) \
auto result = className::create(__VA_ARGS__); \
OMNIUI_PYBIND_INIT_BEGIN \
OMNIUI_PYBIND_INIT_##className OMNIUI_PYBIND_INIT_END return result;
#define OMNIUI_PYBIND_INIT_WITH_DESTRUCTOR(className, destructor, ...) \
auto result = className::createWithDestructor((destructor), ##__VA_ARGS__); \
OMNIUI_PYBIND_INIT_BEGIN \
OMNIUI_PYBIND_INIT_##className OMNIUI_PYBIND_INIT_END return result;
// The header of the code that constructs the C++ object and its properties from pybind11 init. It should only be used
// by OMNIUI_PYBIND_INIT
#define OMNIUI_PYBIND_INIT_BEGIN \
for (auto item : kwargs) \
{ \
auto name = item.first.cast<std::string>(); \
const auto& value = item.second; \
\
if (0) \
{ \
}
// The footer of the code that constructs the C++ object and its properties from pybind11 init. It should only be used
// by OMNIUI_PYBIND_INIT
#define OMNIUI_PYBIND_INIT_END }
// Initialize the property using the pybind11 cast to convert pybind11 handle to the type we need.
#define OMNIUI_PYBIND_INIT_CAST(NAME, METHOD, CASTTO) \
else if (name == #NAME) \
{ \
result->METHOD(value.cast<CASTTO>()); \
}
// Initialize the property using the additional function to convert pybind11 handle to the type we need.
#define OMNIUI_PYBIND_INIT_CALL(NAME, METHOD, CALL) \
else if (name == #NAME) \
{ \
result->METHOD(CALL(value)); \
}
// Initialize the property with the function that is not a method.
#define OMNIUI_PYBIND_INIT_EXT_CALL(NAME, FUNCTION) \
else if (name == #NAME) \
{ \
FUNCTION(result, value); \
}
// Initialize the property of the function type.
#define OMNIUI_PYBIND_INIT_CALLBACK(NAME, METHOD, CASTTO) \
else if (name == #NAME) \
{ \
result->METHOD(wrapPythonCallback(value.cast<std::function<CASTTO>>())); \
}
// Initialize widget style from Python dictionary.
#define OMNIUI_PYBIND_INIT_STYLES \
else if (name == "style") \
{ \
setWidgetStyle(*result.get(), value); \
}
// Extended version of the init macros.
// clang-format off
#define OMNIUI_PYBIND_INIT_EX(className, ...) \
OMNIUI_PYBIND_INIT_EX_BEFORE_##className(__VA_ARGS__) \
OMNIUI_PYBIND_INIT_EX_CREATE_##className(__VA_ARGS__) \
OMNIUI_PYBIND_INIT_EX_AFTER_##className(__VA_ARGS__) \
OMNIUI_PYBIND_INIT_EX_BEGIN_KWARGS_##className(__VA_ARGS__) \
OMNIUI_PYBIND_INIT_EX_KWARGS_##className(__VA_ARGS__) \
OMNIUI_PYBIND_INIT_EX_END_KWARGS_##className(__VA_ARGS__) \
OMNIUI_PYBIND_INIT_EX_FINAL_##className(__VA_ARGS__) \
return result;
// clang-format on
// Expands to the body of the method that is abstract in the base class. This method redirects the call to python
// bindings.
#define OMNIUI_PYBIND_ABSTRACT_METHOD(TYPE, PARENT, PYNAME) \
try \
{ \
PYBIND11_OVERLOAD_PURE_NAME(TYPE, PARENT, #PYNAME, 0); \
} \
catch (const pybind11::error_already_set& e) \
{ \
CARB_LOG_ERROR("%s", e.what()); \
} \
catch (const std::runtime_error& e) \
{ \
CARB_LOG_ERROR("%s", e.what()); \
}
#define OMNIUI_PYBIND_ABSTRACT_METHOD_VA(TYPE, PARENT, PYNAME, ...) \
try \
{ \
PYBIND11_OVERLOAD_PURE_NAME(TYPE, PARENT, #PYNAME, 0, __VA_ARGS__); \
} \
catch (const pybind11::error_already_set& e) \
{ \
CARB_LOG_ERROR("%s", e.what()); \
} \
catch (const std::runtime_error& e) \
{ \
CARB_LOG_ERROR("%s", e.what()); \
}
#define OMNIUI_PYBIND_OVERLOAD(TYPE, PARENT, CNAME, PYNAME) \
try \
{ \
PYBIND11_OVERLOAD_NAME(TYPE, PARENT, #PYNAME, CNAME); \
} \
catch (const pybind11::error_already_set& e) \
{ \
CARB_LOG_ERROR("%s", e.what()); \
} \
catch (const std::runtime_error& e) \
{ \
CARB_LOG_ERROR("%s", e.what()); \
}
#define OMNIUI_PYBIND_OVERLOAD_VA(TYPE, PARENT, CNAME, PYNAME, ...) \
try \
{ \
PYBIND11_OVERLOAD_INT(PYBIND11_TYPE(TYPE), PYBIND11_TYPE(PARENT), #PYNAME, __VA_ARGS__); \
} \
catch (const pybind11::error_already_set& e) \
{ \
CARB_LOG_ERROR("%s", e.what()); \
} \
catch (const std::runtime_error& e) \
{ \
CARB_LOG_ERROR("%s", e.what()); \
} \
return CNAME(__VA_ARGS__);
#define OMNIUI_PYBIND_CLASS_DOC(className) OMNIUI_PYBIND_DOC_##className
#define OMNIUI_PYBIND_CONSTRUCTOR_DOC(className, constructor) \
BOOST_PP_CAT(OMNIUI_PYBIND_DOC_, BOOST_PP_CAT(className, BOOST_PP_CAT(_, constructor))) \
"\n `kwargs : dict`\n See below\n\n### Keyword Arguments:\n" OMNIUI_PYBIND_KWARGS_DOC_##className
#define OMNIUI_PYBIND_DEF_CALLBACK(python_name, cpp_class, cpp_name) \
def("set_" #python_name "_fn", wrapCallbackSetter(&cpp_class::set##cpp_name##Fn), arg("fn"), \
OMNIUI_PYBIND_DOC_##cpp_class##_##cpp_name) \
.def("has_" #python_name "_fn", &cpp_class::has##cpp_name##Fn, OMNIUI_PYBIND_DOC_##cpp_class##_##cpp_name) \
.def("call_" #python_name "_fn", &cpp_class::call##cpp_name##Fn, OMNIUI_PYBIND_DOC_##cpp_class##_##cpp_name)
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* Assuming std::function will call into python code this function makes it safe.
* It wraps it into try/catch, acquires GIL lock and log errors.
*/
template <typename ReturnT, typename... ArgsT>
ReturnT callPythonCodeSafe(const std::function<ReturnT(ArgsT...)>& fn, ArgsT... args)
{
using namespace pybind11;
try
{
if (fn)
{
gil_scoped_acquire gilLock;
return fn(args...);
}
}
catch (const error_already_set& e)
{
CARB_LOG_ERROR("%s", e.what());
}
catch (const std::runtime_error& e)
{
CARB_LOG_ERROR("%s", e.what());
}
return ReturnT();
}
// This is deprecated function, use the one below instead.
template <typename ReturnT, typename... Args>
auto wrapPythonCallback(const std::function<ReturnT(Args...)>& c) -> std::function<ReturnT(Args...)>
{
return [=](Args... args) -> ReturnT { return callPythonCodeSafe<ReturnT, Args...>(c, args...); };
}
template <typename ReturnT, typename... Args>
std::function<ReturnT(Args...)> wrapPythonCallback(std::function<ReturnT(Args...)>&& c)
{
return [c{ std::forward<std::function<ReturnT(Args...)>>(c) }](Args... args) -> ReturnT
{ return callPythonCodeSafe<ReturnT, Args...>(c, args...); };
}
/**
* @brief Should be used when binding the callback setter, and it will lock GIL when calling the python callback.
*/
template <typename ClassT, typename R, typename... Args>
auto wrapCallbackSetter(void (ClassT::*MethodT)(std::function<R(Args...)>))
{
return [MethodT](ClassT& self, std::function<R(Args...)> fn) { (self.*MethodT)(wrapPythonCallback(std::move(fn))); };
}
/**
* @brief Convert pybind11::args to vector
*/
template <typename T, typename U = T>
std::vector<T> argsToVector(pybind11::args args)
{
std::vector<T> result;
// TODO: reserve
for (const auto& it : args)
{
if (pybind11::isinstance<U>(it))
{
result.push_back(it.cast<T>());
}
else
{
CARB_LOG_WARN("Omni::UI Args: argument has wrong type");
}
}
return result;
}
#define OMNIUI_PROTECT_PYBIND11_OBJECT(className, pythonClassName) \
/* Storing shared_ptrs to Python-derived instances for later execution causes virtual functions to fail if the */ \
/* Python instance has subsequently been destroyed. This is the workaround described in */ \
/* https://github.com/pybind/pybind11/issues/1546 */ \
namespace pybind11 \
{ \
namespace detail \
{ \
\
template <> \
class type_caster<std::shared_ptr<className>> \
{ \
PYBIND11_TYPE_CASTER(std::shared_ptr<className>, _(#pythonClassName)); \
\
using BaseCaster = copyable_holder_caster<className, std::shared_ptr<className>>; \
\
bool load(pybind11::handle src, bool b) \
{ \
BaseCaster bc; \
bool success = bc.load(src, b); \
if (!success) \
{ \
return false; \
} \
\
auto py_obj = pybind11::reinterpret_borrow<pybind11::object>(src); \
auto base_ptr = static_cast<std::shared_ptr<className>>(bc); \
\
/* Construct a shared_ptr to the py::object */ \
auto py_obj_ptr = std::shared_ptr<object>{ new object{ py_obj }, [](object* py_object_ptr) \
{ \
/* It's possible that when the shared_ptr dies we won't */ \
/* have the gil (if the last holder is in a non-Python */ \
/* thread, so we make sure to acquire it in the deleter. */ \
gil_scoped_acquire gil; \
delete py_object_ptr; \
} }; \
\
value = std::shared_ptr<className>(py_obj_ptr, base_ptr.get()); \
return true; \
} \
\
static handle cast(std::shared_ptr<className> base, return_value_policy rvp, handle h) \
{ \
return BaseCaster::cast(base, rvp, h); \
} \
}; \
\
template <> \
struct is_holder_type<className, std::shared_ptr<className>> : std::true_type \
{ \
}; \
} \
}
OMNIUI_NAMESPACE_CLOSE_SCOPE
|
omniverse-code/kit/include/omni/ui/bind/DocButton.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Button \
"The Button widget provides a command button.\n" \
"The command button, is perhaps the most commonly used widget in any graphical user interface. Click a button to execute a command. It is rectangular and typically displays a text label describing its action.\n"
#define OMNIUI_PYBIND_DOC_Button_setComputedContentWidth \
"Reimplemented the method to indicate the width hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the text.\n"
#define OMNIUI_PYBIND_DOC_Button_setComputedContentHeight \
"Reimplemented the method to indicate the height hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the text.\n"
#define OMNIUI_PYBIND_DOC_Button_onStyleUpdated \
"Reimplemented. Something happened with the style or with the parent style. We need to gerenerate the cache.\n"
#define OMNIUI_PYBIND_DOC_Button_cascadeStyle \
"Reimplemented. It's called when the style is changed. It should be propagated to children to make the style cached and available to children.\n"
#define OMNIUI_PYBIND_DOC_Button_text "This property holds the button's text.\n"
#define OMNIUI_PYBIND_DOC_Button_imageUrl "This property holds the button's optional image URL.\n"
#define OMNIUI_PYBIND_DOC_Button_imageWidth \
"This property holds the width of the image widget. Do not use this function to find the width of the image.\n"
#define OMNIUI_PYBIND_DOC_Button_imageHeight \
"This property holds the height of the image widget. Do not use this function to find the height of the image.\n"
#define OMNIUI_PYBIND_DOC_Button_spacing "Sets a non-stretchable space in points between image and text.\n"
#define OMNIUI_PYBIND_DOC_Button_Button \
"Construct a button with a text on it.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `text :`\n" \
" The text for the button to use.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocLabel.h | // Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Label \
"The Label widget provides a text to display.\n" \
"Label is used for displaying text. No additional to Widget user interaction functionality is provided.\n"
#define OMNIUI_PYBIND_DOC_Label_setComputedContentWidth \
"Reimplemented the method to indicate the width hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the text.\n"
#define OMNIUI_PYBIND_DOC_Label_setComputedContentHeight \
"Reimplemented the method to indicate the height hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the text.\n"
#define OMNIUI_PYBIND_DOC_Label_onStyleUpdated \
"Reimplemented. Something happened with the style or with the parent style. We need to update the saved font.\n"
#define OMNIUI_PYBIND_DOC_Label_exactContentWidth \
"Return the exact width of the content of this label. Computed content width is a size hint and may be bigger than the text in the label.\n"
#define OMNIUI_PYBIND_DOC_Label_exactContentHeight \
"Return the exact height of the content of this label. Computed content height is a size hint and may be bigger than the text in the label.\n"
#define OMNIUI_PYBIND_DOC_Label_text "This property holds the label's text.\n"
#define OMNIUI_PYBIND_DOC_Label_wordWrap \
"This property holds the label's word-wrapping policy If this property is true then label text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all. By default, word wrap is disabled.\n"
#define OMNIUI_PYBIND_DOC_Label_elidedText \
"When the text of a big length has to be displayed in a small area, it can be useful to give the user a visual hint that not all text is visible. Label can elide text that doesn't fit in the area. When this property is true, Label elides the middle of the last visible line and replaces it with \"...\".\n"
#define OMNIUI_PYBIND_DOC_Label_elidedTextStr \
"Customized elidedText string when elidedText is True, default is ...." \
#define OMNIUI_PYBIND_DOC_Label_hideTextAfterHash \
"Hide anything after a '##' string or not" \
#define OMNIUI_PYBIND_DOC_Label_alignment \
"This property holds the alignment of the label's contents. By default, the contents of the label are left-aligned and vertically-centered.\n"
#define OMNIUI_PYBIND_DOC_Label_Label \
"Create a label with the given text.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `text :`\n" \
" The text for the label.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocImage.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Image \
"The Image widget displays an image.\n" \
"The source of the image is specified as a URL using the source property. By default, specifying the width and height of the item causes the image to be scaled to that size. This behavior can be changed by setting the fill_mode property, allowing the image to be stretched or scaled instead. The property alignment controls where to align the scaled image.\n"
#define OMNIUI_PYBIND_DOC_Image_onStyleUpdated "Reimplemented. Called when the style or the parent style is changed.\n"
#define OMNIUI_PYBIND_DOC_Image_hasSourceUrl \
"Returns true if the image has non empty sourceUrl obtained through the property or the style.\n"
#define OMNIUI_PYBIND_DOC_Image_sourceUrl \
"This property holds the image URL. It can be an\n" \
"omni:\n" \
"file:\n"
#define OMNIUI_PYBIND_DOC_Image_alignment \
"This property holds the alignment of the image when the fill policy is ePreserveAspectFit or ePreserveAspectCrop. By default, the image is centered.\n"
#define OMNIUI_PYBIND_DOC_Image_fillPolicy \
"Define what happens when the source image has a different size than the item.\n"
#define OMNIUI_PYBIND_DOC_Image_pixelAligned \
"Prevents image blurring when it's placed to fractional position (like x=0.5, y=0.5)\n"
#define OMNIUI_PYBIND_DOC_Image_progress "The progress of the image loading.\n"
#define OMNIUI_PYBIND_DOC_Image_Image \
"Construct image with given url. If the url is empty, it gets the image URL from styling.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocPixel.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Pixel \
"Pixel length is exact length in pixels.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Pixel_Pixel "Construct Pixel.\n"
#define OMNIUI_PYBIND_DOC_Pixel_resolve \
"Resolves the length value to a absolute value\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `absoluteFactor :`\n" \
" the unit multiplier\n" \
"the computed absolute value\n"
|
omniverse-code/kit/include/omni/ui/bind/BindIntDrag.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindIntSlider.h"
#include "BindUtils.h"
#include "DocIntDrag.h"
#include "DocUIntDrag.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_IntDrag \
OMNIUI_PYBIND_INIT_IntSlider \
OMNIUI_PYBIND_INIT_CAST(step, setStep, float)
#define OMNIUI_PYBIND_INIT_UIntDrag \
OMNIUI_PYBIND_INIT_UIntSlider \
OMNIUI_PYBIND_INIT_CAST(step, setStep, float)
#define OMNIUI_PYBIND_KWARGS_DOC_IntDrag \
"\n `step : `\n " \
OMNIUI_PYBIND_DOC_IntDrag_step \
OMNIUI_PYBIND_KWARGS_DOC_IntSlider
#define OMNIUI_PYBIND_KWARGS_DOC_UIntDrag \
"\n `step : `\n " \
OMNIUI_PYBIND_DOC_UIntDrag_step \
OMNIUI_PYBIND_KWARGS_DOC_UIntSlider
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/DocSimpleListModel.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_SimpleListModel \
"A very simple model that holds the the root model and the flat list of models.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_SimpleListModel_getItemChildren \
"Reimplemented. Returns the vector of items that are nested to the given parent item.\n"
#define OMNIUI_PYBIND_DOC_SimpleListModel_appendChildItem \
"Reimplemented. Creates a new item from the value model and appends it to the list of the children of the given item.\n"
#define OMNIUI_PYBIND_DOC_SimpleListModel_removeItem "Reimplemented. Removes the item from the model.\n"
#define OMNIUI_PYBIND_DOC_SimpleListModel_getItemValueModel \
"Reimplemented. Get the value model associated with this item.\n"
#define OMNIUI_PYBIND_DOC_SimpleListModel_SimpleListModel \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `rootModel :`\n" \
" The model that will be returned when querying the root item.\n" \
"\n" \
" `models :`\n" \
" The list of all the value submodels of this model.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocIntField.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_IntField \
"The IntField widget is a one-line text editor with a string model.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_IntField_IntField "Construct IntField.\n"
|
omniverse-code/kit/include/omni/ui/bind/Pybind.h | // Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#ifdef _MSC_VER
// WAR Pybind11 issue with VS2019+: https://github.com/pybind/pybind11/issues/3459
// Also: https://github.com/microsoft/onnxruntime/issues/9735
#include <corecrt.h>
#endif
#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
|
omniverse-code/kit/include/omni/ui/bind/BindOffsetLine.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindFreeShape.h"
#include "BindUtils.h"
#include "DocOffsetLine.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_OffsetLine \
OMNIUI_PYBIND_INIT_FreeLine \
OMNIUI_PYBIND_INIT_CAST(offset, setOffset, float) \
OMNIUI_PYBIND_INIT_CAST(bound_offset, setBoundOffset, float)
#define OMNIUI_PYBIND_KWARGS_DOC_OffsetLine \
"\n `offset : `\n " \
OMNIUI_PYBIND_DOC_OffsetLine_offset \
"\n `bound_offset : `\n " \
OMNIUI_PYBIND_DOC_OffsetLine_boundOffset \
OMNIUI_PYBIND_KWARGS_DOC_FreeLine
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/BindIntSlider.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractSlider.h"
#include "BindUtils.h"
#include "DocCommonIntSlider.h"
#include "DocIntSlider.h"
#include "DocUIntSlider.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_IntSlider \
OMNIUI_PYBIND_INIT_AbstractSlider \
OMNIUI_PYBIND_INIT_CAST(min, setMin, int64_t) \
OMNIUI_PYBIND_INIT_CAST(max, setMax, int64_t)
#define OMNIUI_PYBIND_INIT_UIntSlider \
OMNIUI_PYBIND_INIT_AbstractSlider \
OMNIUI_PYBIND_INIT_CAST(min, setMin, uint64_t) \
OMNIUI_PYBIND_INIT_CAST(max, setMax, uint64_t)
#define OMNIUI_PYBIND_KWARGS_DOC_IntSlider \
"\n `min : `\n " \
OMNIUI_PYBIND_DOC_CommonIntSlider_min \
"\n `max : `\n " \
OMNIUI_PYBIND_DOC_CommonIntSlider_max \
OMNIUI_PYBIND_KWARGS_DOC_Widget
#define OMNIUI_PYBIND_KWARGS_DOC_UIntSlider \
OMNIUI_PYBIND_KWARGS_DOC_IntSlider
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/DocContainer.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Container \
"The container is an abstract widget that can hold one or several child widgets.\n" \
"The user is allowed to add or replace child widgets. If the widget has multiple children internally (like Button) and the user doesn't have access to them, it's not necessary to use this class.\n"
#define OMNIUI_PYBIND_DOC_Container_addChild \
"Adds widget to this container in a manner specific to the container. If it's allowed to have one sub-widget only, it will be overwriten.\n"
#define OMNIUI_PYBIND_DOC_Container_clear "Removes the container items from the container.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindWindowHandle.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "DocWindowHandle.h"
#define OMNIUI_PYBIND_KWARGS_DOC_WindowHandle
|
omniverse-code/kit/include/omni/ui/bind/DocContainerScopeBase.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ContainerScopeBase \
"Puts the given container to the top of the stack when this object is constructed. And removes this container when it's destructed.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_ContainerScopeBase_get "Returns the container it was created with.\n"
#define OMNIUI_PYBIND_DOC_ContainerScopeBase_isValid \
"Checks if this object is valid. It's always valid untill it's invalidated. Once it's invalidated, there is no way to make it valid again.\n"
#define OMNIUI_PYBIND_DOC_ContainerScopeBase_invalidate "Makes this object invalid.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindMenuItem.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindMenuHelper.h"
#include "BindUtils.h"
#include "BindWidget.h"
#include "DocMenuItem.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_MenuItem \
OMNIUI_PYBIND_INIT_MenuHelper \
OMNIUI_PYBIND_INIT_Widget
#define OMNIUI_PYBIND_KWARGS_DOC_MenuItem \
OMNIUI_PYBIND_KWARGS_DOC_MenuHelper \
OMNIUI_PYBIND_KWARGS_DOC_Widget
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/BindEllipse.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindShape.h"
#include "BindUtils.h"
#include "DocEllipse.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Ellipse \
OMNIUI_PYBIND_INIT_Shape
#define OMNIUI_PYBIND_KWARGS_DOC_Ellipse \
OMNIUI_PYBIND_KWARGS_DOC_Shape
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/BindAbstractSlider.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindAbstractField.h"
#include "BindUtils.h"
#include "DocAbstractSlider.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_AbstractSlider \
OMNIUI_PYBIND_INIT_AbstractField
#define OMNIUI_PYBIND_KWARGS_DOC_AbstractSlider \
OMNIUI_PYBIND_KWARGS_DOC_AbstractField
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/DocSimpleIntModel.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_SimpleIntModel \
"A very simple Int model.\n" \
"\n"
|
omniverse-code/kit/include/omni/ui/bind/DocPercent.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Percent \
"Percent is the length in percents from the parent widget.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_Percent_Percent "Construct Percent.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocRadioButton.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_RadioButton \
"RadioButton is the widget that allows the user to choose only one of a predefined set of mutually exclusive options.\n" \
"RadioButtons are arranged in collections of two or more with the class RadioCollection, which is the central component of the system and controls the behavior of all the RadioButtons in the collection.\n"
#define OMNIUI_PYBIND_DOC_RadioButton_radioCollection "This property holds the button's text.\n"
#define OMNIUI_PYBIND_DOC_RadioButton_RadioButton "Constructs RadioButton.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindMenu.h | // Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindMenuHelper.h"
#include "BindStack.h"
#include "BindUtils.h"
#include "DocMenu.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Menu \
OMNIUI_PYBIND_INIT_CALLBACK(shown_changed_fn, setShownChangedFn, void(const bool&)) \
OMNIUI_PYBIND_INIT_CAST(tearable, setTearable, bool) \
OMNIUI_PYBIND_INIT_CALLBACK(teared_changed_fn, setTearedChangedFn, void(const bool&)) \
OMNIUI_PYBIND_INIT_CALLBACK(on_build_fn, setOnBuildFn, void()) \
OMNIUI_PYBIND_INIT_MenuHelper \
OMNIUI_PYBIND_INIT_Stack
#define OMNIUI_PYBIND_KWARGS_DOC_Menu \
"\n `tearable : bool`\n " \
OMNIUI_PYBIND_DOC_Menu_tearable \
"\n `shown_changed_fn : `\n " \
OMNIUI_PYBIND_DOC_Menu_shown \
"\n `teared_changed_fn : `\n " \
OMNIUI_PYBIND_DOC_Menu_teared \
"\n `on_build_fn : `\n " \
OMNIUI_PYBIND_DOC_Menu_OnBuild \
OMNIUI_PYBIND_KWARGS_DOC_MenuHelper \
OMNIUI_PYBIND_KWARGS_DOC_Stack
// clang-format off
|
omniverse-code/kit/include/omni/ui/bind/DocColorWidget.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_ColorWidget \
"The ColorWidget widget is a button that displays the color from the item model and can open a picker window to change the color.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_ColorWidget_setComputedContentWidth \
"Reimplemented the method to indicate the width hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the ColorWidget square.\n"
#define OMNIUI_PYBIND_DOC_ColorWidget_setComputedContentHeight \
"Reimplemented the method to indicate the height hint that represents the preferred size of the widget. Currently this widget can't be smaller than the size of the ColorWidget square.\n"
#define OMNIUI_PYBIND_DOC_ColorWidget_onModelUpdated \
"Reimplemented the method from ItemModelHelper that is called when the model is changed.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `item :`\n" \
" The item in the model that is changed. If it's NULL, the root is chaged.\n"
#define OMNIUI_PYBIND_DOC_ColorWidget_ColorWidget "Construct ColorWidget.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindFrame.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindContainer.h"
#include "BindUtils.h"
#include "DocFrame.h"
#include "DocRasterHelper.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_Frame \
OMNIUI_PYBIND_INIT_Container \
OMNIUI_PYBIND_INIT_CAST(horizontal_clipping, setHorizontalClipping, bool) \
OMNIUI_PYBIND_INIT_CAST(vertical_clipping, setVerticalClipping, bool) \
OMNIUI_PYBIND_INIT_CAST(separate_window, setSeparateWindow, bool) \
OMNIUI_PYBIND_INIT_CAST(raster_policy, setRasterPolicy, RasterPolicy) \
OMNIUI_PYBIND_INIT_CALLBACK(build_fn, setBuildFn, void())
#define OMNIUI_PYBIND_KWARGS_DOC_Frame \
"\n `horizontal_clipping : `\n " \
OMNIUI_PYBIND_DOC_Frame_horizontalClipping \
"\n `vertical_clipping : `\n " \
OMNIUI_PYBIND_DOC_Frame_verticalClipping \
"\n `separate_window : `\n " \
OMNIUI_PYBIND_DOC_Frame_separateWindow \
"\n `raster_policy : `\n " \
OMNIUI_PYBIND_DOC_RasterHelper_rasterPolicy \
"\n `build_fn : `\n " \
OMNIUI_PYBIND_DOC_Frame_Build \
OMNIUI_PYBIND_KWARGS_DOC_Container
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/BindHGrid.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindGrid.h"
#include "BindUtils.h"
#include "DocHGrid.h"
#define OMNIUI_PYBIND_INIT_HGrid OMNIUI_PYBIND_INIT_Grid
#define OMNIUI_PYBIND_KWARGS_DOC_HGrid OMNIUI_PYBIND_KWARGS_DOC_Grid
|
omniverse-code/kit/include/omni/ui/bind/DocSeparator.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_Separator \
"The Separator class provides blank space.\n" \
"Normally, it's used to create separator line in the UI elements\n"
#define OMNIUI_PYBIND_DOC_Separator_cascadeStyle \
"It's called when the style is changed. It should be propagated to children to make the style cached and available to children.\n"
#define OMNIUI_PYBIND_DOC_Separator_Separator "Construct Separator.\n"
|
omniverse-code/kit/include/omni/ui/bind/BindComboBox.h | // Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindUtils.h"
#include "BindWidget.h"
#include "DocComboBox.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_ComboBox \
OMNIUI_PYBIND_INIT_Widget \
OMNIUI_PYBIND_INIT_CAST(arrow_only, setArrowOnly, bool)
#define OMNIUI_PYBIND_KWARGS_DOC_ComboBox \
"\n `arrow_only : bool`\n " \
OMNIUI_PYBIND_DOC_ComboBox_arrowOnly \
OMNIUI_PYBIND_KWARGS_DOC_Widget
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/BindArrowHelper.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindShape.h"
#include "BindUtils.h"
#include "DocArrowHelper.h"
// clang-format off
#define OMNIUI_PYBIND_INIT_ArrowHelper \
OMNIUI_PYBIND_INIT_CAST(begin_arrow_width, setBeginArrowWidth, float) \
OMNIUI_PYBIND_INIT_CAST(begin_arrow_height, setBeginArrowHeight, float) \
OMNIUI_PYBIND_INIT_CAST(begin_arrow_type, setBeginArrowType, ArrowHelper::ArrowType) \
OMNIUI_PYBIND_INIT_CAST(end_arrow_width, setEndArrowWidth, float) \
OMNIUI_PYBIND_INIT_CAST(end_arrow_height, setEndArrowHeight, float) \
OMNIUI_PYBIND_INIT_CAST(end_arrow_type, setEndArrowType, ArrowHelper::ArrowType)
#define OMNIUI_PYBIND_KWARGS_DOC_ArrowHelper \
"\n `arrow : `\n " \
OMNIUI_PYBIND_DOC_ArrowHelper_beginArrowWidth \
OMNIUI_PYBIND_DOC_ArrowHelper_beginArrowHeight \
OMNIUI_PYBIND_DOC_ArrowHelper_beginArrowType \
OMNIUI_PYBIND_DOC_ArrowHelper_endArrowWidth \
OMNIUI_PYBIND_DOC_ArrowHelper_endArrowHeight \
OMNIUI_PYBIND_DOC_ArrowHelper_endArrowType
// clang-format on
|
omniverse-code/kit/include/omni/ui/bind/DocIntSlider.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_IntSlider \
"The slider is the classic widget for controlling a bounded value. It lets the user move a slider handle along a horizontal groove and translates the handle's position into an integer value within the legal range.\n" \
"\n"
#define OMNIUI_PYBIND_DOC_IntSlider_IntSlider \
"Constructs IntSlider.\n" \
"\n" \
"\n" \
"### Arguments:\n" \
"\n" \
" `model :`\n" \
" The widget's model. If the model is not assigned, the default model is created.\n"
|
omniverse-code/kit/include/omni/ui/bind/DocSimpleBoolModel.h | // Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#define OMNIUI_PYBIND_DOC_SimpleBoolModel \
"A very simple bool model.\n" \
"\n"
|
omniverse-code/kit/include/omni/ui/bind/BindInvisibleButton.h | // Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "BindWidget.h"
#include "DocInvisibleButton.h"
#define OMNIUI_PYBIND_INIT_InvisibleButton \
OMNIUI_PYBIND_INIT_Widget OMNIUI_PYBIND_INIT_CALLBACK(clicked_fn, setClickedFn, void())
// clang-format off
#define OMNIUI_PYBIND_KWARGS_DOC_InvisibleButton \
"\n `clicked_fn : Callable[[], None]`\n " \
OMNIUI_PYBIND_DOC_InvisibleButton_Clicked \
OMNIUI_PYBIND_KWARGS_DOC_Widget
// clang-format on
|
Subsets and Splits