mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 17:40:39 +00:00
Display resources in shader viewer tooltips properly
This commit is contained in:
@@ -812,6 +812,18 @@ bool RichResourceTextMouseEvent(const QWidget *owner, const QVariant &var, QRect
|
||||
return false;
|
||||
}
|
||||
|
||||
QString RichResourceTextFormat(ICaptureContext &ctx, QVariant var)
|
||||
{
|
||||
RichResourceTextInitialise(var);
|
||||
if(var.userType() == qMetaTypeId<ResourceId>())
|
||||
return GetTruncatedResourceName(ctx, var.value<ResourceId>());
|
||||
|
||||
// either it's something else and wasn't rich resource, in which case just return the string
|
||||
// representation, or it's a fully formatted rich resource document, where the cached text will do
|
||||
// the trick with ResIdTextToString.
|
||||
return var.toString();
|
||||
}
|
||||
|
||||
RichTextViewDelegate::RichTextViewDelegate(QAbstractItemView *parent)
|
||||
: m_widget(parent), ForwardingDelegate(parent)
|
||||
{
|
||||
|
||||
@@ -204,6 +204,10 @@ int RichResourceTextWidthHint(const QWidget *owner, const QFont &font, const QVa
|
||||
bool RichResourceTextMouseEvent(const QWidget *owner, const QVariant &var, QRect rect,
|
||||
const QFont &font, QMouseEvent *event);
|
||||
|
||||
// immediately format a variant that may contain rich resource text. For use in places where we
|
||||
// can't paint rich resource text but we still want to display the string nicely
|
||||
QString RichResourceTextFormat(ICaptureContext &ctx, QVariant var);
|
||||
|
||||
// Register runtime conversions for custom Qt metatypes
|
||||
void RegisterMetatypeConversions();
|
||||
|
||||
|
||||
@@ -3902,11 +3902,21 @@ void ShaderViewer::updateVariableTooltip()
|
||||
|
||||
if(var.type != VarType::Unknown)
|
||||
{
|
||||
QString tooltip = QFormatStr("<pre>%1: %2\n").arg(var.name).arg(RowString(var, 0));
|
||||
QString spacing = QString(var.name.count(), QLatin1Char(' '));
|
||||
for(int i = 1; i < var.rows; i++)
|
||||
tooltip += QFormatStr("%1 %2\n").arg(spacing).arg(RowString(var, i));
|
||||
tooltip += lit("</pre>");
|
||||
QString tooltip;
|
||||
|
||||
if(var.type == VarType::ReadOnlyResource || var.type == VarType::ReadWriteResource)
|
||||
{
|
||||
tooltip = RichResourceTextFormat(m_Ctx, stringRep(var, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltip = QFormatStr("<pre>%1: %2\n").arg(var.name).arg(RowString(var, 0));
|
||||
QString spacing = QString(var.name.count(), QLatin1Char(' '));
|
||||
for(int i = 1; i < var.rows; i++)
|
||||
tooltip += QFormatStr("%1 %2\n").arg(spacing).arg(RowString(var, i));
|
||||
tooltip += lit("</pre>");
|
||||
}
|
||||
|
||||
QToolTip::showText(m_TooltipPos, tooltip);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user