mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
UI and Config support for dec/hex display option for Offsets or Sizes
Used when fields are marked as being an Offset or Size Include simple latch to trigger a UI refresh when closing the settings dialog. Currently only connected to if the Offset/Size format option is altered
This commit is contained in:
@@ -13,6 +13,9 @@ Config
|
||||
|
||||
.. autoclass:: qrenderdoc.TimeUnit
|
||||
:members:
|
||||
|
||||
.. autoclass:: qrenderdoc.OffsetSizeDisplayMode
|
||||
:members:
|
||||
|
||||
.. autofunction:: qrenderdoc.ConfigFilePath
|
||||
.. autofunction:: qrenderdoc.UnitSuffix
|
||||
|
||||
@@ -44,6 +44,18 @@ rdcstr DoStringise(const TimeUnit &el)
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
|
||||
template <>
|
||||
rdcstr DoStringise(const OffsetSizeDisplayMode &el)
|
||||
{
|
||||
BEGIN_ENUM_STRINGISE(OffsetSizeDisplayMode)
|
||||
{
|
||||
STRINGISE_ENUM_CLASS(Auto);
|
||||
STRINGISE_ENUM_CLASS(Decimal);
|
||||
STRINGISE_ENUM_CLASS(Hexadecimal);
|
||||
}
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
|
||||
#define JSON_ID "rdocConfigData"
|
||||
#define JSON_VER 1
|
||||
|
||||
|
||||
@@ -372,6 +372,16 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
"Defaults to ``7``."); \
|
||||
CONFIG_SETTING_VAL(public, int, int, Formatter_PosExp, 7) \
|
||||
\
|
||||
DOCUMENT( \
|
||||
"The formatting mode to use for values marked as Offsets or Sizes.\n" \
|
||||
"\n" \
|
||||
"E.g. Auto: decimal by default and hexadecimal if above a certain threshold, " \
|
||||
"Decimal: always use decimal, Hexadecimal: always use hexadecimal." \
|
||||
"\n" \
|
||||
"Defaults to ``Auto``."); \
|
||||
CONFIG_SETTING_VAL(public, int, OffsetSizeDisplayMode, Formatter_OffsetSizeDisplayMode, \
|
||||
OffsetSizeDisplayMode::Auto) \
|
||||
\
|
||||
DOCUMENT( \
|
||||
"The global scale to apply to fonts in the application, expressed as a float.\n" \
|
||||
"\n" \
|
||||
@@ -529,6 +539,30 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
DOCUMENT(""); \
|
||||
CONFIG_SETTING(private, QVariantList, rdcarray<RemoteHost>, RemoteHostList)
|
||||
|
||||
DOCUMENT(R"(The formatting mode used when displaying fields marked as Offsets or Sizes.
|
||||
|
||||
.. data:: Auto
|
||||
|
||||
The data is displayed as decimal values by default and hexadecimal if above a certain threshold.
|
||||
|
||||
.. data:: Decimal
|
||||
|
||||
The data is displayed as decimal values.
|
||||
|
||||
.. data:: Hexadecimal
|
||||
|
||||
The data is displayed as hexadecimal values.
|
||||
)");
|
||||
enum class OffsetSizeDisplayMode : int
|
||||
{
|
||||
Auto = 0,
|
||||
Decimal,
|
||||
Hexadecimal,
|
||||
Count,
|
||||
};
|
||||
|
||||
DECLARE_REFLECTION_ENUM(OffsetSizeDisplayMode);
|
||||
|
||||
DOCUMENT(R"(The unit that GPU durations are displayed in.
|
||||
|
||||
.. data:: Seconds
|
||||
|
||||
@@ -1782,6 +1782,11 @@ QVariant SDObject2Variant(const SDObject *obj, bool inlineImportant)
|
||||
}
|
||||
else
|
||||
{
|
||||
Formatter::FormatterFlags flags = Formatter::NoFlags;
|
||||
if((obj->type.flags & SDTypeFlags::OffsetOrSize) ||
|
||||
((obj->GetParent() && obj->GetParent()->type.flags & SDTypeFlags::OffsetOrSize)))
|
||||
flags = Formatter::OffsetSize;
|
||||
|
||||
switch(obj->type.basetype)
|
||||
{
|
||||
case SDBasic::Chunk:
|
||||
@@ -1893,7 +1898,9 @@ QVariant SDObject2Variant(const SDObject *obj, bool inlineImportant)
|
||||
}
|
||||
case SDBasic::Resource:
|
||||
case SDBasic::Enum:
|
||||
case SDBasic::UnsignedInteger: param = Formatter::HumanFormat(obj->data.basic.u); break;
|
||||
case SDBasic::UnsignedInteger:
|
||||
param = Formatter::HumanFormat(obj->data.basic.u, flags);
|
||||
break;
|
||||
case SDBasic::SignedInteger: param = Formatter::Format(obj->data.basic.i); break;
|
||||
case SDBasic::Float: param = Formatter::Format(obj->data.basic.d); break;
|
||||
case SDBasic::Boolean: param = (obj->data.basic.b ? lit("True") : lit("False")); break;
|
||||
@@ -2477,6 +2484,7 @@ QString Formatter::m_DefaultFontFamily;
|
||||
QString Formatter::m_DefaultMonoFontFamily;
|
||||
float Formatter::m_FixedFontBaseSize = 10.0f;
|
||||
QColor Formatter::m_DarkChecker, Formatter::m_LightChecker;
|
||||
OffsetSizeDisplayMode Formatter::m_OffsetSizeDisplayMode = OffsetSizeDisplayMode::Auto;
|
||||
|
||||
void Formatter::setParams(const PersistantConfig &config)
|
||||
{
|
||||
@@ -2488,6 +2496,8 @@ void Formatter::setParams(const PersistantConfig &config)
|
||||
m_expNegValue = qPow(10.0, -config.Formatter_NegExp);
|
||||
m_expPosValue = qPow(10.0, config.Formatter_PosExp);
|
||||
|
||||
m_OffsetSizeDisplayMode = config.Formatter_OffsetSizeDisplayMode;
|
||||
|
||||
if(!m_Font)
|
||||
{
|
||||
m_Font = new QFont();
|
||||
@@ -2571,7 +2581,7 @@ QString Formatter::Format(double f, bool)
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString Formatter::HumanFormat(uint64_t u)
|
||||
QString Formatter::HumanFormat(uint64_t u, FormatterFlags flags)
|
||||
{
|
||||
if(u == UINT16_MAX)
|
||||
return lit("UINT16_MAX");
|
||||
@@ -2581,8 +2591,26 @@ QString Formatter::HumanFormat(uint64_t u)
|
||||
return lit("UINT64_MAX");
|
||||
|
||||
// format as hex when over a certain threshold
|
||||
if(u > 0xffffff)
|
||||
bool displayHex = (u > 0xffffff);
|
||||
|
||||
if(flags & OffsetSize)
|
||||
{
|
||||
switch(m_OffsetSizeDisplayMode)
|
||||
{
|
||||
case OffsetSizeDisplayMode::Hexadecimal: displayHex = true; break;
|
||||
case OffsetSizeDisplayMode::Decimal: displayHex = false; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if(displayHex)
|
||||
{
|
||||
if(u < UINT32_MAX)
|
||||
{
|
||||
uint32_t u32 = u;
|
||||
return lit("0x") + Format(u32, true);
|
||||
}
|
||||
return lit("0x") + Format(u, true);
|
||||
}
|
||||
|
||||
return Format(u);
|
||||
}
|
||||
@@ -3007,7 +3035,7 @@ void ShowProgressDialog(QWidget *window, const QString &labelText, ProgressFinis
|
||||
// show the dialog
|
||||
RDDialog::show(&dialog);
|
||||
|
||||
// signal the thread to exit if somehow we got here without it finishing, then wait for it thread
|
||||
// signal the thread to exit if somehow we got here without it finishing, then wait for the thread
|
||||
// to clean itself up
|
||||
tickerSemaphore.tryAcquire();
|
||||
progressTickerThread.wait();
|
||||
|
||||
@@ -368,13 +368,18 @@ void RegisterMetatypeConversions();
|
||||
|
||||
struct Formatter
|
||||
{
|
||||
enum FormatterFlags
|
||||
{
|
||||
NoFlags = 0x0,
|
||||
OffsetSize = 0x1,
|
||||
};
|
||||
static void setParams(const PersistantConfig &config);
|
||||
static void setPalette(QPalette palette);
|
||||
static void shutdown();
|
||||
|
||||
static QString Format(double f, bool hex = false);
|
||||
static QString Format(rdhalf f, bool hex = false) { return Format((float)f, hex); }
|
||||
static QString HumanFormat(uint64_t u);
|
||||
static QString HumanFormat(uint64_t u, FormatterFlags flags);
|
||||
static QString Format(uint64_t u, bool hex = false)
|
||||
{
|
||||
return QFormatStr("%1").arg(u, hex ? 16 : 0, hex ? 16 : 10, QLatin1Char('0')).toUpper();
|
||||
@@ -432,6 +437,7 @@ private:
|
||||
static float m_FontBaseSize, m_FixedFontBaseSize;
|
||||
static QString m_DefaultFontFamily, m_DefaultMonoFontFamily;
|
||||
static QColor m_DarkChecker, m_LightChecker;
|
||||
static OffsetSizeDisplayMode m_OffsetSizeDisplayMode;
|
||||
};
|
||||
|
||||
bool SaveToJSON(QVariantMap &data, QIODevice &f, const char *magicIdentifier, uint32_t magicVersion);
|
||||
|
||||
@@ -146,6 +146,11 @@ SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent)
|
||||
ui->EventBrowser_TimeUnit->addItem(UnitSuffix((TimeUnit)i));
|
||||
}
|
||||
|
||||
for(int i = 0; i < (int)OffsetSizeDisplayMode::Count; i++)
|
||||
{
|
||||
ui->Formatter_OffsetSizeDisplayMode->addItem((ToStr((OffsetSizeDisplayMode)i)));
|
||||
}
|
||||
|
||||
ui->pages->clearSelection();
|
||||
ui->pages->item(0)->setSelected(true);
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
@@ -294,6 +299,8 @@ SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent)
|
||||
ui->Formatter_MaxFigures->setValue(m_Ctx.Config().Formatter_MaxFigures);
|
||||
ui->Formatter_NegExp->setValue(m_Ctx.Config().Formatter_NegExp);
|
||||
ui->Formatter_PosExp->setValue(m_Ctx.Config().Formatter_PosExp);
|
||||
ui->Formatter_OffsetSizeDisplayMode->setCurrentIndex(
|
||||
(int)m_Ctx.Config().Formatter_OffsetSizeDisplayMode);
|
||||
|
||||
if(!RENDERDOC_CanGlobalHook())
|
||||
{
|
||||
@@ -331,6 +338,9 @@ SettingsDialog::~SettingsDialog()
|
||||
m_Ctx.Config().DefaultReplayOptions = m_ReplayOptions->options();
|
||||
m_Ctx.Config().Save();
|
||||
|
||||
if(m_NeedRefresh)
|
||||
m_Ctx.RefreshStatus();
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -439,6 +449,22 @@ void SettingsDialog::formatter_valueChanged(int val)
|
||||
m_Ctx.Config().Save();
|
||||
}
|
||||
|
||||
void SettingsDialog::on_Formatter_OffsetSizeDisplayMode_currentIndexChanged(int index)
|
||||
{
|
||||
if(m_Init)
|
||||
return;
|
||||
|
||||
if(index < 0 || index >= (int)OffsetSizeDisplayMode::Count)
|
||||
return;
|
||||
|
||||
m_Ctx.Config().Formatter_OffsetSizeDisplayMode =
|
||||
(OffsetSizeDisplayMode)(ui->Formatter_OffsetSizeDisplayMode->currentIndex());
|
||||
|
||||
m_Ctx.Config().SetupFormatting();
|
||||
m_Ctx.Config().Save();
|
||||
m_NeedRefresh = true;
|
||||
}
|
||||
|
||||
void SettingsDialog::on_tempDirectory_textEdited(const QString &dir)
|
||||
{
|
||||
if(QDir(dir).exists())
|
||||
|
||||
@@ -116,6 +116,7 @@ private slots:
|
||||
|
||||
// manual slots
|
||||
void formatter_valueChanged(int value);
|
||||
void on_Formatter_OffsetSizeDisplayMode_currentIndexChanged(int index);
|
||||
|
||||
void on_analyticsDescribeLabel_linkActivated(const QString &link);
|
||||
|
||||
@@ -128,5 +129,6 @@ private:
|
||||
ReplayOptionsSelector *m_ReplayOptions;
|
||||
|
||||
ICaptureContext &m_Ctx;
|
||||
bool m_NeedRefresh = false;
|
||||
bool m_Init = false;
|
||||
};
|
||||
|
||||
@@ -287,6 +287,23 @@ e.g. 1000 * 10 = 1e4</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="toolTip">
|
||||
<string>Formatting mode to use for fields marked as a byte offset or a byte size</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Offset or size fields format mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QComboBox" name="Formatter_OffsetSizeDisplayMode">
|
||||
<property name="toolTip">
|
||||
<string>Auto: decimal by default and hexadecimal if above a certain threshold, Decimal: always use decimal, Hexadecimal: always use hexadecimal.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="toolTip">
|
||||
<string>Changes the directory where capture files are saved after being created, until saved manually or deleted.
|
||||
@@ -298,7 +315,7 @@ Defaults to %TEMP%.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="12" column="0">
|
||||
<widget class="QLineEdit" name="tempDirectory">
|
||||
<property name="toolTip">
|
||||
<string>Changes the directory where capture files are saved after being created, until saved manually or deleted.
|
||||
@@ -307,7 +324,7 @@ Defaults to %TEMP%.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<item row="12" column="1">
|
||||
<widget class="QPushButton" name="browseTempCaptureDirectory">
|
||||
<property name="toolTip">
|
||||
<string>Changes the directory where capture files are saved after being created, until saved manually or deleted.
|
||||
@@ -319,7 +336,7 @@ Defaults to %TEMP%.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string>Changes the default directory for the save dialog when saving capture files.
|
||||
@@ -331,7 +348,7 @@ Defaults to blank, which follows system default behaviour.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<item row="14" column="0">
|
||||
<widget class="QLineEdit" name="saveDirectory">
|
||||
<property name="toolTip">
|
||||
<string>Changes the default directory for the save dialog when saving capture files.
|
||||
@@ -340,7 +357,7 @@ Defaults to blank, which follows system default behaviour.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<item row="14" column="1">
|
||||
<widget class="QPushButton" name="browseSaveCaptureDirectory">
|
||||
<property name="toolTip">
|
||||
<string>Changes the default directory for the save dialog when saving capture files.
|
||||
@@ -352,7 +369,7 @@ Defaults to blank, which follows system default behaviour.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<item row="15" column="0">
|
||||
<widget class="QLabel" name="globalHookLabel">
|
||||
<property name="toolTip">
|
||||
<string>Enables functionality on the capture application window that will insert RenderDoc automatically
|
||||
@@ -367,7 +384,7 @@ Since this is a global system hook it must be used carefully and only when neces
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<item row="15" column="1">
|
||||
<widget class="QCheckBox" name="AllowGlobalHook">
|
||||
<property name="toolTip">
|
||||
<string>Enables functionality on the capture application window that will insert RenderDoc automatically
|
||||
@@ -382,7 +399,7 @@ Since this is a global system hook it must be used carefully and only when neces
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="0">
|
||||
<item row="16" column="0">
|
||||
<widget class="QLabel" name="injectProcLabel">
|
||||
<property name="toolTip">
|
||||
<string>Enables the ability to inject into processes on windows.
|
||||
@@ -396,7 +413,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="1">
|
||||
<item row="16" column="1">
|
||||
<widget class="QCheckBox" name="AllowProcessInject">
|
||||
<property name="toolTip">
|
||||
<string>Enables the ability to inject into processes on windows.
|
||||
@@ -410,7 +427,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0">
|
||||
<item row="17" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="toolTip">
|
||||
<string>Allows RenderDoc to phone home to https://renderdoc.org to anonymously check for new versions.</string>
|
||||
@@ -420,7 +437,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="1">
|
||||
<item row="17" column="1">
|
||||
<widget class="QCheckBox" name="CheckUpdate_AllowChecks">
|
||||
<property name="toolTip">
|
||||
<string>Allows RenderDoc to phone home to https://renderdoc.org to anonymously check for new versions.</string>
|
||||
@@ -430,7 +447,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="17" column="0">
|
||||
<item row="18" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="toolTip">
|
||||
<string>If a capture is marked as being created on a significantly different system (different OS or platform)
|
||||
@@ -443,7 +460,7 @@ This option overrides that and will always replay locally if the local context i
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="17" column="1">
|
||||
<item row="18" column="1">
|
||||
<widget class="QCheckBox" name="AlwaysReplayLocally">
|
||||
<property name="toolTip">
|
||||
<string>If a capture is marked as being created on a significantly different system (different OS or platform)
|
||||
@@ -456,7 +473,7 @@ This option overrides that and will always replay locally if the local context i
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="18" column="1">
|
||||
<item row="19" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
||||
@@ -164,6 +164,11 @@ DOCUMENT(R"(Bitfield flags that could be applied to a type.
|
||||
|
||||
Indicates that some children are marked as hidden. This can be important for cases where the
|
||||
number of children is important.
|
||||
|
||||
.. data:: OffsetOrSize
|
||||
|
||||
Special flag to indicate that this type will be used as a byte offset or byte size, which is used to
|
||||
control the formatting mode when the value is displayed in the UI.
|
||||
)");
|
||||
enum class SDTypeFlags : uint32_t
|
||||
{
|
||||
@@ -177,6 +182,7 @@ enum class SDTypeFlags : uint32_t
|
||||
Important = 0x40,
|
||||
ImportantChildren = 0x80,
|
||||
HiddenChildren = 0x100,
|
||||
OffsetOrSize = 0x200,
|
||||
};
|
||||
|
||||
BITMASK_OPERATORS(SDTypeFlags);
|
||||
|
||||
@@ -1224,6 +1224,19 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Serialiser &OffsetOrSize()
|
||||
{
|
||||
if(ExportStructure() && !m_StructureStack.empty())
|
||||
{
|
||||
SDObject ¤t = *m_StructureStack.back();
|
||||
|
||||
if(current.NumChildren() > 0)
|
||||
current.GetChild(current.NumChildren() - 1)->type.flags |= SDTypeFlags::OffsetOrSize;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// these functions should be used very carefully, they completely disable structured export for
|
||||
// anything serialised while internal is set.
|
||||
void PushInternal() { m_InternalElement++; }
|
||||
|
||||
Reference in New Issue
Block a user