From 5a65cbf62c151a0b2d1a0c91a087db4f94f58d85 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 20 May 2021 11:34:36 +0100 Subject: [PATCH] Tweak default item sizing in RDTreeView to better handle font scales * We're somewhat trying to match Qt's behaviour here, as we want to ensure that the items are always sized as if they have space for an icon when ignoreIconSize() is true. In this case there's a +2 added "to avoid icons overlapping" but only after the decorationsize is max'd with the font size. In cases where the font is bigger than the icon, this is important. --- qrenderdoc/Widgets/Extended/RDTreeView.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qrenderdoc/Widgets/Extended/RDTreeView.cpp b/qrenderdoc/Widgets/Extended/RDTreeView.cpp index d3c28a95c..257cf302c 100644 --- a/qrenderdoc/Widgets/Extended/RDTreeView.cpp +++ b/qrenderdoc/Widgets/Extended/RDTreeView.cpp @@ -99,8 +99,12 @@ QSize RDTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo { QSize ret = RichTextViewDelegate::sizeHint(option, index); + int minHeight = option.fontMetrics.height(); + if(!m_View->ignoreIconSize()) + minHeight = qMax(option.decorationSize.height(), minHeight); + if(m_View->ignoreIconSize()) - ret.setHeight(qMax(option.decorationSize.height() + 2, ret.height())); + ret.setHeight(qMax(qMax(option.decorationSize.height(), minHeight) + 2, ret.height())); // expand a pixel for the grid lines if(m_View->visibleGridLines()) @@ -108,9 +112,6 @@ QSize RDTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo // ensure we have at least the margin on top of font size. If the style applied more, don't add to // it. - int minHeight = option.fontMetrics.height(); - if(!m_View->ignoreIconSize()) - minHeight = qMax(option.decorationSize.height(), minHeight); ret.setHeight(qMax(ret.height(), minHeight + m_View->verticalItemMargin())); return ret;