vcl/source/treelist/treelistbox.cxx |   67 +++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 35 deletions(-)

New commits:
commit e9992e96faf92080402ab32322d16d51c367f6ce
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu May 12 13:30:16 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu May 12 20:58:27 2022 +0200

    make the expand/collapse node drawing easier to read
    
    Change-Id: I0b25affad41dfea7c0980c5eb6092fd0a149bae8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134238
    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 1b75487beaac..14089dc53b2e 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -2808,42 +2808,45 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& 
rEntry, tools::Long nLine, vcl:
                                          : *pImg == 
GetDefaultCollapsedNodeImage();
     aPos.AdjustY((nTempEntryHeight - pImg->GetSizePixel().Height()) / 2 );
 
-    DrawImageFlags nStyle = DrawImageFlags::NONE;
-    if (!IsEnabled())
-        nStyle |= DrawImageFlags::Disable;
-
-    //native
-    bool bNativeOK = false;
-    if (bDefaultImage && 
rRenderContext.IsNativeControlSupported(ControlType::ListNode, 
ControlPart::Entire))
+    if (!bDefaultImage)
+    {
+        // If its a custom image then draw what was explicitly set to use
+        DrawImageFlags nStyle = DrawImageFlags::NONE;
+        if (!IsEnabled())
+            nStyle |= DrawImageFlags::Disable;
+        rRenderContext.DrawImage(aPos, *pImg, nStyle);
+    }
+    else
     {
-        ImplControlValue aControlValue;
-        tools::Rectangle aCtrlRegion(aPos,  pImg->GetSizePixel());
-        ControlState nState = ControlState::NONE;
+        bool bNativeOK = false;
+        // native
+        if (rRenderContext.IsNativeControlSupported(ControlType::ListNode, 
ControlPart::Entire))
+        {
+            ImplControlValue aControlValue;
+            tools::Rectangle aCtrlRegion(aPos,  pImg->GetSizePixel());
+            ControlState nState = ControlState::NONE;
 
-        if (IsEnabled())
-            nState |= ControlState::ENABLED;
+            if (IsEnabled())
+                nState |= ControlState::ENABLED;
 
-        if (bExpanded)
-            aControlValue.setTristateVal(ButtonValue::On); //expanded node
-        else
-        {
-            if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() &&
-                (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)))
-            {
-                aControlValue.setTristateVal( ButtonValue::DontKnow ); //don't 
know
-            }
+            if (bExpanded)
+                aControlValue.setTristateVal(ButtonValue::On); //expanded node
             else
             {
-                aControlValue.setTristateVal( ButtonValue::Off ); //collapsed 
node
+                if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() &&
+                    (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)))
+                {
+                    aControlValue.setTristateVal( ButtonValue::DontKnow ); 
//don't know
+                }
+                else
+                {
+                    aControlValue.setTristateVal( ButtonValue::Off ); 
//collapsed node
+                }
             }
-        }
-
-        bNativeOK = rRenderContext.DrawNativeControl(ControlType::ListNode, 
ControlPart::Entire, aCtrlRegion, nState, aControlValue, OUString());
-    }
 
-    if (!bNativeOK)
-    {
-        if (bDefaultImage)
+            bNativeOK = 
rRenderContext.DrawNativeControl(ControlType::ListNode, ControlPart::Entire, 
aCtrlRegion, nState, aControlValue, OUString());
+        }
+        if (!bNativeOK)
         {
             DecorationView aDecoView(&rRenderContext);
             DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
@@ -2857,12 +2860,6 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, 
tools::Long nLine, vcl:
             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);
-        }
     }
 }
 

Reply via email to