From 8f9705333ac704624158f12cff17d4085c993501 Mon Sep 17 00:00:00 2001 From: Remi Palandri Date: Mon, 12 Jan 2026 22:47:03 +0100 Subject: [PATCH] hide empty annotations Only displays annotations when they're not an empty node (struct only) with empty children. Needs to look at children recursively, as deleting foo.bar.baz would keep foo and foo.bar alive. --- qrenderdoc/Widgets/AnnotationDisplay.cpp | 26 ++++++++++++++++++++---- qrenderdoc/Widgets/AnnotationDisplay.h | 3 +++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/qrenderdoc/Widgets/AnnotationDisplay.cpp b/qrenderdoc/Widgets/AnnotationDisplay.cpp index f90d4582a..09d0e6cc1 100644 --- a/qrenderdoc/Widgets/AnnotationDisplay.cpp +++ b/qrenderdoc/Widgets/AnnotationDisplay.cpp @@ -96,14 +96,32 @@ void AnnotationDisplay::OnSelectedEventChanged(uint32_t eventId) setAnnotationObject(ev.annotations); } +bool AnnotationDisplay::shouldBeDisplayed(const SDObject &obj) +{ + if(obj.type.flags & SDTypeFlags::Hidden) + return false; + + if(obj.name.beginsWith("__")) + return false; + + if(obj.type.basetype == SDBasic::Struct) + { + for(const SDObject *child_obj : obj) + { + if(shouldBeDisplayed(*child_obj)) + return true; + } + return false; + } + + return true; +} + void AnnotationDisplay::addStructuredChildren(RDTreeWidgetItem *parent, const SDObject &parentObj) { for(const SDObject *obj : parentObj) { - if(obj->type.flags & SDTypeFlags::Hidden) - continue; - - if(obj->name.beginsWith("__")) + if(!shouldBeDisplayed(*obj)) continue; QVariant name; diff --git a/qrenderdoc/Widgets/AnnotationDisplay.h b/qrenderdoc/Widgets/AnnotationDisplay.h index 348ebb4dc..b55f1a2f4 100644 --- a/qrenderdoc/Widgets/AnnotationDisplay.h +++ b/qrenderdoc/Widgets/AnnotationDisplay.h @@ -66,4 +66,7 @@ private: QMap m_Items; void addStructuredChildren(RDTreeWidgetItem *parent, const SDObject &parentObj); + + // either is a non-empty node, or has at least one non-empty child + bool shouldBeDisplayed(const SDObject &obj); };