vcl/source/treelist/treelistbox.cxx | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
New commits: commit d9b072cd077cbb515e5aef584d98cb5deda48776 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed May 11 13:15:37 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu May 12 16:11:52 2022 +0200 tdf#148740 draw expanders instead of using icons and then the color of the expander can simply follow the text color to get contrast for the selected entry case. At some point someone thought it would be a good idea to expose via uno the possibility to set custom expand/collapse icons so retain that support. Change-Id: I44c40bf691cae228e184e58ed848001aaa4b4996 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134168 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index 7c093a6f6a61..1b75487beaac 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -31,6 +31,7 @@ #include <vcl/toolkit/edit.hxx> #include <vcl/settings.hxx> #include <vcl/commandevent.hxx> +#include <vcl/decoview.hxx> #include <vcl/uitest/uiobject.hxx> #include <sot/formats.hxx> #include <unotools/accessiblestatesethelper.hxx> @@ -2798,10 +2799,13 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, tools::Long nLine, vcl: const Image* pImg = nullptr; - if (IsExpanded(&rEntry)) + const bool bExpanded = IsExpanded(&rEntry); + if (bExpanded) pImg = &pImpl->GetExpandedNodeBmp(); else pImg = &pImpl->GetCollapsedNodeBmp(); + const bool bDefaultImage = bExpanded ? *pImg == GetDefaultExpandedNodeImage() + : *pImg == GetDefaultCollapsedNodeImage(); aPos.AdjustY((nTempEntryHeight - pImg->GetSizePixel().Height()) / 2 ); DrawImageFlags nStyle = DrawImageFlags::NONE; @@ -2810,7 +2814,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, tools::Long nLine, vcl: //native bool bNativeOK = false; - if (rRenderContext.IsNativeControlSupported(ControlType::ListNode, ControlPart::Entire)) + if (bDefaultImage && rRenderContext.IsNativeControlSupported(ControlType::ListNode, ControlPart::Entire)) { ImplControlValue aControlValue; tools::Rectangle aCtrlRegion(aPos, pImg->GetSizePixel()); @@ -2819,7 +2823,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, tools::Long nLine, vcl: if (IsEnabled()) nState |= ControlState::ENABLED; - if (IsExpanded(&rEntry)) + if (bExpanded) aControlValue.setTristateVal(ButtonValue::On); //expanded node else { @@ -2839,7 +2843,26 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, tools::Long nLine, vcl: if (!bNativeOK) { - rRenderContext.DrawImage(aPos, *pImg ,nStyle); + if (bDefaultImage) + { + DecorationView aDecoView(&rRenderContext); + DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE; + if (!IsEnabled()) + nSymbolStyle |= DrawSymbolFlags::Disable; + + Color aCol = aBackupTextColor; + if (pViewDataEntry->IsHighlighted()) + aCol = aHighlightTextColor; + + SymbolType eSymbol = bExpanded ? SymbolType::SPIN_DOWN : SymbolType::SPIN_RIGHT; + aDecoView.DrawSymbol(tools::Rectangle(aPos, pImg->GetSizePixel()), eSymbol, aCol, nSymbolStyle); + } + else + { + // setDefaultExpandedGraphicURL is exposed via uno, see TreeControlPeer::setDefaultExpandedGraphicURL, + // while that's supported keep the possibility to render a custom image here + rRenderContext.DrawImage(aPos, *pImg ,nStyle); + } } }