summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-01-03 19:38:53 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-01-04 08:44:09 +0100
commit1be170d0629cf761f0ee4173007a3c021966546e (patch)
treed46080c76e3d19304ec69164231639c204e236bd /vcl/win
parent71141a78f47f9a70aae986959ac80f19ce0816fa (diff)
tdf#146551: improve native checkmark and bullet drawing on Windows
This takes marks' borders into account, and removes some hacks used previously in place of those. It introduces one new hack - adjusting only rectangle's top in ImplPaintCheckBackground - to workaround one pixel less height of selected images background on Windows, caused by the current method of drawing that background, abusing toolbar button for that on all platforms. Ideally, drawing it (or the whole image) should be implemented using OutputDevice::DrawNativeControl with dedicated ControlPart value, which would enable use of ImplDrawTheme with MCB_BITMAP menu background state on Windows. I have tested on Windows 10 (using both default and Skia drawing, with normal and scaled UI), and on Ubuntu with gtk3, x11, and kf5 plugins (since common code is affected); it seems to give expected results on all of them. Change-Id: I677c3af30fedc608dbc6b391d5dbbbdb141da0d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127909 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/salnativewidgets-luna.cxx65
1 files changed, 13 insertions, 52 deletions
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx
index a8d508c9b44d..6a21a3d6d394 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -365,46 +365,9 @@ static void impl_drawAeroToolbar( HDC hDC, RECT rc, bool bHorizontal )
}
}
-/**
- * Gives the actual rectangle used for rendering by ControlType::MenuPopup's
- * ControlPart::MenuItemCheckMark or ControlPart::MenuItemRadioMark.
- */
-static tools::Rectangle GetMenuPopupMarkRegion(const ImplControlValue& rValue)
-{
- tools::Rectangle aRet;
-
- auto pMVal = dynamic_cast<const MenupopupValue*>(&rValue);
- if (!pMVal)
- return aRet;
-
- aRet.SetTop(pMVal->maItemRect.Top());
- aRet.SetBottom(pMVal->maItemRect.Bottom() + 1); // see below in drawNativeControl
- if (AllSettings::GetLayoutRTL())
- {
- aRet.SetRight(pMVal->maItemRect.Right() + 1);
- aRet.SetLeft(aRet.Right() - (pMVal->getNumericVal() - pMVal->maItemRect.Left()));
- }
- else
- {
- aRet.SetRight(pMVal->getNumericVal());
- aRet.SetLeft(pMVal->maItemRect.Left());
- }
-
- return aRet;
-}
-
static bool implDrawNativeMenuMark(HDC hDC, HTHEME hTheme, RECT rc, ControlPart nPart,
- ControlState nState, const ImplControlValue& aValue,
- OUString const& aCaption)
+ ControlState nState, OUString const& aCaption)
{
- if (aValue.getType() == ControlType::MenuPopup)
- {
- tools::Rectangle aRectangle = GetMenuPopupMarkRegion(aValue);
- rc.top = aRectangle.Top();
- rc.left = aRectangle.Left();
- rc.bottom = aRectangle.Bottom();
- rc.right = aRectangle.Right();
- }
int iState = (nState & ControlState::ENABLED) ? MCB_NORMAL : MCB_DISABLED;
ImplDrawTheme(hTheme, hDC, MENU_POPUPCHECKBACKGROUND, iState, rc, aCaption);
if (nPart == ControlPart::MenuItemCheckMark)
@@ -1015,7 +978,7 @@ static bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
else if( nPart == ControlPart::MenuItemCheckMark || nPart == ControlPart::MenuItemRadioMark )
{
if (nState & ControlState::PRESSED)
- return implDrawNativeMenuMark(hDC, hTheme, rc, nPart, nState, aValue, aCaption);
+ return implDrawNativeMenuMark(hDC, hTheme, rc, nPart, nState, aCaption);
else
return true; // unchecked: do nothing
}
@@ -1072,16 +1035,6 @@ bool WinSalGraphics::drawNativeControl( ControlType nType,
}
}
- if (pImpl && nType == ControlType::MenuPopup && (nPart == ControlPart::MenuItemCheckMark || nPart == ControlPart::MenuItemRadioMark))
- {
- tools::Rectangle aRectangle = GetMenuPopupMarkRegion(aValue);
- if (!aRectangle.IsEmpty())
- {
- cacheRect = buttonRect = aRectangle;
- keySize = cacheRect.GetSize();
- }
- }
-
ControlCacheKey aControlCacheKey(nType, nPart, nState, keySize);
if (pImpl != nullptr && pImpl->TryRenderCachedNativeControl(aControlCacheKey, buttonRect.Left(), buttonRect.Top()))
@@ -1348,10 +1301,18 @@ bool WinSalGraphics::getNativeControlRegion( ControlType nType,
MENU_POPUPCHECK,
MC_CHECKMARKNORMAL,
aBoxRect ) );
- if( aBoxRect.GetWidth() && aBoxRect.GetHeight() )
+ if (!aRect.IsEmpty())
{
- rNativeContentRegion = aRect;
- rNativeBoundingRegion = rNativeContentRegion;
+ if (MARGINS mg;
+ SUCCEEDED(GetThemeMargins(hTheme, hDC, MENU_POPUPCHECK, MC_CHECKMARKNORMAL,
+ TMT_CONTENTMARGINS, nullptr, &mg)))
+ {
+ aRect.AdjustLeft(-mg.cxLeftWidth);
+ aRect.AdjustRight(mg.cxRightWidth);
+ aRect.AdjustTop(-mg.cyTopHeight);
+ aRect.AdjustBottom(mg.cyBottomHeight);
+ }
+ rNativeContentRegion = rNativeBoundingRegion = aRect;
bRet = true;
}
}