Updated the naming convention for material property "names" vs "IDs".
A "property name" is the name of the just the property without regard to the group that it's in. A "group name" is the name of the group. And a "property ID" is the full unique name of a property in the form "groupName.propertyName". This is important preparation for upcoming changes where property sets can contain other property sets, and property IDs can be arbitrarily long like "layer1.baseColor.factor" for example. The naming changes include variables, some code comments, and the .materialtype file format. I was able to make these changes in a backward compatible way so a property or group "id" field has been replaced with a "name" field, but "id" is still supported for compatibility. StandardPBR, EnhancedPBR, StandardMultilayerPBR, and Skin have all been updated. Note that MinimalPBR has not been updated, proving that backward compatibility works. (We can update this one too at some point though). Testing: Opened up materials in the material editor. Ran AtomSampleViewer in dx12 and vulkan with no new failures. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
+3
-3
@@ -32,10 +32,10 @@ namespace AtomToolsFramework
|
||||
// AtomToolsDocumentRequestBus::Handler implementation
|
||||
AZStd::string_view GetAbsolutePath() const override;
|
||||
AZStd::string_view GetRelativePath() const override;
|
||||
const AZStd::any& GetPropertyValue(const AZ::Name& propertyFullName) const override;
|
||||
const AtomToolsFramework::DynamicProperty& GetProperty(const AZ::Name& propertyFullName) const override;
|
||||
const AZStd::any& GetPropertyValue(const AZ::Name& propertyId) const override;
|
||||
const AtomToolsFramework::DynamicProperty& GetProperty(const AZ::Name& propertyId) const override;
|
||||
bool IsPropertyGroupVisible(const AZ::Name& propertyGroupFullName) const override;
|
||||
void SetPropertyValue(const AZ::Name& propertyFullName, const AZStd::any& value) override;
|
||||
void SetPropertyValue(const AZ::Name& propertyId, const AZStd::any& value) override;
|
||||
bool Open(AZStd::string_view loadPath) override;
|
||||
bool Reopen() override;
|
||||
bool Save() override;
|
||||
|
||||
+2
-2
@@ -42,8 +42,8 @@ namespace AtomToolsFramework
|
||||
AZ_CLASS_ALLOCATOR(DynamicPropertyConfig, AZ::SystemAllocator, 0);
|
||||
|
||||
DynamicPropertyType m_dataType = DynamicPropertyType::Invalid;
|
||||
AZ::Name m_id;
|
||||
AZStd::string m_nameId;
|
||||
AZ::Name m_id; //!< The full property ID, which will normally be "groupName.propertyName"
|
||||
AZStd::string m_name;
|
||||
AZStd::string m_displayName;
|
||||
AZStd::string m_groupName;
|
||||
AZStd::string m_description;
|
||||
|
||||
+9
-9
@@ -41,27 +41,27 @@ namespace AtomToolsFramework
|
||||
|
||||
//! Add a group consisting of a collapsable header and widget
|
||||
virtual void AddGroup(
|
||||
const AZStd::string& groupNameId,
|
||||
const AZStd::string& groupName,
|
||||
const AZStd::string& groupDisplayName,
|
||||
const AZStd::string& groupDescription,
|
||||
QWidget* groupWidget) = 0;
|
||||
|
||||
//! Sets the visibility of a specific property group. This impacts both the header and the widget.
|
||||
virtual void SetGroupVisible(const AZStd::string& groupNameId, bool visible) = 0;
|
||||
virtual void SetGroupVisible(const AZStd::string& groupName, bool visible) = 0;
|
||||
|
||||
//! Returns whether a specific property is visible.
|
||||
//! Note this follows the same rules as QWidget::isVisible(), meaning a group could be not visible due to the widget's parents being not visible.
|
||||
virtual bool IsGroupVisible(const AZStd::string& groupNameId) const = 0;
|
||||
virtual bool IsGroupVisible(const AZStd::string& groupName) const = 0;
|
||||
|
||||
//! Returns whether a specific property is explicitly hidden.
|
||||
//! Note this follows the same rules as QWidget::isHidden(), meaning a group that is hidden will not become visible automatically when the parent becomes visible.
|
||||
virtual bool IsGroupHidden(const AZStd::string& groupNameId) const = 0;
|
||||
virtual bool IsGroupHidden(const AZStd::string& groupName) const = 0;
|
||||
|
||||
//! Calls Refresh for a specific InspectorGroupWidget, allowing for non-destructive UI changes
|
||||
virtual void RefreshGroup(const AZStd::string& groupNameId) = 0;
|
||||
virtual void RefreshGroup(const AZStd::string& groupName) = 0;
|
||||
|
||||
//! Calls Rebuild for a specific InspectorGroupWidget, allowing for destructive UI changes
|
||||
virtual void RebuildGroup(const AZStd::string& groupNameId) = 0;
|
||||
virtual void RebuildGroup(const AZStd::string& groupName) = 0;
|
||||
|
||||
//! Calls Refresh for all InspectorGroupWidget, allowing for non-destructive UI changes
|
||||
virtual void RefreshAll() = 0;
|
||||
@@ -70,13 +70,13 @@ namespace AtomToolsFramework
|
||||
virtual void RebuildAll() = 0;
|
||||
|
||||
//! Expands a specific group
|
||||
virtual void ExpandGroup(const AZStd::string& groupNameId) = 0;
|
||||
virtual void ExpandGroup(const AZStd::string& groupName) = 0;
|
||||
|
||||
//! Collapses a specific group
|
||||
virtual void CollapseGroup(const AZStd::string& groupNameId) = 0;
|
||||
virtual void CollapseGroup(const AZStd::string& groupName) = 0;
|
||||
|
||||
//! Checks the expansion state of a specific group
|
||||
virtual bool IsGroupExpanded(const AZStd::string& groupNameId) const = 0;
|
||||
virtual bool IsGroupExpanded(const AZStd::string& groupName) const = 0;
|
||||
|
||||
//! Expands all groups and headers
|
||||
virtual void ExpandAll() = 0;
|
||||
|
||||
+13
-13
@@ -52,33 +52,33 @@ namespace AtomToolsFramework
|
||||
void AddGroupsEnd() override;
|
||||
|
||||
void AddGroup(
|
||||
const AZStd::string& groupNameId,
|
||||
const AZStd::string& groupName,
|
||||
const AZStd::string& groupDisplayName,
|
||||
const AZStd::string& groupDescription,
|
||||
QWidget* groupWidget) override;
|
||||
|
||||
void SetGroupVisible(const AZStd::string& groupNameId, bool visible) override;
|
||||
bool IsGroupVisible(const AZStd::string& groupNameId) const override;
|
||||
bool IsGroupHidden(const AZStd::string& groupNameId) const override;
|
||||
void SetGroupVisible(const AZStd::string& groupName, bool visible) override;
|
||||
bool IsGroupVisible(const AZStd::string& groupName) const override;
|
||||
bool IsGroupHidden(const AZStd::string& groupName) const override;
|
||||
|
||||
void RefreshGroup(const AZStd::string& groupNameId) override;
|
||||
void RebuildGroup(const AZStd::string& groupNameId) override;
|
||||
void RefreshGroup(const AZStd::string& groupName) override;
|
||||
void RebuildGroup(const AZStd::string& groupName) override;
|
||||
|
||||
void RefreshAll() override;
|
||||
void RebuildAll() override;
|
||||
|
||||
void ExpandGroup(const AZStd::string& groupNameId) override;
|
||||
void CollapseGroup(const AZStd::string& groupNameId) override;
|
||||
bool IsGroupExpanded(const AZStd::string& groupNameId) const override;
|
||||
void ExpandGroup(const AZStd::string& groupName) override;
|
||||
void CollapseGroup(const AZStd::string& groupName) override;
|
||||
bool IsGroupExpanded(const AZStd::string& groupName) const override;
|
||||
|
||||
void ExpandAll() override;
|
||||
void CollapseAll() override;
|
||||
|
||||
protected:
|
||||
virtual bool ShouldGroupAutoExpanded(const AZStd::string& groupNameId) const;
|
||||
virtual void OnGroupExpanded(const AZStd::string& groupNameId);
|
||||
virtual void OnGroupCollapsed(const AZStd::string& groupNameId);
|
||||
virtual void OnHeaderClicked(const AZStd::string& groupNameId, QMouseEvent* event);
|
||||
virtual bool ShouldGroupAutoExpanded(const AZStd::string& groupName) const;
|
||||
virtual void OnGroupExpanded(const AZStd::string& groupName);
|
||||
virtual void OnGroupCollapsed(const AZStd::string& groupName);
|
||||
virtual void OnHeaderClicked(const AZStd::string& groupName, QMouseEvent* event);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::InspectorWidget> m_ui;
|
||||
|
||||
@@ -38,16 +38,16 @@ namespace AtomToolsFramework
|
||||
return m_relativePath;
|
||||
}
|
||||
|
||||
const AZStd::any& AtomToolsDocument::GetPropertyValue([[maybe_unused]] const AZ::Name& propertyFullName) const
|
||||
const AZStd::any& AtomToolsDocument::GetPropertyValue([[maybe_unused]] const AZ::Name& propertyId) const
|
||||
{
|
||||
AZ_UNUSED(propertyFullName);
|
||||
AZ_UNUSED(propertyId);
|
||||
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
|
||||
return m_invalidValue;
|
||||
}
|
||||
|
||||
const AtomToolsFramework::DynamicProperty& AtomToolsDocument::GetProperty([[maybe_unused]] const AZ::Name& propertyFullName) const
|
||||
const AtomToolsFramework::DynamicProperty& AtomToolsDocument::GetProperty([[maybe_unused]] const AZ::Name& propertyId) const
|
||||
{
|
||||
AZ_UNUSED(propertyFullName);
|
||||
AZ_UNUSED(propertyId);
|
||||
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
|
||||
return m_invalidProperty;
|
||||
}
|
||||
@@ -59,9 +59,9 @@ namespace AtomToolsFramework
|
||||
return false;
|
||||
}
|
||||
|
||||
void AtomToolsDocument::SetPropertyValue([[maybe_unused]] const AZ::Name& propertyFullName, [[maybe_unused]] const AZStd::any& value)
|
||||
void AtomToolsDocument::SetPropertyValue([[maybe_unused]] const AZ::Name& propertyId, [[maybe_unused]] const AZStd::any& value)
|
||||
{
|
||||
AZ_UNUSED(propertyFullName);
|
||||
AZ_UNUSED(propertyId);
|
||||
AZ_UNUSED(value);
|
||||
AZ_Error("AtomToolsDocument", false, "%s not implemented.", __FUNCTION__);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace AtomToolsFramework
|
||||
|
||||
AZStd::string DynamicProperty::GetDisplayName() const
|
||||
{
|
||||
return !m_config.m_displayName.empty() ? m_config.m_displayName : m_config.m_nameId;
|
||||
return !m_config.m_displayName.empty() ? m_config.m_displayName : m_config.m_name;
|
||||
}
|
||||
|
||||
AZStd::string DynamicProperty::GetGroupName() const
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace AtomToolsFramework
|
||||
}
|
||||
|
||||
void InspectorWidget::AddGroup(
|
||||
const AZStd::string& groupNameId,
|
||||
const AZStd::string& groupName,
|
||||
const AZStd::string& groupDisplayName,
|
||||
const AZStd::string& groupDescription,
|
||||
QWidget* groupWidget)
|
||||
@@ -76,31 +76,31 @@ namespace AtomToolsFramework
|
||||
groupHeader->setToolTip(groupDescription.c_str());
|
||||
m_ui->m_groupContentsLayout->addWidget(groupHeader);
|
||||
|
||||
groupWidget->setObjectName(groupNameId.c_str());
|
||||
groupWidget->setObjectName(groupName.c_str());
|
||||
groupWidget->setParent(m_ui->m_groupContents);
|
||||
m_ui->m_groupContentsLayout->addWidget(groupWidget);
|
||||
|
||||
m_groups[groupNameId] = {groupHeader, groupWidget};
|
||||
m_groups[groupName] = {groupHeader, groupWidget};
|
||||
|
||||
connect(groupHeader, &InspectorGroupHeaderWidget::clicked, this, [this, groupNameId](QMouseEvent* event) {
|
||||
OnHeaderClicked(groupNameId, event);
|
||||
connect(groupHeader, &InspectorGroupHeaderWidget::clicked, this, [this, groupName](QMouseEvent* event) {
|
||||
OnHeaderClicked(groupName, event);
|
||||
});
|
||||
connect(groupHeader, &InspectorGroupHeaderWidget::expanded, this, [this, groupNameId]() { OnGroupExpanded(groupNameId); });
|
||||
connect(groupHeader, &InspectorGroupHeaderWidget::collapsed, this, [this, groupNameId]() { OnGroupCollapsed(groupNameId); });
|
||||
connect(groupHeader, &InspectorGroupHeaderWidget::expanded, this, [this, groupName]() { OnGroupExpanded(groupName); });
|
||||
connect(groupHeader, &InspectorGroupHeaderWidget::collapsed, this, [this, groupName]() { OnGroupCollapsed(groupName); });
|
||||
|
||||
if (ShouldGroupAutoExpanded(groupNameId))
|
||||
if (ShouldGroupAutoExpanded(groupName))
|
||||
{
|
||||
ExpandGroup(groupNameId);
|
||||
ExpandGroup(groupName);
|
||||
}
|
||||
else
|
||||
{
|
||||
CollapseGroup(groupNameId);
|
||||
CollapseGroup(groupName);
|
||||
}
|
||||
}
|
||||
|
||||
void InspectorWidget::SetGroupVisible(const AZStd::string& groupNameId, bool visible)
|
||||
void InspectorWidget::SetGroupVisible(const AZStd::string& groupName, bool visible)
|
||||
{
|
||||
auto groupItr = m_groups.find(groupNameId);
|
||||
auto groupItr = m_groups.find(groupName);
|
||||
if (groupItr != m_groups.end())
|
||||
{
|
||||
groupItr->second.m_header->setVisible(visible);
|
||||
@@ -108,29 +108,29 @@ namespace AtomToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
bool InspectorWidget::IsGroupVisible(const AZStd::string& groupNameId) const
|
||||
bool InspectorWidget::IsGroupVisible(const AZStd::string& groupName) const
|
||||
{
|
||||
auto groupItr = m_groups.find(groupNameId);
|
||||
auto groupItr = m_groups.find(groupName);
|
||||
return groupItr != m_groups.end() ? groupItr->second.m_header->isVisible() : false;
|
||||
}
|
||||
|
||||
bool InspectorWidget::IsGroupHidden(const AZStd::string& groupNameId) const
|
||||
bool InspectorWidget::IsGroupHidden(const AZStd::string& groupName) const
|
||||
{
|
||||
auto groupItr = m_groups.find(groupNameId);
|
||||
auto groupItr = m_groups.find(groupName);
|
||||
return groupItr != m_groups.end() ? groupItr->second.m_header->isHidden() : false;
|
||||
}
|
||||
|
||||
void InspectorWidget::RefreshGroup(const AZStd::string& groupNameId)
|
||||
void InspectorWidget::RefreshGroup(const AZStd::string& groupName)
|
||||
{
|
||||
for (auto groupWidget : m_ui->m_groupContents->findChildren<InspectorGroupWidget*>(groupNameId.c_str()))
|
||||
for (auto groupWidget : m_ui->m_groupContents->findChildren<InspectorGroupWidget*>(groupName.c_str()))
|
||||
{
|
||||
groupWidget->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void InspectorWidget::RebuildGroup(const AZStd::string& groupNameId)
|
||||
void InspectorWidget::RebuildGroup(const AZStd::string& groupName)
|
||||
{
|
||||
for (auto groupWidget : m_ui->m_groupContents->findChildren<InspectorGroupWidget*>(groupNameId.c_str()))
|
||||
for (auto groupWidget : m_ui->m_groupContents->findChildren<InspectorGroupWidget*>(groupName.c_str()))
|
||||
{
|
||||
groupWidget->Rebuild();
|
||||
}
|
||||
@@ -152,9 +152,9 @@ namespace AtomToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void InspectorWidget::ExpandGroup(const AZStd::string& groupNameId)
|
||||
void InspectorWidget::ExpandGroup(const AZStd::string& groupName)
|
||||
{
|
||||
auto groupItr = m_groups.find(groupNameId);
|
||||
auto groupItr = m_groups.find(groupName);
|
||||
if (groupItr != m_groups.end())
|
||||
{
|
||||
groupItr->second.m_header->SetExpanded(true);
|
||||
@@ -162,9 +162,9 @@ namespace AtomToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void InspectorWidget::CollapseGroup(const AZStd::string& groupNameId)
|
||||
void InspectorWidget::CollapseGroup(const AZStd::string& groupName)
|
||||
{
|
||||
auto groupItr = m_groups.find(groupNameId);
|
||||
auto groupItr = m_groups.find(groupName);
|
||||
if (groupItr != m_groups.end())
|
||||
{
|
||||
groupItr->second.m_header->SetExpanded(false);
|
||||
@@ -172,9 +172,9 @@ namespace AtomToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
bool InspectorWidget::IsGroupExpanded(const AZStd::string& groupNameId) const
|
||||
bool InspectorWidget::IsGroupExpanded(const AZStd::string& groupName) const
|
||||
{
|
||||
auto groupItr = m_groups.find(groupNameId);
|
||||
auto groupItr = m_groups.find(groupName);
|
||||
return groupItr != m_groups.end() ? groupItr->second.m_header->IsExpanded() : false;
|
||||
}
|
||||
|
||||
@@ -196,33 +196,33 @@ namespace AtomToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
bool InspectorWidget::ShouldGroupAutoExpanded(const AZStd::string& groupNameId) const
|
||||
bool InspectorWidget::ShouldGroupAutoExpanded(const AZStd::string& groupName) const
|
||||
{
|
||||
AZ_UNUSED(groupNameId);
|
||||
AZ_UNUSED(groupName);
|
||||
return true;
|
||||
}
|
||||
|
||||
void InspectorWidget::OnGroupExpanded(const AZStd::string& groupNameId)
|
||||
void InspectorWidget::OnGroupExpanded(const AZStd::string& groupName)
|
||||
{
|
||||
AZ_UNUSED(groupNameId);
|
||||
AZ_UNUSED(groupName);
|
||||
}
|
||||
|
||||
void InspectorWidget::OnGroupCollapsed(const AZStd::string& groupNameId)
|
||||
void InspectorWidget::OnGroupCollapsed(const AZStd::string& groupName)
|
||||
{
|
||||
AZ_UNUSED(groupNameId);
|
||||
AZ_UNUSED(groupName);
|
||||
}
|
||||
|
||||
void InspectorWidget::OnHeaderClicked(const AZStd::string& groupNameId, QMouseEvent* event)
|
||||
void InspectorWidget::OnHeaderClicked(const AZStd::string& groupName, QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::MouseButton::LeftButton)
|
||||
{
|
||||
if (!IsGroupExpanded(groupNameId))
|
||||
if (!IsGroupExpanded(groupName))
|
||||
{
|
||||
ExpandGroup(groupNameId);
|
||||
ExpandGroup(groupName);
|
||||
}
|
||||
else
|
||||
{
|
||||
CollapseGroup(groupNameId);
|
||||
CollapseGroup(groupName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -230,8 +230,8 @@ namespace AtomToolsFramework
|
||||
if (event->button() == Qt::MouseButton::RightButton)
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction("Expand", [this, groupNameId]() { ExpandGroup(groupNameId); })->setEnabled(!IsGroupExpanded(groupNameId));
|
||||
menu.addAction("Collapse", [this, groupNameId]() { CollapseGroup(groupNameId); })->setEnabled(IsGroupExpanded(groupNameId));
|
||||
menu.addAction("Expand", [this, groupName]() { ExpandGroup(groupName); })->setEnabled(!IsGroupExpanded(groupName));
|
||||
menu.addAction("Collapse", [this, groupName]() { CollapseGroup(groupName); })->setEnabled(IsGroupExpanded(groupName));
|
||||
menu.addAction("Expand All", [this]() { ExpandAll(); });
|
||||
menu.addAction("Collapse All", [this]() { CollapseAll(); });
|
||||
menu.exec(event->globalPos());
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace AtomToolsFramework
|
||||
void ConvertToPropertyConfig(AtomToolsFramework::DynamicPropertyConfig& propertyConfig, const AZ::RPI::MaterialTypeSourceData::PropertyDefinition& propertyDefinition)
|
||||
{
|
||||
propertyConfig.m_dataType = ConvertToEditableType(propertyDefinition.m_dataType);
|
||||
propertyConfig.m_nameId = propertyDefinition.m_nameId;
|
||||
propertyConfig.m_name = propertyDefinition.m_name;
|
||||
propertyConfig.m_displayName = propertyDefinition.m_displayName;
|
||||
propertyConfig.m_description = propertyDefinition.m_description;
|
||||
propertyConfig.m_defaultValue = ConvertToEditableType(propertyDefinition.m_value);
|
||||
|
||||
Reference in New Issue
Block a user