EMSUSD-3340 support drag-and-drop material in AE - #4670
Closed
pierrebai-adsk wants to merge 1 commit into
Closed
Conversation
New drag-and-drop text field: - Added `DragAndDropTextField` class to make a MEL textField support drag-and-drop of text. - The class supports validation of the dropped value. - The class has callbacks for user text changes and drag-and-drop changes. Enhance AE material UI: - Use the drag-and-drop text filed in the material cutom control. - Added `AssignedMaterialUI` to replace `TextField` for clarity. - Added undo label to matadata UI. - Added goto-prim button for all fields with prim paths. Edit restrictions for material commands: - Added edit restriction enforcement in the bind, unbind amd strength commands. - Made the unbind command not unbind collections. (We're not managing collections.) - Added unit tests for restrictions.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds UI support for drag-and-drop material assignment in Maya’s Attribute Editor (AE) and strengthens USD material binding command behavior by enforcing edit restrictions, with accompanying unit tests.
Changes:
- Added a reusable
DragAndDropTextFieldhelper and integrated it into the AE material custom control. - Improved AE metadata/material UI behaviors (undo labels, goto-prim buttons, clearer controls).
- Enforced edit restrictions for bind/unbind/strength material commands and added new restriction-focused unit tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/lib/ufe/testMaterialBindingCommands.py | Adds unit tests covering edit-restriction failures for bind/unbind/strength commands. |
| lib/usdUfe/ufe/UsdUndoMaterialCommands.cpp | Enforces edit restrictions for material binding operations and adjusts unbind behavior to avoid collection-based unbinding. |
| lib/mayaUsd/resources/scripts/mayaUsdLibRegisterStrings.py | Registers new undo-label strings used by AE controls. |
| lib/mayaUsd/resources/ae/usdschemabase/metadataCustomControl.py | Applies undo labels to metadata edits (kind/active/instanceable). |
| lib/mayaUsd/resources/ae/usdschemabase/materialCustomControl.py | Integrates drag-and-drop text fields and adds goto-prim buttons across relevant material fields. |
| lib/mayaUsd/resources/ae/usdschemabase/dragAndDropTextField.py | Introduces the drag-and-drop-capable text field wrapper used by AE controls. |
| lib/mayaUsd/resources/ae/CMakeLists.txt | Installs the newly added AE Python module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
281
to
+287
| const UsdRelationship directRel = bindingAPI.GetDirectBindingRel(_purpose); | ||
| const TfToken strength = directRel | ||
| ? UsdShadeMaterialBindingAPI::GetMaterialBindingStrength(directRel) | ||
| : UsdShadeTokens->fallbackStrength; | ||
|
|
||
| enforceMaterialBindingEditRestriction(directRel); | ||
|
|
Comment on lines
+89
to
+93
| potentialNewValue = validation(self.lastValue, newValues) | ||
| if potentialNewValue is not None: | ||
| return potentialNewValue | ||
|
|
||
| return value |
| In Maya, when text is dropped, it is inserted in the middle of the existing text. | ||
| What we want is replacement, not insertion. So we try to detect that and extract | ||
| the dropped value from the new text. Unfortunately, there may be corner cases | ||
| where we cannot be sure what is teh new text. For example, if the previous text |
| if self.lastValue == value: | ||
| return None | ||
| # If the new value is shorter than the last value, it is not a drop. | ||
| # If teh new value is just ne character longer, then we assume the user is typing and not dropping. |
Comment on lines
+168
to
+173
| hasLookdevX = self._hasLookdevX() | ||
| graphIcon = 'LookdevX.png' if hasLookdevX else None | ||
|
|
||
| graphTooltip = getMayaUsdLibString('kAnnShowMaterialInLookdevx') | ||
| graphButton = cmds.symbolButton(enable=False, image=graphIcon, annotation=graphTooltip) | ||
| graphMenu = self._createGraphMenu(graphButton) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New drag-and-drop text field:
DragAndDropTextFieldclass to make a MEL textField support drag-and-drop of text.Enhance AE material UI:
AssignedMaterialUIto replaceTextFieldfor clarity.Edit restrictions for material commands: