file_path
stringlengths 21
202
| content
stringlengths 19
1.02M
| size
int64 19
1.02M
| lang
stringclasses 8
values | avg_line_length
float64 5.88
100
| max_line_length
int64 12
993
| alphanum_fraction
float64 0.27
0.93
|
---|---|---|---|---|---|---|
omniverse-code/kit/include/omni/ui/Axis.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 <stdint.h>
OMNIUI_NAMESPACE_OPEN_SCOPE
enum class Axis : uint8_t
{
eNone = 0,
eX = 1,
eY = 2,
eXY = 3,
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 634 | C | 23.423076 | 77 | 0.739748 |
omniverse-code/kit/include/omni/ui/StyleContainer.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 "Property.h"
#include "StyleProperties.h"
#include <array>
#include <string>
#include <unordered_map>
#include <vector>
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The StyleContainer class encapsulates the look and feel of a GUI.
*
* 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.
*/
class OMNIUI_CLASS_API StyleContainer
{
public:
enum class State
{
eNormal = 0,
eHovered,
ePressed,
eDisabled,
eSelected,
eChecked,
eDrop,
eCount
};
StyleContainer() = default;
template <typename... Args>
StyleContainer(Args... args)
{
_initializeBlock(args...);
}
/**
* @brief Preset with a default style.
*/
OMNIUI_API
static const StyleContainer& defaultStyle();
/**
* @brief Check if the style contains anything.
*/
OMNIUI_API
bool valid() const;
/**
* @brief Merges another style to this style. The given style is strongest.
*/
OMNIUI_API
void merge(const StyleContainer& style);
/**
* @brief Find the style state group by type and name. It's pretty slow, so it shouldn't be used in the draw cycle.
*/
OMNIUI_API
size_t getStyleStateGroupIndex(const std::string& type, const std::string& name) const;
/**
* @brief Get all the types in this StyleContainer.
*/
OMNIUI_API
std::vector<std::string> getCachedTypes() const;
/**
* @brief Get all the names related to the type in this StyleContainer.
*/
OMNIUI_API
std::vector<std::string> getCachedNames(const std::string& type) const;
/**
* @brief Get all the available states in the given index in this StyleContainer.
*/
OMNIUI_API
std::vector<State> getCachedStates(size_t styleStateGroupIndex) const;
/**
* @brief 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.
*
* @tparam T StyleFloatProperty or StyleColorProperty
* @tparam U float or uint32_t
*/
template <typename T, typename U>
bool resolveStyleProperty(
size_t styleStateGroupIndex, State state, T property, U* result, bool checkParentGroup = true) const;
/**
* @brief Get the the mapping between property and its string
*
* @tparam T StyleFloatProperty, StyleEnumProperty, StyleColorProperty, StyleStringProperty or State
*/
template <typename T>
static const std::unordered_map<std::string, T>& getNameToPropertyMapping();
/**
* @brief Get the Property from the string
*
* @tparam T StyleFloatProperty, StyleEnumProperty, StyleColorProperty or StyleStringProperty
*/
template <typename T>
static T getPropertyEnumeration(const std::string& property);
private:
/**
* @brief StyleContainer block represents one single block of properties.
*
* It keeps the indices of all possible properties, the values are in the vectors, and the index represents the
* position of the value in the vector. Thus, since we always know if the property exists and its location, it's
* possible to access the value very fast. Variadic arguments of the constructor allow creating styles with any
* number of properties. The initialization usually looks like this:
*
* StyleBlock{ StyleColorProperty::eBackgroundColor, 0xff292929, StyleFloatProperty::eMargin, 3.0f }
*
*/
class OMNIUI_CLASS_API StyleBlock
{
public:
/**
* @brief Construct a new StyleContainer Block object. It's usually looks like this:
*
* StyleBlock{ StyleColorProperty::eBackgroundColor, 0xff292929, StyleFloatProperty::eMargin, 3.0f }
*
*/
template <typename... Args>
StyleBlock(Args... args)
{
// TODO: with reserve it will be faster.
m_floatIndices.fill(SIZE_MAX);
m_enumIndices.fill(SIZE_MAX);
m_colorIndices.fill(SIZE_MAX);
m_stringIndices.fill(SIZE_MAX);
_initialize(args...);
}
/**
* @brief Query the properties in the block.
*
* @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 block contains given property
* @return false when the block doesn't have the given property
*/
template <typename T, typename U>
bool get(T property, U* result) const;
/**
* @brief Merge another property into this one.
*
* @param styleBlock The given property. It's stronger than the current one.
*/
void merge(const StyleBlock& styleBlock);
/**
* @brief Introducing a new conception of cascading and parenting
*
* This relationship can be described in the following diagram. We keep the indices of other nodes when they are
* available. And it allows fast iterating cascade styles when resolving the properties.
*
* Button <-------cascade--+ Button:hovered
* ^ ^
* | |
* parent parent
* | |
* + +
* Button::name <--cascade--+ Button::name::hovered
*
*/
OMNIUI_PROPERTY(size_t, parentIndex, DEFAULT, SIZE_MAX, READ, getParentIndex, WRITE, setParentIndex);
OMNIUI_PROPERTY(size_t, cascadeIndex, DEFAULT, SIZE_MAX, READ, getCascadeIndex, WRITE, setCascadeIndex);
private:
/**
* @brief A helper for variadic construction.
*/
OMNIUI_API
void _initialize(StyleFloatProperty property, const char* value);
/**
* @brief A helper for variadic construction.
*/
OMNIUI_API
void _initialize(StyleFloatProperty property, float value);
/**
* @brief A helper for variadic construction.
*/
OMNIUI_API
void _initialize(StyleColorProperty property, const char* value);
/**
* @brief A helper for variadic construction.
*/
OMNIUI_API
void _initialize(StyleColorProperty property, uint32_t value);
/**
* @brief A helper for variadic construction.
*/
OMNIUI_API
void _initialize(StyleEnumProperty property, uint32_t value);
/**
* @brief A helper for variadic construction.
*/
OMNIUI_API
void _initialize(StyleStringProperty property, const char* value);
/**
* @brief A helper for variadic construction.
*/
template <typename T, typename U, typename... Args>
void _initialize(T property, U value, Args... args)
{
_initialize(property, value);
_initialize(args...);
}
// The data model of the style block is simple. We keep all the values in the vector and all the indices in the
// array. It allows us to track which properties are in this block with excellent performance. If the property
// is not here, its index is SIZE_MAX.
//
// +------------------+ +----------+
// | m_floatIndices | | m_floats |
// |------------------| |----------|
// | padding +------------> 0.0 |
// | margin +------> 1.0 |
// | radius | | | |
// | thickness +---+ | | |
// +------------------+ +----------+
//
std::array<size_t, static_cast<size_t>(StyleFloatProperty::eCount)> m_floatIndices = {};
std::array<size_t, static_cast<size_t>(StyleColorProperty::eCount)> m_colorIndices = {};
std::array<size_t, static_cast<size_t>(StyleStringProperty::eCount)> m_stringIndices = {};
std::vector<uint32_t> m_enums = {};
std::array<size_t, static_cast<size_t>(StyleEnumProperty::eCount)> m_enumIndices = {};
};
/**
* @brief Find the given property in the given block index. If the property is not found, it continues finding in
* cascading and parent blocks.
*
* @tparam T StyleFloatProperty or StyleColorProperty
* @tparam U float or uint32_t
*/
template <typename T, typename U>
bool _resolveStyleProperty(size_t blockIndex, T property, U* result, bool checkParentGroup) const;
/**
* @brief A helper for variadic construction.
*/
template <typename... Args>
void _initializeBlock(StyleFloatProperty prop, Args... args)
{
static const std::string empty{};
_initializeBlock(empty, prop, args...);
}
/**
* @brief A helper for variadic construction.
*/
template <typename... Args>
void _initializeBlock(StyleEnumProperty prop, Args... args)
{
static const std::string empty{};
_initializeBlock(empty, prop, args...);
}
/**
* @brief A helper for variadic construction.
*/
template <typename... Args>
void _initializeBlock(StyleColorProperty prop, Args... args)
{
static const std::string empty{};
_initializeBlock(empty, prop, args...);
}
/**
* @brief A helper for variadic construction.
*/
template <typename... Args>
void _initializeBlock(StyleStringProperty prop, Args... args)
{
static const std::string empty{};
_initializeBlock(empty, prop, args...);
}
/**
* @brief A helper for variadic construction.
*/
template <typename... Args>
void _initializeBlock(const std::string& scope, Args... args)
{
// Can't move it to cpp because of the variadic template
std::string type;
std::string name;
State state;
StyleContainer::_parseScopeString(scope, type, name, state);
if (state == State::eCount)
{
// TODO: Warning message. BTW, what do we need to use for warnings?
return;
}
auto index = _createStyleStateGroup(type, name);
m_styleStateGroups[index][static_cast<int32_t>(state)] = m_styleBlocks.size();
m_styleBlocks.emplace_back(args...);
}
/**
* @brief Create a StyleContainer State Group object and puts it to the internal data structure.
*
* @return the index of created or existed StyleContainer State Group object in the data structure.
*/
OMNIUI_API
size_t _createStyleStateGroup(const std::string& type, const std::string& name);
/**
* @brief Perses a string that looks like "Widget::name:state", split it to the parts and return the parts.
*/
OMNIUI_API
static void _parseScopeString(const std::string& input, std::string& type, std::string& name, State& state);
/**
* @brief This is the group that contains indices to blocks. The index per state. Also, it has an index of the group
* that is the parent of this group.
*
* It's different from the block. The block has a list of properties. The group has the indices to the block.
*/
struct StyleStateIndices
{
public:
StyleStateIndices() : m_parent{ SIZE_MAX }
{
// By default everything is invalid.
m_indices.fill(SIZE_MAX);
}
size_t& operator[](size_t i)
{
// Fast access the indices
return m_indices[i];
}
const size_t& operator[](size_t i) const
{
// Fast access the indices
return m_indices[i];
}
size_t getParentIndex() const
{
return m_parent;
}
void setParentIndex(size_t i)
{
m_parent = i;
}
private:
std::array<size_t, static_cast<size_t>(State::eCount)> m_indices;
size_t m_parent;
};
using StyleBlocks = std::unordered_map<std::string, std::unordered_map<std::string, size_t>>;
// The data structure is pretty simple. We keep all the style blocks in the vector. We have an array with all the
// possible states (StyleContainer State Group) of the block. The states are hovered, pressed, etc. The
// StyleContainer State Group has the indices of the style blocks in the data structure. The StyleContainer State
// Groups are also placed to the vector, and it allows us to keep the index of the StyleContainer State Group in
// each widget. Also, we have a dictionary that maps the string names to the indices of StyleContainer State Group.
// See the following diagram for details.
//
// The workflow is simple. Once the style is changed, the widget should ask the index of StyleContainer State Group
// with the method `getStyleStateGroupIndex`, and use this index in the draw cycle to query style properties with
// the method
// `_resolveStyleProperty`.
//
// +-----------------------------+ +---------------------+ +----------------+
// | m_styleStateGroupIndicesMap | | m_styleStateGroups | | m_styleBlocks |
// |-----------------------------| |---------------------| |----------------|
// | 'Widget' | | +---------> +-StyleBlock-+ |
// | '' +-------------------------> +------------|----+ | | | padding | |
// | 'name' | | | normal | | | | | margin | |
// | 'Button' | | | hovered +--+ | | | | color | |
// | '' | | +-----------------+ | | | background | |
// | 'cancel' +-------------------> +-----------------+ | | +------------+ |
// | | | | normal +-------------> +-StyleBlock-+ |
// | | | | hovered | | | | padding | |
// | | | +-----------------+ | | | margin | |
// | | | | | | color | |
// | | | | | | background | |
// | | | | | +------------+ |
// +-----------------------------+ +---------------------+ +----------------+
std::vector<StyleBlock> m_styleBlocks = {};
std::vector<StyleStateIndices> m_styleStateGroups = {};
StyleBlocks m_styleStateGroupIndicesMap;
// The index of the block that is the global override. It's the block with no name and no type.
size_t m_globalOverrideIndex = SIZE_MAX;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 15,725 | C | 35.657343 | 120 | 0.571065 |
omniverse-code/kit/include/omni/ui/Shape.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 <imgui/imgui.h>
#include "StyleProperties.h"
#include "Widget.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
struct ShapeStyleSnapshot;
/**
* @brief The Shape widget provides a base class for all the Shape Widget
* currently implemented are Rectangle, Circle, Tiangle, Line
* TODO: those need to have a special draw overide to deal with intersection better
*/
class OMNIUI_CLASS_API Shape : public Widget
{
OMNIUI_OBJECT(Shape)
public:
OMNIUI_API
~Shape() override;
/**
* @brief Determines which style entry the shape should use for the background. It's very useful when we need to use
* a custom color. For example, when we draw the triangle for a collapsable frame, we use "color" instead of
* "background_color".
*/
OMNIUI_PROPERTY(StyleColorProperty,
backgroundColorProperty,
DEFAULT,
StyleColorProperty::eBackgroundColor,
READ,
getBackgroundColorProperty,
WRITE,
setBackgroundColorProperty);
/**
* @brief Determines which style entry the shape should use for the border color.
*/
OMNIUI_PROPERTY(StyleColorProperty,
borderColorProperty,
DEFAULT,
StyleColorProperty::eBorderColor,
READ,
getBorderColorProperty,
WRITE,
setBorderColorProperty);
/**
* @brief Determines which style entry the shape should use for the shadow color.
*/
OMNIUI_PROPERTY(StyleColorProperty,
shadowColorProperty,
DEFAULT,
StyleColorProperty::eShadowColor,
READ,
getShadowColorProperty,
WRITE,
setShadowColorProperty);
protected:
OMNIUI_API
Shape();
OMNIUI_API
void _drawContent(float elapsedTime) override;
OMNIUI_API
void _drawShapeShadow(float elapsedTime, float x, float y, float width, float height);
virtual void _drawShape(float elapsedTime, float x, float y, float width, float height){}
virtual void _drawShadow(
float elapsedTime,
float x,
float y,
float width,
float height,
uint32_t shadowColor,
float dpiScale,
ImVec2 shadowOffset,
float shadowThickness,
uint32_t shadowFlag){}
/**
* @brief Segment-circle intersection.
* Follows closely https://stackoverflow.com/questions/1073336/circle-line-segment-collision-detection-algorithm
*
* @param p1 start of line
* @param p2 end of line
* @param center center of circle
* @param r radius
* @return true intercects
* @return false doesn't intersect
*/
static bool _intersects(float p1X, float p1Y, float p2X, float p2Y, float centerX, float centerY, float r);
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 3,459 | C | 30.743119 | 120 | 0.633998 |
omniverse-code/kit/include/omni/ui/ShadowFlag.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 <cstdint>
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief Used to specify how shadow is rendered
*/
enum ShadowFlag : uint8_t
{
eNone = 0,
eCutOutShapeBackground = 1 << 0 // Do not render the shadow shape under the objects to be shadowed to save on
// fill-rate or facilitate blending. Slower on CPU.
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 859 | C | 29.714285 | 115 | 0.721769 |
omniverse-code/kit/include/omni/ui/CornerFlag.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 <cstdint>
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief Used to specify one or many corners of a rectangle.
*/
enum CornerFlag : uint32_t
{
eNone = 0,
eTopLeft = 1 << 0, // 0x1
eTopRight = 1 << 1, // 0x2
eBottomLeft = 1 << 2, // 0x4
eBottomRight = 1 << 3, // 0x8
eTop = eTopLeft | eTopRight, // 0x3
eBottom = eBottomLeft | eBottomRight, // 0xC
eLeft = eTopLeft | eBottomLeft, // 0x5
eRight = eTopRight | eBottomRight, // 0xA
eAll = 0xF // In your function calls you may use ~0 (= all bits sets) instead of ImDrawCornerFlags_All, as a
// convenience
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 1,116 | C | 30.027777 | 112 | 0.69086 |
omniverse-code/kit/include/omni/ui/Property.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 "Profile.h"
#include <boost/preprocessor.hpp>
#include <functional>
#include <memory>
#include <vector>
/**
* @brief Defines and declares a property in the class.
*
* Example:
* OMNIUI_PROPERTY(float, height,
* [PROTECTED],
* [READ, getHeight],
* [READ_VALUE, getHeightByValue],
* [WRITE, setHeight],
* [DEFAULT, 0.0f],
* [NOTIFY, onHeightChanged])
*
* Usage:
* OMNIUI_PROPERTY(
* Length, height,
* DEFAULT, Fraction{ 1.0f },
* READ, getHeight,
* WRITE, setHeight,
* PROTECTED,
* NOTIFY, _setHeightChangedFn);
*
* Expands to:
* private:
* Length m_height = Fraction{ 1.0f };
* PropertyCallback<Length const&> m__setHeightChangedFnCallbacks{ this };
* public:
* virtual Length const& getHeight() const
* {
* return m_height;
* }
* public:
* virtual void setHeight(Length const& v)
* {
* if (!checkIfEqual(m_height, v))
* {
* m_height = v;
* m__setHeightChangedFnCallbacks(v);
* }
* }
* protected:
* virtual void _setHeightChangedFn(std::function<void(Length const&)> f)
* {
* m__setHeightChangedFnCallbacks.add(std::move(f));
* }
* public:
*
* Everything on the right side of PROTECTED keyword will go to the protected section.
*
* The difference between READ and READ_VALUE is that READ returns const reference, READ_VALUE returns value.
*
* TODO: Callbacks are executed right on the time the value is changed. It would be better to accumulate them and
* execute once altogether. The question: at which point we need to execute them?
*/
#define OMNIUI_PROPERTY(type, name, ...) OMNIUI_PROPERTY_DEFINE(type, name, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)(END))
// Defines a private member variable and public members
#define OMNIUI_PROPERTY_DEFINE(type, name, arguments) \
OMNIUI_PROPERTY_DEFINE_VAR( \
type, name, OMNIUI_PROPERTY_FIND_DEFAULT(arguments), OMNIUI_PROPERTY_FIND_NOTIFY(arguments), arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_PUBLIC_, BOOST_PP_SEQ_ELEM(0, arguments)) \
(type, name, OMNIUI_PROPERTY_FIND_NOTIFY(arguments), arguments) public:
// Expands to
// private:
// type m_name [= default];
#define OMNIUI_PROPERTY_DEFINE_VAR(type, name, default, notify, arguments) \
private: \
type OMNI_PROPERTY_NAME(name) OMNIUI_PROPERTY_DEFAULT(default); \
OMNIUI_PROPERTY_DEFINE_CALLBACKS(type, notify)
// Expands to `m_name`
#define OMNI_PROPERTY_NAME(name) BOOST_PP_CAT(m_, name)
#define OMNI_PROPERTY_CALLBACK_NAME(...) BOOST_PP_CAT(BOOST_PP_CAT(m_, __VA_ARGS__), Callbacks)
// If something is passed, expands to `= args`, otherwise expands to empty
#define OMNIUI_PROPERTY_DEFAULT(...) BOOST_PP_IF(BOOST_PP_IS_EMPTY(__VA_ARGS__), BOOST_PP_EMPTY(), = __VA_ARGS__)
#define OMNIUI_PROPERTY_DEFINE_CALLBACK_EMPTY(type, ...) BOOST_PP_EMPTY()
#define OMNIUI_PROPERTY_DEFINE_CALLBACK_VAR(type, ...) \
PropertyCallback<CallbackHelperBase, type const&> OMNI_PROPERTY_CALLBACK_NAME(__VA_ARGS__){ this };
#define OMNIUI_PROPERTY_DEFINE_CALLBACKS(type, ...) \
BOOST_PP_IF( \
BOOST_PP_IS_EMPTY(__VA_ARGS__), OMNIUI_PROPERTY_DEFINE_CALLBACK_EMPTY, OMNIUI_PROPERTY_DEFINE_CALLBACK_VAR) \
(type, __VA_ARGS__)
#define OMNIUI_PROPERTY_CALLBACK_CODE(type, name, ...) \
BOOST_PP_IF(BOOST_PP_IS_EMPTY(__VA_ARGS__), BOOST_PP_EMPTY(), OMNI_PROPERTY_CALLBACK_NAME(__VA_ARGS__)(v);)
// It works like a chain. For example we have arguments like this: (READ)(getHeight)(WRITE)(setHeight)(PROTECTED).
// It works with getHeight and calls OMNIUI_PROPERTY_PUBLIC_*WRITE* with arguments (WRITE)(setHeight)(PROTECTED).
// The called macro is doing the same.
/* Common macro to expand all other property-get macros */
#define OMNIUI_PROPERTY_DECLARE_GETTER(scope, getDeclaration, qual_type, type, name, notify, arguments) \
scope: \
virtual qual_type BOOST_PP_SEQ_ELEM(1, arguments)() const \
getDeclaration \
/* Call the proper macro for the next argument */ \
BOOST_PP_CAT(OMNIUI_PROPERTY_PUBLIC_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(type, name, notify, BOOST_PP_SEQ_REST_N(2, arguments))
/* READ key, declare the virtual function to return by const reference */
#define OMNIUI_PROPERTY_PUBLIC_READ(type, name, notify, arguments) \
OMNIUI_PROPERTY_DECLARE_GETTER(public, \
{return OMNI_PROPERTY_NAME(name);}, \
type const&, \
type, name, notify, arguments)
#define OMNIUI_PROPERTY_PROTECTED_READ(type, name, notify, arguments) \
OMNIUI_PROPERTY_DECLARE_GETTER(protected, \
{return OMNI_PROPERTY_NAME(name);}, \
type const&, \
type, name, notify, arguments)
/* READ_VALUE key, declare the virtual function to return by value (copy) */
#define OMNIUI_PROPERTY_PUBLIC_READ_VALUE(type, name, notify, arguments) \
OMNIUI_PROPERTY_DECLARE_GETTER(public, \
{return OMNI_PROPERTY_NAME(name);}, \
type, \
type, name, notify, arguments)
#define OMNIUI_PROPERTY_PROTECTED_READ_VALUE(type, name, notify, arguments) \
OMNIUI_PROPERTY_DECLARE_GETTER(protected, \
{return OMNI_PROPERTY_NAME(name);}, \
type, \
type, name, notify, arguments)
/* GET_VALUE key, declare the virtual function, but use must implement it */
#define OMNIUI_PROPERTY_PUBLIC_GET_VALUE(type, name, notify, arguments) \
OMNIUI_PROPERTY_DECLARE_GETTER(public, \
;, \
type, \
type, name, notify, arguments)
#define OMNIUI_PROPERTY_PROTECTED_GET_VALUE(type, name, notify, arguments) \
OMNIUI_PROPERTY_DECLARE_GETTER(protected, \
;, \
type, \
type, name, notify, arguments)
/* Common macro for scoped write implementation */
#define OMNIUI_PROPERTY_SCOPED_WRITE(scope, type, name, notify, arguments) \
scope: \
virtual void BOOST_PP_SEQ_ELEM(1, arguments)(type const& v) \
{ \
if (!checkIfEqual(OMNI_PROPERTY_NAME(name), v)) \
{ \
OMNI_PROPERTY_NAME(name) = v; \
OMNIUI_PROFILE_VERBOSE_FUNCTION; \
OMNIUI_PROPERTY_CALLBACK_CODE(type, name, notify) \
} \
} \
/* Call the proper macro for the next argument */ \
BOOST_PP_CAT(OMNIUI_PROPERTY_PUBLIC_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(type, name, notify, BOOST_PP_SEQ_REST_N(2, arguments))
/* WRITE key for public access */
#define OMNIUI_PROPERTY_PUBLIC_WRITE(type, name, notify, arguments) \
OMNIUI_PROPERTY_SCOPED_WRITE(public, type, name, notify, arguments)
/* WRITE key for protected access */
#define OMNIUI_PROPERTY_PROTECTED_WRITE(type, name, notify, arguments) \
OMNIUI_PROPERTY_SCOPED_WRITE(protected, type, name, notify, arguments)
#define OMNIUI_PROPERTY_PUBLIC_NOTIFY(type, name, notify, arguments) \
public: \
virtual void notify(std::function<void(type const&)> f) \
{ \
OMNI_PROPERTY_CALLBACK_NAME(notify).add(std::move(f)); \
} \
/* Call the proper macro for the next argument */ \
BOOST_PP_CAT(OMNIUI_PROPERTY_PUBLIC_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(type, name, notify, BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_PROTECTED_NOTIFY(type, name, notify, arguments) \
protected: \
virtual void notify(std::function<void(type const&)> f) \
{ \
OMNI_PROPERTY_CALLBACK_NAME(notify).add(std::move(f)); \
} \
/* Call the proper macro for the next argument */ \
BOOST_PP_CAT(OMNIUI_PROPERTY_PROTECTED_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(type, name, notify, BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_PUBLIC_PROTECTED(type, name, notify, arguments) \
/* Change the next keyword to PROTECTED */ \
BOOST_PP_CAT(OMNIUI_PROPERTY_PROTECTED_, BOOST_PP_SEQ_ELEM(1, arguments)) \
(type, name, notify, BOOST_PP_SEQ_REST_N(1, arguments))
#define OMNIUI_PROPERTY_PROTECTED_PROTECTED(type, name, notify, arguments) /* Should never happen */ \
BOOST_PP_ERROR(0x0001)
#define OMNIUI_PROPERTY_PUBLIC_DEFAULT(type, name, notify, arguments) \
/* Skip and continue working with the next keyword */ \
BOOST_PP_CAT(OMNIUI_PROPERTY_PUBLIC_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(type, name, notify, BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_PROTECTED_DEFAULT(type, name, notify, arguments) \
/* Skip and continue working with the next keyword */ \
BOOST_PP_CAT(OMNIUI_PROPERTY_PROTECTED_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(type, name, notify, BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_PUBLIC_END(type, name, notify, arguments)
#define OMNIUI_PROPERTY_PROTECTED_END(type, name, notify, arguments)
// Looking for DEFAULT in the sequece
#define OMNIUI_PROPERTY_FIND_DEFAULT(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_DEFAULT_, BOOST_PP_SEQ_ELEM(0, arguments))(arguments)
#define OMNIUI_PROPERTY_FIND_DEFAULT_READ(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_DEFAULT_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_DEFAULT_READ_VALUE(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_DEFAULT_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_DEFAULT_GET_VALUE(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_DEFAULT_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_DEFAULT_WRITE(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_DEFAULT_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_DEFAULT_NOTIFY(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_DEFAULT_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_DEFAULT_PROTECTED(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_DEFAULT_, BOOST_PP_SEQ_ELEM(1, arguments)) \
(BOOST_PP_SEQ_REST_N(1, arguments))
#define OMNIUI_PROPERTY_FIND_DEFAULT_DEFAULT(arguments) BOOST_PP_SEQ_ELEM(1, arguments)
#define OMNIUI_PROPERTY_FIND_DEFAULT_END(arguments) BOOST_PP_EMPTY()
// Looking for NOTIFY in the sequece
#define OMNIUI_PROPERTY_FIND_NOTIFY(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_NOTIFY_, BOOST_PP_SEQ_ELEM(0, arguments))(arguments)
#define OMNIUI_PROPERTY_FIND_NOTIFY_READ(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_NOTIFY_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_NOTIFY_READ_VALUE(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_NOTIFY_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_NOTIFY_GET_VALUE(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_NOTIFY_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_NOTIFY_WRITE(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_NOTIFY_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_NOTIFY_DEFAULT(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_NOTIFY_, BOOST_PP_SEQ_ELEM(2, arguments)) \
(BOOST_PP_SEQ_REST_N(2, arguments))
#define OMNIUI_PROPERTY_FIND_NOTIFY_PROTECTED(arguments) \
BOOST_PP_CAT(OMNIUI_PROPERTY_FIND_NOTIFY_, BOOST_PP_SEQ_ELEM(1, arguments)) \
(BOOST_PP_SEQ_REST_N(1, arguments))
#define OMNIUI_PROPERTY_FIND_NOTIFY_NOTIFY(arguments) BOOST_PP_SEQ_ELEM(1, arguments)
#define OMNIUI_PROPERTY_FIND_NOTIFY_END(arguments) BOOST_PP_EMPTY()
OMNIUI_NAMESPACE_OPEN_SCOPE
class Widget;
// We need a custom fuction to test if the objects are equal because some objects don't provide equal operator.
template <typename T>
inline bool checkIfEqual(T const& t, T const& u)
{
return t == u;
}
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 19,689 | C | 67.846154 | 120 | 0.429631 |
omniverse-code/kit/include/omni/ui/SimpleListModel.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 <memory>
OMNIUI_NAMESPACE_OPEN_SCOPE
class SimpleStringModel;
/**
* @brief A very simple model that holds the the root model and the flat list of models.
*/
class OMNIUI_CLASS_API SimpleListModel : public AbstractItemModel
{
public:
static std::shared_ptr<SimpleListModel> create();
template <typename T>
static std::shared_ptr<SimpleListModel> create(const std::vector<T>& valueList, int32_t rootValue = 0);
/**
* @brief Reimplemented. Returns the vector of items that are nested to the given parent item.
*/
OMNIUI_API
std::vector<std::shared_ptr<const AbstractItem>> getItemChildren(
const std::shared_ptr<const AbstractItem>& parentItem = nullptr) override;
/**
* @brief Reimplemented. Creates a new item from the value model and appends it to the list of the children of the
* given item.
*/
OMNIUI_API
std::shared_ptr<const AbstractItem> appendChildItem(const std::shared_ptr<const AbstractItem>& parentItem,
std::shared_ptr<AbstractValueModel> model) override;
/**
* @brief Reimplemented. Removes the item from the model.
*/
OMNIUI_API
void removeItem(const std::shared_ptr<const AbstractItem>& item) override;
OMNIUI_API
size_t getItemValueModelCount(const std::shared_ptr<const AbstractItem>& item = nullptr) override;
/**
* @brief Reimplemented. Get the value model associated with this item.
*/
OMNIUI_API
std::shared_ptr<AbstractValueModel> getItemValueModel(const std::shared_ptr<const AbstractItem>& item = nullptr,
size_t index = 0) override;
protected:
/**
* @param rootModel The model that will be returned when querying the root item.
* @param models The list of all the value submodels of this model.
*/
OMNIUI_API
SimpleListModel(std::shared_ptr<AbstractValueModel> rootModel,
const std::vector<std::shared_ptr<AbstractValueModel>>& models);
private:
/**
* @brief Storrage for the items.
*/
class ListItem : public AbstractItemModel::AbstractItem
{
public:
ListItem(const std::shared_ptr<AbstractValueModel>& model) : m_model{ model }, m_callbackId{ -1 }
{
}
~ListItem() override;
// No copy
ListItem(const ListItem&) = delete;
// No copy-assignment
ListItem& operator=(const ListItem&) = 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 Keep callbackId from the model. When this object is destroyed, it removes this callback.
*
*/
void setCallbackId(int32_t callbackId);
private:
friend class SimpleListModel;
std::shared_ptr<AbstractValueModel> m_model;
int32_t m_callbackId;
};
std::shared_ptr<AbstractValueModel> m_rootModel;
std::vector<std::shared_ptr<ListItem>> m_items;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 3,624 | C | 32.878504 | 118 | 0.664459 |
omniverse-code/kit/include/omni/ui/CollapsableFrame.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 "Frame.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
class Rectangle;
/**
* @brief 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.
*/
class OMNIUI_CLASS_API CollapsableFrame : public Frame
{
OMNIUI_OBJECT(CollapsableFrame)
public:
/**
* @brief Reimplemented. It adds a widget to m_body.
*
* @see Container::addChild
*/
OMNIUI_API
void addChild(std::shared_ptr<Widget> widget) 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 Set flags to rebuild the body and header of this frame on the next drawing cycle
*/
OMNIUI_API
void rebuild() override;
/**
* @brief 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.
*/
OMNIUI_CALLBACK(BuildHeader, void, bool, std::string);
/**
* @brief The state of the CollapsableFrame.
*/
OMNIUI_PROPERTY(bool, collapsed, DEFAULT, false, READ, isCollapsed, WRITE, setCollapsed, NOTIFY, setCollapsedChangedFn);
/**
* @brief The header text
*/
OMNIUI_PROPERTY(std::string, title, READ, getTitle, WRITE, setTitle, NOTIFY, setTitleChangedFn);
/**
* @brief 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.
*/
OMNIUI_PROPERTY(Alignment,
alignment,
DEFAULT,
Alignment::eLeftCenter,
READ,
getAlignment,
WRITE,
setAlignment,
NOTIFY,
setAlignmentChangedFn);
protected:
/**
* @brief Constructs CollapsableFrame
*
* @param text The text for the caption of the frame.
*/
OMNIUI_API
CollapsableFrame(const std::string& text = {});
/**
* @brief Creates widgets that represent the header. Basically, it creates a triangle and a label. This function is
* called every time the frame collapses/expands, so if Python user wants to reimplement it, he doesn't care about
* keeping widgets and tracking the state of the frame.
*/
virtual void _buildHeader();
private:
/**
* @brief Checks if it's necessary to recreate the header and call _buildHeader.
*/
void _updateHeader();
/**
* @brief Sets a flag that it's necessary to recreate the header.
*/
void _invalidateState();
// The important widgets we need to access.
// Two rectangles to fill the background.
std::shared_ptr<Rectangle> m_backgroundHeader;
std::shared_ptr<Rectangle> m_backgroundBody;
// The frame for the title
std::shared_ptr<Frame> m_header;
// The frame for the body
std::shared_ptr<Frame> m_body;
// If true, the header will be recreated.
bool m_headerNeedsToBeUpdated = true;
std::function<void(bool, std::string)> m_buildHeaderFn;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 4,459 | C | 32.037037 | 124 | 0.67033 |
omniverse-code/kit/include/omni/ui/Line.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 "ArrowHelper.h"
#include "Shape.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
struct LineStyleSnapshot;
/**
* @brief The Line widget provides a colored line to display.
*/
class OMNIUI_CLASS_API Line : public Shape, public ArrowHelper
{
OMNIUI_OBJECT(Line)
public:
OMNIUI_API
~Line() override;
/**
* @brief Sets the function that will be called when the user use mouse enter/leave on the line. It's the override
* to prevent Widget from the bounding box logic.
* The function specification is:
* void onMouseHovered(bool hovered)
*/
OMNIUI_API
void setMouseHoveredFn(std::function<void(bool)> fn) override;
/**
* @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)
*
* It's the override to prevent the bounding box logic.
*/
OMNIUI_API
void setMousePressedFn(std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> fn) override;
/**
* @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_API
void setMouseReleasedFn(std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> fn) override;
/**
* @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_API
void setMouseDoubleClickedFn(std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> fn) 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 1 pixel
*
* @see Widget::setComputedContentHeight
*/
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 1 pixel
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) override;
/**
* @brief This property holds the alignment of the Line can only LEFT, RIGHT, VCENTER, HCENTER , BOTTOM, TOP.
* By default, the Line is HCenter.
*/
OMNIUI_PROPERTY(Alignment, alignment, DEFAULT, Alignment::eVCenter, READ, getAlignment, WRITE, setAlignment);
protected:
/**
* @brief Constructs Line
*/
OMNIUI_API
Line();
/**
* @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:
// Don't use m_mouseHoveredFn and m_isHovered to prevent the bbox logic of Widget.
std::function<void(bool)> m_mouseHoveredLineFn;
std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> m_mousePressedLineFn;
std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> m_mouseReleasedLineFn;
std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> m_mouseDoubleClickedLineFn;
bool m_isHoveredLine = false;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 4,625 | C | 34.312977 | 125 | 0.697514 |
omniverse-code/kit/include/omni/ui/MultiField.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 "AbstractMultiField.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief MultiFloatField is the widget that has a sub widget (FloatField) per model item.
*
* It's handy to use it for multi-component data, like for example, float3 or color.
*/
class OMNIUI_CLASS_API MultiFloatField : public AbstractMultiField
{
OMNIUI_OBJECT(MultiFloatField)
protected:
/**
* Constructor.
*/
OMNIUI_API
MultiFloatField(const std::shared_ptr<AbstractItemModel>& model = {});
/**
* @brief Create the widget with the model provided.
*/
OMNIUI_API
std::shared_ptr<Widget> _createField(const std::shared_ptr<AbstractValueModel>& model) override;
/**
* @brief Called to assign the new model to the widget created with `_createField`
*/
OMNIUI_API
void _setFieldModel(std::shared_ptr<Widget>& widget, const std::shared_ptr<AbstractValueModel>& model) override;
};
/**
* @brief MultiIntField is the widget that has a sub widget (IntField) per model item.
*
* It's handy to use it for multi-component data, like for example, int3.
*/
class OMNIUI_CLASS_API MultiIntField : public AbstractMultiField
{
OMNIUI_OBJECT(MultiIntField)
protected:
/**
* Constructor.
*/
OMNIUI_API
MultiIntField(const std::shared_ptr<AbstractItemModel>& model = {});
/**
* @brief Create the widget with the model provided.
*/
OMNIUI_API
std::shared_ptr<Widget> _createField(const std::shared_ptr<AbstractValueModel>& model) override;
/**
* @brief Called to assign the new model to the widget created with `_createField`
*/
OMNIUI_API
void _setFieldModel(std::shared_ptr<Widget>& widget, const std::shared_ptr<AbstractValueModel>& model) override;
};
/**
* @brief MultiStringField is the widget that has a sub widget (StringField) per model item.
*
* It's handy to use it for string arrays.
*/
class OMNIUI_CLASS_API MultiStringField : public AbstractMultiField
{
OMNIUI_OBJECT(MultiStringField)
protected:
/**
* Constructor.
*/
OMNIUI_API
MultiStringField(const std::shared_ptr<AbstractItemModel>& model = {});
/**
* @brief Create the widget with the model provided.
*/
OMNIUI_API
std::shared_ptr<Widget> _createField(const std::shared_ptr<AbstractValueModel>& model) override;
/**
* @brief Called to assign the new model to the widget created with `_createField`
*/
OMNIUI_API
void _setFieldModel(std::shared_ptr<Widget>& widget, const std::shared_ptr<AbstractValueModel>& model) override;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 3,063 | C | 28.747573 | 116 | 0.702579 |
omniverse-code/kit/include/omni/ui/CheckBox.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
/**
* @brief A CheckBox is an option button that can be switched on (checked) or off (unchecked). Checkboxes are typically
* used to represent features in an application that can be enabled or disabled without affecting others.
*
* The checkbox is implemented using the model-view pattern. The model is the central component of this system. It is
* the application's dynamic data structure independent of the widget. It directly manages the data, logic, and rules of
* the checkbox. If the model is not specified, the simple one is created automatically when the object is constructed.
*/
class OMNIUI_CLASS_API CheckBox : public Widget, public ValueModelHelper, public FontHelper
{
OMNIUI_OBJECT(CheckBox)
public:
OMNIUI_API
~CheckBox() 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 checkbox 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 checkbox square.
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) 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 Reimplemented. Something happened with the style or with the parent style. We need to gerenerate the
* cache.
*/
OMNIUI_API
void onStyleUpdated() override;
protected:
/**
* @brief CheckBox with specified model. If model is not specified, it's using the default one.
*/
OMNIUI_API
CheckBox(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:
// The state of the checkbox. We need to cache it anyway. Because we can't query the model every frame because the
// model can be written in python and query filesystem or USD. Of course, it can be cached on the Model level, but
// it means we ask the user to cache it, which is not preferable. Right now, we allow the model to do very expensive
// operations.
bool m_value = false;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 3,294 | C | 36.022472 | 120 | 0.721615 |
omniverse-code/kit/include/omni/ui/ToolBar.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 "Property.h"
#include "Window.h"
#include <memory>
#include <string>
namespace omni
{
namespace kit
{
struct Window;
}
}
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The ToolBar class represents a window in the underlying windowing system that as some fixed size property
*
*/
class OMNIUI_CLASS_API ToolBar : public Window
{
public:
enum class Axis : uint8_t
{
eX = 0,
eY = 1,
eNone = 2,
};
virtual ~ToolBar(){};
// We need it to make sure it's created as a shared pointer.
template <typename... Args>
static std::shared_ptr<ToolBar> 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 */
auto window = std::shared_ptr<ToolBar>{ new ToolBar{ std::forward<Args>(args)... } };
Workspace::RegisterWindow(window);
return window;
}
/**
* @breif axis for the toolbar
*/
OMNIUI_PROPERTY(ToolBar::Axis, axis, DEFAULT, Axis::eX, READ, getAxis, WRITE, setAxis, NOTIFY, setAxisChangedFn);
protected:
/**
* @brief Construct ToolBar
*/
OMNIUI_API
ToolBar(const std::string& title);
/**
* @brief Execute the rendering code of the widget.
*
* It's in protected section because it can be executed only by this object itself.
*/
virtual void _draw(const char* windowName, float elapsedTime) override;
private:
float m_prevContentRegionWidth = 0.0f;
float m_prevContentRegionHeight = 0.0f;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 2,132 | C | 25.012195 | 117 | 0.668856 |
omniverse-code/kit/include/omni/ui/IGlyphManager.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 <omni/kit/KitTypes.h>
#include <omni/ui/Font.h>
namespace carb
{
namespace imgui
{
struct Font;
}
}
namespace omni
{
namespace ui
{
struct GlyphInfo
{
const char* code;
float scale;
};
constexpr char kFontFileSettingsPath[] = "/app/font/file";
constexpr char kFontSizeSettingsPath[] = "/app/font/size";
constexpr char kFontScaleSettingsPath[] = "/app/font/scale";
constexpr char kResourceConfigFileSettingsPath[] = "/app/resourceConfig";
constexpr char kFontSaveAtlasSettingsPath[] = "/app/font/saveAtlas";
constexpr char kFontCustomRegionFilesSettingsPath[] = "/app/font/customRegionFiles";
constexpr char kFontCustomFontPathSettingsPath[] = "/app/font/customFontPath";
struct FontAtlas;
/**
* Defines a interface managing custom glyphs for the UI system.
*/
class IGlyphManager
{
public:
CARB_PLUGIN_INTERFACE("omni::ui::IGlyphManager", 1, 0);
virtual ~IGlyphManager(){};
virtual void setFontPath(const char* fontPath) = 0;
virtual void setFontSize(float fontSize) = 0;
virtual void setFontScale(float fontScale) = 0;
virtual void setResourcesConfigPath(const char* resourcesConfigPath) = 0;
virtual FontAtlas* createFontAtlas() = 0;
virtual void destroyFontAtlas(FontAtlas* fontAtlas) = 0;
virtual void* getContextFontAtlas(FontAtlas* fontAtlas) = 0;
/**
* Rebuilds fonts. If fontAtlas is nullptr, will create internal font atlas - deprecated approach.
*/
virtual void rebuildFonts(FontAtlas* fontAtlas) = 0;
/**
* Associates a registered glyph such as a SVG or PNG
*
* @param glyphPath The glyph resource path. Ex ${glyphs}/folder-solid.svg
*/
virtual bool registerGlyph(const char* glyphPath, FontStyle style) = 0;
/**
* Retrieves glyph Unicode character code for a registered glyph resource.
*
* @param glyphPath The glyph resource path. Ex ${glyphs}/folder-solid.svg
* @return The glyph information
*/
virtual GlyphInfo getGlyphInfo(const char* glyphPath, FontStyle style = FontStyle::eNormal) const = 0;
virtual void* getFont(FontStyle style) = 0;
};
}
}
| 2,566 | C | 29.2 | 106 | 0.72993 |
omniverse-code/kit/include/omni/ui/ColorWidget.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 "ItemModelHelper.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
class AbstractItemModel;
/**
* @brief The ColorWidget widget is a button that displays the color from the item model and can open a picker window to
* change the color.
*/
class OMNIUI_CLASS_API ColorWidget : public Widget, public ItemModelHelper
{
OMNIUI_OBJECT(ColorWidget)
public:
OMNIUI_API
~ColorWidget() 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 ColorWidget 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 ColorWidget square.
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) 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;
// TODO: Color space
// TODO: Property for float/int
// TODO: Property for disabling color picker
// TODO: Property for disabling popup
// TODO: Property for disabling alpha
protected:
/**
* @brief Construct ColorWidget
*/
OMNIUI_API
ColorWidget(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 ColorWidget allows to query the model only if it's changed.
static constexpr size_t kRgbaComponentsNumber = 4;
size_t m_componentsNumber = 0;
float m_colorBuffer[kRgbaComponentsNumber] = { 0.0f };
bool m_popupOpen = false;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 2,715 | C | 30.952941 | 120 | 0.713076 |
omniverse-code/kit/include/omni/ui/WindowHandle.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.
//
//! @file
//!
//! @brief omni::ui WindowHandle
#pragma once
#include "Api.h"
#include <memory>
#include <string>
namespace omni
{
namespace kit
{
class IAppWindow;
}
}
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief 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.
*/
class OMNIUI_CLASS_API WindowHandle
{
public:
// This is the DockPosition relative to a Split in a DockNode, Same reflect that the position is not Splitted but
// over the other window in the same dockNode
enum class DockPosition : uint8_t
{
eLeft = 0,
eRight = 1,
eTop = 2,
eBottom = 3,
eSame = 4
};
virtual ~WindowHandle();
/**
* @brief The title of the window.
*/
OMNIUI_API
virtual std::string getTitle() const;
/**
* @brief The position of the window in points.
*/
OMNIUI_API
virtual float getPositionX() const;
/**
* @brief Set the position of the window in points.
*/
OMNIUI_API
virtual void setPositionX(const float& positionX);
/**
* @brief The position of the window in points.
*/
OMNIUI_API
virtual float getPositionY() const;
/**
* @brief Set the position of the window in points.
*/
OMNIUI_API
virtual void setPositionY(const float& positionY);
/**
* @brief The width of the window in points.
*/
OMNIUI_API
virtual float getWidth() const;
/**
* @brief Set the width of the window in points.
*/
OMNIUI_API
virtual void setWidth(const float& width);
/**
* @brief The height of the window in points.
*/
OMNIUI_API
virtual float getHeight() const;
/**
* @brief Set the height of the window in points.
*/
OMNIUI_API
virtual void setHeight(const float& height);
/**
* @brief Returns whether the window is visible.
*/
OMNIUI_API
virtual bool isVisible() const;
/**
* @brief Set the visibility of the windows. It's the way to hide the window.
*/
OMNIUI_API
virtual void setVisible(const bool& visible);
/**
* @brief Checks if the current docking space has the tab bar.
*/
OMNIUI_API
virtual bool isDockTabBarVisible() const;
/**
* @brief 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.
*/
OMNIUI_API
virtual void setDockTabBarVisible(const bool& visible);
/**
* @brief Checks if the current docking space is disabled. The disabled
* docking tab bar can't be shown by the user.
*/
OMNIUI_API
virtual bool isDockTabBarEnabled() const;
/**
* @brief Sets the visibility of the current docking space tab bar. The disabled
* docking tab bar can't be shown by the user.
*/
OMNIUI_API
virtual void setDockTabBarEnabled(const bool& disabled);
/**
* @brief Undock the window and make it floating.
*/
OMNIUI_API
virtual void undock();
/**
* @brief 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.
*/
OMNIUI_API
virtual void dockIn(const std::shared_ptr<WindowHandle>& window, const DockPosition& dockPosition, float ratio = 0.5);
/**
* @brief The position of the window in the dock.
*/
OMNIUI_API
virtual int32_t getDockOrder() const;
/**
* @brief Set the position of the window in the dock.
*/
OMNIUI_API
virtual void setDockOrder(const int32_t& dockOrder);
/**
* @brief True if this window is docked. False otherwise.
*/
OMNIUI_API
virtual bool isDocked() const;
/**
* @brief Returns ID of the dock node this window is docked to.
*/
OMNIUI_API
virtual uint32_t getDockId() const;
/**
* @brief Brings the window to the top. If it's a docked window, it makes the window currently visible in the dock.
*/
OMNIUI_API
virtual void focus();
/**
* @brief Return true is the window is the current window in the docking area.
*/
OMNIUI_API
virtual bool isSelectedInDock();
/**
* @brief Notifies the UI window that the AppWindow it attached to has changed.
*/
OMNIUI_API
virtual void notifyAppWindowChange(omni::kit::IAppWindow* newAppWindow);
protected:
friend class Workspace;
/**
* @brief Create a handle with the given ID.
*
* Only Workspace can create this object.
*/
OMNIUI_API
WindowHandle(uint32_t windowId);
/**
* @brief Given an input window, check if it is the current window in the docking area.
* @details This is to give the API to check if the current window is selected when we
* already have the window, saving us running the slow `_GET_WINDOW`.
*/
OMNIUI_API
bool _isWindowSelectedInDock(void *window);
// Underlying ID of the window.
uint32_t m_windowId = 0;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 5,635 | C | 24.273542 | 122 | 0.644898 |
omniverse-code/kit/include/omni/ui/MainWindow.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 "Property.h"
#include <carb/IObject.h>
#include <memory>
#include <string>
OMNIUI_NAMESPACE_OPEN_SCOPE
namespace windowmanager
{
class IWindowCallback;
}
class MenuBar;
struct MainWindowPrivate;
/**
* @brief The MainWindow class represents Main Window for the Application, draw optional MainMenuBar and StatusBar
*
*/
class OMNIUI_CLASS_API MainWindow : public std::enable_shared_from_this<MainWindow>, protected CallbackHelper<MainWindow>
{
public:
virtual ~MainWindow();
/**
* @brief Removes all the callbacks and circular references.
*/
OMNIUI_API
virtual void destroy();
// We need it to make sure it's created as a shared pointer.
template <typename... Args>
static std::shared_ptr<MainWindow> 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 */
auto window = std::shared_ptr<MainWindow>{ new MainWindow{ std::forward<Args>(args)... } };
return window;
}
/**
* @brief The main MenuBar for the application
*/
OMNIUI_PROPERTY(std::shared_ptr<MenuBar>, mainMenuBar, READ, getMainMenuBar, PROTECTED, WRITE, setMainMenuBar);
/**
* @brief This represents Styling opportunity for the Window background
*/
OMNIUI_PROPERTY(std::shared_ptr<Frame>, mainFrame, READ, getMainFrame, PROTECTED, WRITE, setMainFrame);
/**
* @brief The StatusBar Frame is empty by default and is meant to be filled by other part of the system
*/
OMNIUI_PROPERTY(std::shared_ptr<Frame>, statusBarFrame, READ, getStatusBarFrame, PROTECTED, WRITE, setStatusBarFrame);
/**
* @brief Workaround to reserve space for C++ status bar
*/
OMNIUI_PROPERTY(bool, cppStatusBarEnabled, DEFAULT, false, READ, getCppStatusBarEnabled, WRITE, setCppStatusBarEnabled);
/**
* @brief When show_foreground is True, MainWindow prevents other windows from showing.
*/
OMNIUI_PROPERTY(bool,
showForeground,
DEFAULT,
false,
READ,
isShowForeground,
WRITE,
setShowForeground,
PROTECTED,
NOTIFY,
_setShowForegroundChangedFn);
protected:
/**
* @brief Construct the main window, add it to the underlying windowing system, and makes it appear.
*/
OMNIUI_API
MainWindow(bool showForeground = false);
/**
* @brief Execute the rendering code of the widget.
*
* It's in protected section because it can be executed only by this object itself.
*/
virtual void _draw(float elapsedTime);
/**
* @brief Execute the rendering code that prevents other windows from showing.
*/
virtual void _drawForeground(float elapsedTime);
private:
// We need it to keep carb::settings::ThreadSafeLocalCache<bool> and avoid
// including carb stuff here.
std::unique_ptr<MainWindowPrivate> m_prv;
float m_viewportSizeX = 0.0f;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 3,688 | C | 30.262712 | 124 | 0.664588 |
omniverse-code/kit/include/omni/ui/Plot.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 "StyleProperties.h"
#include "Widget.h"
#include <float.h>
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The Plot widget provides a line/histogram to display.
*/
class OMNIUI_CLASS_API Plot : public Widget
{
OMNIUI_OBJECT(Plot)
public:
OMNIUI_API
~Plot() override;
/**
* @brief This type is used to determine the type of the image.
*/
enum class Type
{
eLine,
eHistogram,
eLine2D,
};
/**
* @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 1 pixel
*
* @see Widget::setComputedContentHeight
*/
OMNIUI_API
void setComputedContentHeight(float height) override;
/**
* @brief Sets the function that will be called when when data required.
*/
OMNIUI_API
virtual void setDataProviderFn(std::function<float(int)> fn, int valuesCount);
/**
* @brief Sets the image data value.
*/
OMNIUI_API
virtual void setData(const std::vector<float>& valueList);
/**
* @brief Sets the 2d data. X coordinate helps to put the point at the exact
* position. Useful when the points are at different distance.
*/
OMNIUI_API
virtual void setXYData(const std::vector<std::pair<float, float>>& valueList);
/**
* @brief This property holds the type of the image, can only be line or histogram.
* By default, the type is line.
*/
OMNIUI_PROPERTY(Type, type, DEFAULT, Type::eLine, READ, getType, WRITE, setType);
/**
* @brief This property holds the min scale values.
* By default, the value is FLT_MAX.
*/
OMNIUI_PROPERTY(float, scaleMin, DEFAULT, FLT_MAX, READ, getScaleMin, WRITE, setScaleMin);
/**
* @brief This property holds the max scale values.
* By default, the value is FLT_MAX.
*/
OMNIUI_PROPERTY(float, scaleMax, DEFAULT, FLT_MAX, READ, getScaleMax, WRITE, setScaleMax);
/**
* @brief This property holds the value offset.
* By default, the value is 0.
*/
OMNIUI_PROPERTY(int, valueOffset, DEFAULT, 0, READ, getValueOffset, WRITE, setValueOffset);
/**
* @brief This property holds the stride to get value list.
* By default, the value is 1.
*/
OMNIUI_PROPERTY(int, valueStride, DEFAULT, 1, READ, getValueStride, WRITE, setValueStride);
/**
* @brief This property holds the title of the image.
*/
OMNIUI_PROPERTY(std::string, title, DEFAULT, "", READ, getTitle, WRITE, setTitle);
protected:
/**
* @brief Construct Plot
*
* @param type The type of the image, can be line or histogram.
* @param scaleMin The minimal scale value.
* @param scaleMax The maximum scale value.
* @param valueList The list of values to draw the image.
*/
OMNIUI_API
Plot(Type type, float scaleMin, float scaleMax, const std::vector<float>& valueList);
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
std::vector<float> m_plotData;
std::vector<std::pair<float, float>> m_plotXYData;
float m_prevWidth = 0;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 3,779 | C | 28.302325 | 116 | 0.664197 |
omniverse-code/kit/include/omni/ui/MultiDragField.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 "MultiField.h"
#include <limits>
OMNIUI_NAMESPACE_OPEN_SCOPE
class FloatDrag;
class IntDrag;
/**
* @brief The base class for MultiFloatDragField and MultiIntDragField. We need it because there classes are very
* similar, so we can template them.
*
* @tparam T FloatDrag or IntDrag
* @tparam U float or Int
*/
template <typename T, typename U>
class OMNIUI_CLASS_API MultiDragField : public AbstractMultiField
{
public:
/**
* @brief Reimplemented. Called by the model when the model value is changed.
*/
OMNIUI_API
void onModelUpdated(const std::shared_ptr<const AbstractItemModel::AbstractItem>& item) override;
// TODO: We are going to get min/max from the model.
/**
* @brief This property holds the drag's minimum value.
*/
OMNIUI_PROPERTY(U, min, DEFAULT, std::numeric_limits<U>::lowest(), READ, getMin, WRITE, setMin, NOTIFY, setMinChangedFn);
/**
* @brief This property holds the drag's maximum value.
*/
OMNIUI_PROPERTY(U, max, DEFAULT, std::numeric_limits<U>::max(), READ, getMax, WRITE, setMax, NOTIFY, setMaxChangedFn);
/**
* @brief This property controls the steping speed on the drag
*/
OMNIUI_PROPERTY(float, step, DEFAULT, 0.001f, READ, getStep, WRITE, setStep, NOTIFY, setStepChangedFn);
protected:
/**
* @brief Constructs MultiDragField
*
* @param model The widget's model. If the model is not assigned, the default model is created.
*/
OMNIUI_API
MultiDragField(const std::shared_ptr<AbstractItemModel>& model = {});
/**
* @brief Create the widget with the model provided.
*/
OMNIUI_API
std::shared_ptr<Widget> _createField(const std::shared_ptr<AbstractValueModel>& model) override;
/**
* @brief Called to assign the new model to the widget created with `_createField`
*/
OMNIUI_API
void _setFieldModel(std::shared_ptr<Widget>& widget, const std::shared_ptr<AbstractValueModel>& model) override;
private:
/**
* @brief Called when the min/max property is changed. It propagates min/max to children.
*/
void _onMinMaxChanged();
/**
* @brief Called when the user changes step
*/
void _onStepChanged(float step);
std::vector<std::weak_ptr<T>> m_drags;
};
/**
* @brief MultiFloatDragField is the widget that has a sub widget (FloatDrag) per model item.
*
* It's handy to use it for multi-component data, like for example, float3 or color.
*/
class OMNIUI_CLASS_API MultiFloatDragField : public MultiDragField<FloatDrag, double>
{
OMNIUI_OBJECT(MultiFloatDragField)
protected:
/**
* @brief Constructs MultiFloatDragField
*
* @param model The widget's model. If the model is not assigned, the default model is created.
*/
OMNIUI_API
MultiFloatDragField(const std::shared_ptr<AbstractItemModel>& model = {})
: MultiDragField<FloatDrag, double>{ model }
{
}
};
/**
* @brief MultiIntDragField is the widget that has a sub widget (IntDrag) per model item.
*
* It's handy to use it for multi-component data, like for example, int3.
*/
class OMNIUI_CLASS_API MultiIntDragField : public MultiDragField<IntDrag, int32_t>
{
OMNIUI_OBJECT(MultiIntDragField)
protected:
/**
* @brief Constructs MultiIntDragField
*
* @param model The widget's model. If the model is not assigned, the default model is created.
*/
OMNIUI_API
MultiIntDragField(const std::shared_ptr<AbstractItemModel>& model = {}) : MultiDragField<IntDrag, int32_t>{ model }
{
}
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 4,061 | C | 29.772727 | 125 | 0.694164 |
omniverse-code/kit/include/omni/ui/Callback.h | // Copyright (c) 2021-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 "Profile.h"
#include <omni/kit/IApp.h>
#include <boost/preprocessor.hpp>
#include <algorithm>
#include <functional>
#include <vector>
// Receives: 3, 1, (int, char, float)
// Generates: char arg1
#define OMNIUI_ARGUMENT_NAME(z, n, seq) BOOST_PP_TUPLE_ELEM(n, seq) arg##n
// Receives: int, char, float
// Generates: (int arg0, char arg1, float arg2)
#define OMNIUI_FUNCTION_ARGS(...) \
BOOST_PP_IF( \
BOOST_PP_IS_EMPTY(__VA_ARGS__), (), \
(BOOST_PP_ENUM(BOOST_PP_TUPLE_SIZE(BOOST_PP_VARIADIC_TO_TUPLE(__VA_ARGS__)), OMNIUI_ARGUMENT_NAME, \
BOOST_PP_IF(BOOST_PP_IS_EMPTY(__VA_ARGS__), (error), BOOST_PP_VARIADIC_TO_TUPLE(__VA_ARGS__)))))
// Receives: int, char, float
// Generates: (arg0, arg1, arg2)
#define OMNIUI_CALL_ARGS(...) \
BOOST_PP_IF(BOOST_PP_IS_EMPTY(__VA_ARGS__), (), (BOOST_PP_ENUM_PARAMS(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), arg)))
#define OMNIUI_VA_TEMPLATE(type, ...) type BOOST_PP_COMMA_IF(BOOST_PP_NOT(BOOST_PP_IS_EMPTY(__VA_ARGS__))) __VA_ARGS__
template <typename T>
inline T __return_type_init()
{
return static_cast<T>(NULL);
}
template <>
inline std::string __return_type_init<std::string>()
{
return std::string("");
}
/**
* @brief This is the macro to define a widget callback. It creates the callback holder and four methods: set, on
* changed, has and call.
*
* Using: OMNIUI_CALLBACK(MouseReleased, void, float, float, int32_t, carb::input::KeyboardModifierFlags);
*
* Expands to:
* private:
* Callback<void, float, float, int32_t, carb::input::KeyboardModifierFlags> m_MouseReleasedCallback{ this };
* public:
* virtual void setMouseReleasedFn(
* std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> fn)
* {
* m_MouseReleasedCallback.set(std::move(fn));
* }
* virtual void setMouseReleasedChangedFn(std::function<void()> fn)
* {
* m_MouseReleasedCallback.setOnChanged(std::move(fn));
* }
* void callMouseReleasedFn(float arg0, float arg1, int32_t arg2, carb::input::KeyboardModifierFlags arg3)
* {
* if (this->hasMouseReleasedFn())
* {
* m_MouseReleasedCallback(arg0, arg1, arg2, arg3);
* }
* return static_cast<void>(0);
* }
* bool hasMouseReleasedFn() const
* {
* return m_MouseReleasedCallback;
* }
*/
#define OMNIUI_CALLBACK(name, type, ...) \
private: \
Callback<CallbackHelperBase, OMNIUI_VA_TEMPLATE(type, __VA_ARGS__)> m_##name##Callback{ this }; \
\
public: \
virtual void set##name##Fn(std::function<type(__VA_ARGS__)> fn) \
{ \
m_##name##Callback.set(std::move(fn)); \
} \
\
virtual void set##name##ChangedFn(std::function<void()> fn) \
{ \
m_##name##Callback.setOnChanged(std::move(fn)); \
} \
type call##name##Fn OMNIUI_FUNCTION_ARGS(__VA_ARGS__) \
{ \
if (this->has##name##Fn()) \
{ \
OMNIUI_PROFILE_VERBOSE_FUNCTION; \
return m_##name##Callback OMNIUI_CALL_ARGS(__VA_ARGS__); \
} \
\
return __return_type_init<type>(); \
} \
\
bool has##name##Fn() const \
{ \
return m_##name##Callback; \
}
OMNIUI_NAMESPACE_OPEN_SCOPE
template <typename W>
class CallbackBase;
/**
* @brief Base class for the objects that should automatically clean up the callbacks. It collects all the callbacks
* created with OMNIUI_CALLBACK and is able to clean all of them. We use it to destroy the callbacks if the parent
* object is destroyed, and it helps to break circular references created by pybind11 because pybind11 can't use weak
* pointers.
*/
template <typename W>
class OMNIUI_CLASS_API CallbackHelper
{
public:
using CallbackHelperBase = W;
void initializeCallback(CallbackBase<W>* callback)
{
if (callback)
{
m_callbacks.push_back(callback);
}
}
void disposeCallback(CallbackBase<W>* callback)
{
auto found = std::find(m_callbacks.begin(), m_callbacks.end(), callback);
if (found != m_callbacks.end())
{
m_callbacks.erase(found);
}
}
void destroyCallbacks()
{
if (!m_callbacksValid)
{
return;
}
m_callbacksValid = false;
for (auto& callback : m_callbacks)
{
callback->destroy();
}
}
private:
std::vector<CallbackBase<W>*> m_callbacks;
bool m_callbacksValid = true;
};
/**
* @brief Base object for callback containers.
*/
template <typename W>
class OMNIUI_CLASS_API CallbackBase
{
public:
CallbackBase(CallbackHelper<W>* widget) : m_parent{ widget }
{
if (m_parent)
{
m_parent->initializeCallback(this);
}
}
virtual ~CallbackBase()
{
if (m_parent)
{
m_parent->disposeCallback(this);
}
}
virtual operator bool() const = 0;
virtual void destroy() = 0;
private:
CallbackHelper<W>* m_parent;
};
/**
* @brief Callback containers that is used with OMNIUI_CALLBACK macro. It keeps only one function, but it's possible to
* set up another function called when the main one is replaced.
*/
template <typename W, typename T, typename... Args>
class Callback : public CallbackBase<W>
{
public:
using CallbackType = std::function<T(Args...)>;
Callback(CallbackHelper<W>* widget) : CallbackBase<W>{ widget }
{
}
void set(std::function<T(Args...)> fn)
{
m_callback = std::move(fn);
if (m_onChanged)
{
m_onChanged();
}
}
void setOnChanged(std::function<void()> fn)
{
m_onChanged = std::move(fn);
}
T operator()(Args... args)
{
if (m_callback)
{
return m_callback(args...);
}
// TODO: Error on empty m_callback?
return noCallbackValue(static_cast<const T*>(nullptr));
}
operator bool() const override
{
return static_cast<bool>(m_callback);
}
void destroy() override
{
m_callback = {};
m_onChanged = {};
}
private:
static void noCallbackValue(const void*) { return; }
template <typename R> static R noCallbackValue(const R*) { return R{}; }
CallbackType m_callback;
std::function<void()> m_onChanged;
};
/**
* @brief Callback containers that is used with OMNIUI_PROPERTY macro.
*/
template <typename W, typename... Args>
class PropertyCallback : public CallbackBase<W>
{
public:
PropertyCallback(CallbackHelper<W>* widget) : CallbackBase<W>{ widget }
{
}
void add(std::function<void(Args...)> fn)
{
// TODO: There exists code that does ui_obj.set_xxx_changed_fn(None) which assumes
// the callback is removed, not added to a list
if (fn)
{
m_callbacks.emplace_back(std::move(fn));
}
}
void operator()(Args... args)
{
// TODO: Handle mutation during iteration better
const size_t n = m_callbacks.size();
for (size_t i = 0; i < n; ++i)
{
if (i < m_callbacks.size())
{
m_callbacks[i](args...);
}
else
{
break;
}
}
}
operator bool() const override
{
return !m_callbacks.empty();
}
void destroy() override
{
m_callbacks.clear();
}
private:
std::vector<std::function<void(Args...)>> m_callbacks;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 11,077 | C | 35.08469 | 128 | 0.435768 |
omniverse-code/kit/include/omni/ui/Container.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"
#include <memory>
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The container is an abstract widget that can hold one or several child widgets.
*
* 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.
*/
class OMNIUI_CLASS_API Container : public Widget
{
public:
OMNIUI_API
~Container() override;
/**
* @brief 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.
*/
virtual void addChild(std::shared_ptr<Widget> widget){}
/**
* @brief Removes the container items from the container.
*/
virtual void clear(){}
protected:
friend class Inspector;
OMNIUI_API
Container();
/**
* @brief Return the list of children for the Container, only used by Inspector and for debug/inspection
* perspective.
*/
OMNIUI_API
virtual const std::vector<std::shared_ptr<Widget>> _getChildren() const { return {}; }
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 1,623 | C | 28.527272 | 120 | 0.71411 |
omniverse-code/kit/include/omni/ui/FreeShape.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 "BezierCurve.h"
#include "Circle.h"
#include "Ellipse.h"
#include "Line.h"
#include "Rectangle.h"
#include "Triangle.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The free widget is the widget that is independent of the layout. It means it is stuck to other widgets.
* When initializing, it's necessary to provide two widgets, and the shape is drawn from one widget position to
* the another.
*/
template <typename T>
class OMNIUI_CLASS_API FreeShape : public T
{
/**
* @brief Reimplemented the method to indicate the width hint that represents the preferred size of the widget.
* It always returns 0 because FreeShape is layout-free.
*/
OMNIUI_API
void setComputedContentWidth(float height) override
{
// This Widget doesn't modify the layout as it's a free-floating shape.
Widget::setComputedContentWidth(0.0f);
}
/**
* @brief Reimplemented the method to indicate the height hint that represents the preferred size of the widget.
* It always returns 0 because FreeShape is layout-free.
*/
OMNIUI_API
void setComputedContentHeight(float height) override
{
// This Widget doesn't modify the layout as it's a free-floating shape.
Widget::setComputedContentHeight(0.0f);
}
protected:
/**
* @brief Initialize the the shape with bounds limited to the positions of the given widgets.
*
* @param start The bound corder is in the center of this given widget.
* @param end The bound corder is in the center of this given widget.
*/
OMNIUI_API
FreeShape(std::shared_ptr<Widget> start, std::shared_ptr<Widget> end)
: m_startPointWidget{ start }, m_endPointWidget{ end }
{
m_bbox.width = 0.0f;
m_bbox.height = 0.0f;
}
/**
* @brief Reimplemented the rendering code of the shape.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override
{
auto startPointWidget = m_startPointWidget.lock();
auto endPointWidget = m_endPointWidget.lock();
if (!startPointWidget || !endPointWidget)
{
return;
}
// Shape bound corners. 0.5 to have the point in the middle of the widget.
float startX = startPointWidget->getScreenPositionX() + startPointWidget->getComputedWidth() * 0.5f;
float startY = startPointWidget->getScreenPositionY() + startPointWidget->getComputedHeight() * 0.5f;
float endX = endPointWidget->getScreenPositionX() + endPointWidget->getComputedWidth() * 0.5f;
float endY = endPointWidget->getScreenPositionY() + endPointWidget->getComputedHeight() * 0.5f;
m_bbox.width = fabsf(endX - startX);
m_bbox.height = fabsf(endY - startY);
this->_drawShapeShadow(elapsedTime, startX, startY, endX - startX, endY - startY);
this->_drawShape(elapsedTime, startX, startY, endX - startX, endY - startY);
}
OMNIUI_API
Widget::BoundingBox _getInteractionBBox() const override
{
return m_bbox;
}
// Weak pointers to the widgets the shape should stick to.
std::weak_ptr<Widget> m_startPointWidget;
std::weak_ptr<Widget> m_endPointWidget;
// Track our bounding box for mouse events, because we set computed width/height to zero.
Widget::BoundingBox m_bbox;
};
#define _OMNIUI_DEFINE_FREE_SHAPE(name, parent) \
class name : public FreeShape<parent> \
{ \
OMNIUI_OBJECT(name) \
\
protected: \
OMNIUI_API \
name(std::shared_ptr<Widget> start, std::shared_ptr<Widget> end) \
: FreeShape<parent>{ std::move(start), std::move(end) } \
{ \
} \
}
_OMNIUI_DEFINE_FREE_SHAPE(FreeBezierCurve, BezierCurve);
_OMNIUI_DEFINE_FREE_SHAPE(FreeCircle, Circle);
_OMNIUI_DEFINE_FREE_SHAPE(FreeEllipse, Ellipse);
_OMNIUI_DEFINE_FREE_SHAPE(FreeLine, Line);
_OMNIUI_DEFINE_FREE_SHAPE(FreeRectangle, Rectangle);
_OMNIUI_DEFINE_FREE_SHAPE(FreeTriangle, Triangle);
#undef _OMNIUI_DEFINE_FREE_SHAPE
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 5,521 | C | 42.140625 | 120 | 0.560225 |
omniverse-code/kit/include/omni/ui/AbstractMultiField.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 "ItemModelHelper.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
class AbstractItemModel;
class AbstractValueModel;
class ValueModelHelper;
class Stack;
/**
* @brief AbstractMultiField is the abstract class that has everything to create a custom widget per model item.
*
* The class that wants to create multiple widgets per item needs to reimplement the method _createField.
*/
class OMNIUI_CLASS_API AbstractMultiField : public Widget, public ItemModelHelper
{
OMNIUI_OBJECT(AbstractMultiField)
public:
OMNIUI_API
~AbstractMultiField() 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 text.
*
* @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 text.
*
* @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. Called by the model when the model value 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 The max number of fields in a line.
*/
OMNIUI_PROPERTY(
uint8_t, columnCount, DEFAULT, 4, READ, getColumnCount, WRITE, setColumnCount, NOTIFY, setColumnCountChangedFn);
/**
* @brief Sets a non-stretchable horizontal space in pixels between child fields.
*/
OMNIUI_PROPERTY(float, hSpacing, DEFAULT, 0.0f, READ, getHSpacing, WRITE, setHSpacing, NOTIFY, setHSpacingChangedFn);
/**
* @brief Sets a non-stretchable vertical space in pixels between child fields.
*/
OMNIUI_PROPERTY(float, vSpacing, DEFAULT, 0.0f, READ, getVSpacing, WRITE, setVSpacing, NOTIFY, setVSpacingChangedFn);
protected:
/**
* Constructor.
*/
OMNIUI_API
AbstractMultiField(const std::shared_ptr<AbstractItemModel>& model = {});
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
/**
* @brief It's necessary to implement this method to create a custom widget per model item. It creates the widget
* with the model provided and returns it.
*/
OMNIUI_API
virtual std::shared_ptr<Widget> _createField(const std::shared_ptr<AbstractValueModel>& model){ return {}; }
/**
* @brief Called to assign the new model to the widget created with `_createField`
*/
OMNIUI_API
virtual void _setFieldModel(std::shared_ptr<Widget>& widget, const std::shared_ptr<AbstractValueModel>& model){}
protected:
// All the widgets to change the name
std::vector<std::shared_ptr<Widget>> m_children;
private:
/**
* @brief Called when the spacing property is changed. It propagates spacing to children.
*/
void _onSpacingChanged();
// The main layout. All the sub-widgets are children of the main layout.
std::shared_ptr<Stack> m_mainLayout;
// All the stacks. We need them to change spacing.
std::vector<std::shared_ptr<Stack>> m_stacks;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 4,228 | C | 32.299212 | 121 | 0.703406 |
omniverse-code/kit/include/omni/ui/MenuHelper.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 "Callback.h"
#include "Property.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
class Widget;
class Frame;
class MenuDelegate;
/**
* @brief The helper class for the menu that draws the menu line.
*/
class OMNIUI_CLASS_API MenuHelper : private CallbackHelper<MenuHelper>
{
public:
OMNIUI_API
virtual ~MenuHelper();
/**
* @brief Returns true if the item is in horizontal layout.
*/
bool isInHorizontalLayout() const;
/**
* @brief Sets the function that is called when an action is activated by the user; for example, when the user
* clicks a menu option, or presses an action's shortcut key combination.
*/
OMNIUI_CALLBACK(Triggered, void);
/**
* @brief This property holds the menu's text.
*/
OMNIUI_PROPERTY(std::string, text, READ, getText, WRITE, setText, PROTECTED, NOTIFY, _setTextChangedFn);
/**
* @brief This property holds the menu's hotkey text.
*/
OMNIUI_PROPERTY(
std::string, hotkeyText, READ, getHotkeyText, WRITE, setHotkeyText, PROTECTED, NOTIFY, _setHotkeyTextChangedFn);
/**
* @brief This property holds whether this menu item is checkable. A checkable item is one which has an on/off
* state.
*/
OMNIUI_PROPERTY(
bool, checkable, DEFAULT, false, READ, isCheckable, WRITE, setCheckable, PROTECTED, NOTIFY, _setCheckableChangedFn);
/**
* @brief The delegate that generates a widget per menu item.
*/
OMNIUI_PROPERTY(std::shared_ptr<MenuDelegate>,
delegate,
READ,
getDelegate,
WRITE,
setDelegate,
PROTECTED,
NOTIFY,
_setDelegateChangedFn);
/**
* @brief Hide or keep the window when the user clicked this item.
*/
OMNIUI_PROPERTY(bool, hideOnClick, DEFAULT, true, READ, isHideOnClick, WRITE, setHideOnClick);
OMNIUI_PROPERTY(bool,
compatibility,
DEFAULT,
true,
READ,
isMenuCompatibility,
WRITE,
setMenuCompatibility,
PROTECTED,
NOTIFY,
_setMenuCompatibilityChangedFn);
protected:
friend class MenuDelegate;
/**
* @brief Constructor
*/
OMNIUI_API
MenuHelper();
/**
* @brief Should be called by the widget in init time.
*/
void _menuHelperInit(Widget& widget);
/**
* @brief Should be called by the widget in destroy time.
*/
void _menuHelperDestroy();
/**
* @brief Eval and return width of the item.
*/
float _menuHelperEvalWidth(Widget& widget, float proposed);
/**
* @brief Eval and return height of the item.
*/
float _menuHelperEvalHeight(Widget& widget, float proposed);
/**
* @brief Should be called by the widget during draw.
*/
void _menuHelperDraw(Widget& widget, float elapsedTime);
/**
* @brief Should be called by the widget during change of the style.
*/
void _menuHelperCascadeStyle();
/**
* @brief Should be called to make the item dirty.
*/
void _menuHelperInvalidate();
/**
* @brief Iterate the parents and find the delegate.
*/
const std::shared_ptr<MenuDelegate>& _obtainDelegate(Widget& widget);
/**
* @brief Convert Widget to MenuHelper if possible.
*/
static MenuHelper* _getMenuHelper(Widget& widget);
private:
/**
* @brief Check if the item is dirty and call the delegate.
*/
void _verifyFrame(Widget& widget);
/**
* @brief Convert MenuHelper to Widget if possible.
*/
const Widget* _getWidget() const;
/**
* @brief List of siblings.
*/
std::vector<std::shared_ptr<Widget>> _getSiblings() const;
/**
* @brief Iterate the parents and find the delegate.
*/
const std::shared_ptr<MenuDelegate>& _obtainDelegateRecursive(Widget& widget, uint16_t depth = 0);
// All the widgets of the item
std::shared_ptr<Frame> m_frame;
// Dirty flag
bool m_dirty = true;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 4,711 | C | 26.555555 | 124 | 0.617066 |
omniverse-code/kit/include/omni/ui/Image.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 "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 Image : public Widget
{
OMNIUI_OBJECT(Image)
public:
enum class FillPolicy : uint8_t
{
eStretch = 0,
ePreserveAspectFit,
ePreserveAspectCrop
};
OMNIUI_API
~Image() override;
OMNIUI_API
void destroy() override;
/**
* @brief Reimplemented. Called when the style or the parent style is changed.
*/
OMNIUI_API
void onStyleUpdated() override;
/**
* @brief Returns true if the image has non empty sourceUrl obtained through the property or the style.
*/
OMNIUI_API
bool hasSourceUrl() const;
/**
* @brief This property holds the image URL. It can be an `omni:` path, a `file:` path, a direct path or the path
* relative to the application root directory.
*/
OMNIUI_PROPERTY(std::string, sourceUrl, READ, getSourceUrl, WRITE, setSourceUrl, NOTIFY, setSourceUrlChangedFn);
/**
* @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
/**
* @brief The progress of the image loading.
*
* TODO: For now we only have two states, 0.0 and 1.0
*/
OMNIUI_PROPERTY(
float, progress, DEFAULT, 0.0f, READ, getProgress, NOTIFY, setProgressChangedFn, PROTECTED, WRITE, _setProgress);
protected:
/**
* @brief Construct image with given url. If the url is empty, it gets the image URL from styling.
*/
OMNIUI_API
Image(const std::string& sourceUrl = {});
/**
* @brief the default constructor will need to get the image URL from styling
*/
// OMNIUI_API
// Image();
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
/**
* @brief Check if it's necessary to load new textures and load them for all the style states.
*/
void _loadSourceUrl();
/**
* @brief Load the given texture for the given style state. If the texture was loaded before, it just modifies the
* indexes without reloading.
*/
void _loadSourceUrl(const std::string sourceUrl, StyleContainer::State state);
// Returns true if the url from the style is changed since the image is loaded.
bool _hasStyleUrlChanged() const;
// This function triggers the progress of the image loading in the main thread in next frame.
void _deferredTriggerProgressDone();
// The mutex for the texture operations, because we load the texture in the background.
std::mutex m_textureMutex;
// Flag to check all the textures if it's necessary to reload them.
bool m_texturesLoaded = false;
struct TextureData;
// 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;
// Texture data for all the loaded textures
std::vector<std::unique_ptr<TextureData>> m_textureData;
class DeferredTriggerProgressDone;
std::unique_ptr<DeferredTriggerProgressDone> m_deferredTriggerProgressDone;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 6,293 | C | 36.023529 | 121 | 0.682504 |
omniverse-code/kit/include/omni/ui/ProgressBar.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
/**
* @brief A progressbar is a classic widget for showing the progress of an operation.
*/
class OMNIUI_CLASS_API ProgressBar : public Widget, public ValueModelHelper, public FontHelper
{
OMNIUI_OBJECT(ProgressBar)
public:
OMNIUI_API
~ProgressBar() 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.
*/
OMNIUI_API
void onModelUpdated() override;
protected:
/**
* @brief Construct ProgressBar
*
* @param model The model that determines if the button is checked.
*/
OMNIUI_API
ProgressBar(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:
void _drawUnderlyingItem();
// The cached state.
double m_valueCache = 0;
std::string m_overlayCache;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 2,016 | C | 26.256756 | 116 | 0.704365 |
omniverse-code/kit/include/omni/ui/DockSpace.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 "Property.h"
#include <carb/IObject.h>
#include <omni/ui/Frame.h>
#include <memory>
#include <string>
OMNIUI_NAMESPACE_OPEN_SCOPE
namespace windowmanager
{
struct WindowSet;
class IWindowCallback;
}
class MenuBar;
/**
* @brief The DockSpace class represents Dock Space for the OS Window
*
*/
class OMNIUI_CLASS_API DockSpace
{
public:
virtual ~DockSpace();
// We need it to make sure it's created as a shared pointer.
template <typename... Args>
static std::shared_ptr<DockSpace> 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 */
auto dockSpace = std::shared_ptr<DockSpace>{ new DockSpace{ std::forward<Args>(args)... } };
return dockSpace;
}
/**
* @brief This represents Styling opportunity for the Window background
*/
OMNIUI_PROPERTY(std::shared_ptr<Frame>, dockFrame, READ, getDockFrame, PROTECTED, WRITE, setDockFrame);
protected:
/**
* @brief Construct the main window, add it to the underlying windowing system, and makes it appear.
*/
OMNIUI_API
DockSpace(windowmanager::WindowSet* windowSet = nullptr);
/**
* @brief Execute the rendering code of the widget.
*
* It's in protected section because it can be executed only by this object itself.
*/
virtual void _draw(float elapsedTime);
private:
// the windowCallback
carb::ObjectPtr<windowmanager::IWindowCallback> m_windowCallback;
windowmanager::WindowSet* m_windowSet = nullptr;
std::string m_name;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 2,193 | C | 27.128205 | 107 | 0.699042 |
omniverse-code/kit/include/omni/ui/Grid.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 "Stack.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief Grid is a container that arranges its child views in a grid. The grid vertical/horizontal direction is the
* direction the grid size growing with creating more children.
*/
class OMNIUI_CLASS_API Grid : public Stack
{
OMNIUI_OBJECT(Grid)
public:
OMNIUI_API
~Grid() 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 The width of the column. It's only possible to set it if the grid is vertical. Once it's set, the column
* count depends on the size of the widget.
*/
OMNIUI_PROPERTY(float,
columnWidth,
DEFAULT,
0.0f,
READ,
getColumnWidth,
WRITE,
setColumnWidth,
PROTECTED,
NOTIFY,
_setColumnWidthChangedFn);
/**
* @brief The height of the row. It's only possible to set it if the grid is horizontal. Once it's set, the row
* count depends on the size of the widget.
*/
OMNIUI_PROPERTY(
float, rowHeight, DEFAULT, 0.0f, READ, getRowHeight, WRITE, setRowHeight, PROTECTED, NOTIFY, _setRowHeightChangedFn);
/**
* @brief The number of columns. It's only possible to set it if the grid is vertical. Once it's set, the column
* width depends on the widget size.
*/
OMNIUI_PROPERTY(uint32_t,
columnCount,
DEFAULT,
1,
READ,
getColumnCount,
WRITE,
setColumnCount,
PROTECTED,
NOTIFY,
_setColumnCountChangedFn);
/**
* @brief The number of rows. It's only possible to set it if the grid is horizontal. Once it's set, the row height
* depends on the widget size.
*/
OMNIUI_PROPERTY(
uint32_t, rowCount, DEFAULT, 1, READ, getRowCount, WRITE, setRowCount, PROTECTED, NOTIFY, _setRowCountChangedFn);
protected:
/**
* @brief Constructor.
*
* @param direction Determines the direction the widget grows when adding more children.
*
* @see Stack::Direction
*/
OMNIUI_API
Grid(Direction direction);
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
/**
* @brief The grid has two modes of working. When the current mode is eSizeFromCount, the grid computes the size of
* the cell using the number of columns/rows. When eCountFromSize, the size of the cells is always the same, but the
* number of columns varies depending on the grid's full size.
*/
enum class CellSizeMode : uint8_t
{
eSizeFromCount,
eCountFromSize
};
CellSizeMode m_cellSizeMode = CellSizeMode::eSizeFromCount;
// Flag to determine if the property set by user or by this class.
bool m_internalPropertyChange = false;
// True to determine that height (for V) or width (for H) was set explicitly.
bool m_isLineSizeSet = false;
// List of line offsets. It's empty if height (for V) or width (for H) was set explicitly.
std::vector<float> m_lineOffset;
// Currently visible lines.
size_t m_lineLower = 0;
// Max for the first frame and then it will be corrected.
size_t m_lineUpper = SIZE_MAX;
size_t m_prevColumnCount = 0;
size_t m_prevRowCount = 0;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 4,554 | C | 31.535714 | 125 | 0.631533 |
omniverse-code/kit/include/omni/ui/ScrollingFrame.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 "Frame.h"
#include "ScrollBarPolicy.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The ScrollingFrame class provides the ability to scroll onto another widget.
*
* 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().
*/
class OMNIUI_CLASS_API ScrollingFrame : public Frame
{
OMNIUI_OBJECT(ScrollingFrame)
public:
OMNIUI_API
~ScrollingFrame() 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 The horizontal position of the scroll bar. When it's changed, the contents will be scrolled accordingly.
*/
OMNIUI_PROPERTY(float, scrollX, DEFAULT, 0.0f, READ, getScrollX, WRITE, setScrollX, NOTIFY, setScrollXChangedFn);
/**
* @brief The vertical position of the scroll bar. When it's changed, the contents will be scrolled accordingly.
*/
OMNIUI_PROPERTY(float, scrollY, DEFAULT, 0.0f, READ, getScrollY, WRITE, setScrollY, NOTIFY, setScrollYChangedFn);
/**
* @brief The max position of the horizontal scroll bar.
*/
OMNIUI_PROPERTY(float, scrollXMax, DEFAULT, 0.0f, READ, getScrollXMax, PROTECTED, WRITE, setScrollXMax);
/**
* @brief The max position of the vertical scroll bar.
*/
OMNIUI_PROPERTY(float, scrollYMax, DEFAULT, 0.0f, READ, getScrollYMax, PROTECTED, WRITE, setScrollYMax);
/**
* @brief This property holds the policy for the horizontal scroll bar.
*/
OMNIUI_PROPERTY(ScrollBarPolicy,
horizontalScrollBarPolicy,
DEFAULT,
ScrollBarPolicy::eScrollBarAsNeeded,
READ,
getHorizontalScrollBarPolicy,
WRITE,
setHorizontalScrollBarPolicy);
/**
* @brief This property holds the policy for the vertical scroll bar.
*/
OMNIUI_PROPERTY(ScrollBarPolicy,
verticalScrollBarPolicy,
DEFAULT,
ScrollBarPolicy::eScrollBarAsNeeded,
READ,
getVerticalScrollBarPolicy,
WRITE,
setVerticalScrollBarPolicy);
protected:
/**
* @brief Construct ScrollingFrame
*/
OMNIUI_API
ScrollingFrame();
/**
* @brief Reimplemented the rendering code of the widget.
*
* Draw the content in the scrolling frame.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
void _scrollXExplicitlyChanged();
void _scrollYExplicitlyChanged();
// Flags for synchronization of the scrollX and scrollY properties and the underlying windowing system.
bool m_scrollXExplicitlyChanged = false;
bool m_scrollYExplicitlyChanged = false;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 4,114 | C | 33.291666 | 118 | 0.675984 |
omniverse-code/kit/include/omni/ui/SimpleNumericModel.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 "AbstractValueModel.h"
#include "Property.h"
#include <memory>
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief A very simple value model that holds a single number. It's still an abstract class. It's necessary to
* reimplement `setValue(std::string value)` because each numeric type can be represented with different string.
*/
template <typename T>
class OMNIUI_CLASS_API SimpleNumericModel : public AbstractValueModel
{
public:
using Base = SimpleNumericModel<T>;
using CarriedType = T;
/**
* @brief This property holds the model's minimum value.
*/
OMNIUI_PROPERTY(T, min, DEFAULT, T(1), READ_VALUE, getMin, WRITE, setMin);
/**
* @brief This property holds the model's maximum value.
*/
OMNIUI_PROPERTY(T, max, DEFAULT, T(0), READ_VALUE, getMax, WRITE, setMax);
/**
* @brief Get the value as bool.
*/
bool getValueAsBool() const override
{
return m_value != static_cast<T>(0);
}
/**
* @brief Get the value as double.
*/
double getValueAsFloat() const override
{
return static_cast<double>(m_value);
}
/**
* @brief Get the value as int64_t.
*/
int64_t getValueAsInt() const override
{
return static_cast<int64_t>(m_value);
}
/**
* @brief Get the value as string.
*/
std::string getValueAsString() const override
{
return std::to_string(m_value);
}
/**
* @brief Set the bool value. It will convert bool to the model's typle.
*/
void setValue(bool value) override
{
this->_setNumericValue(static_cast<T>(value));
}
/**
* @brief Set the double value. It will convert double to the model's typle.
*/
void setValue(double value) override
{
this->_setNumericValue(static_cast<T>(value));
}
/**
* @brief Set the int64_t value. It will convert int64_t to the model's typle.
*/
void setValue(int64_t value) override
{
this->_setNumericValue(static_cast<T>(value));
}
protected:
SimpleNumericModel(T defaultValue = static_cast<T>(0)) : m_value{ defaultValue }
{
}
/**
* @brief Template to set the value of native type.
*/
void _setNumericValue(T value)
{
// Clamp
if (this->getMin() <= this->getMax())
{
value = std::min(this->getMax(), std::max(this->getMin(), value));
}
if (m_value != value)
{
m_value = value;
this->_valueChanged();
}
}
private:
T m_value;
};
#define SIMPLENUMERICMODEL_CREATOR(THIS) \
public: \
using This = THIS; \
template <typename... Args> \
static std::shared_ptr<This> create(Args&&... args) \
{ \
return std::shared_ptr<This>{ new This{ std::forward<Args>(args)... } }; \
} \
\
protected: \
THIS(CarriedType devaultValue = {}) : SimpleNumericModel<CarriedType>{ devaultValue } \
{ \
}
/**
* @brief A very simple bool model.
*/
class OMNIUI_CLASS_API SimpleBoolModel : public SimpleNumericModel<bool>
{
SIMPLENUMERICMODEL_CREATOR(SimpleBoolModel)
public:
OMNIUI_API
std::string getValueAsString() const override;
// Reimplemented because it's a special case for string.
OMNIUI_API
void setValue(std::string value) override;
};
/**
* @brief A very simple double model.
*/
class OMNIUI_CLASS_API SimpleFloatModel : public SimpleNumericModel<double>
{
SIMPLENUMERICMODEL_CREATOR(SimpleFloatModel)
public:
// Reimplemented because it's a special case for string.
OMNIUI_API
void setValue(std::string value) override;
};
/**
* @brief A very simple Int model.
*/
class OMNIUI_CLASS_API SimpleIntModel : public SimpleNumericModel<int64_t>
{
SIMPLENUMERICMODEL_CREATOR(SimpleIntModel)
public:
// Reimplemented because it's a special case for string.
OMNIUI_API
void setValue(std::string value) override;
};
#undef SIMPLENUMERICMODEL_CREATOR
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 5,552 | C | 29.679558 | 120 | 0.519993 |
omniverse-code/kit/include/omni/ui/AbstractItemDelegate.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"
OMNIUI_NAMESPACE_OPEN_SCOPE
class AbstractItemModel;
/**
* @brief AbstractItemDelegate is used to generate widgets that display and edit data items from a model.
*/
class OMNIUI_CLASS_API AbstractItemDelegate
{
public:
OMNIUI_API
virtual ~AbstractItemDelegate();
/**
* @brief This pure abstract method must be reimplemented to generate custom collapse/expand button.
*/
OMNIUI_API
virtual void buildBranch(const std::shared_ptr<AbstractItemModel>& model,
const std::shared_ptr<const AbstractItemModel::AbstractItem>& item = nullptr,
size_t index = 0,
uint32_t level = 0,
bool expanded = false);
/**
* @brief This pure abstract method must be reimplemented to generate custom widgets for specific item in the model.
*/
virtual void buildWidget(const std::shared_ptr<AbstractItemModel>& model,
const std::shared_ptr<const AbstractItemModel::AbstractItem>& item = nullptr,
size_t index = 0,
uint32_t level = 0,
bool expanded = false) = 0;
/**
* @brief This pure abstract method must be reimplemented to generate custom widgets for the header table.
*/
OMNIUI_API
virtual void buildHeader(size_t index = 0);
protected:
/**
* @brief Constructs AbstractItemDelegate
*/
OMNIUI_API
AbstractItemDelegate();
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 2,048 | C | 33.149999 | 120 | 0.652832 |
omniverse-code/kit/include/omni/ui/AbstractValueModel.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 <functional>
#include <string>
#include <unordered_set>
#include <vector>
OMNIUI_NAMESPACE_OPEN_SCOPE
class ValueModelHelper;
class OMNIUI_CLASS_API AbstractValueModel
{
public:
OMNIUI_API
virtual ~AbstractValueModel();
// We assume that all the operations with the model should be performed with smart pointers because it will register
// subscription. If the object is copied or moved, it will break the subscription.
// No copy
AbstractValueModel(const AbstractValueModel&) = delete;
// No copy-assignment
AbstractValueModel& operator=(const AbstractValueModel&) = 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 Return the bool representation of the value.
*/
virtual bool getValueAsBool() const = 0;
/**
* @brief Return the float representation of the value.
*/
virtual double getValueAsFloat() const = 0;
/**
* @brief Return the int representation of the value.
*/
virtual int64_t getValueAsInt() const = 0;
/**
* @brief Return the string representation of the value.
*/
virtual std::string getValueAsString() const = 0;
/**
* @brief A helper that calls the correct getValueXXX method.
*/
template <class T>
OMNIUI_API T getValue() const;
/**
* @brief 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. This method should be reimplemented.
*/
OMNIUI_API
virtual void beginEdit();
/**
* @brief 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. This method should be reimplemented.
*/
OMNIUI_API
virtual void endEdit();
/**
* @brief Set the value.
*/
virtual void setValue(bool value) = 0;
virtual void setValue(double value) = 0;
virtual void setValue(int64_t value) = 0;
virtual void setValue(std::string value) = 0;
/**
* @brief Subscribe the ValueModelHelper widget to the changes of the model.
*
* 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.
*/
OMNIUI_API
void subscribe(ValueModelHelper* widget);
/**
* @brief Unsubscribe the ValueModelHelper widget from the changes of the model.
*/
OMNIUI_API
void unsubscribe(ValueModelHelper* widget);
/**
* @brief Adds the function that will be called every time the value changes.
*
* @return The id of the callback that is used to remove the callback.
*/
OMNIUI_API
uint32_t addValueChangedFn(std::function<void(const AbstractValueModel*)> fn);
/**
* @brief Remove the callback by its id.
*
* @param id The id that addValueChangedFn returns.
*/
OMNIUI_API
void removeValueChangedFn(uint32_t id);
/**
* @brief Adds the function that will be called every time the user starts the editing.
*
* @return The id of the callback that is used to remove the callback.
*/
OMNIUI_API
uint32_t addBeginEditFn(std::function<void(const AbstractValueModel*)> fn);
/**
* @brief Remove the callback by its id.
*
* @param id The id that addBeginEditFn returns.
*/
OMNIUI_API
void removeBeginEditFn(uint32_t id);
/**
* @brief Adds the function that will be called every time the user finishes the editing.
*
* @return The id of the callback that is used to remove the callback.
*/
OMNIUI_API
uint32_t addEndEditFn(std::function<void(const AbstractValueModel*)> fn);
/**
* @brief Remove the callback by its id.
*
* @param id The id that addEndEditFn returns.
*/
OMNIUI_API
void removeEndEditFn(uint32_t id);
/**
* @brief Called by the widget when the user starts editing. It calls beginEdit and the callbacks.
*/
OMNIUI_API
void processBeginEditCallbacks();
/**
* @brief Called by the widget when the user finishes editing. It calls endEdit and the callbacks.
*/
OMNIUI_API
void processEndEditCallbacks();
protected:
friend class AbstractMultiField;
/**
* @brief Constructs AbstractValueModel
*/
OMNIUI_API
AbstractValueModel();
/**
* @brief Called when any data of the model is changed. It will notify the subscribed widgets.
*/
OMNIUI_API
void _valueChanged();
// All the widgets who use this model. See description of subscribe for the information why it's regular pointers.
// TODO: we can use m_callbacks for subscribe-unsubscribe. But in this way it's nesessary to keep widget-id map.
// When the _valueChanged code will be more complicated, we need to do it. Now it's simple enought and m_widgets
// stays here.
std::unordered_set<ValueModelHelper*> m_widgets;
// Callbacks that called when the value is changed.
std::vector<std::function<void(const AbstractValueModel*)>> m_valueChangedCallbacks;
// Callbacks that called when the user starts the editing.
std::vector<std::function<void(const AbstractValueModel*)>> m_beginEditCallbacks;
// Callbacks that called when the user finishes the editing.
std::vector<std::function<void(const AbstractValueModel*)>> m_endEditCallbacks;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 6,172 | C | 31.489474 | 120 | 0.683895 |
omniverse-code/kit/include/omni/ui/InvisibleButton.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"
#include <functional>
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief The InvisibleButton widget provides a transparent command button.
*/
class OMNIUI_CLASS_API InvisibleButton : public Widget
{
OMNIUI_OBJECT(InvisibleButton)
public:
OMNIUI_API
~InvisibleButton() override;
/**
* @brief Sets the function that will be called when when the button is activated (i.e., pressed down then released
* while the mouse cursor is inside the button).
*/
OMNIUI_CALLBACK(Clicked, void);
protected:
/**
* Constructor.
*/
OMNIUI_API
InvisibleButton();
/**
* @brief Reimplemented the rendering code of the widget.
*
* @see Widget::_drawContent
*/
OMNIUI_API
void _drawContent(float elapsedTime) override;
private:
/**
* @brief Called then the user clicks this button.
*/
OMNIUI_API
virtual void _clicked();
std::function<void()> m_clickedFn;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 1,454 | C | 23.25 | 119 | 0.69945 |
omniverse-code/kit/include/omni/ui/MenuDelegate.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 "Callback.h"
#include "Property.h"
#include <memory>
#include <functional>
OMNIUI_NAMESPACE_OPEN_SCOPE
class MenuHelper;
/**
* @brief MenuDelegate is used to generate widgets that represent the menu item.
*/
class OMNIUI_CLASS_API MenuDelegate : CallbackHelper<MenuDelegate>
{
public:
/**
* @brief Constructor
*/
OMNIUI_API
MenuDelegate();
OMNIUI_API
virtual ~MenuDelegate();
/**
* @brief This method must be reimplemented to generate custom item.
*/
OMNIUI_API
virtual void buildItem(const MenuHelper* item);
/**
* @brief This method must be reimplemented to generate custom title.
*/
OMNIUI_API
virtual void buildTitle(const MenuHelper* item);
/**
* @brief This method must be reimplemented to generate custom widgets on
* the bottom of the window.
*/
OMNIUI_API
virtual void buildStatus(const MenuHelper* item);
/**
* @brief Get the default delegate that is used when the menu doesn't have
* anything.
*/
OMNIUI_API
static const std::shared_ptr<MenuDelegate>& getDefaultDelegate();
/**
* @brief Set the default delegate to use it when the item doesn't have a
* delegate.
*/
OMNIUI_API
static void setDefaultDelegate(std::shared_ptr<MenuDelegate> delegate);
/**
* @brief Called to create a new item
*/
OMNIUI_CALLBACK(OnBuildItem, void, MenuHelper const*);
/**
* @brief Called to create a new title
*/
OMNIUI_CALLBACK(OnBuildTitle, void, MenuHelper const*);
/**
* @brief Called to create a new widget on the bottom of the window
*/
OMNIUI_CALLBACK(OnBuildStatus, void, MenuHelper const*);
/**
* @brief Determine if Menu children should use this delegate when they
* don't have the own one.
*/
OMNIUI_PROPERTY(bool, propagate, DEFAULT, true, READ_VALUE, isPropagate, WRITE, setPropagate);
private:
/**
* @brief Return true if at least one of the siblings have the hotkey text.
*/
static bool _siblingsHaveHotkeyText(const MenuHelper* item);
/**
* @brief Return true if at least one of the siblings is checkable.
*/
static bool _siblingsHaveCheckable(const MenuHelper* item);
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 2,774 | C | 25.682692 | 98 | 0.680966 |
omniverse-code/kit/include/omni/ui/BezierCurve.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 "ArrowHelper.h"
#include "Shape.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief Smooth curve that can be scaled infinitely.
*/
class OMNIUI_CLASS_API BezierCurve : public Shape, public ArrowHelper
{
OMNIUI_OBJECT(BezierCurve)
public:
OMNIUI_API
~BezierCurve() override;
/**
* @brief Sets the function that will be called when the user use mouse enter/leave on the line. It's the override
* to prevent Widget from the bounding box logic.
* The function specification is:
* void onMouseHovered(bool hovered)
*/
OMNIUI_API
void setMouseHoveredFn(std::function<void(bool)> fn) override;
/**
* @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)
*
* It's the override to prevent the bounding box logic.
*
* Where:
* button is the number of the mouse button pressed
* modifier is the flag for the keyboard modifier key
*/
OMNIUI_API
void setMousePressedFn(std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> fn) override;
/**
* @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_API
void setMouseReleasedFn(std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> fn) override;
/**
* @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_API
void setMouseDoubleClickedFn(std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> fn) override;
/**
* @brief This property holds the X coordinate of the start of the curve relative to the width bound of the curve.
*/
OMNIUI_PROPERTY(
Length, startTangentWidth, DEFAULT, Fraction{ 1.0f }, READ, getStartTangentWidth, WRITE, setStartTangentWidth);
/**
* @brief This property holds the Y coordinate of the start of the curve relative to the width bound of the curve.
*/
OMNIUI_PROPERTY(
Length, startTangentHeight, DEFAULT, Pixel{ 0.0f }, READ, getStartTangentHeight, WRITE, setStartTangentHeight);
/**
* @brief This property holds the X coordinate of the end of the curve relative to the width bound of the curve.
*/
OMNIUI_PROPERTY(Length, endTangentWidth, DEFAULT, Fraction{ -1.0f }, READ, getEndTangentWidth, WRITE, setEndTangentWidth);
/**
* @brief This property holds the Y coordinate of the end of the curve relative to the width bound of the curve.
*/
OMNIUI_PROPERTY(Length, endTangentHeight, DEFAULT, Pixel{ 0.0f }, READ, getEndTangentHeight, WRITE, setEndTangentHeight);
protected:
/**
* @brief Initialize the the curve.
*/
OMNIUI_API
BezierCurve();
/**
* @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:
/**
* @brief Return width/height of two tangents.
*/
void _evaluateTangents(
float width, float height, float& startWidth, float& startHeight, float& endWidth, float& endHeight) const;
// void _calculteNormalPoints(
// const ImVec2& p1, const ImVec2& p2, float dist, int id, int size, std::vector<ImVec2>& points);
// Don't use m_mouseHoveredFn and m_isHovered to prevent the bbox logic of Widget.
std::function<void(bool)> m_mouseHoveredLineFn;
bool m_isHoveredLine = false;
// Don't use m_mousePressedFn to prevent the bbox logic of Widget.
std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> m_mousePressedLineFn;
std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> m_mouseReleasedLineFn;
std::function<void(float, float, int32_t, carb::input::KeyboardModifierFlags)> m_mouseDoubleClickedLineFn;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 5,325 | C | 37.042857 | 126 | 0.695399 |
omniverse-code/kit/include/omni/ui/ToolButton.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 "Button.h"
#include "ValueModelHelper.h"
OMNIUI_NAMESPACE_OPEN_SCOPE
/**
* @brief ToolButton is functionally similar to Button, but provides a model that determines if the button is checked.
* This button toggles between checked (on) and unchecked (off) when the user clicks it.
*/
class OMNIUI_CLASS_API ToolButton : public Button, public ValueModelHelper
{
OMNIUI_OBJECT(ToolButton)
public:
OMNIUI_API
~ToolButton() override;
/**
* @brief Reimplemented from ValueModelHelper. It's called when the model is changed.
*/
OMNIUI_API
void onModelUpdated() override;
protected:
/**
* @brief Construct a checkable button with the model. If the bodel is not provided, then the default model is
* created.
*
* @param model The model that determines if the button is checked.
*/
OMNIUI_API
ToolButton(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 Reimplemented from InvisibleButton. Called then the user clicks this button. We don't use `m_clickedFn`
* because the user can set it. If we are using it in our internal code and the user overrides it, the behavior of
* the button will be changed.
*/
OMNIUI_API
void _clicked() override;
// Flag to call onModelUpdated
bool m_modelUpdated = false;
};
OMNIUI_NAMESPACE_CLOSE_SCOPE
| 2,020 | C | 29.621212 | 118 | 0.710396 |
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
| 6,783 | C | 27.384937 | 124 | 0.674333 |
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
| 31,395 | C | 36.067296 | 135 | 0.663959 |
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
| 1,646 | C | 27.894736 | 112 | 0.735723 |
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
| 3,676 | C | 26.646616 | 120 | 0.678455 |
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
| 2,565 | C | 28.494253 | 125 | 0.654971 |
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
| 3,828 | C | 29.149606 | 120 | 0.651515 |
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
| 2,195 | C | 26.111111 | 117 | 0.702961 |
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
| 6,542 | C | 33.989305 | 118 | 0.692296 |
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
| 4,122 | C | 31.210937 | 119 | 0.698205 |
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
| 1,371 | C | 18.6 | 77 | 0.725748 |
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
| 2,993 | C | 26.722222 | 107 | 0.701303 |
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
| 2,144 | C | 27.223684 | 120 | 0.698228 |
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
| 935 | C | 23.631578 | 101 | 0.729412 |
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, )
| 6,172 | C | 96.984125 | 120 | 0.299903 |
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
| 1,771 | C | 29.033898 | 117 | 0.726143 |
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
| 999 | C | 24.641025 | 120 | 0.734735 |
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
| 3,211 | C | 32.113402 | 120 | 0.710682 |
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
| 1,606 | C | 24.919354 | 117 | 0.708593 |
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
| 1,709 | C | 29.535714 | 100 | 0.702165 |
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
| 2,881 | C | 31.382022 | 119 | 0.694898 |
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
| 3,362 | C | 34.03125 | 120 | 0.701666 |
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
| 1,800 | C | 25.485294 | 114 | 0.7 |
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
| 1,801 | C | 25.115942 | 117 | 0.686841 |
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
| 5,988 | C | 35.742331 | 120 | 0.685371 |
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
| 1,730 | C | 42.274999 | 120 | 0.726012 |
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
| 7,954 | C | 35.159091 | 121 | 0.647222 |
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;
}
}
}
}
| 3,377 | C | 35.717391 | 117 | 0.577436 |
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)
/**/;
}
}
}
}
| 5,566 | C | 41.496183 | 120 | 0.68074 |
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();
}
}
| 6,507 | C | 31.378109 | 142 | 0.598125 |
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;
};
}
}
| 3,403 | C | 32.048543 | 108 | 0.604761 |
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;
};
}
}
| 1,113 | C | 24.906976 | 90 | 0.760108 |
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;
};
}
}
| 1,938 | C | 26.309859 | 118 | 0.705366 |
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) };
}
}
}
| 4,939 | C | 25.276596 | 145 | 0.668759 |
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();
};
}
}
| 2,887 | C | 27.038835 | 118 | 0.699342 |
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"
| 6,645 | C | 87.613332 | 265 | 0.324454 |
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"
| 1,610 | C | 46.382352 | 133 | 0.675155 |
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"
| 14,195 | C | 87.724999 | 454 | 0.362663 |
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
| 2,919 | C | 65.363635 | 120 | 0.412813 |
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"
| 4,688 | C | 71.13846 | 747 | 0.539889 |
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"
| 1,721 | C | 70.749997 | 120 | 0.396862 |
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"
| 932 | C | 53.88235 | 125 | 0.641631 |
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
| 897 | C | 41.761903 | 120 | 0.638796 |
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"
| 1,926 | C | 42.795454 | 123 | 0.658359 |
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
| 2,388 | C | 71.393937 | 120 | 0.36809 |
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
| 2,740 | C | 75.138887 | 120 | 0.364599 |
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"
| 3,170 | C | 62.419999 | 176 | 0.523344 |
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"
| 2,759 | C | 57.723403 | 278 | 0.657847 |
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
| 2,754 | C | 71.499998 | 120 | 0.378722 |
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"
| 1,548 | C | 52.413791 | 134 | 0.613695 |
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"
| 824 | C | 47.529409 | 120 | 0.680825 |
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"
| 3,509 | C | 70.632652 | 333 | 0.504987 |
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"
| 2,230 | C | 46.468084 | 127 | 0.632287 |
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"
| 1,326 | C | 48.148146 | 152 | 0.671946 |
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"
| 1,928 | C | 67.892855 | 153 | 0.388485 |
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"
| 4,514 | C | 44.60606 | 170 | 0.638901 |
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"
| 3,915 | C | 77.319998 | 266 | 0.426054 |
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
| 1,025 | C | 40.039998 | 120 | 0.755122 |
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"
| 2,299 | C | 98.999996 | 636 | 0.588082 |
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"
| 11,851 | C | 73.54088 | 158 | 0.28428 |
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
| 25,117 | C | 70.561253 | 121 | 0.315006 |
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"
| 3,695 | C | 63.842104 | 215 | 0.498512 |
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"
| 4,682 | C | 72.171874 | 310 | 0.48334 |
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"
| 2,793 | C | 59.739129 | 363 | 0.546724 |
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"
| 1,773 | C | 62.357141 | 120 | 0.343486 |
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
| 1,992 | C | 55.942856 | 120 | 0.421185 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.