mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 17:40:39 +00:00
Add a 'human formatting' function for special-case/heuristic display
* For unsigned integers this notices UINT16/32/64_MAX and displays as a text string for easier consumption. * Also for numbers over a given threshold we display them as hex instead of decimal.
This commit is contained in:
@@ -716,7 +716,7 @@ void addStructuredObjects(RDTreeWidgetItem *parent, const StructuredObjectList &
|
||||
case SDBasic::String: param = obj->data.str; break;
|
||||
case SDBasic::Resource:
|
||||
case SDBasic::Enum:
|
||||
case SDBasic::UnsignedInteger: param = Formatter::Format(obj->data.basic.u); break;
|
||||
case SDBasic::UnsignedInteger: param = Formatter::HumanFormat(obj->data.basic.u); 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;
|
||||
@@ -1184,6 +1184,22 @@ QString Formatter::Format(double f, bool)
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString Formatter::HumanFormat(uint64_t u)
|
||||
{
|
||||
if(u == UINT16_MAX)
|
||||
return lit("UINT16_MAX");
|
||||
if(u == UINT32_MAX)
|
||||
return lit("UINT32_MAX");
|
||||
if(u == UINT64_MAX)
|
||||
return lit("UINT64_MAX");
|
||||
|
||||
// format as hex when over a certain threshold
|
||||
if(u > 0xffffff)
|
||||
return lit("0x") + Format(u, true);
|
||||
|
||||
return Format(u);
|
||||
}
|
||||
|
||||
class RDProgressDialog : public QProgressDialog
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -166,6 +166,7 @@ struct Formatter
|
||||
static void shutdown();
|
||||
|
||||
static QString Format(double f, bool hex = false);
|
||||
static QString HumanFormat(uint64_t u);
|
||||
static QString Format(uint64_t u, bool hex = false)
|
||||
{
|
||||
return QFormatStr("%1").arg(u, hex ? 16 : 0, hex ? 16 : 10, QLatin1Char('0')).toUpper();
|
||||
|
||||
Reference in New Issue
Block a user