diff options
author | Sahil <me.sahilgautam@gmail.com> | 2024-01-04 16:47:17 +0530 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2024-01-10 18:01:24 +0100 |
commit | 986b5bb3c183b038ecc1ce4e16cff1dca837932a (patch) | |
tree | dfe02d546bbcbb056bc6042f47dd9db348d76b82 /sc/source/ui/cctrl | |
parent | 772da0f1aa6891a0b31d45d99a5978c65ed24e34 (diff) |
tdf#42030 Add UI label for page preview zoom slider
* Scale before the page preview zoom slider
* zoom % after the page preview zoom slider
Change-Id: I893852bf48e31b36a028f9ee282d47a627bb0086
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159362
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'sc/source/ui/cctrl')
-rw-r--r-- | sc/source/ui/cctrl/tbzoomsliderctrl.cxx | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx index 4ec776de100c..d14dd1cb08c0 100644 --- a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx +++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include <tbzoomsliderctrl.hxx> +#include <i18nutil/unicode.hxx> +#include <vcl/svapp.hxx> #include <comphelper/propertyvalue.hxx> #include <utility> @@ -102,8 +104,7 @@ const tools::Long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance sal_uInt16 ScZoomSlider::Offset2Zoom( tools::Long nOffset ) const { - Size aSliderWindowSize = GetOutputSizePixel(); - const tools::Long nControlWidth = aSliderWindowSize.Width(); + const tools::Long nControlWidth = GetSliderLength(); sal_uInt16 nRet = 0; if( nOffset < nSliderXOffset ) @@ -154,8 +155,7 @@ sal_uInt16 ScZoomSlider::Offset2Zoom( tools::Long nOffset ) const tools::Long ScZoomSlider::Zoom2Offset( sal_uInt16 nCurrentZoom ) const { - Size aSliderWindowSize = GetOutputSizePixel(); - const tools::Long nControlWidth = aSliderWindowSize.Width(); + const tools::Long nControlWidth = GetSliderLength(); tools::Long nRect = nSliderXOffset; const tools::Long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset; @@ -183,6 +183,8 @@ ScZoomSliderWnd::ScZoomSliderWnd( vcl::Window* pParent, sal_uInt16 nCurrentZoom ): InterimItemWindow(pParent, "modules/scalc/ui/zoombox.ui", "ZoomBox"), mxWidget(new ScZoomSlider(rDispatchProvider, nCurrentZoom)), + mxPercentage(m_xBuilder->weld_label("current_zoom")), + mxLabel(m_xBuilder->weld_label("zoom_label")), mxWeld(new weld::CustomWeld(*m_xBuilder, "zoom", *mxWidget)) { Size aLogicalSize( 115, 40 ); @@ -190,7 +192,14 @@ ScZoomSliderWnd::ScZoomSliderWnd( vcl::Window* pParent, Size aPreferredSize(aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight); mxWidget->GetDrawingArea()->set_size_request(aPreferredSize.Width(), aPreferredSize.Height()); mxWidget->SetOutputSizePixel(aPreferredSize); + mxWidget->SetSliderLength(aPreferredSize.Width() + nIncDecWidth); + + aPreferredSize.setWidth(aPreferredSize.Width() + mxLabel->get_pixel_size(mxLabel->get_label()).Width() + + mxPercentage->get_pixel_size(mxPercentage->get_label()).Width()); + SetSizePixel(aPreferredSize); + OUString sCurrentZoom(unicode::formatPercent(nCurrentZoom, Application::GetSettings().GetUILanguageTag())); + mxPercentage->set_label(sCurrentZoom); } ScZoomSliderWnd::~ScZoomSliderWnd() @@ -236,12 +245,12 @@ bool ScZoomSlider::MouseButtonDown( const MouseEvent& rMEvt ) mnCurrentZoom = mnCurrentZoom - 5; } // click to + button - else if ( aPoint.X() >= aSliderWindowSize.Width() - nSliderXOffset + nButtonLeftOffset && - aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset + nButtonRightOffset ) + else if ( aPoint.X() >= GetSliderLength() - nSliderXOffset + nButtonLeftOffset && + aPoint.X() <= GetSliderLength() - nSliderXOffset + nButtonRightOffset ) { mnCurrentZoom = mnCurrentZoom + 5; } - else if( aPoint.X() >= nSliderXOffset && aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset ) + else if( aPoint.X() >= nSliderXOffset && aPoint.X() <= GetSliderLength() - nSliderXOffset ) { mnCurrentZoom = Offset2Zoom( aPoint.X() ); } @@ -276,7 +285,7 @@ bool ScZoomSlider::MouseButtonDown( const MouseEvent& rMEvt ) bool ScZoomSlider::MouseMove( const MouseEvent& rMEvt ) { Size aSliderWindowSize = GetOutputSizePixel(); - const tools::Long nControlWidth = aSliderWindowSize.Width(); + const tools::Long nControlWidth = GetSliderLength(); const short nButtons = rMEvt.GetButtons(); // check mouse move with button pressed @@ -312,6 +321,8 @@ bool ScZoomSlider::MouseMove( const MouseEvent& rMEvt ) void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem ) { + OUString sCurrentZoom(unicode::formatPercent(pZoomSliderItem->GetValue(), Application::GetSettings().GetUILanguageTag())); + mxPercentage->set_label(sCurrentZoom); mxWidget->UpdateFromItem(pZoomSliderItem); } @@ -377,6 +388,7 @@ void ScZoomSlider::DoPaint(vcl::RenderContext& rRenderContext) pVDev->SetOutputSizePixel(aSliderWindowSize); tools::Rectangle aSlider = aRect; + aSlider.setWidth(GetSliderLength()); aSlider.AdjustTop((aSliderWindowSize.Height() - nSliderHeight) / 2 - 1 ); aSlider.SetBottom( aSlider.Top() + nSliderHeight ); @@ -449,7 +461,7 @@ void ScZoomSlider::DoPaint(vcl::RenderContext& rRenderContext) pVDev->DrawImage(aImagePoint, maDecreaseButton); // draw increase button - aImagePoint.setX( aRect.Left() + aSliderWindowSize.Width() - nIncDecWidth - (nSliderXOffset - nIncDecWidth) / 2 ); + aImagePoint.setX( aRect.Left() + GetSliderLength() - nIncDecWidth - (nSliderXOffset - nIncDecWidth) / 2 ); pVDev->DrawImage(aImagePoint, maIncreaseButton); rRenderContext.DrawOutDev(Point(0, 0), aSliderWindowSize, Point(0, 0), aSliderWindowSize, *pVDev); |