vcl/source/treelist/treelistbox.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
New commits: commit 4b2543693ed3ffb4d9f0d70f53f32127115c128d Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Sat Sep 9 21:21:03 2023 -0800 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Tue Sep 12 00:45:51 2023 +0200 tdf#156890 SalInstanceTreeView: Indent the entry context bitmap when the bitmap is too large to center without it touching the expand button Change-Id: If4e307ed50eff9bdebe6c377847283ae2eea9543 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156787 Tested-by: Jenkins Tested-by: Heiko Tietze <heiko.tie...@documentfoundation.org> Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> Reviewed-by: Jim Raykowski <rayk...@gmail.com> diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index 94d561ced049..e944214c5b88 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -1452,6 +1452,9 @@ void SvTreeListBox::SetTabs() else nStartPos += nContextWidthDIV2; AddTab( nStartPos, TABFLAGS_CONTEXTBMP ); + // add an indent if the context bitmap can't be centered without touching the expander + if (nContextBmpWidthMax > nIndent + (nNodeWidthPixel / 2)) + nStartPos += nIndent; nStartPos += nContextWidthDIV2; // right edge of context bitmap // only set a distance if there are bitmaps if( nContextBmpWidthMax ) @@ -2584,6 +2587,10 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, tools::Long nLine, vcl: SvViewDataEntry* pViewDataEntry = GetViewDataEntry( &rEntry ); const bool bSeparator(rEntry.GetFlags() & SvTLEntryFlags::IS_SEPARATOR); + const auto nMaxContextBmpWidthBeforeIndentIsNeeded = + nIndent + GetExpandedNodeBmp().GetSizePixel().Width() / 2; + const bool bHasButtonsAtRoot = nWindowStyle & WB_HASBUTTONSATROOT; + const size_t nTabCount = aTabs.size(); const size_t nItemCount = rEntry.ItemCount(); size_t nCurTab = 0; @@ -2618,6 +2625,13 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, tools::Long nLine, vcl: else nX = nTabPos + pTab->CalcOffset(aSize.Width(), nNextTabPos - nTabPos); + // add an indent if the context bitmap can't be centered without touching the expander + if (nCurTab == 0 && !(nTreeFlags & SvTreeFlags::CHKBTN) && bHasButtonsAtRoot && + pTab->nFlags & SvLBoxTabFlags::ADJUST_CENTER && + !(pTab->nFlags & SvLBoxTabFlags::FORCE) && + aSize.Width() > nMaxContextBmpWidthBeforeIndentIsNeeded) + nX += nIndent; + aEntryPos.setX( nX ); aEntryPos.setY( nLine );