def __init__(self, plug, **kw): frame = GafferUI.Frame(borderWidth=4) GafferUI.PlugValueWidget.__init__(self, frame, plug, **kw) # Style selector specificity rules seem to preclude us styling this # based on gafferClass. frame._qtWidget().setObjectName("gafferColorInspector") with frame: GafferUI.LayoutPlugValueWidget(plug)
def __parametersPlugValueWidgetCreator(plug): # Because we don't know the names of sections in advance, # we must use this opportunity to do a just-in-time registration of # metadata values for the collapsed status of each section. An # alternative approach would perhaps allow Metadata to be registered # with wildcards in the name, and with an associated method to return all # matching names (so registeredPlugValues() could continue to work). collapsedRe = re.compile("^page\.(.+)\.collapsed") annotations = _shaderAnnotations(plug.node()) for name, value in annotations.items(): m = collapsedRe.match(name) if m: Gaffer.Metadata.registerPlugValue( plug, "layout:section:" + m.group(1) + ":collapsed", value in ("True", "true", "1"), persistent=False, ) shader = _shader(plug.node()) if shader is not None: # when shaders are reloaded after having new parameters added, # the order of the plugs and the parameters don't match, so we # use the parameter ordering to define the ui order via metadata. ## \todo Ideally we'd get the plug ordering to match in # RenderManShader::loadShader(), and then the ordering of # connections in the node graph would be correct too. orderedParameterNames = shader.blindData()["ri:orderedParameterNames"] index = 0 for name in orderedParameterNames: if name.endswith( "Values") and name[:-6] + "Positions" in shader.parameters: name = name[:-6] elif name.endswith( "Positions") and name[:-9] + "Values" in shader.parameters: continue if name in plug: Gaffer.Metadata.registerPlugValue(plug[name], "layout:index", index, persistent=False) index += 1 # Now we've created the appropriate metadata, we can just defer to a standard LayoutPlugValueWidget return GafferUI.LayoutPlugValueWidget(plug)