From 91675e8dbbd0eb210161208e4a2d2dcd73eb7eae Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 25 May 2022 15:37:44 +0100 Subject: [PATCH] Improve sizing of custom format setcion and use splitter between sides --- qrenderdoc/Widgets/BufferFormatSpecifier.cpp | 23 +++++- qrenderdoc/Widgets/BufferFormatSpecifier.h | 3 + qrenderdoc/Widgets/BufferFormatSpecifier.ui | 73 ++++++++------------ 3 files changed, 54 insertions(+), 45 deletions(-) diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.cpp b/qrenderdoc/Widgets/BufferFormatSpecifier.cpp index 2eeda8e6b..b56c57f6c 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.cpp +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.cpp @@ -31,6 +31,7 @@ #include #include "Code/QRDUtils.h" #include "Code/ScintillaSyntax.h" +#include "Widgets/Extended/RDSplitter.h" #include "scintilla/include/SciLexer.h" #include "scintilla/include/qt/ScintillaEdit.h" #include "ui_BufferFormatSpecifier.h" @@ -125,7 +126,24 @@ BufferFormatSpecifier::BufferFormatSpecifier(QWidget *parent) formatText->annotationClearAll(); }); - ui->mainLayout->insertWidget(0, formatContainer); + QHBoxLayout *hbox = new QHBoxLayout(this); + hbox->setSpacing(0); + hbox->setContentsMargins(2, 2, 2, 2); + + QWidget *helpOrFormat = new QWidget(this); + helpOrFormat->setLayout(hbox); + + hbox->insertWidget(0, formatContainer); + hbox->insertWidget(1, ui->helpText); + + m_Splitter = new RDSplitter(Qt::Horizontal, this); + m_Splitter->setHandleWidth(12); + m_Splitter->setChildrenCollapsible(false); + + m_Splitter->addWidget(helpOrFormat); + m_Splitter->addWidget(ui->savedContainer); + + ui->formatGroup->layout()->addWidget(m_Splitter); ui->savedList->setItemDelegate(new FullEditorDelegate(ui->savedList)); ui->savedList->setFont(Formatter::PreferredFont()); @@ -346,6 +364,9 @@ void BufferFormatSpecifier::on_showHelp_toggled(bool help) { ui->helpText->setVisible(help); formatText->parentWidget()->setVisible(!help); + + if(help) + ui->verticalLayout->invalidate(); } void BufferFormatSpecifier::on_loadDef_clicked() diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.h b/qrenderdoc/Widgets/BufferFormatSpecifier.h index 3344b34cb..9a4120d1f 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.h +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.h @@ -31,6 +31,7 @@ struct ICaptureContext; class ScintillaEdit; class RDTreeWidgetItem; +class RDSplitter; namespace Ui { @@ -98,5 +99,7 @@ private: ScintillaEdit *formatText; + RDSplitter *m_Splitter = NULL; + QString m_AutoFormat; }; diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.ui b/qrenderdoc/Widgets/BufferFormatSpecifier.ui index a533238a3..5f2e0d937 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.ui +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.ui @@ -6,8 +6,8 @@ 0 0 - 800 - 600 + 625 + 395 @@ -40,21 +40,21 @@ Format - + - 2 + 0 - 2 + 0 - 2 + 0 - 2 + 0 - 2 + 0 @@ -65,13 +65,13 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Exhaustive documentation can be found in the </span><a href="https://renderdoc.org/docs/how/how_buffer_format.html"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">online docs</span></a><span style=" font-size:8pt;">.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Buffer format declarations are similar to HLSL or GLSL struct definitions with normal vector, matrix and base types (e.g. <code>float</code>, <code>float4</code> or <code>vec4</code>, etc). In many cases these can be copied and pasted from shader source.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Buffer format declarations are similar to HLSL or GLSL struct definitions with normal vector, matrix and base types (e.g. </span><span style=" font-family:'Courier New'; font-size:8pt;">float</span><span style=" font-size:8pt;">, </span><span style=" font-family:'Courier New'; font-size:8pt;">float4</span><span style=" font-size:8pt;"> or </span><span style=" font-family:'Courier New'; font-size:8pt;">vec4</span><span style=" font-size:8pt;">, etc). In many cases these can be copied and pasted from shader source.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You can define and use structs. The buffer format is defined by all global variables. If there are no globals defined, the last struct defined will be used.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Most types that can be declared in shaders can be used, including half, short, as well as the usual int, float. All of these can be matrices or arrays.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Packing/padding rules can be specified with <code>#pack(rules)</code>. Supported D3D rules: <code>cbuffer</code>, <code>uav</code>. Supported GL/VK rules: <code>std140</code>, <code>std430</code>, <code>scalar</code>.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Packing/padding rules can be specified with </span><span style=" font-family:'Courier New'; font-size:8pt;">#pack(rules)</span><span style=" font-size:8pt;">. Supported D3D rules: </span><span style=" font-family:'Courier New'; font-size:8pt;">cbuffer</span><span style=" font-size:8pt;">, </span><span style=" font-family:'Courier New'; font-size:8pt;">uav</span><span style=" font-size:8pt;">. Supported GL/VK rules: </span><span style=" font-family:'Courier New'; font-size:8pt;">std140</span><span style=" font-size:8pt;">, </span><span style=" font-family:'Courier New'; font-size:8pt;">std430</span><span style=" font-size:8pt;">, </span><span style=" font-family:'Courier New'; font-size:8pt;">scalar</span><span style=" font-size:8pt;">.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Bitfields are supported using C syntax, enums can be defined but all enum values must have explicit decimal or hexadecimal numerical values.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p> @@ -84,42 +84,42 @@ p, li { white-space: pre-wrap; } - - - 0 - 0 - - 2 - 0 + 2 - 0 + 2 - 0 + 2 - 0 + 2 - - - 0 - 0 - - Qt::ScrollBarAlwaysOff QAbstractScrollArea::AdjustIgnored + + QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + false + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + 0 @@ -129,21 +129,6 @@ p, li { white-space: pre-wrap; } false - - false - - - QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - @@ -177,12 +162,12 @@ p, li { white-space: pre-wrap; } Qt::Horizontal - QSizePolicy::Preferred + QSizePolicy::Expanding - 100 - 20 + 0 + 0