Tweak the event browser to support richtext in drawcall names

* This lets Resource ID text become links to the resource inspector even
  in drawcall names (like glBlitFramebuffer(src, dst)).
This commit is contained in:
baldurk committed 2018-02-13 21:10:06 +00:00
1 parent 8b66e3dcd9
commit cad5520238
3 files changed
+53 -5

No files matched your search

+2
View File
@@ -283,6 +283,8 @@ void RichResourceTextPaint(const QWidget *owner, QPainter *painter, QRect rect,
blockrect.translate(0.0, -2.0);
blockrect.setRight(qMin(blockrect.right(), (qreal)rect.width()));
painter->drawLine(blockrect.bottomLeft(), blockrect.bottomRight());
}
}
+45 -3
View File
@@ -599,7 +599,21 @@ void RDTreeWidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
painter->save();
RichResourceTextPaint(m_widget, painter, option.rect, option.font, option.palette,
QRect rect = option.rect;
if(!opt.icon.isNull())
{
QIcon::Mode mode;
if((opt.state & QStyle::State_Enabled) == 0)
mode = QIcon::Disabled;
else if(opt.state & QStyle::State_Selected)
mode = QIcon::Selected;
else
mode = QIcon::Normal;
QIcon::State state = opt.state & QStyle::State_Open ? QIcon::On : QIcon::Off;
rect.setX(rect.x() + opt.icon.actualSize(opt.decorationSize, mode, state).width());
}
RichResourceTextPaint(m_widget, painter, rect, option.font, option.palette,
option.state & QStyle::State_MouseOver,
m_widget->viewport()->mapFromGlobal(QCursor::pos()), v);
@@ -645,8 +659,23 @@ bool RDTreeWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
if(RichResourceTextCheck(v))
{
QRect rect = option.rect;
if(!item->m_icons[index.column()].isNull())
{
QIcon::Mode mode;
if((option.state & QStyle::State_Enabled) == 0)
mode = QIcon::Disabled;
else if(option.state & QStyle::State_Selected)
mode = QIcon::Selected;
else
mode = QIcon::Normal;
QIcon::State state = option.state & QStyle::State_Open ? QIcon::On : QIcon::Off;
rect.setX(rect.x() + option.icon.actualSize(option.decorationSize, mode, state).width());
}
// ignore the return value, we always consume clicks on this cell
RichResourceTextMouseEvent(m_widget, v, option.rect, (QMouseEvent *)event);
RichResourceTextMouseEvent(m_widget, v, rect, (QMouseEvent *)event);
return true;
}
}
@@ -666,7 +695,20 @@ bool RDTreeWidgetDelegate::linkHover(QMouseEvent *e, const QModelIndex &index)
QVariant v = item->m_text[index.column()];
if(RichResourceTextCheck(v))
return RichResourceTextMouseEvent(m_widget, v, m_widget->visualRect(index), e);
{
QRect rect = m_widget->visualRect(index);
QIcon icon = item->m_icons[index.column()];
if(!icon.isNull())
{
rect.setX(
rect.x() +
icon.actualSize(QSize(rect.height(), rect.height()), QIcon::Normal, QIcon::On).width());
}
return RichResourceTextMouseEvent(m_widget, v, rect, e);
}
}
}
+6 -2
View File
@@ -91,7 +91,7 @@ EventBrowser::EventBrowser(ICaptureContext &ctx, QWidget *parent)
ui->events->header()->setCascadingSectionResizes(false);
ui->events->setItemVerticalMargin(3);
ui->events->setItemVerticalMargin(4);
ui->events->setIgnoreIconSize(true);
// set up default section layout. This will be overridden in restoreState()
@@ -253,8 +253,12 @@ QPair<uint32_t, uint32_t> EventBrowser::AddDrawcalls(RDTreeWidgetItem *parent,
{
const DrawcallDescription &d = draws[i];
QVariant name = QString(d.name);
RichResourceTextInitialise(name);
RDTreeWidgetItem *child = new RDTreeWidgetItem(
{d.name, QString::number(d.eventId), QString::number(d.drawcallId), lit("---")});
{name, QString::number(d.eventId), QString::number(d.drawcallId), lit("---")});
QPair<uint32_t, uint32_t> last = AddDrawcalls(child, d.children);
lastEID = last.first;