Merge pull request #4376 from aws-lumberyard-dev/Atom/guthadam/material_editor_replace_modified_color_with_indicator

Replace modified property name highlighting with indicator icon in material editor and component inspectors
This commit is contained in:
Guthrie Adams
2021-10-01 18:42:01 -05:00
committed by GitHub
10 changed files with 57 additions and 37 deletions
@@ -1102,10 +1102,7 @@ namespace AzToolsFramework
{
m_dropDownArrow->hide();
}
m_indent->changeSize((m_treeDepth * m_treeIndentation) + m_leafIndentation, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_leftHandSideLayout->invalidate();
m_leftHandSideLayout->update();
m_leftHandSideLayout->activate();
SetIndentSize(m_treeDepth * m_treeIndentation + m_leafIndentation);
}
else
{
@@ -1117,10 +1114,7 @@ namespace AzToolsFramework
connect(m_dropDownArrow, &QCheckBox::clicked, this, &PropertyRowWidget::OnClickedExpansionButton);
}
m_dropDownArrow->show();
m_indent->changeSize((m_treeDepth * m_treeIndentation), 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_leftHandSideLayout->invalidate();
m_leftHandSideLayout->update();
m_leftHandSideLayout->activate();
SetIndentSize(m_treeDepth * m_treeIndentation);
m_dropDownArrow->setChecked(m_expanded);
}
}
@@ -1720,10 +1714,9 @@ namespace AzToolsFramework
}
else
{
m_indicatorButton->setVisible(true);
QPixmap pixmap(imagePath);
m_indicatorButton->setIcon(pixmap);
m_indicatorButton->setVisible(true);
};
}
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/PropertyEditor/Resources">
<file>blank.png</file>
<file>point_hand.png</file>
<file>cross-circle-small.png</file>
<file>cross-small.png</file>
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:81b5fa1f978888c3be8a40fce20455668df2723a77587aeb7039f8bf74bdd0e3
size 119
@@ -41,7 +41,9 @@ namespace AtomToolsFramework
AzToolsFramework::IPropertyEditorNotify* instanceNotificationHandler = {},
QWidget* parent = {},
const AZ::u32 saveStateKey = {},
const AzToolsFramework::InstanceDataHierarchy::ValueComparisonFunction& valueComparisonFunction = {});
const AzToolsFramework::InstanceDataHierarchy::ValueComparisonFunction& valueComparisonFunction = {},
const AzToolsFramework::IndicatorQueryFunction& indicatorQueryFunction = {},
int leafIndentSize = 16);
void Refresh() override;
void Rebuild() override;
@@ -20,7 +20,9 @@ namespace AtomToolsFramework
AzToolsFramework::IPropertyEditorNotify* instanceNotificationHandler,
QWidget* parent,
const AZ::u32 saveStateKey,
const AzToolsFramework::InstanceDataHierarchy::ValueComparisonFunction& valueComparisonFunction)
const AzToolsFramework::InstanceDataHierarchy::ValueComparisonFunction& valueComparisonFunction,
const AzToolsFramework::IndicatorQueryFunction& indicatorQueryFunction,
int leafIndentSize)
: InspectorGroupWidget(parent)
{
AZ::SerializeContext* context = nullptr;
@@ -33,8 +35,10 @@ namespace AtomToolsFramework
m_propertyEditor = new AzToolsFramework::ReflectedPropertyEditor(this);
m_propertyEditor->SetHideRootProperties(true);
m_propertyEditor->SetAutoResizeLabels(true);
m_propertyEditor->SetAutoResizeLabels(false);
m_propertyEditor->SetLeafIndentation(leafIndentSize);
m_propertyEditor->SetValueComparisonFunction(valueComparisonFunction);
m_propertyEditor->SetIndicatorQueryFunction(indicatorQueryFunction);
m_propertyEditor->SetSavedStateKey(saveStateKey);
m_propertyEditor->Setup(context, instanceNotificationHandler, false);
m_propertyEditor->AddInstance(instance, instanceClassId, nullptr, instanceToCompare);
@@ -150,6 +150,7 @@ namespace AtomToolsFramework
ComparePropertyValues<AZ::Vector4>(valueA, valueB) ||
ComparePropertyValues<AZ::Color>(valueA, valueB) ||
ComparePropertyValues<AZ::Data::AssetId>(valueA, valueB) ||
ComparePropertyValues<AZ::Data::Asset<AZ::Data::AssetData>>(valueA, valueB) ||
ComparePropertyValues<AZ::Data::Asset<AZ::RPI::ImageAsset>>(valueA, valueB) ||
ComparePropertyValues<AZ::Data::Asset<AZ::RPI::StreamingImageAsset>>(valueA, valueB) ||
ComparePropertyValues<AZ::Data::Asset<AZ::RPI::MaterialAsset>>(valueA, valueB) ||
@@ -91,12 +91,19 @@ namespace MaterialEditor
return AZ::Crc32(AZStd::string::format("MaterialInspector::PropertyGroup::%s::%s", m_documentPath.c_str(), groupName.c_str()));
}
bool MaterialInspector::CompareInstanceNodeProperties(
const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target) const
bool MaterialInspector::IsInstanceNodePropertyModifed(const AzToolsFramework::InstanceDataNode* node) const
{
AZ_UNUSED(source);
const AtomToolsFramework::DynamicProperty* property = AtomToolsFramework::FindDynamicPropertyForInstanceDataNode(target);
return property && AtomToolsFramework::ArePropertyValuesEqual(property->GetValue(), property->GetConfig().m_parentValue);
const AtomToolsFramework::DynamicProperty* property = AtomToolsFramework::FindDynamicPropertyForInstanceDataNode(node);
return property && !AtomToolsFramework::ArePropertyValuesEqual(property->GetValue(), property->GetConfig().m_parentValue);
}
const char* MaterialInspector::GetInstanceNodePropertyIndicator(const AzToolsFramework::InstanceDataNode* node) const
{
if (IsInstanceNodePropertyModifed(node))
{
return ":/PropertyEditor/Resources/changed_data_item.png";
}
return ":/PropertyEditor/Resources/blank.png";
}
void MaterialInspector::AddOverviewGroup()
@@ -122,8 +129,8 @@ namespace MaterialEditor
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName), {},
[this](const auto node) { return GetInstanceNodePropertyIndicator(node); }, 0);
AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
}
@@ -153,8 +160,8 @@ namespace MaterialEditor
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName), {},
[this](const auto node) { return GetInstanceNodePropertyIndicator(node); }, 0);
AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
}
@@ -189,8 +196,8 @@ namespace MaterialEditor
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName), {},
[this](const auto node) { return GetInstanceNodePropertyIndicator(node); }, 0);
AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
bool isGroupVisible = false;
@@ -43,8 +43,8 @@ namespace MaterialEditor
private:
AZ::Crc32 GetGroupSaveStateKey(const AZStd::string& groupName) const;
bool CompareInstanceNodeProperties(
const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target) const;
bool IsInstanceNodePropertyModifed(const AzToolsFramework::InstanceDataNode* node) const;
const char* GetInstanceNodePropertyIndicator(const AzToolsFramework::InstanceDataNode* node) const;
void AddOverviewGroup();
void AddUvNamesGroup();
@@ -277,7 +277,8 @@ namespace AZ
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, nullptr, group.TYPEINFO_Uuid(), this, this, GetSaveStateKeyForGroup(groupName));
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName), {},
[this](const auto node) { return GetInstanceNodePropertyIndicator(node); }, 0);
AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
}
@@ -322,7 +323,8 @@ namespace AZ
// Passing in same group as main and comparison instance to enable custom value comparison for highlighting modified properties
auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
&group, nullptr, group.TYPEINFO_Uuid(), this, this, GetSaveStateKeyForGroup(groupName));
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupName), {},
[this](const auto node) { return GetInstanceNodePropertyIndicator(node); }, 0);
AddGroup(groupName, groupDisplayName, groupDescription, propertyGroupWidget);
}
@@ -502,19 +504,26 @@ namespace AZ
}
}
AZ::Crc32 MaterialPropertyInspector::GetSaveStateKeyForGroup(const AZStd::string& groupName) const
AZ::Crc32 MaterialPropertyInspector::GetGroupSaveStateKey(const AZStd::string& groupName) const
{
return AZ::Crc32(AZStd::string::format(
"MaterialPropertyInspector::PropertyGroup::%s::%s", m_editData.m_materialAssetId.ToString<AZStd::string>().c_str(),
groupName.c_str()));
}
bool MaterialPropertyInspector::AreNodePropertyValuesEqual(
const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target)
bool MaterialPropertyInspector::IsInstanceNodePropertyModifed(const AzToolsFramework::InstanceDataNode* node) const
{
AZ_UNUSED(source);
const AtomToolsFramework::DynamicProperty* property = AtomToolsFramework::FindDynamicPropertyForInstanceDataNode(target);
return property && AtomToolsFramework::ArePropertyValuesEqual(property->GetValue(), property->GetConfig().m_parentValue);
const AtomToolsFramework::DynamicProperty* property = AtomToolsFramework::FindDynamicPropertyForInstanceDataNode(node);
return property && !AtomToolsFramework::ArePropertyValuesEqual(property->GetValue(), property->GetConfig().m_parentValue);
}
const char* MaterialPropertyInspector::GetInstanceNodePropertyIndicator(const AzToolsFramework::InstanceDataNode* node) const
{
if (IsInstanceNodePropertyModifed(node))
{
return ":/PropertyEditor/Resources/changed_data_item.png";
}
return ":/PropertyEditor/Resources/blank.png";
}
bool MaterialPropertyInspector::SaveMaterial() const
@@ -100,9 +100,9 @@ namespace AZ
void RunEditorMaterialFunctors();
void UpdateMaterialInstanceProperty(const AtomToolsFramework::DynamicProperty& property);
AZ::Crc32 GetSaveStateKeyForGroup(const AZStd::string& groupName) const;
static bool AreNodePropertyValuesEqual(
const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target);
AZ::Crc32 GetGroupSaveStateKey(const AZStd::string& groupName) const;
bool IsInstanceNodePropertyModifed(const AzToolsFramework::InstanceDataNode* node) const;
const char* GetInstanceNodePropertyIndicator(const AzToolsFramework::InstanceDataNode* node) const;
// Tracking the property that is actively being edited in the inspector
const AtomToolsFramework::DynamicProperty* m_activeProperty = {};