LibreOffice Module sd (master) 1
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
sd::slidesorter::controller::ScrollBarManager Class Reference

Manage the horizontal and vertical scroll bars. More...

#include <SlsScrollBarManager.hxx>

Collaboration diagram for sd::slidesorter::controller::ScrollBarManager:
[legend]

Public Types

enum  Orientation {
  Orientation_Horizontal ,
  Orientation_Vertical
}
 

Public Member Functions

 ScrollBarManager (SlideSorter &rSlideSorter)
 Create a new scroll bar manager that manages three controls: the horizontal scroll bar, the vertical scroll bar, and the little window that fills the gap at the bottom right corner that is left between the two scroll bars. More...
 
 ~ScrollBarManager ()
 
void Connect ()
 Register listeners at the scroll bars. More...
 
void Disconnect ()
 Remove listeners from the scroll bars. More...
 
void UpdateScrollBars (bool bScrollToCurrentPosition)
 Set up the scroll bar, i.e. More...
 
::tools::Rectangle PlaceScrollBars (const ::tools::Rectangle &rAvailableArea, const bool bIsHorizontalScrollBarAllowed, const bool bIsVerticalScrollBarAllowed)
 Place the scroll bars inside the given area. More...
 
void SetTopLeft (const Point &rNewTopLeft)
 Update the vertical and horizontal scroll bars so that the visible area has the given top and left values. More...
 
int GetVerticalScrollBarWidth () const
 Return the width of the vertical scroll bar, which–when shown–should be fixed in contrast to its height. More...
 
int GetHorizontalScrollBarHeight () const
 Return the height of the horizontal scroll bar, which–when shown–should be fixed in contrast to its width. More...
 
bool AutoScroll (const Point &rMouseWindowPosition, const ::std::function< void()> &rAutoScrollFunctor)
 Call this method to scroll a window while the mouse is in dragging a selection. More...
 
void StopAutoScroll ()
 
void clearAutoScrollFunctor ()
 
void Scroll (const Orientation eOrientation, const sal_Int32 nDistance)
 Scroll the slide sorter by setting the thumbs of the scroll bars and by moving the content of the content window. More...
 

Private Member Functions

void SetWindowOrigin (double nHorizontalPosition, double nVerticalPosition)
 
::tools::Rectangle DetermineScrollBarVisibilities (const ::tools::Rectangle &rAvailableArea, const bool bIsHorizontalScrollBarAllowed, const bool bIsVerticalScrollBarAllowed)
 Determine the visibility of the scroll bars so that the window content is not clipped in any dimension without showing a scroll bar. More...
 
bool TestScrollBarVisibilities (bool bHorizontalScrollBarVisible, bool bVerticalScrollBarVisible, const ::tools::Rectangle &rAvailableArea)
 Typically called by DetermineScrollBarVisibilities() this method tests a specific configuration of the two scroll bars being visible or hidden. More...
 
void CalcAutoScrollOffset (const Point &rMouseWindowPosition)
 
bool RepeatAutoScroll ()
 
 DECL_LINK (HorizontalScrollBarHandler, weld::Scrollbar &, void)
 
 DECL_LINK (VerticalScrollBarHandler, weld::Scrollbar &, void)
 
 DECL_LINK (AutoScrollTimeoutHandler, Timer *, void)
 
void PlaceHorizontalScrollBar (const ::tools::Rectangle &aArea)
 
void PlaceVerticalScrollBar (const ::tools::Rectangle &aArea)
 

Private Attributes

SlideSortermrSlideSorter
 
VclPtr< ScrollAdaptormpHorizontalScrollBar
 The horizontal scroll bar. More...
 
VclPtr< ScrollAdaptormpVerticalScrollBar
 The vertical scroll bar. More...
 
double mnHorizontalPosition
 Relative horizontal position of the visible area in the view. More...
 
double mnVerticalPosition
 Relative vertical position of the visible area in the view. More...
 
Size maScrollBorder
 The width and height of the border at the inside of the window which when entered while in drag mode leads to a scrolling of the window. More...
 
Timer maAutoScrollTimer
 The auto scroll timer is used for keep scrolling the window when the mouse reaches its border while dragging a selection. More...
 
Size maAutoScrollOffset
 
bool mbIsAutoScrollActive
 
VclPtr< sd::WindowmpContentWindow
 The content window is the one whose view port is controlled by the scroll bars. More...
 
::std::function< void()> maAutoScrollFunctor
 

Detailed Description

Manage the horizontal and vertical scroll bars.

Listen for events, set their sizes, place them in the window, determine their visibilities.

Handle auto scrolling, i.e. the scrolling of the window when the mouse comes near the window border while dragging a selection.

In order to make the slide sorter be used in the task pane with its own vertical scrollbars the vertical scrollbar of the use of the slide sorter is optional. When using it the available area in a window is used and the vertical scrollbar is displayed when that area is not large enough. When the vertical scrollbar is not used then the available area is assumed to be modifiable. In that case the PlaceScrollBars() method may return an area larger than the one given.

Definition at line 50 of file SlsScrollBarManager.hxx.

Member Enumeration Documentation

◆ Orientation

Enumerator
Orientation_Horizontal 
Orientation_Vertical 

Definition at line 148 of file SlsScrollBarManager.hxx.

Constructor & Destructor Documentation

◆ ScrollBarManager()

sd::slidesorter::controller::ScrollBarManager::ScrollBarManager ( SlideSorter rSlideSorter)

Create a new scroll bar manager that manages three controls: the horizontal scroll bar, the vertical scroll bar, and the little window that fills the gap at the bottom right corner that is left between the two scroll bars.

Call LateInitialization() after constructing a new object.

Definition at line 39 of file SlsScrollBarManager.cxx.

References LINK, maAutoScrollTimer, mpHorizontalScrollBar, mpVerticalScrollBar, Timer::SetInvokeHandler(), and Timer::SetTimeout().

◆ ~ScrollBarManager()

sd::slidesorter::controller::ScrollBarManager::~ScrollBarManager ( )

Definition at line 64 of file SlsScrollBarManager.cxx.

Member Function Documentation

◆ AutoScroll()

bool sd::slidesorter::controller::ScrollBarManager::AutoScroll ( const Point rMouseWindowPosition,
const ::std::function< void()> &  rAutoScrollFunctor 
)

Call this method to scroll a window while the mouse is in dragging a selection.

If the mouse is near the window border or is outside the window then scroll the window accordingly.

Parameters
rMouseWindowPositionThe mouse position for which the scroll amount is calculated.
rAutoScrollFunctorEvery time when the window is scrolled then this functor is executed.
Returns
When the window is scrolled then this method returns <TRUE>. When the window is not changed then <FALSE> is returned.

Definition at line 462 of file SlsScrollBarManager.cxx.

References CalcAutoScrollOffset(), maAutoScrollFunctor, mbIsAutoScrollActive, and RepeatAutoScroll().

Referenced by sd::slidesorter::controller::DragAndDropContext::UpdatePosition().

◆ CalcAutoScrollOffset()

void sd::slidesorter::controller::ScrollBarManager::CalcAutoScrollOffset ( const Point rMouseWindowPosition)
private

◆ clearAutoScrollFunctor()

void sd::slidesorter::controller::ScrollBarManager::clearAutoScrollFunctor ( )

Definition at line 507 of file SlsScrollBarManager.cxx.

References maAutoScrollFunctor.

Referenced by RepeatAutoScroll().

◆ Connect()

void sd::slidesorter::controller::ScrollBarManager::Connect ( )

Register listeners at the scroll bars.

This method is called after startup of a new slide sorter object or after a reactivation of a slide sorter that for example is taken from a cache.

Definition at line 68 of file SlsScrollBarManager.cxx.

References LINK, mpHorizontalScrollBar, and mpVerticalScrollBar.

◆ DECL_LINK() [1/3]

sd::slidesorter::controller::ScrollBarManager::DECL_LINK ( AutoScrollTimeoutHandler  ,
Timer ,
void   
)
private

◆ DECL_LINK() [2/3]

sd::slidesorter::controller::ScrollBarManager::DECL_LINK ( HorizontalScrollBarHandler  ,
weld::Scrollbar ,
void   
)
private

◆ DECL_LINK() [3/3]

sd::slidesorter::controller::ScrollBarManager::DECL_LINK ( VerticalScrollBarHandler  ,
weld::Scrollbar ,
void   
)
private

◆ DetermineScrollBarVisibilities()

tools::Rectangle sd::slidesorter::controller::ScrollBarManager::DetermineScrollBarVisibilities ( const ::tools::Rectangle rAvailableArea,
const bool  bIsHorizontalScrollBarAllowed,
const bool  bIsVerticalScrollBarAllowed 
)
private

Determine the visibility of the scroll bars so that the window content is not clipped in any dimension without showing a scroll bar.

Determining the visibility of the scroll bars is quite complicated.

Parameters
rAvailableAreaThe area in which the scroll bars, the scroll bar filler, and the SlideSorterView will be placed.
Returns
The area that is enclosed by the scroll bars is returned. It will be filled with the SlideSorterView.

The visibility of one influences that of the other because showing a scroll bar makes the available space smaller and may lead to the need of displaying the other. To solve this we test all four combinations of showing or hiding each scroll bar and use the best one. The best one is that combination that a) shows the least number of scroll bars with preference of showing the vertical over showing the horizontal and b) when not showing a scroll bar the area used by the page objects fits into the available area in the scroll bars orientation.

Definition at line 277 of file SlsScrollBarManager.cxx.

References tools::Rectangle::AdjustBottom(), tools::Rectangle::AdjustRight(), sd::slidesorter::SlideSorter::GetModel(), sd::slidesorter::model::SlideSorterModel::GetPageCount(), mpHorizontalScrollBar, mpVerticalScrollBar, mrSlideSorter, and TestScrollBarVisibilities().

Referenced by PlaceScrollBars().

◆ Disconnect()

void sd::slidesorter::controller::ScrollBarManager::Disconnect ( )

Remove listeners from the scroll bars.

This method is called when the slide sorter is destroyed or when it is suspended, e.g. put into a cache for later reuse.

Definition at line 82 of file SlsScrollBarManager.cxx.

References mpHorizontalScrollBar, and mpVerticalScrollBar.

◆ GetHorizontalScrollBarHeight()

int sd::slidesorter::controller::ScrollBarManager::GetHorizontalScrollBarHeight ( ) const

Return the height of the horizontal scroll bar, which–when shown–should be fixed in contrast to its width.

Returns
Returns 0 when the vertical scroll bar is not shown or does not exist, otherwise its height in pixel is returned.

Definition at line 400 of file SlsScrollBarManager.cxx.

References mpHorizontalScrollBar.

Referenced by PlaceVerticalScrollBar().

◆ GetVerticalScrollBarWidth()

int sd::slidesorter::controller::ScrollBarManager::GetVerticalScrollBarWidth ( ) const

Return the width of the vertical scroll bar, which–when shown–should be fixed in contrast to its height.

Returns
Returns 0 when the vertical scroll bar is not shown or does not exist, otherwise its width in pixel is returned.

Definition at line 392 of file SlsScrollBarManager.cxx.

References mpVerticalScrollBar.

Referenced by PlaceHorizontalScrollBar().

◆ PlaceHorizontalScrollBar()

void sd::slidesorter::controller::ScrollBarManager::PlaceHorizontalScrollBar ( const ::tools::Rectangle aArea)
private

◆ PlaceScrollBars()

tools::Rectangle sd::slidesorter::controller::ScrollBarManager::PlaceScrollBars ( const ::tools::Rectangle rAvailableArea,
const bool  bIsHorizontalScrollBarAllowed,
const bool  bIsVerticalScrollBarAllowed 
)

Place the scroll bars inside the given area.

Placing the scroll bars is an iterative process.

When the available area is not large enough for the content to display the horizontal and/or vertical scroll bar is enabled.

Parameters
rAvailableAreaThe scroll bars will be placed inside this rectangle. It is expected to be given in pixel relative to its parent.
bIsHorizontalScrollBarAllowedOnly when this flag is <TRUE> the horizontal scroll may be displayed.
bIsVerticalScrollBarAllowedOnly when this flag is <TRUE> the horizontal scroll may be displayed.
Returns
Returns the space that remains after the scroll bars are placed.

The visibility of one scroll bar affects the remaining size and thus may lead to the other scroll bar becoming visible.

First we determine the visibility of the horizontal scroll bar. After that we do the same for the vertical scroll bar. To have an initial value for the required size we call the layouter before that. When one of the two scroll bars is made visible then the size of the browser window changes and a second call to the layouter becomes necessary. That call is made anyway after this method returns.

Definition at line 105 of file SlsScrollBarManager.cxx.

References DetermineScrollBarVisibilities(), mpHorizontalScrollBar, mpVerticalScrollBar, PlaceHorizontalScrollBar(), and PlaceVerticalScrollBar().

Referenced by sd::slidesorter::controller::SlideSorterController::Rearrange().

◆ PlaceVerticalScrollBar()

void sd::slidesorter::controller::ScrollBarManager::PlaceVerticalScrollBar ( const ::tools::Rectangle aArea)
private

◆ RepeatAutoScroll()

bool sd::slidesorter::controller::ScrollBarManager::RepeatAutoScroll ( )
private

◆ Scroll()

void sd::slidesorter::controller::ScrollBarManager::Scroll ( const Orientation  eOrientation,
const sal_Int32  nDistance 
)

◆ SetTopLeft()

void sd::slidesorter::controller::ScrollBarManager::SetTopLeft ( const Point rNewTopLeft)

◆ SetWindowOrigin()

void sd::slidesorter::controller::ScrollBarManager::SetWindowOrigin ( double  nHorizontalPosition,
double  nVerticalPosition 
)
private

◆ StopAutoScroll()

void sd::slidesorter::controller::ScrollBarManager::StopAutoScroll ( )

◆ TestScrollBarVisibilities()

bool sd::slidesorter::controller::ScrollBarManager::TestScrollBarVisibilities ( bool  bHorizontalScrollBarVisible,
bool  bVerticalScrollBarVisible,
const ::tools::Rectangle rAvailableArea 
)
private

◆ UpdateScrollBars()

void sd::slidesorter::controller::ScrollBarManager::UpdateScrollBars ( bool  bScrollToCurrentPosition)

Set up the scroll bar, i.e.

thumb size and position. Call this method when the content of the browser window changed, i.e. pages were inserted or deleted, the layout or the zoom factor has changed.

Parameters
bScrollToCurrentPositionWhen <TRUE> then scroll the window to the new offset that is defined by the scroll bars. Otherwise the new offset is simply set and the whole window is repainted.

Definition at line 158 of file SlsScrollBarManager.cxx.

References tools::Rectangle::Bottom(), VclPtr< class reference_type >::get(), sd::slidesorter::SlideSorter::GetContentWindow(), sd::slidesorter::view::SlideSorterView::GetModelArea(), vcl::Window::GetSizePixel(), sd::slidesorter::SlideSorter::GetView(), sd::Window::GetVisibleX(), sd::Window::GetVisibleY(), Size::Height(), sd::slidesorter::view::SlideSorterView::InvalidatePageObjectVisibilities(), tools::Rectangle::Left(), mnHorizontalPosition, mnVerticalPosition, mpContentWindow, mpHorizontalScrollBar, mpVerticalScrollBar, mrSlideSorter, vcl::Window::PixelToLogic(), tools::Rectangle::Right(), sd::Window::SetVisibleXY(), SetWindowOrigin(), tools::Rectangle::Top(), and Size::Width().

Referenced by sd::slidesorter::controller::SlideSorterController::Rearrange().

Member Data Documentation

◆ maAutoScrollFunctor

::std::function<void ()> sd::slidesorter::controller::ScrollBarManager::maAutoScrollFunctor
private

Definition at line 195 of file SlsScrollBarManager.hxx.

Referenced by AutoScroll(), clearAutoScrollFunctor(), and RepeatAutoScroll().

◆ maAutoScrollOffset

Size sd::slidesorter::controller::ScrollBarManager::maAutoScrollOffset
private

Definition at line 187 of file SlsScrollBarManager.hxx.

Referenced by CalcAutoScrollOffset(), and RepeatAutoScroll().

◆ maAutoScrollTimer

Timer sd::slidesorter::controller::ScrollBarManager::maAutoScrollTimer
private

The auto scroll timer is used for keep scrolling the window when the mouse reaches its border while dragging a selection.

When the mouse is not moved the timer issues events to keep scrolling.

Definition at line 186 of file SlsScrollBarManager.hxx.

Referenced by RepeatAutoScroll(), ScrollBarManager(), and StopAutoScroll().

◆ maScrollBorder

Size sd::slidesorter::controller::ScrollBarManager::maScrollBorder
private

The width and height of the border at the inside of the window which when entered while in drag mode leads to a scrolling of the window.

Definition at line 180 of file SlsScrollBarManager.hxx.

Referenced by CalcAutoScrollOffset().

◆ mbIsAutoScrollActive

bool sd::slidesorter::controller::ScrollBarManager::mbIsAutoScrollActive
private

Definition at line 188 of file SlsScrollBarManager.hxx.

Referenced by AutoScroll(), RepeatAutoScroll(), and StopAutoScroll().

◆ mnHorizontalPosition

double sd::slidesorter::controller::ScrollBarManager::mnHorizontalPosition
private

Relative horizontal position of the visible area in the view.

Definition at line 174 of file SlsScrollBarManager.hxx.

Referenced by PlaceHorizontalScrollBar(), SetTopLeft(), SetWindowOrigin(), and UpdateScrollBars().

◆ mnVerticalPosition

double sd::slidesorter::controller::ScrollBarManager::mnVerticalPosition
private

Relative vertical position of the visible area in the view.

Definition at line 176 of file SlsScrollBarManager.hxx.

Referenced by PlaceVerticalScrollBar(), SetTopLeft(), SetWindowOrigin(), and UpdateScrollBars().

◆ mpContentWindow

VclPtr<sd::Window> sd::slidesorter::controller::ScrollBarManager::mpContentWindow
private

The content window is the one whose view port is controlled by the scroll bars.

Definition at line 193 of file SlsScrollBarManager.hxx.

Referenced by TestScrollBarVisibilities(), and UpdateScrollBars().

◆ mpHorizontalScrollBar

VclPtr<ScrollAdaptor> sd::slidesorter::controller::ScrollBarManager::mpHorizontalScrollBar
private

The horizontal scroll bar.

Note that is used but not owned by objects of this class. It is given to the constructor.

Definition at line 166 of file SlsScrollBarManager.hxx.

Referenced by CalcAutoScrollOffset(), Connect(), DetermineScrollBarVisibilities(), Disconnect(), GetHorizontalScrollBarHeight(), PlaceHorizontalScrollBar(), PlaceScrollBars(), Scroll(), ScrollBarManager(), SetTopLeft(), TestScrollBarVisibilities(), and UpdateScrollBars().

◆ mpVerticalScrollBar

VclPtr<ScrollAdaptor> sd::slidesorter::controller::ScrollBarManager::mpVerticalScrollBar
private

The vertical scroll bar.

Note that is used but not owned by objects of this class. It is given to the constructor.

Definition at line 171 of file SlsScrollBarManager.hxx.

Referenced by Connect(), DetermineScrollBarVisibilities(), Disconnect(), GetVerticalScrollBarWidth(), PlaceScrollBars(), PlaceVerticalScrollBar(), Scroll(), ScrollBarManager(), SetTopLeft(), TestScrollBarVisibilities(), and UpdateScrollBars().

◆ mrSlideSorter

SlideSorter& sd::slidesorter::controller::ScrollBarManager::mrSlideSorter
private

The documentation for this class was generated from the following files: