diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-08-05 16:16:53 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-08-06 13:08:15 +0200 |
commit | 800551502416d3d80c8d14a53335dad5190290a4 (patch) | |
tree | 9df0058337946e3237a1a45c4c7e14d94bd7faf6 /reportdesign | |
parent | 59a2650101a0ce711151bfd39af1bbb69f71f318 (diff) |
tdf#117388 use native scrollbar under gtk in reportdesigner
Change-Id: If7a66055dbae6d8ee31768ff438eb8105b8f980f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137880
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'reportdesign')
-rw-r--r-- | reportdesign/source/ui/inc/ScrollHelper.hxx | 18 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ScrollHelper.cxx | 22 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ViewsWindow.cxx | 8 | ||||
-rw-r--r-- | reportdesign/source/ui/report/dlgedfunc.cxx | 21 |
4 files changed, 39 insertions, 30 deletions
diff --git a/reportdesign/source/ui/inc/ScrollHelper.hxx b/reportdesign/source/ui/inc/ScrollHelper.hxx index 076943ff76fc..02b34d6e6034 100644 --- a/reportdesign/source/ui/inc/ScrollHelper.hxx +++ b/reportdesign/source/ui/inc/ScrollHelper.hxx @@ -16,9 +16,10 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_REPORTDESIGN_SOURCE_UI_INC_SCROLLHELPER_HXX -#define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_SCROLLHELPER_HXX +#pragma once + +#include <svtools/scrolladaptor.hxx> #include <vcl/scrbar.hxx> #include <com/sun/star/report/XSection.hpp> #include <comphelper/propmultiplex.hxx> @@ -44,8 +45,8 @@ namespace rptui , public IMarkedSection { private: - VclPtr<ScrollBar> m_aHScroll; - VclPtr<ScrollBar> m_aVScroll; + VclPtr<ScrollAdaptor> m_aHScroll; + VclPtr<ScrollAdaptor> m_aVScroll; VclPtr<ScrollBarBox> m_aCornerWin; // window in the bottom right corner Size m_aTotalPixelSize; VclPtr<ODesignView> m_pParent; @@ -53,10 +54,10 @@ namespace rptui ::rtl::Reference<comphelper::OPropertyChangeMultiplexer > m_pReportDefinitionMultiPlexer; // listener for property changes - DECL_LINK( ScrollHdl, ScrollBar*, void); + DECL_LINK( ScrollHdl, weld::Scrollbar&, void); Size ResizeScrollBars(); void ImplInitSettings(); - void impl_initScrollBar( ScrollBar& _rScrollBar ) const; + void impl_initScrollBar(ScrollAdaptor& rScrollBar) const; OScrollWindowHelper(OScrollWindowHelper const &) = delete; void operator =(OScrollWindowHelper const &) = delete; @@ -79,8 +80,8 @@ namespace rptui Point getThumbPos() const { return Point(m_aHScroll->GetThumbPos(),m_aVScroll->GetThumbPos())/*m_aScrollOffset*/; } void setTotalSize(sal_Int32 _nWidth, sal_Int32 _nHeight); const Size& getTotalSize() const { return m_aTotalPixelSize; } - ScrollBar& GetHScroll() { return *m_aHScroll; } - ScrollBar& GetVScroll() { return *m_aVScroll; } + ScrollAdaptor& GetHScroll() { return *m_aHScroll; } + ScrollAdaptor& GetVScroll() { return *m_aVScroll; } // forwards void SetMode( DlgEdMode _eMode ); @@ -205,6 +206,5 @@ namespace rptui sal_uInt16 getZoomFactor(SvxZoomType _eType) const; }; } -#endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_SCROLLHELPER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/reportdesign/source/ui/report/ScrollHelper.cxx b/reportdesign/source/ui/report/ScrollHelper.cxx index bf5f261cfd7f..de342a17807c 100644 --- a/reportdesign/source/ui/report/ScrollHelper.cxx +++ b/reportdesign/source/ui/report/ScrollHelper.cxx @@ -34,7 +34,7 @@ namespace rptui using namespace ::com::sun::star; -static void lcl_setScrollBar(sal_Int32 _nNewValue,const Point& _aPos,const Size& _aSize,ScrollBar& _rScrollBar) +static void lcl_setScrollBar(sal_Int32 _nNewValue,const Point& _aPos,const Size& _aSize,ScrollAdaptor& _rScrollBar) { _rScrollBar.SetPosSizePixel(_aPos,_aSize); _rScrollBar.SetPageSize( _nNewValue ); @@ -45,8 +45,8 @@ static void lcl_setScrollBar(sal_Int32 _nNewValue,const Point& _aPos,const Size& OScrollWindowHelper::OScrollWindowHelper( ODesignView* _pDesignView) : OScrollWindowHelper_BASE( _pDesignView,WB_DIALOGCONTROL) ,OPropertyChangeListener(m_aMutex) - ,m_aHScroll( VclPtr<ScrollBar>::Create(this, WB_HSCROLL|WB_REPEAT|WB_DRAG) ) - ,m_aVScroll( VclPtr<ScrollBar>::Create(this, WB_VSCROLL|WB_REPEAT|WB_DRAG) ) + ,m_aHScroll( VclPtr<ScrollAdaptor>::Create(this, true) ) + ,m_aVScroll( VclPtr<ScrollAdaptor>::Create(this, false) ) ,m_aCornerWin( VclPtr<ScrollBarBox>::Create(this) ) ,m_pParent(_pDesignView) ,m_aReportWindow(VclPtr<rptui::OReportWindow>::Create(this,m_pParent)) @@ -83,20 +83,12 @@ void OScrollWindowHelper::dispose() OScrollWindowHelper_BASE::dispose(); } - -void OScrollWindowHelper::impl_initScrollBar( ScrollBar& _rScrollBar ) const +void OScrollWindowHelper::impl_initScrollBar( ScrollAdaptor& _rScrollBar ) const { - AllSettings aSettings( _rScrollBar.GetSettings() ); - StyleSettings aStyle( aSettings.GetStyleSettings() ); - aStyle.SetDragFullOptions( aStyle.GetDragFullOptions() | DragFullOptions::Scroll ); // live scrolling - aSettings.SetStyleSettings( aStyle ); - _rScrollBar.SetSettings( aSettings ); - _rScrollBar.SetScrollHdl( LINK( const_cast<OScrollWindowHelper*>(this), OScrollWindowHelper, ScrollHdl ) ); _rScrollBar.SetLineSize( SCR_LINE_SIZE ); } - void OScrollWindowHelper::initialize() { uno::Reference<report::XReportDefinition> xReportDefinition = m_pParent->getController().getReportDefinition(); @@ -191,7 +183,7 @@ void OScrollWindowHelper::Resize() m_aReportWindow->SetPosSizePixel(Point( 0, 0 ),aTotalOutputSize); } -IMPL_LINK( OScrollWindowHelper, ScrollHdl, ScrollBar*, /*pScroll*/, void ) +IMPL_LINK_NOARG(OScrollWindowHelper, ScrollHdl, weld::Scrollbar&, void) { m_aReportWindow->ScrollChildren( getThumbPos() ); } @@ -331,8 +323,8 @@ bool OScrollWindowHelper::EventNotify( NotifyEvent& rNEvt ) (pCommandEvent->GetCommand() == CommandEventId::StartAutoScroll) || (pCommandEvent->GetCommand() == CommandEventId::AutoScroll)) ) { - ScrollBar* pHScrBar = nullptr; - ScrollBar* pVScrBar = nullptr; + ScrollAdaptor* pHScrBar = nullptr; + ScrollAdaptor* pVScrBar = nullptr; if ( m_aHScroll->IsVisible() ) pHScrBar = m_aHScroll.get(); diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index 9dfec8d91574..50269c10f4fc 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -1371,9 +1371,13 @@ void OViewsWindow::handleKey(const vcl::KeyCode& _rCode) { // scroll page OScrollWindowHelper* pScrollWindow = getView()->getScrollWindow(); - ScrollBar& rScrollBar = ( nCode == KEY_LEFT || nCode == KEY_RIGHT ) ? pScrollWindow->GetHScroll() : pScrollWindow->GetVScroll(); + ScrollAdaptor& rScrollBar = ( nCode == KEY_LEFT || nCode == KEY_RIGHT ) ? pScrollWindow->GetHScroll() : pScrollWindow->GetVScroll(); if ( rScrollBar.IsVisible() ) - rScrollBar.DoScrollAction(( nCode == KEY_RIGHT || nCode == KEY_UP ) ? ScrollType::LineUp : ScrollType::LineDown ); + { + auto nCurrentPos = rScrollBar.GetThumbPos(); + auto nLineSize = rScrollBar.GetLineSize(); + rScrollBar.DoScroll(( nCode == KEY_RIGHT || nCode == KEY_UP ) ? (nCurrentPos - nLineSize) : (nCurrentPos + nLineSize)); + } return; } diff --git a/reportdesign/source/ui/report/dlgedfunc.cxx b/reportdesign/source/ui/report/dlgedfunc.cxx index 8a84093cd6d9..6252e298e8bd 100644 --- a/reportdesign/source/ui/report/dlgedfunc.cxx +++ b/reportdesign/source/ui/report/dlgedfunc.cxx @@ -86,8 +86,8 @@ void DlgEdFunc::ForceScroll( const Point& rPos ) aWorkArea = pScrollWindow->PixelToLogic( aWorkArea ); if( !aOutRect.Contains( rPos ) && aWorkArea.Contains( rPos ) ) { - ScrollBar& rHScroll = pScrollWindow->GetHScroll(); - ScrollBar& rVScroll = pScrollWindow->GetVScroll(); + ScrollAdaptor& rHScroll = pScrollWindow->GetHScroll(); + ScrollAdaptor& rVScroll = pScrollWindow->GetVScroll(); ScrollType eH = ScrollType::LineDown,eV = ScrollType::LineDown; if( rPos.X() < aOutRect.Left() ) eH = ScrollType::LineUp; @@ -99,8 +99,21 @@ void DlgEdFunc::ForceScroll( const Point& rPos ) else if( rPos.Y() <= aOutRect.Bottom() ) eV = ScrollType::DontKnow; - rHScroll.DoScrollAction(eH); - rVScroll.DoScrollAction(eV); + if (eH != ScrollType::DontKnow) + { + auto nCurrentPos = rHScroll.GetThumbPos(); + auto nLineSize = rHScroll.GetLineSize(); + assert(eH == ScrollType::LineUp || eH == ScrollType::LineDown); + rHScroll.DoScroll(eH == ScrollType::LineUp ? (nCurrentPos - nLineSize) : (nCurrentPos + nLineSize)); + } + + if (eV != ScrollType::DontKnow) + { + auto nCurrentPos = rVScroll.GetThumbPos(); + auto nLineSize = rVScroll.GetLineSize(); + assert(eV == ScrollType::LineUp || eV == ScrollType::LineDown); + rVScroll.DoScroll(eV == ScrollType::LineUp ? (nCurrentPos - nLineSize) : (nCurrentPos + nLineSize)); + } } aScrollTimer.Start(); |