mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-29 01:46:38 +00:00
Add custom painting and section handling to RDTableView & RDHeaderView
* This is used primarily for the buffer/mesh viewer to be able to pin the index/element column to the left side, group columns together with a noticeable separator, and other minor tweaks. * Unfortunately due to tight private coupling and lack of virtual functions in the QTableView and QHeaderView, a few unrelated functions have to be re-implemented to point to our own header.
This commit is contained in:
@@ -357,6 +357,8 @@ uint32_t CalcIndex(BufferData *data, uint32_t vertID, int32_t baseVertex)
|
||||
return idx;
|
||||
}
|
||||
|
||||
static int columnGroupRole = Qt::UserRole + 10000;
|
||||
|
||||
class BufferItemModel : public QAbstractItemModel
|
||||
{
|
||||
public:
|
||||
@@ -396,26 +398,29 @@ public:
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
|
||||
{
|
||||
if(section < m_ColumnCount && orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||
if(section < m_ColumnCount && orientation == Qt::Horizontal)
|
||||
{
|
||||
if(section == 0)
|
||||
if(role == Qt::DisplayRole || role == columnGroupRole)
|
||||
{
|
||||
return meshView ? lit("VTX") : lit("Element");
|
||||
}
|
||||
else if(section == 1 && meshView)
|
||||
{
|
||||
return lit("IDX");
|
||||
}
|
||||
else
|
||||
{
|
||||
const FormatElement &el = elementForColumn(section);
|
||||
if(section == 0)
|
||||
{
|
||||
return meshView ? lit("VTX") : lit("Element");
|
||||
}
|
||||
else if(section == 1 && meshView)
|
||||
{
|
||||
return lit("IDX");
|
||||
}
|
||||
else
|
||||
{
|
||||
const FormatElement &el = elementForColumn(section);
|
||||
|
||||
if(el.format.compCount == 1)
|
||||
return el.name;
|
||||
if(el.format.compCount == 1 || role == columnGroupRole)
|
||||
return el.name;
|
||||
|
||||
QChar comps[] = {QLatin1Char('x'), QLatin1Char('y'), QLatin1Char('z'), QLatin1Char('w')};
|
||||
QChar comps[] = {QLatin1Char('x'), QLatin1Char('y'), QLatin1Char('z'), QLatin1Char('w')};
|
||||
|
||||
return QFormatStr("%1.%2").arg(el.name).arg(comps[componentForIndex(section)]);
|
||||
return QFormatStr("%1.%2").arg(el.name).arg(comps[componentForIndex(section)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,6 +453,14 @@ public:
|
||||
uint32_t row = index.row();
|
||||
int col = index.column();
|
||||
|
||||
if(role == columnGroupRole)
|
||||
{
|
||||
if(col < reservedColumnCount())
|
||||
return -1 - col;
|
||||
else
|
||||
return columnLookup[col - reservedColumnCount()];
|
||||
}
|
||||
|
||||
if((role == Qt::BackgroundRole || role == Qt::ForegroundRole) && col >= reservedColumnCount())
|
||||
{
|
||||
if(meshView)
|
||||
@@ -1088,6 +1101,9 @@ void BufferViewer::SetupRawView()
|
||||
ui->dockarea->addToolWindow(ui->vsinData, ToolWindowManager::EmptySpace);
|
||||
ui->dockarea->setToolWindowProperties(ui->vsinData, ToolWindowManager::HideCloseButton);
|
||||
|
||||
ui->vsinData->setPinnedColumns(1);
|
||||
ui->vsinData->setColumnGroupRole(columnGroupRole);
|
||||
|
||||
ui->formatSpecifier->setWindowTitle(tr("Buffer Format"));
|
||||
ui->dockarea->addToolWindow(ui->formatSpecifier, ToolWindowManager::AreaReference(
|
||||
ToolWindowManager::BottomOf,
|
||||
@@ -1191,6 +1207,14 @@ void BufferViewer::SetupMeshView()
|
||||
ui->vsoutData->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->gsoutData->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
ui->vsinData->setPinnedColumns(2);
|
||||
ui->vsoutData->setPinnedColumns(2);
|
||||
ui->gsoutData->setPinnedColumns(2);
|
||||
|
||||
ui->vsinData->setColumnGroupRole(columnGroupRole);
|
||||
ui->vsoutData->setColumnGroupRole(columnGroupRole);
|
||||
ui->gsoutData->setColumnGroupRole(columnGroupRole);
|
||||
|
||||
QObject::connect(ui->vsinData->horizontalHeader(), &QHeaderView::customContextMenuRequested,
|
||||
[this](const QPoint &pos) { meshHeaderMenu(MeshDataStage::VSIn, pos); });
|
||||
QObject::connect(ui->vsoutData->horizontalHeader(), &QHeaderView::customContextMenuRequested,
|
||||
@@ -2307,17 +2331,21 @@ void BufferViewer::ApplyRowAndColumnDims(int numColumns, RDTableView *view)
|
||||
{
|
||||
int start = 0;
|
||||
|
||||
QList<int> widths;
|
||||
|
||||
// vertex/element
|
||||
view->setColumnWidth(start++, m_IdxColWidth);
|
||||
widths << m_IdxColWidth;
|
||||
|
||||
// mesh view only - index
|
||||
if(m_MeshView)
|
||||
view->setColumnWidth(start++, m_IdxColWidth);
|
||||
widths << m_IdxColWidth;
|
||||
|
||||
for(int i = start; i < numColumns; i++)
|
||||
view->setColumnWidth(i, m_DataColWidth);
|
||||
widths << m_DataColWidth;
|
||||
|
||||
view->verticalHeader()->setDefaultSectionSize(m_DataRowHeight);
|
||||
|
||||
view->setColumnWidths(widths);
|
||||
}
|
||||
|
||||
void BufferViewer::UpdateMeshConfig()
|
||||
|
||||
Reference in New Issue
Block a user