HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
primHints.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_PRIM_HINTS_H
9 #define PXR_USD_USDUI_PRIM_HINTS_H
10 
11 /// \file usdUI/primHints.h
12 
14 #include "pxr/usd/usd/prim.h"
15 
16 #include "pxr/base/vt/dictionary.h"
17 
19 
20 /// \class UsdUIPrimHints
21 ///
22 /// A "schema-like" wrapper that provides API for retrieving and authoring UI
23 /// hint values within the \c uiHints dictionary metadata field on a UsdPrim
24 /// instance.
25 ///
26 /// UsdUIPrimHints is "schema-like" in that it interprets fields belonging to
27 /// a core object type (in this case UsdPrim, but see also UsdUIObjectHints,
28 /// UsdUIPropertyHints, and UsdUIAttributeHints), and provides convenient API
29 /// for using those fields. However, it is not formally a schema and does not
30 /// derive from UsdSchemaBase.
31 ///
32 /// See \ref usdUI_hintsOverview for an overview of UI hints.
34 {
35 public:
36  /// Default constructor that creates an invalid hints object.
37  ///
38  /// Calling "set" operations on this object will post errors. "Get"
39  /// operations will return fallback values.
40  USDUI_API
42 
43  /// Construct a hints object for the given \p prim.
44  USDUI_API
45  explicit UsdUIPrimHints(const UsdPrim& prim);
46 
47  /// Return the prim that this hints instance is interpreting.
48  UsdPrim GetPrim() const { return _prim; }
49 
50  /// Return the prim's display group expansion dictionary.
51  ///
52  /// This dictionary is keyed by group name and holds boolean values
53  /// indicating whether groups should be expanded or collapsed by default.
54  USDUI_API
56 
57  /// Set the prim's display group expansion dictionary. Return \c true if
58  /// successful.
59  ///
60  /// Note that since this field is dictionary-valued, its composed value will
61  /// be the combination of all its entries as specified across all relevant
62  /// edit targets. Overrides occur per-entry rather than the dictionary as a
63  /// whole.
64  USDUI_API
65  bool SetDisplayGroupsExpanded(const VtDictionary& expanded);
66 
67  /// Return whether the display group named by \p group should be expanded
68  /// by default.
69  USDUI_API
70  bool GetDisplayGroupExpanded(const std::string& group) const;
71 
72  /// Set whether the display group named by \p group should be expanded
73  /// by default. Return \c true if successful.
74  USDUI_API
76  const std::string& group,
77  bool expanded);
78 
79  /// Return the prim's display group "shown if" dictionary.
80  ///
81  /// This dictionary is keyed by group name and holds expression strings
82  /// that, when evaluated, determine whether the corresponding groups should
83  /// be shown or hidden in the UI.
84  ///
85  /// \sa UsdUIPropertyHints::GetShownIf()
86  USDUI_API
88 
89  /// Set the prim's display group "shown if" dictionary to \p shownIf. Return
90  /// \c true if successful.
91  ///
92  /// Note that since this field is dictionary-valued, its composed value will
93  /// be the combination of all its entries as specified across all relevant
94  /// edit targets. Overrides occur per-entry rather than the dictionary as a
95  /// whole.
96  ///
97  /// \sa UsdUIPropertyHints::SetShownIf()
98  USDUI_API
99  bool SetDisplayGroupsShownIf(const VtDictionary& shownIf);
100 
101  /// Return the "shown if" expression string for the named \p group.
102  USDUI_API
103  std::string GetDisplayGroupShownIf(const std::string& group) const;
104 
105  /// Set the "shown if" expression string for the named \p group to
106  /// \p shownIf. Return \c true if successful.
107  USDUI_API
109  const std::string& group,
110  const std::string& shownIf);
111 
112 private:
113  UsdPrim _prim;
114 };
115 
117 
118 #endif
USDUI_API VtDictionary GetDisplayGroupsExpanded() const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
USDUI_API bool GetDisplayGroupExpanded(const std::string &group) const
USDUI_API std::string GetDisplayGroupShownIf(const std::string &group) const
Return the "shown if" expression string for the named group.
USDUI_API bool SetDisplayGroupShownIf(const std::string &group, const std::string &shownIf)
USDUI_API VtDictionary GetDisplayGroupsShownIf() const
Definition: prim.h:116
USDUI_API bool SetDisplayGroupsShownIf(const VtDictionary &shownIf)
USDUI_API bool SetDisplayGroupExpanded(const std::string &group, bool expanded)
#define USDUI_API
Definition: api.h:23
USDUI_API bool SetDisplayGroupsExpanded(const VtDictionary &expanded)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDUI_API UsdUIPrimHints()
UsdPrim GetPrim() const
Return the prim that this hints instance is interpreting.
Definition: primHints.h:48