Files
renderdoc/qrenderdoc/Widgets/AnnotationDisplay.h
T
Remi Palandri 8f9705333a 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.
2026-01-28 14:42:10 +00:00

73 lines
2.6 KiB
C++

/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2025 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#pragma once
#include "Extended/RDTreeWidget.h"
// can be used either as an embedded control in the resource inspector, or as a separate panel for
// monitoring API events
class AnnotationDisplay : public QFrame, public IAnnotationViewer, public ICaptureViewer
{
Q_OBJECT
public:
explicit AnnotationDisplay(ICaptureContext &ctx, bool standalone, QWidget *parent = 0);
~AnnotationDisplay();
// IAnnotationViewer
QWidget *Widget() override { return this; }
void RevealAnnotation(const rdcstr &keyPath) override;
// ICaptureViewer
void OnCaptureLoaded() override;
void OnCaptureClosed() override;
void OnSelectedEventChanged(uint32_t eventId) override;
void OnEventChanged(uint32_t eventId) override {}
void setAnnotationObject(const SDObject *annotation);
private slots:
void customContextMenu(QModelIndex index, QMenu *menu);
protected:
private:
ICaptureContext &m_Ctx;
const SDObject *m_Annotation = NULL;
RDTreeWidget *m_Tree;
RDTreeViewExpansionState m_Expansion;
// if this is a standalone viewer or not
bool m_Standalone = false;
QMap<const SDObject *, RDTreeWidgetItem *> 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);
};