Changed to use direct line drawing rather than adding svg.

This commit is contained in:
sphrose
2021-04-19 15:54:41 +01:00
parent fece27b1b0
commit 2dbd9e4a05
3 changed files with 16 additions and 35 deletions
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="25px" height="3px" viewBox="0 0 25 3" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>line</title>
<g id="line" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<line x1="0" y1="1" x2="25" y2="1" id="Line-5" stroke="#3B3E3F"></line>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 382 B

@@ -27,6 +27,7 @@ AZ_PUSH_DISABLE_WARNING(4244 4251 4800, "-Wunknown-warning-option") // 4244: con
#include <QtGui/QTextLayout>
#include <QtGui/QPainter>
#include <QMessageBox>
#include <QStylePainter>
AZ_POP_DISABLE_WARNING
static const int LabelColumnStretch = 2;
@@ -44,24 +45,6 @@ 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);
@@ -136,8 +119,20 @@ namespace AzToolsFramework
m_handler = nullptr;
m_containerSize = 0;
m_outerLayout->addLayout(m_mainLayout);
setLayout(m_outerLayout);
setLayout(m_mainLayout);
}
void PropertyRowWidget::paintEvent(QPaintEvent* event)
{
QStylePainter p(this);
if (IsSectionSeparator())
{
const QPen linePen(QColor(0x3B3E3F));
p.setPen(linePen);
int indent = m_treeDepth * m_treeIndentation;
p.drawLine(event->rect().topLeft() + QPoint(indent, 0), event->rect().topRight());
}
}
bool PropertyRowWidget::HasChildWidgetAlready() const
@@ -321,7 +316,6 @@ namespace AzToolsFramework
}
m_isSectionSeparator = false;
m_separatorLine.setVisible(false);
RefreshAttributesFromNode(true);
@@ -970,7 +964,6 @@ namespace AzToolsFramework
}
else if (attributeName == AZ::Edit::Attributes::RPESectionSeparator)
{
m_separatorLine.setVisible(true);
m_isSectionSeparator = true;
}
}
@@ -1097,7 +1090,6 @@ 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();
@@ -1113,7 +1105,6 @@ 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();
@@ -1124,7 +1115,6 @@ 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();
@@ -129,6 +129,7 @@ namespace AzToolsFramework
void SetSelectionEnabled(bool selectionEnabled);
void SetSelected(bool selected);
bool eventFilter(QObject *watched, QEvent *event) override;
void paintEvent(QPaintEvent*) override;
/// Apply tooltip to widget and some of its children.
void SetDescription(const QString& text);
@@ -164,9 +165,6 @@ namespace AzToolsFramework
QHBoxLayout* m_leftHandSideLayout;
QHBoxLayout* m_middleLayout;
QHBoxLayout* m_rightHandSideLayout;
QVBoxLayout* m_outerLayout;
QSvgWidget m_separatorLine;
QSpacerItem* m_separatorIndent;
QPointer <QCheckBox> m_dropDownArrow;
QPointer <QToolButton> m_containerClearButton;