HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
objectHints.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 
8 #ifndef PXR_USD_USDUI_OBJECT_HINTS_H
9 #define PXR_USD_USDUI_OBJECT_HINTS_H
10 
11 /// \file usdUI/objectHints.h
12 
13 #include "pxr/usd/usd/object.h"
14 #include "pxr/usd/usdUI/api.h"
15 
16 #include "pxr/base/tf/envSetting.h"
18 
19 #include <string>
20 
22 
25 
26 /// \hideinitializer
27 #define USDUI_HINT_KEYS \
28  ((UIHints, "uiHints")) \
29  ((DisplayName, "displayName")) \
30  ((DisplayGroup, "displayGroup")) \
31  ((Hidden, "hidden")) \
32  ((ShownIf, "shownIf")) \
33  ((ValueLabels, "valueLabels")) \
34  ((ValueLabelsOrder, "valueLabelsOrder")) \
35  ((DisplayGroupsExpanded, "displayGroupsExpanded")) \
36  ((DisplayGroupsShownIf, "displayGroupsShownIf")) \
37 
38 /// \anchor UsdUIHintKeys
39 /// <b>UsdUIHintKeys</b> provides tokens for the various entries in the
40 /// \c uiHints dictionary metadata field. Named API corresponding to these
41 /// entries is provided by the hint access classes UsdUIObjectHints,
42 /// UsdUIPrimHints, UsdUIPropertyHints, and UsdUIAttributeHints. See
43 /// documentation there for field descriptions.
45  UsdUIHintKeys, USDUI_API, USDUI_HINT_KEYS);
46 
47 /// \class UsdUIObjectHints
48 ///
49 /// A "schema-like" wrapper that provides API for retrieving and authoring UI
50 /// hint values within the \c uiHints dictionary field on a UsdObject instance.
51 ///
52 /// UsdUIObjectHints is "schema-like" in that it interprets fields belonging to
53 /// a core object type (in this case UsdObject, but see also UsdUIPrimHints,
54 /// UsdUIPropertyHints, and UsdUIAttributeHints), and provides convenient API
55 /// for using those fields. However, it is not formally a schema and does not
56 /// derive from UsdSchemaBase.
57 ///
58 /// See \ref usdUI_hintsOverview for an overview of UI hints.
60 {
61 public:
62  /// Default constructor that creates an invalid hints object.
63  ///
64  /// Calling "set" operations on this object will post errors. "Get"
65  /// operations will return fallback values.
66  USDUI_API
68 
69  /// Construct a hints object for the given UsdObject \p obj.
70  USDUI_API
71  explicit UsdUIObjectHints(const UsdObject& obj);
72 
73  /// Return the object that this hints intance is interpreting.
74  UsdObject GetObject() const { return _obj; }
75 
76  /// Return the object's display name, indicating how it should appear in
77  /// the UI.
78  ///
79  /// Backwards compatibility note: If no display name is stored in the
80  /// object's \c uiHints dictionary, the value of UsdObject::GetDisplayName
81  /// (which has been deprecated) will be returned. This fallback behavior is
82  /// temporary, and will be removed in a future release.
83  USDUI_API
84  std::string GetDisplayName() const;
85 
86  /// Set the object's display name to \p name. Return \c true if successful.
87  ///
88  /// Backwards compatibility note: this function always writes to the
89  /// \c uiHints dictionary. It does not call UsdObject::SetDisplayName, which
90  /// has been deprecated.
91  USDUI_API
92  bool SetDisplayName(const std::string& name);
93 
94  /// Return the object's hidden status, indicating whether or not it should
95  /// be hidden from the UI.
96  ///
97  /// Backwards compatibility note: If no hidden status is stored in the
98  /// object's \c uiHints dictionary, the value of UsdObject::GetHidden
99  /// (which has been deprecated) will be returned. This fallback behavior
100  /// is temporary, and will be removed in a future release.
101  USDUI_API
102  bool GetHidden() const;
103 
104  /// Set the object's hidden status to \p hidden. Return \c true if
105  /// successful.
106  ///
107  /// Backwards compatibility note: this function always writes to the
108  /// \c uiHints dictionary. It does not call UsdObject::SetHidden, which
109  /// has been deprecated.
110  USDUI_API
111  bool SetHidden(bool hidden);
112 
113  /// Return \c true if this hints object is valid.
114  explicit operator bool() const {
115  return bool(_obj);
116  }
117 
118  /// Equality operator.
119  bool operator==(const UsdUIObjectHints& rhs) const {
120  return _obj == rhs._obj;
121  }
122 
123  /// Inequality operator.
124  bool operator!=(const UsdUIObjectHints& rhs) const {
125  return !(*this == rhs);
126  }
127 
128 protected:
129  /// Combine \p key1 and \p key2 into a single token, separated by the
130  /// namespace delimiter ':'.
131  USDUI_API
132  static TfToken _MakeKeyPath(
133  const TfToken& key1,
134  const TfToken& key2);
135 
136 private:
137  UsdObject _obj;
138 };
139 
141 
142 #endif
USDUI_API bool SetDisplayName(const std::string &name)
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
bool operator!=(const UsdUIObjectHints &rhs) const
Inequality operator.
Definition: objectHints.h:124
PXR_NAMESPACE_OPEN_SCOPE USDUI_API TfEnvSetting< bool > USDUI_WRITE_LEGACY_UI_HINTS
TF_DECLARE_PUBLIC_TOKENS(UsdUIHintKeys, USDUI_API, USDUI_HINT_KEYS)
#define USDUI_HINT_KEYS
Definition: objectHints.h:27
OutGridT const XformOp bool bool
Definition: token.h:70
USDUI_API bool SetHidden(bool hidden)
USDUI_API UsdUIObjectHints()
USDUI_API std::string GetDisplayName() const
GLuint const GLchar * name
Definition: glcorearb.h:786
static USDUI_API TfToken _MakeKeyPath(const TfToken &key1, const TfToken &key2)
UsdObject GetObject() const
Return the object that this hints intance is interpreting.
Definition: objectHints.h:74
#define USDUI_API
Definition: api.h:23
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
bool operator==(const UsdUIObjectHints &rhs) const
Equality operator.
Definition: objectHints.h:119
USDUI_API bool GetHidden() const