Skip to content
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-181: Tooltips are not formatted correctly #3536

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/mayaUsd/resources/ae/usdschemabase/ae_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from .custom_image_control import customImageControlCreator
from .attribute_custom_control import getNiceAttributeName
from .attribute_custom_control import cleanAndFormatTooltip
from .attribute_custom_control import AttributeCustomControl

import collections
Expand Down Expand Up @@ -294,7 +295,7 @@ def onCreate(self, *args):
# See comment in ConnectionsCustomControl below for why nc=5.
rl = cmds.rowLayout(nc=5, adj=3)
with LayoutManager(rl):
cmds.text(nameTxt, al='right', label=attrLabel, annotation=attr.GetDocumentation())
cmds.text(nameTxt, al='right', label=attrLabel, annotation=cleanAndFormatTooltip(attr.GetDocumentation()))
cmds.textField(attrTypeFld, editable=False, text=typeNameStr, font='obliqueLabelFont', width=singleWidgetWidth*1.5)

if hasAEPopupMenu:
Expand Down Expand Up @@ -360,7 +361,7 @@ def onCreate(self, *args):
# remain at a given width.
rl = cmds.rowLayout(nc=5, adj=3)
with LayoutManager(rl):
cmds.text(nameTxt, al='right', label=attrLabel, annotation=attr.GetDocumentation())
cmds.text(nameTxt, al='right', label=attrLabel, annotation=cleanAndFormatTooltip(attr.GetDocumentation()))
cmds.textField(attrTypeFld, editable=False, text=attrType, backgroundColor=[0.945, 0.945, 0.647], font='obliqueLabelFont', width=singleWidgetWidth*1.5)

# Add a menu item for each connection.
Expand Down Expand Up @@ -433,7 +434,7 @@ def arrayCustomControlCreator(aeTemplate, c):
def defaultControlCreator(aeTemplate, c):
ufeAttr = aeTemplate.attrS.attribute(c)
uiLabel = getNiceAttributeName(ufeAttr, c) if aeTemplate.useNiceName else c
cmds.editorTemplate(addControl=[c], label=uiLabel)
cmds.editorTemplate(addControl=[c], label=uiLabel, annotation=cleanAndFormatTooltip(ufeAttr.getDocumentation()))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When debugging this I realized that we were only adding tooltips to the array and connected attributes. After discussion with Nat I added them to all the attributes.

return None

class AEShaderLayout(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def getNiceAttributeName(ufeAttr, attrName):
attrName = str(ufeAttr.getMetadata("uiname"))
return mayaUsd.lib.Util.prettifyName(attrName)

def cleanAndFormatTooltip(s):
# Remove leading/trailing whitespace and replace newlines.
lines = s.splitlines()
stripped = [line.strip() for line in lines]
cleaned = '<br>'.join(stripped)

# Don't allow the tooltip to word-wrap.
return "<p style='white-space:pre'>" + cleaned + '</p>'
Comment on lines +35 to +42
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

splitlines() returns list splitting string at line breaks. Then create new list by removing spaces at beginning and end of strings. Then create one string using
instead of newline. Finally don't allow tooltip to wrap, as it contains breaks.

I think this is better than what UsdView is doing since it also removes the single leading space that subsequent lines have.


class AttributeCustomControl(object):
'''
Expand All @@ -55,4 +63,3 @@ def getUILabel(self):
Return the label to be used in the UI for the attribute set on this object.
'''
return self.getAttributeUILabel(self.ufeAttr, self.attrName)

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#

from .attribute_custom_control import AttributeCustomControl
from .attribute_custom_control import cleanAndFormatTooltip

import ufe
import mayaUsd.ufe as mayaUsdUfe
Expand All @@ -32,7 +33,7 @@ def __init__(self, ufeAttr, ufeAttrType, prim, attrName, useNiceName):
def onCreate(self, *args):
# Create the control.
attrLabel = self.getUILabel()
self.uiControl = cmds.optionMenuGrp(label=attrLabel)
self.uiControl = cmds.optionMenuGrp(label=attrLabel, annotation=cleanAndFormatTooltip(self.ufeAttr.getDocumentation()))
attributes.AEPopupMenu(self.uiControl, self.ufeAttr)

# Add the menu items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#

from .attribute_custom_control import AttributeCustomControl
from .attribute_custom_control import cleanAndFormatTooltip

import mayaUsd.lib as mayaUsdLib
from mayaUsdLibRegisterStrings import getMayaUsdLibString
Expand Down Expand Up @@ -51,7 +52,7 @@ def onCreate(self, *args):
createdControl = cmds.rowLayout(nc=3)
self.controlName = createdControl
with LayoutManager(createdControl):
cmds.text(label=attrUIName)
cmds.text(label=attrUIName, annotation=cleanAndFormatTooltip(ufeAttr.getDocumentation()))
cmds.textField(ImageCustomControl.filenameField)
cmds.symbolButton("browser", image="navButtonBrowse.png")

Expand Down
Loading