From a71a5746ccd6734a68b8c592cab757879993301f Mon Sep 17 00:00:00 2001 From: sphrose <82213493+sphrose@users.noreply.github.com> Date: Tue, 13 Apr 2021 17:15:10 +0100 Subject: [PATCH] [LY-113714] Jira: LY-113714 https://jira.agscollab.com/browse/LY-113714 --- .../Serialization/EditContextConstants.inl | 2 + .../Components/img/UI20/line.svg | 7 ++++ .../AzQtComponents/Components/resources.qrc | 1 + .../UI/PropertyEditor/PropertyRowWidget.cpp | 37 ++++++++++++++++++- .../UI/PropertyEditor/PropertyRowWidget.hxx | 8 ++++ Code/Sandbox/Editor/Style/Editor.qss | 5 +++ Gems/Vegetation/Code/Source/Descriptor.cpp | 2 + 7 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg diff --git a/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl b/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl index d4658d4e8c..de67013741 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl +++ b/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl @@ -62,6 +62,8 @@ namespace AZ const static AZ::Crc32 ButtonTooltip = AZ_CRC("ButtonTooltip", 0x1605a7d2); const static AZ::Crc32 CheckboxTooltip = AZ_CRC("CheckboxTooltip", 0x1159eb78); const static AZ::Crc32 CheckboxDefaultValue = AZ_CRC("CheckboxDefaultValue", 0x03f117e6); + //! Emboldens the text and adds a line above this item within the RPE. + const static AZ::Crc32 RPESectionSeparator = AZ_CRC("RPESectionSeparator", 0xc6249a95); //! Affects the display order of a node relative to it's parent/children. Higher values display further down (after) lower values. Default is 0, negative values are allowed. Must be applied as an attribute to the EditorData element const static AZ::Crc32 DisplayOrder = AZ_CRC("DisplayOrder", 0x23660ec2); //! Specifies whether the UI should support multi-edit for aggregate instances of this property diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg new file mode 100644 index 0000000000..60f7c07c8d --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg @@ -0,0 +1,7 @@ + + + line + + + + \ No newline at end of file diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc index 77dead96a1..decc1bd72f 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc @@ -627,6 +627,7 @@ img/UI20/Settings.svg img/UI20/Asset_Folder.svg img/UI20/Asset_File.svg + img/UI20/line.svg img/UI20/AssetEditor/default_document.svg diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp index 8c371baf8c..a16c1f7480 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp @@ -44,6 +44,24 @@ namespace AzToolsFramework m_iconOpen = s_iconOpen; m_iconClosed = s_iconClosed; + m_outerLayout = new QVBoxLayout(nullptr); + m_outerLayout->setSpacing(0); + m_outerLayout->setContentsMargins(0, 0, 0, 0); + + // separatorLayout will contain a spacer and a separator line. The width of the spacer is adjusted later to ensure the line is the + // correct length. + QHBoxLayout* separatorLayout = new QHBoxLayout(nullptr); + m_outerLayout->addLayout(separatorLayout); + + m_separatorIndent = new QSpacerItem(1, 1); + separatorLayout->addItem(m_separatorIndent); + + m_separatorLine.load(QStringLiteral(":/Gallery/line.svg")); + m_separatorLine.setFixedHeight(3); + + separatorLayout->addWidget(&m_separatorLine); + m_separatorLine.setVisible(false); + m_mainLayout = new QHBoxLayout(); m_mainLayout->setSpacing(0); m_mainLayout->setContentsMargins(0, 1, 0, 1); @@ -118,7 +136,8 @@ namespace AzToolsFramework m_handler = nullptr; m_containerSize = 0; - setLayout(m_mainLayout); + m_outerLayout->addLayout(m_mainLayout); + setLayout(m_outerLayout); } bool PropertyRowWidget::HasChildWidgetAlready() const @@ -301,6 +320,9 @@ namespace AzToolsFramework } } + m_isSectionSeparator = false; + m_separatorLine.setVisible(false); + RefreshAttributesFromNode(true); // --------------------- HANDLER discovery: @@ -946,6 +968,11 @@ namespace AzToolsFramework { HandleChangeNotifyAttribute(reader, m_sourceNode ? m_sourceNode->GetParent() : nullptr, m_editingCompleteNotifiers); } + else if (attributeName == AZ::Edit::Attributes::RPESectionSeparator) + { + m_separatorLine.setVisible(true); + m_isSectionSeparator = true; + } } void PropertyRowWidget::SetReadOnlyQueryFunction(const ReadOnlyQueryFunction& readOnlyQueryFunction) @@ -1070,6 +1097,7 @@ namespace AzToolsFramework { m_dropDownArrow->hide(); } + m_separatorIndent->changeSize((m_treeDepth * m_treeIndentation) + m_leafIndentation, 1, QSizePolicy::Fixed, QSizePolicy::Fixed); m_indent->changeSize((m_treeDepth * m_treeIndentation) + m_leafIndentation, 1, QSizePolicy::Fixed, QSizePolicy::Fixed); m_leftHandSideLayout->invalidate(); m_leftHandSideLayout->update(); @@ -1085,6 +1113,7 @@ namespace AzToolsFramework connect(m_dropDownArrow, &QCheckBox::clicked, this, &PropertyRowWidget::OnClickedExpansionButton); } m_dropDownArrow->show(); + m_separatorIndent->changeSize((m_treeDepth * m_treeIndentation), 1, QSizePolicy::Fixed, QSizePolicy::Fixed); m_indent->changeSize((m_treeDepth * m_treeIndentation), 1, QSizePolicy::Fixed, QSizePolicy::Fixed); m_leftHandSideLayout->invalidate(); m_leftHandSideLayout->update(); @@ -1095,6 +1124,7 @@ namespace AzToolsFramework void PropertyRowWidget::SetIndentSize(int w) { + m_separatorIndent->changeSize(w, 1, QSizePolicy::Fixed, QSizePolicy::Fixed); m_indent->changeSize(w, 1, QSizePolicy::Fixed, QSizePolicy::Fixed); m_leftHandSideLayout->invalidate(); m_leftHandSideLayout->update(); @@ -1318,6 +1348,11 @@ namespace AzToolsFramework return canBeTopLevel(this); } + bool PropertyRowWidget::IsSectionSeparator() const + { + return m_isSectionSeparator; + } + bool PropertyRowWidget::GetAppendDefaultLabelToName() { return false; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx index e4b538ccdc..af1b68b66f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx @@ -25,6 +25,7 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // class '...' needs t #include #include #include +#include #include AZ_POP_DISABLE_WARNING @@ -44,6 +45,7 @@ namespace AzToolsFramework Q_PROPERTY(bool hasChildRows READ HasChildRows); Q_PROPERTY(bool isTopLevel READ IsTopLevel); Q_PROPERTY(int getLevel READ GetLevel); + Q_PROPERTY(bool isSectionSeparator READ IsSectionSeparator); Q_PROPERTY(bool appendDefaultLabelToName READ GetAppendDefaultLabelToName WRITE AppendDefaultLabelToName) public: AZ_CLASS_ALLOCATOR(PropertyRowWidget, AZ::SystemAllocator, 0) @@ -82,6 +84,7 @@ namespace AzToolsFramework PropertyRowWidget* GetParentRow() const { return m_parentRow; } int GetLevel() const; bool IsTopLevel() const; + bool IsSectionSeparator() const; // Remove the default label and append the text to the name label. bool GetAppendDefaultLabelToName(); @@ -161,6 +164,9 @@ namespace AzToolsFramework QHBoxLayout* m_leftHandSideLayout; QHBoxLayout* m_middleLayout; QHBoxLayout* m_rightHandSideLayout; + QVBoxLayout* m_outerLayout; + QSvgWidget m_separatorLine; + QSpacerItem* m_separatorIndent; QPointer m_dropDownArrow; QPointer m_containerClearButton; @@ -229,6 +235,8 @@ namespace AzToolsFramework int m_treeIndentation = 14; int m_leafIndentation = 16; + bool m_isSectionSeparator = false; + QIcon m_iconOpen; QIcon m_iconClosed; diff --git a/Code/Sandbox/Editor/Style/Editor.qss b/Code/Sandbox/Editor/Style/Editor.qss index 0c3f64b85c..7887560105 100644 --- a/Code/Sandbox/Editor/Style/Editor.qss +++ b/Code/Sandbox/Editor/Style/Editor.qss @@ -38,6 +38,11 @@ AzToolsFramework--ComponentPaletteWidget > QTreeView background-color: #222222; } +AzToolsFramework--PropertyRowWidget[isSectionSeparator="true"] QLabel#Name +{ + font-weight: bold; +} + /* Style for visualizing property values overridden from their prefab values */ AzToolsFramework--PropertyRowWidget[IsOverridden=true] #Name QLabel, AzToolsFramework--ComponentEditorHeader #Title[IsOverridden="true"] diff --git a/Gems/Vegetation/Code/Source/Descriptor.cpp b/Gems/Vegetation/Code/Source/Descriptor.cpp index 93a301f073..4fd1037f09 100644 --- a/Gems/Vegetation/Code/Source/Descriptor.cpp +++ b/Gems/Vegetation/Code/Source/Descriptor.cpp @@ -170,6 +170,8 @@ namespace Vegetation { edit->Class( "Vegetation Descriptor", "Details used to create vegetation instances") + ->ClassElement(AZ::Edit::ClassElements::EditorData, "") + ->Attribute(AZ::Edit::Attributes::RPESectionSeparator, true) // For this ComboBox to actually work, there is a PropertyHandler registration in EditorVegetationSystemComponent.cpp ->DataElement(AZ::Edit::UIHandlers::ComboBox, &Descriptor::m_spawnerType, "Instance Spawner", "The type of instances to spawn") ->Attribute(AZ::Edit::Attributes::GenericValueList, &Descriptor::GetSpawnerTypeList)