Merge pull request #265 from aws-lumberyard-dev/Atom/mnaumov/ATOM-13851

[ATOM-13851] Adding custom title to PropertyAssetCtrl
This commit is contained in:
AMZN-mnaumov
2021-04-27 17:42:23 -07:00
committed by GitHub
7 changed files with 46 additions and 2 deletions
@@ -118,6 +118,7 @@ namespace AZ
const static AZ::Crc32 StringLineEditingCompleteNotify = AZ_CRC("StringLineEditingCompleteNotify", 0x139e5fa9);
const static AZ::Crc32 NameLabelOverride = AZ_CRC("NameLabelOverride", 0x9ff79cab);
const static AZ::Crc32 AssetPickerTitle = AZ_CRC_CE("AssetPickerTitle");
const static AZ::Crc32 ChildNameLabelOverride = AZ_CRC("ChildNameLabelOverride", 0x73dd2909);
//! Container attribute that is used to override labels for its elements given the index of the element
const static AZ::Crc32 IndexedChildNameLabelOverride = AZ_CRC("IndexedChildNameLabelOverride", 0x5f313ac2);
@@ -680,6 +680,13 @@ namespace AzToolsFramework
AzQtComponents::BrowseEdit::removeDropTargetStyle(m_browseEdit);
}
AssetSelectionModel PropertyAssetCtrl::GetAssetSelectionModel()
{
auto selectionModel = AssetSelectionModel::AssetTypeSelection(GetCurrentAssetType());
selectionModel.SetTitle(m_title);
return selectionModel;
}
void PropertyAssetCtrl::UpdateTabOrder()
{
setTabOrder(m_browseEdit, m_editButton);
@@ -1058,6 +1065,11 @@ namespace AzToolsFramework
m_editButton->setIcon(icon);
}
void PropertyAssetCtrl::SetTitle(const QString& title)
{
m_title = title;
}
void PropertyAssetCtrl::SetEditNotifyTarget(void* editNotifyTarget)
{
m_editNotifyTarget = editNotifyTarget;
@@ -1193,7 +1205,16 @@ namespace AzToolsFramework
{
(void)debugName;
if (attrib == AZ_CRC("EditCallback", 0xb74f2ee1))
if (attrib == AZ_CRC_CE("AssetPickerTitle"))
{
AZStd::string title;
attrValue->Read<AZStd::string>(title);
if (!title.empty())
{
GUI->SetTitle(title.c_str());
}
}
else if (attrib == AZ_CRC("EditCallback", 0xb74f2ee1))
{
PropertyAssetCtrl::EditCallbackType* func = azdynamic_cast<PropertyAssetCtrl::EditCallbackType*>(attrValue->GetAttribute());
if (func)
@@ -89,12 +89,13 @@ namespace AzToolsFramework
void dragLeaveEvent(QDragLeaveEvent* event) override;
void dropEvent(QDropEvent* event) override;
virtual AssetSelectionModel GetAssetSelectionModel() { return AssetSelectionModel::AssetTypeSelection(GetCurrentAssetType()); }
virtual AssetSelectionModel GetAssetSelectionModel();
signals:
void OnAssetIDChanged(AZ::Data::AssetId newAssetID);
protected:
QString m_title;
ThumbnailPropertyCtrl* m_thumbnail = nullptr;
QPushButton* m_errorButton = nullptr;
QToolButton* m_editButton = nullptr;
@@ -191,6 +192,7 @@ namespace AzToolsFramework
//////////////////////////////////////////////////////////////////////////
public slots:
void SetTitle(const QString& title);
void SetEditNotifyTarget(void* editNotifyTarget);
void SetEditNotifyCallback(EditCallbackType* editNotifyCallback); // This is meant to be used with the "EditCallback" Attribute
void SetClearNotifyCallback(ClearCallbackType* clearNotifyCallback); // This is meant to be used with the "ClearNotify" Attribute
@@ -49,6 +49,7 @@ namespace AtomToolsFramework
AZ::Name m_id;
AZStd::string m_nameId;
AZStd::string m_displayName;
AZStd::string m_groupName;
AZStd::string m_description;
AZStd::any m_defaultValue;
AZStd::any m_parentValue;
@@ -108,6 +109,8 @@ namespace AtomToolsFramework
private:
// Functions used to configure edit data attributes.
AZStd::string GetDisplayName() const;
AZStd::string GetGroupName() const;
AZStd::string GetAssetPickerTitle() const;
AZStd::string GetDescription() const;
AZStd::vector<AZ::Edit::EnumConstant<uint32_t>> GetEnumValues() const;
@@ -135,6 +135,7 @@ namespace AtomToolsFramework
m_editData.m_elementId = AZ::Edit::UIHandlers::Default;
AddEditDataAttributeMemberFunction(AZ::Edit::Attributes::NameLabelOverride, &DynamicProperty::GetDisplayName);
AddEditDataAttributeMemberFunction(AZ::Edit::Attributes::AssetPickerTitle, &DynamicProperty::GetAssetPickerTitle);
AddEditDataAttributeMemberFunction(AZ::Edit::Attributes::DescriptionTextOverride, &DynamicProperty::GetDescription);
AddEditDataAttributeMemberFunction(AZ::Edit::Attributes::ReadOnly, &DynamicProperty::IsReadOnly);
AddEditDataAttributeMemberFunction(AZ::Edit::Attributes::EnumValues, &DynamicProperty::GetEnumValues);
@@ -197,6 +198,16 @@ namespace AtomToolsFramework
return !m_config.m_displayName.empty() ? m_config.m_displayName : m_config.m_nameId;
}
AZStd::string DynamicProperty::GetGroupName() const
{
return m_config.m_groupName;
}
AZStd::string DynamicProperty::GetAssetPickerTitle() const
{
return GetGroupName().empty() ? GetDisplayName() : GetGroupName() + " " + GetDisplayName();
}
AZStd::string DynamicProperty::GetDescription() const
{
return AZStd::string::format("%s%s(Script Name = '%s')",
@@ -773,6 +773,7 @@ namespace MaterialEditor
AtomToolsFramework::ConvertToPropertyConfig(propertyConfig, propertyDefinition);
propertyConfig.m_originalValue = AtomToolsFramework::ConvertToEditableType(m_materialAsset->GetPropertyValues()[propertyIndex.GetIndex()]);
propertyConfig.m_parentValue = AtomToolsFramework::ConvertToEditableType(parentPropertyValues[propertyIndex.GetIndex()]);
propertyConfig.m_groupName = m_materialTypeSourceData.FindGroup(groupNameId)->m_displayName;
m_properties[propertyConfig.m_id] = AtomToolsFramework::DynamicProperty(propertyConfig);
}
return true;
@@ -789,6 +790,7 @@ namespace MaterialEditor
propertyConfig.m_id = "details.materialType";
propertyConfig.m_nameId = "materialType";
propertyConfig.m_displayName = "Material Type";
propertyConfig.m_groupName = "Details";
propertyConfig.m_description = propertyConfig.m_displayName;
propertyConfig.m_defaultValue = AZStd::any(materialTypeAsset);
propertyConfig.m_originalValue = propertyConfig.m_defaultValue;
@@ -802,6 +804,7 @@ namespace MaterialEditor
propertyConfig.m_id = "details.parentMaterial";
propertyConfig.m_nameId = "parentMaterial";
propertyConfig.m_displayName = "Parent Material";
propertyConfig.m_groupName = "Details";
propertyConfig.m_description = propertyConfig.m_displayName;
propertyConfig.m_defaultValue = AZStd::any(parentMaterialAsset);
propertyConfig.m_originalValue = propertyConfig.m_defaultValue;
@@ -822,6 +825,7 @@ namespace MaterialEditor
propertyConfig.m_id = MaterialPropertyId(UvGroupName, shaderInput).GetCStr();
propertyConfig.m_nameId = shaderInput;
propertyConfig.m_displayName = shaderInput;
propertyConfig.m_groupName = "UV Names";
propertyConfig.m_description = shaderInput;
propertyConfig.m_defaultValue = uvName;
propertyConfig.m_originalValue = uvName;
@@ -203,6 +203,7 @@ namespace AZ
propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupNameId, shaderInputStr).GetCStr();
propertyConfig.m_nameId = shaderInputStr;
propertyConfig.m_displayName = shaderInputStr;
propertyConfig.m_groupName = groupDisplayName;
propertyConfig.m_description = shaderInputStr;
propertyConfig.m_defaultValue = uvName;
propertyConfig.m_originalValue = uvName;
@@ -247,6 +248,7 @@ namespace AZ
AtomToolsFramework::ConvertToPropertyConfig(propertyConfig, propertyDefinition);
propertyConfig.m_id = AZ::RPI::MaterialPropertyId(groupNameId, propertyDefinition.m_nameId).GetFullName();
propertyConfig.m_groupName = groupDisplayName;
const auto& propertyIndex = m_editData.m_materialAsset->GetMaterialPropertiesLayout()->FindPropertyIndex(propertyConfig.m_id);
propertyConfig.m_defaultValue = AtomToolsFramework::ConvertToEditableType(m_editData.m_materialTypeAsset->GetDefaultPropertyValues()[propertyIndex.GetIndex()]);
propertyConfig.m_parentValue = AtomToolsFramework::ConvertToEditableType(m_editData.m_materialTypeAsset->GetDefaultPropertyValues()[propertyIndex.GetIndex()]);