HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
attributeHints.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_ATTRIBUTE_HINTS_H
9 #define PXR_USD_USDUI_ATTRIBUTE_HINTS_H
10 
12 #include "pxr/usd/usd/attribute.h"
13 
14 #include "pxr/base/vt/dictionary.h"
15 #include "pxr/base/vt/value.h"
16 
17 #include <string>
18 
20 
21 /// \class UsdUIAttributeHints
22 ///
23 /// A "schema-like" wrapper that provides API for retrieving and authoring UI
24 /// hint values within the \c uiHints dictionary field on a UsdAttribute
25 /// instance.
26 ///
27 /// UsdUIAttributeHints is "schema-like" in that it interprets fields belonging
28 /// to a core object type (in this case UsdAttribute, but see also
29 /// UsdUIObjectHints, UsdUIPrimHints, and UsdUIPropertyHints), and provides
30 /// convenient API for using those fields. However, it is not formally a schema
31 /// and does not derive from UsdSchemaBase.
32 ///
33 /// See \ref usdUI_hintsOverview for an overview of UI hints.
35 {
36 public:
37  /// Default constructor that creates an invalid hints object.
38  ///
39  /// Calling "set" operations on this object will post errors. "Get"
40  /// operations will return fallback values.
41  USDUI_API
43 
44  /// Construct a hints object for the given UsdAttribute \p attr.
45  USDUI_API
46  explicit UsdUIAttributeHints(const UsdAttribute& attr);
47 
48  /// Return the attribute that this hints instance is interpreting.
49  UsdAttribute GetAttribute() const { return _attr; }
50 
51  /// Return the attribute's value labels dictionary.
52  ///
53  /// This dictionary associates user-facing labels for display in the UI with
54  /// underlying values to be authored to the attribute when selected.
55  USDUI_API
57 
58  /// Set the attribute's value labels dictionary. Return \c true if
59  /// successful.
60  ///
61  /// Note that since this field is dictionary-valued, its composed value will
62  /// be the combination of all its entries as specified across all relevant
63  /// edit targets. Overrides occur per-entry rather than the dictionary as a
64  /// whole.
65  USDUI_API
66  bool SetValueLabels(const VtDictionary& labels);
67 
68  /// Return the value labels order, indicating the order in which value
69  /// labels should appear.
70  USDUI_API
71  VtTokenArray GetValueLabelsOrder() const;
72 
73  /// Set the attribute's value labels order. Return \c true if successful.
74  USDUI_API
75  bool SetValueLabelsOrder(const VtTokenArray& order);
76 
77  /// Author the value associated with the given \p label to the attribute.
78  /// If \p label is not a key in the attribute's value labels dictionary,
79  /// return \c false. Otherwise return \c true if \p label was successfully
80  /// applied.
81  USDUI_API
82  bool ApplyValueLabel(const std::string& label);
83 
84 private:
85  UsdAttribute _attr;
86 };
87 
89 
90 #endif
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
USDUI_API bool ApplyValueLabel(const std::string &label)
USDUI_API VtDictionary GetValueLabels() const
GLdouble GLdouble GLint GLint order
Definition: glad.h:2676
USDUI_API UsdUIAttributeHints()
#define USDUI_API
Definition: api.h:23
USDUI_API bool SetValueLabelsOrder(const VtTokenArray &order)
Set the attribute's value labels order. Return true if successful.
USDUI_API VtTokenArray GetValueLabelsOrder() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
UsdAttribute GetAttribute() const
Return the attribute that this hints instance is interpreting.
USDUI_API bool SetValueLabels(const VtDictionary &labels)