MCPcopy Create free account
hub / github.com/baldurk/renderdoc / RichResourceTextWidthHint

Function RichResourceTextWidthHint

qrenderdoc/Code/QRDUtils.cpp:936–986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

934}
935
936int RichResourceTextWidthHint(const QWidget *owner, const QFont &font, const QVariant &var)
937{
938 // special case handling for ResourceId/GPUAddress on its own
939 if(var.userType() == qMetaTypeId<ResourceId>() || var.userType() == qMetaTypeId<GPUAddressPtr>())
940 {
941 QFont f = font;
942 f.setBold(true);
943
944 static const int margin = RichResourceTextMargin;
945
946 QFontMetrics metrics(f);
947
948 QString name;
949
950 if(var.userType() == qMetaTypeId<ResourceId>())
951 {
952 ICaptureContext *ctxptr = getCaptureContext(owner);
953
954 ResourceId id = var.value<ResourceId>();
955
956 if(ctxptr)
957 name = GetTruncatedResourceName(*ctxptr, id);
958 else
959 name = ToQStr(id);
960 }
961 else
962 {
963 GPUAddressPtr ptr = var.value<GPUAddressPtr>();
964
965 ptr->cacheAddress(owner);
966
967 if(ptr->val.pointer != 0)
968 name =
969 QFormatStr("%1+%2").arg(GetTruncatedResourceName(*ptr->ctxptr, ptr->base)).arg(ptr->offset);
970 else
971 name = lit("NULL");
972 }
973
974 // this calculation is in device independent sizes so use a ratio of 1 for the pixmap
975 const QPixmap &px = Pixmaps::link(1);
976
977 int ret = margin + metrics.boundingRect(name).width() + margin + px.width() + margin;
978 return ret;
979 }
980
981 RichResourceTextPtr linkedText = var.value<RichResourceTextPtr>();
982
983 linkedText->cacheDocument(owner);
984
985 return linkedText->idealWidth;
986}
987
988int RichResourceTextHeightHint(const QWidget *owner, const QFont &font, const QVariant &var)
989{

Callers 2

sizeHintMethod · 0.85
modifySizeHintMethod · 0.85

Calls 9

getCaptureContextFunction · 0.85
GetTruncatedResourceNameFunction · 0.85
cacheAddressMethod · 0.80
boundingRectMethod · 0.80
cacheDocumentMethod · 0.80
ToQStrFunction · 0.70
setBoldMethod · 0.45
argMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected