summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2016-02-17 21:42:37 +0000
committerTomaž Vajngerl <quikee@gmail.com>2016-02-18 10:44:01 +0000
commit8ad929ba03551b75e79c88699d44d75dc07669e2 (patch)
tree121bbf37886bb364df26e3b927240385791faa93
parent4d7c06741967a84142bbe8fa8ae608e5e7df7b0f (diff)
tdf#95618 - opengl - mend control regions and caching for tab headers.
Some tab headers in some themes unhelpfully enlarge the control region in some states - so query the region size in advance. Sadly the control region querying is something of a train-wreck too - so only use that for CTRL_TAB_ITEMs for now. Also fix Rectangle constructor ordering. Change-Id: I5e66ec541193f5b66a656dd45d5fba67a771e132 Reviewed-on: https://gerrit.libreoffice.org/22447 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--vcl/source/control/tabctrl.cxx2
-rw-r--r--vcl/win/source/gdi/salnativewidgets-luna.cxx36
2 files changed, 28 insertions, 10 deletions
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index d848ab04d945..2fa312afb4ec 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -847,8 +847,8 @@ void TabControl::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem* p
if (!bLayout && (bNativeOK = rRenderContext.IsNativeControlSupported(CTRL_TAB_ITEM, PART_ENTIRE_CONTROL)))
{
TabitemValue tiValue(Rectangle(pItem->maRect.Left() + TAB_TABOFFSET_X,
- pItem->maRect.Right() - TAB_TABOFFSET_X,
pItem->maRect.Top() + TAB_TABOFFSET_Y,
+ pItem->maRect.Right() - TAB_TABOFFSET_X,
pItem->maRect.Bottom() - TAB_TABOFFSET_Y));
if (pItem->maRect.Left() < 5)
tiValue.mnAlignment |= TabitemFlags::LeftAligned;
diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx
index e10de37da9c4..35b8acd9bf31 100644
--- a/vcl/win/source/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx
@@ -1162,20 +1162,35 @@ bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
* aCaption: A caption or title string (like button text etc)
*/
bool WinSalGraphics::drawNativeControl( ControlType nType,
- ControlPart nPart,
- const Rectangle& rControlRegion,
- ControlState nState,
- const ImplControlValue& aValue,
- const OUString& aCaption )
+ ControlPart nPart,
+ const Rectangle& rControlRegion,
+ ControlState nState,
+ const ImplControlValue& aValue,
+ const OUString& aCaption )
{
bool bOk = false;
HTHEME hTheme = NULL;
Rectangle buttonRect = rControlRegion;
+ Rectangle cacheRect = rControlRegion;
+ Size keySize = cacheRect.GetSize();
WinOpenGLSalGraphicsImpl* pImpl = dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get());
- ControlCacheKey aControlCacheKey(nType, nPart, nState, buttonRect.GetSize());
+ // tdf#95618 - A few controls render outside the region they're given.
+ if (pImpl && nType == CTRL_TAB_ITEM)
+ {
+ Rectangle rNativeBoundingRegion;
+ Rectangle rNativeContentRegion;
+ if (getNativeControlRegion(nType, nPart, rControlRegion, nState, aValue, aCaption,
+ rNativeBoundingRegion, rNativeContentRegion))
+ {
+ cacheRect = rNativeBoundingRegion;
+ keySize = rNativeBoundingRegion.GetSize();
+ }
+ }
+
+ ControlCacheKey aControlCacheKey(nType, nPart, nState, keySize);
if (pImpl != NULL && pImpl->TryRenderCachedNativeControl(aControlCacheKey, buttonRect.Left(), buttonRect.Top()))
{
return true;
@@ -1288,18 +1303,18 @@ bool WinSalGraphics::drawNativeControl( ControlType nType,
else
{
// We can do OpenGL
- OpenGLCompatibleDC aBlackDC(*this, buttonRect.Left(), buttonRect.Top(), buttonRect.GetWidth(), buttonRect.GetHeight());
+ OpenGLCompatibleDC aBlackDC(*this, cacheRect.Left(), cacheRect.Top(), cacheRect.GetWidth()+1, cacheRect.GetHeight()+1);
SetTextAlign(aBlackDC.getCompatibleHDC(), TA_LEFT|TA_TOP|TA_NOUPDATECP);
aBlackDC.fill(MAKE_SALCOLOR(0, 0, 0));
- OpenGLCompatibleDC aWhiteDC(*this, buttonRect.Left(), buttonRect.Top(), buttonRect.GetWidth(), buttonRect.GetHeight());
+ OpenGLCompatibleDC aWhiteDC(*this, cacheRect.Left(), cacheRect.Top(), cacheRect.GetWidth()+1, cacheRect.GetHeight()+1);
SetTextAlign(aWhiteDC.getCompatibleHDC(), TA_LEFT|TA_TOP|TA_NOUPDATECP);
aWhiteDC.fill(MAKE_SALCOLOR(0xff, 0xff, 0xff));
if (ImplDrawNativeControl(aBlackDC.getCompatibleHDC(), hTheme, rc, nType, nPart, nState, aValue, aCaptionStr) &&
ImplDrawNativeControl(aWhiteDC.getCompatibleHDC(), hTheme, rc, nType, nPart, nState, aValue, aCaptionStr))
{
- bOk = pImpl->RenderAndCacheNativeControl(aWhiteDC, aBlackDC, buttonRect.Left(), buttonRect.Top(), aControlCacheKey);
+ bOk = pImpl->RenderAndCacheNativeControl(aWhiteDC, aBlackDC, cacheRect.Left(), cacheRect.Top(), aControlCacheKey);
}
}
@@ -1330,6 +1345,9 @@ bool WinSalGraphics::getNativeControlRegion( ControlType nType,
{
bool bRet = FALSE;
+ // FIXME: rNativeBoundingRegion has a different origin
+ // depending on which part is used; horrors.
+
HDC hDC = GetDC( mhWnd );
if( nType == CTRL_TOOLBAR )
{