diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-08-05 12:27:08 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-08-05 22:39:57 +0200 |
commit | bbf8673da5a7f1154111776378edb158707c80db (patch) | |
tree | 3ba90c1514fb4840b0a71a0b2866f7def361c992 /svtools | |
parent | 805e2a18b0da06ab01cb4d516d6ceda44c358507 (diff) |
tdf#117388 use native scrollbar under gtk in data browser
Change-Id: I22745f1c910f68fd2c0b31e8392c111fc76ef529
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137864
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/brwbox/brwbox1.cxx | 12 | ||||
-rw-r--r-- | svtools/source/brwbox/brwbox2.cxx | 56 | ||||
-rw-r--r-- | svtools/source/brwbox/datwin.cxx | 38 | ||||
-rw-r--r-- | svtools/source/brwbox/datwin.hxx | 24 |
4 files changed, 44 insertions, 86 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx index 4eafda7e9ad9..c9f0dd681b94 100644 --- a/svtools/source/brwbox/brwbox1.cxx +++ b/svtools/source/brwbox/brwbox1.cxx @@ -19,6 +19,7 @@ #include <svtools/brwbox.hxx> #include <svtools/brwhead.hxx> +#include <svtools/scrolladaptor.hxx> #include <o3tl/numeric.hxx> #include <o3tl/safeint.hxx> #include "datwin.hxx" @@ -101,7 +102,7 @@ void BrowseBox::ConstructImpl( BrowserMode nMode ) uRow.nSel = BROWSER_ENDOFSELECTION; aHScroll->SetLineSize(1); - aHScroll->SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) ); + aHScroll->SetScrollHdl( LINK( this, BrowseBox, HorzScrollHdl ) ); pDataWin->Show(); SetMode( nMode ); @@ -161,7 +162,7 @@ BrowseBox::BrowseBox( vcl::Window* pParent, WinBits nBits, BrowserMode nMode ) :Control( pParent, nBits | WB_3DLOOK ) ,DragSourceHelper( this ) ,DropTargetHelper( this ) - ,aHScroll( VclPtr<ScrollBar>::Create(this, WB_HSCROLL) ) + ,aHScroll( VclPtr<ScrollAdaptor>::Create(this, true) ) // see NavigationBar ctor, here we just want to know its height ,aStatusBarHeight(VclPtr<MeasureStatusBar>::Create(this)) { @@ -2181,13 +2182,10 @@ void BrowseBox::SetMode( BrowserMode nMode ) bHLines = ( nMode & BrowserMode::HLINES ) == BrowserMode::HLINES; bVLines = ( nMode & BrowserMode::VLINES ) == BrowserMode::VLINES; - constexpr WinBits nVScrollWinBits = WB_VSCROLL; - pVScroll = ( nMode & BrowserMode::TRACKING_TIPS ) == BrowserMode::TRACKING_TIPS - ? VclPtr<BrowserScrollBar>::Create( this, nVScrollWinBits, pDataWin.get() ) - : VclPtr<ScrollBar>::Create( this, nVScrollWinBits ); + pVScroll = VclPtr<ScrollAdaptor>::Create(this, false); pVScroll->SetLineSize( 1 ); pVScroll->SetPageSize(1); - pVScroll->SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) ); + pVScroll->SetScrollHdl( LINK( this, BrowseBox, VertScrollHdl ) ); pDataWin->bAutoSizeLastCol = BrowserMode::AUTOSIZE_LASTCOL == ( nMode & BrowserMode::AUTOSIZE_LASTCOL ); diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx index 98eb5e88d5da..7bcdea5ca770 100644 --- a/svtools/source/brwbox/brwbox2.cxx +++ b/svtools/source/brwbox/brwbox2.cxx @@ -23,11 +23,12 @@ #include <tools/debug.hxx> #include <svtools/brwbox.hxx> #include <svtools/brwhead.hxx> -#include "datwin.hxx" #include <svtools/colorcfg.hxx> +#include <svtools/scrolladaptor.hxx> +#include "datwin.hxx" #include <vcl/commandevent.hxx> +#include <vcl/help.hxx> #include <vcl/ptrstyle.hxx> -#include <vcl/scrbar.hxx> #include <vcl/settings.hxx> #include <tools/multisel.hxx> @@ -1120,9 +1121,18 @@ void BrowseBox::UpdateScrollbars() ? static_cast<short>( mvCols.size() - nFirstCol ) : static_cast<short>( nLastCol - nFirstCol ); - short nRange = std::max( nScrollCols, short(0) ); - aHScroll->SetVisibleSize( nVisibleHSize ); - aHScroll->SetRange( Range( 0, nRange )); + if (nVisibleHSize) + { + short nRange = std::max( nScrollCols, short(0) ); + aHScroll->SetVisibleSize( nVisibleHSize ); + aHScroll->SetRange( Range( 0, nRange )); + } + else + { + // ensure scrollbar is shown as fully filled + aHScroll->SetVisibleSize(1); + aHScroll->SetRange(Range(0, 1)); + } if ( bNeedsHScroll && !aHScroll->IsVisible() ) aHScroll->Show(); @@ -1251,7 +1261,6 @@ tools::Long BrowseBox::GetFrozenWidth() const return nWidth; } - void BrowseBox::ColumnInserted( sal_uInt16 nPos ) { if ( pColSel ) @@ -1259,7 +1268,6 @@ void BrowseBox::ColumnInserted( sal_uInt16 nPos ) UpdateScrollbars(); } - sal_uInt16 BrowseBox::FrozenColCount() const { std::size_t nCol; @@ -1270,27 +1278,39 @@ sal_uInt16 BrowseBox::FrozenColCount() const return nCol; //TODO: BrowserColumns::size_type -> sal_uInt16! } - -IMPL_LINK(BrowseBox, ScrollHdl, ScrollBar*, pBar, void) +IMPL_LINK(BrowseBox, VertScrollHdl, weld::Scrollbar&, rScrollbar, void) { - if ( pBar->GetDelta() == 0 ) - return; - - if ( pBar == aHScroll.get() ) - ScrollColumns( aHScroll->GetDelta() ); - if ( pBar == pVScroll ) - ScrollRows( pVScroll->GetDelta() ); + auto nCurScrollRow = nTopRow; + auto nPos = rScrollbar.adjustment_get_value(); + ScrollRows(nPos - nCurScrollRow); + + bool bShowTooltip = ((m_nCurrentMode & BrowserMode::TRACKING_TIPS) == BrowserMode::TRACKING_TIPS); + if (bShowTooltip && + rScrollbar.get_scroll_type() == ScrollType::Drag && + Help::IsQuickHelpEnabled()) + { + OUString aTip = OUString::number(nPos) + "/"; + if (!pDataWin->GetRealRowCount().isEmpty()) + aTip += pDataWin->GetRealRowCount(); + else + aTip += OUString::number(rScrollbar.adjustment_get_upper()); + tools::Rectangle aRect(GetPointerPosPixel(), Size(GetTextWidth(aTip), GetTextHeight())); + Help::ShowQuickHelp(this, aRect, aTip); + } } +IMPL_LINK(BrowseBox, HorzScrollHdl, weld::Scrollbar&, rScrollbar, void) +{ + auto nCurScrollCol = nFirstCol - FrozenColCount(); + ScrollColumns(rScrollbar.adjustment_get_value() - nCurScrollCol); +} IMPL_LINK( BrowseBox, StartDragHdl, HeaderBar*, pBar, void ) { pBar->SetDragSize( pDataWin->GetOutputSizePixel().Height() ); } - // usually only the first column was resized - void BrowseBox::MouseButtonDown( const MouseEvent& rEvt ) { diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx index 331fd2571226..2eea4a5e4255 100644 --- a/svtools/source/brwbox/datwin.cxx +++ b/svtools/source/brwbox/datwin.cxx @@ -20,6 +20,7 @@ #include "datwin.hxx" #include <o3tl/numeric.hxx> #include <svtools/brwhead.hxx> +#include <svtools/scrolladaptor.hxx> #include <utility> #include <vcl/commandevent.hxx> #include <vcl/help.hxx> @@ -635,7 +636,6 @@ void BrowserDataWin::DoOutstandingInvalidations() aInvalidRegion.clear(); } - void BrowserDataWin::Invalidate( InvalidateFlags nFlags ) { if ( !GetUpdateMode() ) @@ -656,40 +656,4 @@ void BrowserDataWin::Invalidate( const tools::Rectangle& rRect, InvalidateFlags Window::Invalidate( rRect, nFlags ); } -BrowserScrollBar::~BrowserScrollBar() -{ - disposeOnce(); -} - -void BrowserScrollBar::dispose() -{ - _pDataWin.clear(); - ScrollBar::dispose(); -} - -void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt ) -{ - tools::Long nPos = GetThumbPos(); - if ( nPos != _nLastPos ) - { - OUString aTip = OUString::number(nPos) + "/"; - if ( !_pDataWin->GetRealRowCount().isEmpty() ) - aTip += _pDataWin->GetRealRowCount(); - else - aTip += OUString::number(GetRangeMax()); - - tools::Rectangle aRect(GetPointerPosPixel(), Size(GetTextWidth(aTip), GetTextHeight())); - Help::ShowQuickHelp(this, aRect, aTip); - _nLastPos = nPos; - } - - ScrollBar::Tracking( rTEvt ); -} - -void BrowserScrollBar::EndScroll() -{ - Help::HideBalloonAndQuickHelp(); - ScrollBar::EndScroll(); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/datwin.hxx b/svtools/source/brwbox/datwin.hxx index 460712e34afd..acabcc0cf8d6 100644 --- a/svtools/source/brwbox/datwin.hxx +++ b/svtools/source/brwbox/datwin.hxx @@ -79,30 +79,6 @@ public: void ZoomChanged(const Fraction& rNewZoom); }; - -class BrowserScrollBar: public ScrollBar -{ - tools::Long _nLastPos; - VclPtr<BrowserDataWin> _pDataWin; - -public: - BrowserScrollBar( vcl::Window* pParent, WinBits nStyle, - BrowserDataWin *pDataWin ) - : ScrollBar( pParent, nStyle ), - _nLastPos( std::numeric_limits<tools::Long>::max() ), - _pDataWin( pDataWin ) - {} - virtual ~BrowserScrollBar() override; - virtual void dispose() override; - //ScrollBar( vcl::Window* pParent, const ResId& rResId ); - - virtual void Tracking( const TrackingEvent& rTEvt ) override; - virtual void EndScroll() override; -}; - - void InitSettings_Impl( vcl::Window *pWin ); - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |