Material editor: replacing modified property highlight color with indicator icons

Testing to see how easy it is to set up the indicated icons.
Problematic because icons are to the left of property labels instead of the left of property widget.
This completely destroys alignment.

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
Guthrie Adams
2021-09-27 20:35:54 -05:00
parent 133c85c641
commit 3fa9d16be2
4 changed files with 25 additions and 15 deletions
@@ -41,7 +41,8 @@ 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 = {});
void Refresh() override;
void Rebuild() override;
@@ -19,7 +19,8 @@ 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)
: InspectorGroupWidget(parent)
{
AZ::SerializeContext* context = nullptr;
@@ -34,6 +35,7 @@ namespace AtomToolsFramework
m_propertyEditor->SetHideRootProperties(true);
m_propertyEditor->SetAutoResizeLabels(true);
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);
@@ -91,12 +91,19 @@ namespace MaterialEditor
return AZ::Crc32(AZStd::string::format("MaterialInspector::PropertyGroup::%s::%s", m_documentPath.c_str(), groupNameId.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 nullptr;
}
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(groupNameId),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId), {},
[this](const auto node) { return GetInstanceNodePropertyIndicator(node); });
AddGroup(groupNameId, 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(groupNameId),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId), {},
[this](const auto node) { return GetInstanceNodePropertyIndicator(node); });
AddGroup(groupNameId, 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(groupNameId),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId), {},
[this](const auto node) { return GetInstanceNodePropertyIndicator(node); });
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupWidget);
bool isGroupVisible = false;
@@ -43,8 +43,8 @@ namespace MaterialEditor
private:
AZ::Crc32 GetGroupSaveStateKey(const AZStd::string& groupNameId) 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();