-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EMSUSD-215 support custom display name for USD attributes #3487
Conversation
d1a17cf
to
b94b8cd
Compare
b94b8cd
to
f943191
Compare
f943191
to
ebf754a
Compare
ebf754a
to
5cf9892
Compare
5cf9892
to
cfce354
Compare
Add support to have custom names for USD attributes to have nicer names for UI display purpose. We already had an algorithm to automatically make the names prettier, this adds support for user-defined attribute names. We now read the USD 'displayName' metadata on each attribute. If the metadata exists then we use its value as the display name. The built-in function to make the name prettier has also been enhanced to remove the "xformOp:" prefix. Also, the prettyfying avoids generating two spaces in a row (if, for example, : was followed by _). Modify the USD attribute-related classes: - Add a displayName funtion to the UsdAttrbute class. - Add a displayName funtion to the UsdAttributeHolder class. - Add a displayName funtion to the UsdShaderAttributeHolder class. - The displayName function in UsdAttributeHolder prettify the name. Add support for display name in the Attribute Editor template: - Refactor custom-control for various types into their own files. - Add a AttributeCustomControl base class to handle display names. - Make the default control creation use the display names. Added a simple unit test and fix some attribute unit tests.
cfce354
to
85c9969
Compare
|
||
import maya.cmds as cmds | ||
|
||
class AEUITemplate: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these is code extracted from ae_template.py, which had a lot of classes inside a single file that got split into their own file. The code did not change.
break | ||
except Exception as ex: | ||
# Do not let one custom control failure affect others. | ||
print('Failed to create control %s: %s' % (c, ex)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a custom control creator failed for any reason, it prevented all other attributes to be handled and there was no error message printed, which made diagnostic harder.
import ufe | ||
import mayaUsd.ufe as mayaUsdUfe | ||
import mayaUsd.lib as mayaUsdLib | ||
import maya.cmds as cmds | ||
import maya.internal.ufeSupport.attributes as attributes | ||
|
||
class CustomEnumControl(object): | ||
class EnumCustomControl(AttributeCustomControl): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the class name to follow the same pattern as the others.
InputsInControl = self.searchForMayaControl(frameLayout, cmds.text, 'Inputs In') | ||
self.assertIsNotNone(InputsInControl, 'Could not find D_filename "Inputs In" control') | ||
InputsInControl = self.searchForMayaControl(frameLayout, cmds.text, 'In') | ||
self.assertIsNotNone(InputsInControl, 'Could not find D_filename "In" control') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are shader attributes that now use the UI name. I asked lookdeX and these attributes never were meant to have the "Input" prefix to begin with.
Will remove all refactoring and cleanups and open another PR. |
Add support to have custom names for USD attributes to have nicer names for UI display purpose. We already had an algorithm to automatically make the names prettier, this adds support for user-defined attribute names. We now read the USD 'displayName' metadata on each attribute. If the metadata exists then we use its value as the display name.
The built-in function to make the name prettier has also been enhanced to remove the "xformOp:" prefix.
Modify the USD attribute-related classes:
Add support for display name in the Attribute Editor template:
Added a simple unit test.