Implementing A Custom Asset Control Widget
The entry point that Katana needs, in order to create a custom asset control widget is the createAssetControlWidget() method of our custom AssetWidgetDelegate class.
The createAssetControlWidget() method instantiates the SimpleMockAssetControlWidget, which must inherit from BaseAssetControlWidget. BaseAssetControlWidget is a QT QWidget with an HBoxLayout. createAssetControlWidget() then adds the control widget to the parent layout. The parent is a QWidget and part of the Parameter tab.
The following methods must be implemented by an asset control widget:
• buildWidgets()
This is invoked by the BaseAssetControlWidget constructor to build the child widgets. This is where most of the work happens.
• setValue()
Updates this widget with the given Asset ID.
• getValue()
Return the Asset ID from this widget.
• setReadOnly()
Enable/Disable editing of this widget.
The BaseAssetControlWidget supplies an emitValueChanged() method for notifying Katana that the user has changed the Asset ID in the widget. This must be called when the value in the UI has changed.