Fixed issues after merging latest main, as well as some edge cases I didn't notice before.
The structure of InspectorWidget::m_groups changed, so I had to update my new code accordingly. Updated the InspectorWidget::m_groups code a bit to be more readable. Discovered the initial property group visiblity state wasn't being set correctly when a material was first opened, so groups weren't initially hidden when they should have been. This had to be fixed in different ways for MaterialEditor's inspector and MaterialComponent's inspector. ATOM-14688 Disable Individual Layers
This commit is contained in:
+6
-1
@@ -47,8 +47,13 @@ namespace AtomToolsFramework
|
|||||||
//! Sets the visibility of a specific property group. This impacts both the header and the widget.
|
//! 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& groupNameId, bool visible) = 0;
|
||||||
|
|
||||||
//! Returns the visibility of a specific property group.
|
//! 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& groupNameId) 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;
|
||||||
|
|
||||||
//! Calls Refresh for a specific InspectorGroupWidget, allowing for non-destructive UI changes
|
//! 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& groupNameId) = 0;
|
||||||
|
|||||||
+9
-1
@@ -59,6 +59,7 @@ namespace AtomToolsFramework
|
|||||||
|
|
||||||
void SetGroupVisible(const AZStd::string& groupNameId, bool visible) override;
|
void SetGroupVisible(const AZStd::string& groupNameId, bool visible) override;
|
||||||
bool IsGroupVisible(const AZStd::string& groupNameId) const override;
|
bool IsGroupVisible(const AZStd::string& groupNameId) const override;
|
||||||
|
bool IsGroupHidden(const AZStd::string& groupNameId) const override;
|
||||||
|
|
||||||
void RefreshGroup(const AZStd::string& groupNameId) override;
|
void RefreshGroup(const AZStd::string& groupNameId) override;
|
||||||
void RebuildGroup(const AZStd::string& groupNameId) override;
|
void RebuildGroup(const AZStd::string& groupNameId) override;
|
||||||
@@ -82,6 +83,13 @@ namespace AtomToolsFramework
|
|||||||
private:
|
private:
|
||||||
QVBoxLayout* m_layout = nullptr;
|
QVBoxLayout* m_layout = nullptr;
|
||||||
QScopedPointer<Ui::InspectorWidget> m_ui;
|
QScopedPointer<Ui::InspectorWidget> m_ui;
|
||||||
AZStd::unordered_map<AZStd::string, AZStd::pair<InspectorGroupHeaderWidget*, QWidget*>> m_groups;
|
|
||||||
|
struct GroupWidgetPair
|
||||||
|
{
|
||||||
|
InspectorGroupHeaderWidget* m_header;
|
||||||
|
QWidget* m_panel;
|
||||||
|
};
|
||||||
|
|
||||||
|
AZStd::unordered_map<AZStd::string, GroupWidgetPair> m_groups;
|
||||||
};
|
};
|
||||||
} // namespace AtomToolsFramework
|
} // namespace AtomToolsFramework
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace AtomToolsFramework
|
|||||||
groupWidget->setParent(m_ui->m_propertyContent);
|
groupWidget->setParent(m_ui->m_propertyContent);
|
||||||
m_layout->addWidget(groupWidget);
|
m_layout->addWidget(groupWidget);
|
||||||
|
|
||||||
m_groups[groupNameId] = AZStd::make_pair(groupHeader, groupWidget);
|
m_groups[groupNameId] = {groupHeader, groupWidget};
|
||||||
|
|
||||||
connect(groupHeader, &InspectorGroupHeaderWidget::clicked, this, [this, groupNameId](QMouseEvent* event) {
|
connect(groupHeader, &InspectorGroupHeaderWidget::clicked, this, [this, groupNameId](QMouseEvent* event) {
|
||||||
OnHeaderClicked(groupNameId, event);
|
OnHeaderClicked(groupNameId, event);
|
||||||
@@ -95,25 +95,31 @@ namespace AtomToolsFramework
|
|||||||
|
|
||||||
void InspectorWidget::SetGroupVisible(const AZStd::string& groupNameId, bool visible)
|
void InspectorWidget::SetGroupVisible(const AZStd::string& groupNameId, bool visible)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_groups.size(); ++i)
|
auto groupItr = m_groups.find(groupNameId);
|
||||||
|
if (groupItr != m_groups.end())
|
||||||
{
|
{
|
||||||
if (m_groups[i]->objectName() == groupNameId.c_str())
|
groupItr->second.m_header->setVisible(visible);
|
||||||
{
|
groupItr->second.m_panel->setVisible(visible && groupItr->second.m_header->IsExpanded());
|
||||||
m_headers[i]->setVisible(visible);
|
|
||||||
m_groups[i]->setVisible(visible && m_headers[i]->IsExpanded());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InspectorWidget::IsGroupVisible(const AZStd::string& groupNameId) const
|
bool InspectorWidget::IsGroupVisible(const AZStd::string& groupNameId) const
|
||||||
{
|
{
|
||||||
for (auto& header : m_headers)
|
auto groupItr = m_groups.find(groupNameId);
|
||||||
|
if (groupItr != m_groups.end())
|
||||||
{
|
{
|
||||||
if (header->objectName() == groupNameId.c_str())
|
return groupItr->second.m_header->isVisible();
|
||||||
{
|
}
|
||||||
return header->isVisible();
|
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InspectorWidget::IsGroupHidden(const AZStd::string& groupNameId) const
|
||||||
|
{
|
||||||
|
auto groupItr = m_groups.find(groupNameId);
|
||||||
|
if (groupItr != m_groups.end())
|
||||||
|
{
|
||||||
|
return groupItr->second.m_header->isHidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -156,8 +162,8 @@ namespace AtomToolsFramework
|
|||||||
auto groupItr = m_groups.find(groupNameId);
|
auto groupItr = m_groups.find(groupNameId);
|
||||||
if (groupItr != m_groups.end())
|
if (groupItr != m_groups.end())
|
||||||
{
|
{
|
||||||
groupItr->second.first->SetExpanded(true);
|
groupItr->second.m_header->SetExpanded(true);
|
||||||
groupItr->second.second->setVisible(true);
|
groupItr->second.m_panel->setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,23 +172,23 @@ namespace AtomToolsFramework
|
|||||||
auto groupItr = m_groups.find(groupNameId);
|
auto groupItr = m_groups.find(groupNameId);
|
||||||
if (groupItr != m_groups.end())
|
if (groupItr != m_groups.end())
|
||||||
{
|
{
|
||||||
groupItr->second.first->SetExpanded(false);
|
groupItr->second.m_header->SetExpanded(false);
|
||||||
groupItr->second.second->setVisible(false);
|
groupItr->second.m_panel->setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InspectorWidget::IsGroupExpanded(const AZStd::string& groupNameId) const
|
bool InspectorWidget::IsGroupExpanded(const AZStd::string& groupNameId) const
|
||||||
{
|
{
|
||||||
auto groupItr = m_groups.find(groupNameId);
|
auto groupItr = m_groups.find(groupNameId);
|
||||||
return groupItr != m_groups.end() ? groupItr->second.first->IsExpanded() : false;
|
return groupItr != m_groups.end() ? groupItr->second.m_header->IsExpanded() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorWidget::ExpandAll()
|
void InspectorWidget::ExpandAll()
|
||||||
{
|
{
|
||||||
for (auto& groupPair : m_groups)
|
for (auto& groupPair : m_groups)
|
||||||
{
|
{
|
||||||
groupPair.second.first->SetExpanded(true);
|
groupPair.second.m_header->SetExpanded(true);
|
||||||
groupPair.second.second->setVisible(true);
|
groupPair.second.m_panel->setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,8 +196,8 @@ namespace AtomToolsFramework
|
|||||||
{
|
{
|
||||||
for (auto& groupPair : m_groups)
|
for (auto& groupPair : m_groups)
|
||||||
{
|
{
|
||||||
groupPair.second.first->SetExpanded(false);
|
groupPair.second.m_header->SetExpanded(false);
|
||||||
groupPair.second.second->setVisible(false);
|
groupPair.second.m_panel->setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -198,6 +198,11 @@ namespace MaterialEditor
|
|||||||
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId),
|
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId),
|
||||||
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
|
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
|
||||||
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupWidget);
|
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupWidget);
|
||||||
|
|
||||||
|
bool isGroupVisible = false;
|
||||||
|
MaterialDocumentRequestBus::EventResult(
|
||||||
|
isGroupVisible, m_documentId, &MaterialDocumentRequestBus::Events::IsPropertyGroupVisible, AZ::Name{groupNameId});
|
||||||
|
SetGroupVisible(groupNameId, isGroupVisible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -305,8 +305,11 @@ namespace AZ
|
|||||||
{
|
{
|
||||||
AZ::RPI::MaterialPropertyGroupDynamicMetadata& metadata = propertyGroupDynamicMetadata[AZ::Name{groupPair.first}];
|
AZ::RPI::MaterialPropertyGroupDynamicMetadata& metadata = propertyGroupDynamicMetadata[AZ::Name{groupPair.first}];
|
||||||
|
|
||||||
metadata.m_visibility = IsGroupVisible(groupPair.first) ?
|
// It's significant that we check IsGroupHidden rather than IsGroupVisisble, because it follows the same rules as QWidget::isHidden().
|
||||||
AZ::RPI::MaterialPropertyGroupVisibility::Enabled : AZ::RPI::MaterialPropertyGroupVisibility::Hidden;
|
// We don't care whether the widget and all its parents are visible, we only care about whether the group was hidden within the context
|
||||||
|
// of the material property inspector.
|
||||||
|
metadata.m_visibility = IsGroupHidden(groupPair.first) ?
|
||||||
|
AZ::RPI::MaterialPropertyGroupVisibility::Hidden : AZ::RPI::MaterialPropertyGroupVisibility::Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AZ::RPI::Ptr<AZ::RPI::MaterialFunctor>& functor : m_editorFunctors)
|
for (AZ::RPI::Ptr<AZ::RPI::MaterialFunctor>& functor : m_editorFunctors)
|
||||||
|
|||||||
Reference in New Issue
Block a user