svtools/source/control/valueset.cxx |   32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

New commits:
commit b6ef68cdaa51ca5c9fdab40ade97f4a0f18da51b
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Nov 1 20:45:20 2021 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Nov 2 14:54:50 2021 +0100

    keep showing focus rect on the first element during highlight
    
    for the case nothing is selected but non-hover shows the bare focus
    rect to indicate focus is in the valueset though nothing is truly
    selected
    
    Change-Id: Ibe7fa38711f935126e1c0803c395b43b9720ca6b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124575
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/svtools/source/control/valueset.cxx 
b/svtools/source/control/valueset.cxx
index 2afd1dfdeb57..f8b0267316aa 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -1178,13 +1178,9 @@ void ValueSet::ImplDrawSelect(vcl::RenderContext& 
rRenderContext)
         return;
 
     const bool bFocus = HasFocus();
-    const bool bDrawSel = !mbNoSelection || mbHighlight;
 
-    if (!bFocus && !bDrawSel)
-    {
-        ImplDrawItemText(rRenderContext, OUString());
+    if (!bFocus && mbNoSelection && !mbHighlight)
         return;
-    }
 
     tools::Rectangle aSelectedRect, aHoverRect;
     ValueSetItem* pSelectedItem = ImplGetDrawSelectItem(mnSelItemId, bFocus, 
aSelectedRect);
@@ -1192,12 +1188,26 @@ void ValueSet::ImplDrawSelect(vcl::RenderContext& 
rRenderContext)
 
     if (pSelectedItem)
     {
-        const bool bHover = mnHighItemId && pSelectedItem == pHighlightItem;
-        ImplDrawSelect(rRenderContext, aSelectedRect, pSelectedItem, bFocus, 
bDrawSel, true, bHover);
-    }
-    if (mnHighItemId && pHighlightItem && pSelectedItem != pHighlightItem)
-    {
-        ImplDrawSelect(rRenderContext, aHoverRect, pHighlightItem, false, 
bDrawSel, false, true);
+        const bool bHover = pSelectedItem == pHighlightItem;
+        ImplDrawSelect(rRenderContext, aSelectedRect, pSelectedItem, bFocus, 
!mbNoSelection, true, bHover);
+    }
+    if (pHighlightItem && (pSelectedItem != pHighlightItem || mbNoSelection))
+    {
+        // For the case that there isn't a selected item, but due to wanting to
+        // show focus is in the valueset, the above block will have drawn the
+        // first item with a focus rect. For that situation; if the valueset is
+        // the thin WB_MENUSTYLEVALUESET case then blend this highlight border
+        // on top of that focus rect and it will appear with a highlighted
+        // focus rect. If it's the other case of a thicker border then redraw
+        // the focus rect highlighted with the hover color.
+        bool bDrawFocus;
+        WinBits nStyle = GetStyle();
+        if (nStyle & WB_MENUSTYLEVALUESET)
+            bDrawFocus = false;
+        else
+            bDrawFocus = pSelectedItem == pHighlightItem && mbNoSelection;
+
+        ImplDrawSelect(rRenderContext, aHoverRect, pHighlightItem, bDrawFocus, 
mbHighlight, false, true);
     }
 }
 

Reply via email to