summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-06-10 14:04:17 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-06-10 15:17:33 +0200
commitd693223b84b518701d308678801ccc50877490dc (patch)
treee23b67953add9c9acc2f5b06bcb34bd35b5e507d
parent0963d6b25e6861591805c0d6ae8c0476adf177c0 (diff)
tdf#136766 Zoom slider in calc print preview has white background
I cannot figure out any way to make transparent stuff on the toolbar behave under all rendering backends, so just revert this this reverts commit 00cffc20e40b2412c7e9867eed24c9834504e24f Date: Mon Sep 7 13:28:33 2020 +0200 tdf#135181 Calc print preview zoom slider print preview not transparent (gen) commit 444c7c736be7545344298a9cbb3a69886edc5ecb Date: Mon May 18 18:23:13 2020 +0200 tdf#125538 fix background of zoom control Change-Id: I7c351796b2c0778c1520fc8177d05567b2ae8a48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116982 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/ui/cctrl/tbzoomsliderctrl.cxx45
-rw-r--r--sc/source/ui/inc/tbzoomsliderctrl.hxx2
2 files changed, 30 insertions, 17 deletions
diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
index ed8b05b3a0b4..ee0a5021fc66 100644
--- a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
+++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
@@ -95,9 +95,8 @@ struct ScZoomSlider::ScZoomSliderWnd_Impl
Image maIncreaseButton;
Image maDecreaseButton;
bool mbOmitPaint;
- VclPtr<vcl::Window> mxParentWindow;
- explicit ScZoomSliderWnd_Impl( sal_uInt16 nCurrentZoom, vcl::Window* parentWindow ) :
+ explicit ScZoomSliderWnd_Impl( sal_uInt16 nCurrentZoom ) :
mnCurrentZoom( nCurrentZoom ),
mnMinZoom( 10 ),
mnMaxZoom( 400 ),
@@ -106,8 +105,7 @@ struct ScZoomSlider::ScZoomSliderWnd_Impl
maSliderButton(),
maIncreaseButton(),
maDecreaseButton(),
- mbOmitPaint( false ),
- mxParentWindow(parentWindow)
+ mbOmitPaint( false )
{
}
};
@@ -207,7 +205,7 @@ ScZoomSliderWnd::ScZoomSliderWnd( vcl::Window* pParent,
const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider,
sal_uInt16 nCurrentZoom ):
InterimItemWindow(pParent, "modules/scalc/ui/zoombox.ui", "ZoomBox"),
- mxWidget(new ScZoomSlider(rDispatchProvider, nCurrentZoom, pParent)),
+ mxWidget(new ScZoomSlider(rDispatchProvider, nCurrentZoom)),
mxWeld(new weld::CustomWeld(*m_xBuilder, "zoom", *mxWidget))
{
Size aLogicalSize( 115, 40 );
@@ -231,8 +229,8 @@ void ScZoomSliderWnd::dispose()
}
ScZoomSlider::ScZoomSlider(const css::uno::Reference< css::frame::XDispatchProvider>& rDispatchProvider,
- sal_uInt16 nCurrentZoom, vcl::Window* parentWindow)
- : mpImpl(new ScZoomSliderWnd_Impl(nCurrentZoom, parentWindow))
+ sal_uInt16 nCurrentZoom)
+ : mpImpl(new ScZoomSliderWnd_Impl(nCurrentZoom))
, m_xDispatchProvider(rDispatchProvider)
{
mpImpl->maSliderButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERBUTTON);
@@ -275,8 +273,9 @@ bool ScZoomSlider::MouseButtonDown( const MouseEvent& rMEvt )
if( nOldZoom == mpImpl->mnCurrentZoom )
return true;
- // need to invalidate parent since we rely on the toolbox drawing it's fancy gradient background
- mpImpl->mxParentWindow->Invalidate();
+ tools::Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
+
+ Invalidate(aRect);
mpImpl->mbOmitPaint = true;
SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom );
@@ -310,8 +309,8 @@ bool ScZoomSlider::MouseMove( const MouseEvent& rMEvt )
{
mpImpl->mnCurrentZoom = Offset2Zoom( aPoint.X() );
- // need to invalidate parent since we rely on the toolbox drawing it's fancy gradient background
- mpImpl->mxParentWindow->Invalidate();
+ tools::Rectangle aRect(Point(0, 0), aSliderWindowSize);
+ Invalidate(aRect);
mpImpl->mbOmitPaint = true; // optimization: paint before executing command,
@@ -377,9 +376,11 @@ void ScZoomSlider::UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem)
}
}
+ Size aSliderWindowSize = GetOutputSizePixel();
+ tools::Rectangle aRect(Point(0, 0), aSliderWindowSize);
+
if ( !mpImpl->mbOmitPaint )
- // need to invalidate parent since we rely on the toolbox drawing it's fancy gradient background
- mpImpl->mxParentWindow->Invalidate();
+ Invalidate(aRect);
}
void ScZoomSlider::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
@@ -397,9 +398,6 @@ void ScZoomSlider::DoPaint(vcl::RenderContext& rRenderContext)
ScopedVclPtrInstance< VirtualDevice > pVDev(rRenderContext);
pVDev->SetOutputSizePixel(aSliderWindowSize);
- pVDev->SetFillColor( COL_TRANSPARENT );
- pVDev->SetLineColor( COL_TRANSPARENT );
- pVDev->DrawRect( aRect );
tools::Rectangle aSlider = aRect;
@@ -420,6 +418,21 @@ void ScZoomSlider::DoPaint(vcl::RenderContext& rRenderContext)
tools::Rectangle aRight(aSlider);
aRight.SetLeft( aRight.Right() );
+ // draw VirtualDevice's background color
+ Color aStartColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor();
+ Color aEndColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor();
+
+ if (aEndColor.IsDark())
+ aStartColor = aEndColor;
+
+ Gradient aGradient;
+ aGradient.SetAngle(0_deg10);
+ aGradient.SetStyle(GradientStyle::Linear);
+
+ aGradient.SetStartColor(aStartColor);
+ aGradient.SetEndColor(aEndColor);
+ pVDev->DrawGradient(aRect, aGradient);
+
// draw slider
pVDev->SetLineColor(COL_WHITE);
pVDev->DrawRect(aSecondLine);
diff --git a/sc/source/ui/inc/tbzoomsliderctrl.hxx b/sc/source/ui/inc/tbzoomsliderctrl.hxx
index 3be8d7556b65..1a18fc80cee1 100644
--- a/sc/source/ui/inc/tbzoomsliderctrl.hxx
+++ b/sc/source/ui/inc/tbzoomsliderctrl.hxx
@@ -52,7 +52,7 @@ private:
void DoPaint(vcl::RenderContext& rRenderContext);
public:
ScZoomSlider(const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider,
- sal_uInt16 nCurrentZoom, vcl::Window*);
+ sal_uInt16 nCurrentZoom);
void UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem);