[Libreoffice-commits] core.git: vcl/osx vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Mar 4 13:08:14 UTC 2021


 vcl/osx/salnativewidgets.cxx       |   24 ++++++++++++++++--------
 vcl/source/control/imp_listbox.cxx |    3 +++
 vcl/source/window/brdwin.cxx       |    8 +++++++-
 3 files changed, 26 insertions(+), 9 deletions(-)

New commits:
commit 5e75b7ca828954f9a23d7a3e8c3be3e0934210b3
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Wed Mar 3 21:10:57 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Mar 4 14:07:31 2021 +0100

    macOS: use HITheme to draw listbox window border
    
    Change-Id: I39fd6f643649bc405447d10e7072ae6dabd679b6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111935
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index 17d1744433f4..5dd5929c2fc6 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -732,16 +732,14 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
                 case ControlPart::ListboxWindow:
                     HIThemeFrameDrawInfo aTextDrawInfo;
                     aTextDrawInfo.version = 0;
-                    aTextDrawInfo.kind = kHIThemeFrameTextFieldSquare;
-                    aTextDrawInfo.state = getState(nState);
+                    aTextDrawInfo.kind = kHIThemeFrameListBox;
+                    aTextDrawInfo.state = kThemeStateActive;
                     aTextDrawInfo.isFocused = false;
-                    rc.size.width -= 2 * FOCUS_RING_WIDTH;
-                    rc.size.height -= 2 * FOCUS_RING_WIDTH;
-                    rc.origin.x += FOCUS_RING_WIDTH;
-                    rc.origin.y += FOCUS_RING_WIDTH;
+                    rc.size.width += 2 * kThemeMetricListBoxFrameOutset - 2;
+                    rc.size.height += 2 * kThemeMetricListBoxFrameOutset - 2;
+                    rc.origin.x -= kThemeMetricListBoxFrameOutset - 1;
+                    rc.origin.y -= kThemeMetricListBoxFrameOutset - 1;
                     HIThemeDrawFrame(&rc, &aTextDrawInfo, maContextHolder.get(), kHIThemeOrientationNormal);
-                    if (nState & ControlState::FOCUSED)
-                        HIThemeDrawFocusRect(&rc, true, maContextHolder.get(), kHIThemeOrientationNormal);
                     bOK = true;
                     break;
                 default:
@@ -1046,6 +1044,16 @@ bool AquaSalGraphics::getNativeControlRegion(ControlType nType,
                 rNativeContentRegion = tools::Rectangle(Point(x, y), Size(w, h));
                 toReturn = true;
             }
+            else if (nPart == ControlPart::ListboxWindow)
+            {
+                w = aCtrlBoundRect.GetWidth() - 2 * kThemeMetricListBoxFrameOutset;
+                h = aCtrlBoundRect.GetHeight() - 2 * kThemeMetricListBoxFrameOutset;
+                x += kThemeMetricListBoxFrameOutset;
+                y += kThemeMetricListBoxFrameOutset;
+                rNativeBoundingRegion = aCtrlBoundRect;
+                rNativeContentRegion = tools::Rectangle(Point(x, y), Size(w, h));
+                toReturn = true;
+            }
             break;
         case ControlType::Spinbox:
             if (nPart == ControlPart::Entire)
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index ddff67bae584..0c5e8f1237f6 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -2792,6 +2792,9 @@ void ImplBtn::MouseButtonDown( const MouseEvent& )
 ImplListBoxFloatingWindow::ImplListBoxFloatingWindow( vcl::Window* pParent ) :
     FloatingWindow( pParent, WB_BORDER | WB_SYSTEMWINDOW | WB_NOSHADOW )    // no drop shadow for list boxes
 {
+    // for native widget rendering we must be able to detect this window type
+    SetType( WindowType::LISTBOXWINDOW );
+
     mpImplLB = nullptr;
     mnDDLineCount = 0;
     mbAutoWidth = false;
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index b5bdd05d53d4..ec1e95c9db46 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -427,6 +427,7 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, tools::Long nWidth, to
             // for native widget drawing we must find out what
             // control this border belongs to
             ControlType aCtrlType = ControlType::Generic;
+            ControlPart aCtrlPart = ControlPart::Entire;
             if (pCtrl)
             {
                 switch( pCtrl->GetType() )
@@ -438,6 +439,11 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, tools::Long nWidth, to
                             mbNWFBorder = true;
                         }
                         break;
+                    case WindowType::LISTBOXWINDOW:
+                        aCtrlType = ControlType::Listbox;
+                        aCtrlPart = ControlPart::ListboxWindow;
+                        mbNWFBorder = true;
+                        break;
                     case WindowType::COMBOBOX:
                         if( pCtrl->GetStyle() & WB_DROPDOWN )
                         {
@@ -475,7 +481,7 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, tools::Long nWidth, to
                 if( aMinSize.Height() < 10 ) aMinSize.setHeight( 10 );
                 tools::Rectangle aCtrlRegion( Point(mnLeftBorder, mnTopBorder), aMinSize );
                 tools::Rectangle aBounds, aContent;
-                if( pWin->GetNativeControlRegion( aCtrlType, ControlPart::Entire, aCtrlRegion,
+                if( pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion,
                                                   ControlState::ENABLED, aControlValue,
                                                   aBounds, aContent ) )
                 {


More information about the Libreoffice-commits mailing list