Skip to content

Commit

Permalink
Merge pull request #3536 from Autodesk/donnels/EMSUSD-181/clean_attri…
Browse files Browse the repository at this point in the history
…bute_tooltip_strings

EMSUSD-181: Tooltips are not formatted correctly
  • Loading branch information
seando-adsk authored Jan 4, 2024
2 parents b9c7094 + 7e56457 commit 8f5704b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
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()))
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>'

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

0 comments on commit 8f5704b

Please sign in to comment.