LibreOffice Module sd (master) 1
|
Manage the horizontal and vertical scroll bars. More...
#include <SlsScrollBarManager.hxx>
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 | |
SlideSorter & | mrSlideSorter |
VclPtr< ScrollAdaptor > | mpHorizontalScrollBar |
The horizontal scroll bar. More... | |
VclPtr< ScrollAdaptor > | mpVerticalScrollBar |
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::Window > | mpContentWindow |
The content window is the one whose view port is controlled by the scroll bars. More... | |
::std::function< void()> | maAutoScrollFunctor |
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.
Enumerator | |
---|---|
Orientation_Horizontal | |
Orientation_Vertical |
Definition at line 148 of file SlsScrollBarManager.hxx.
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().
sd::slidesorter::controller::ScrollBarManager::~ScrollBarManager | ( | ) |
Definition at line 64 of file SlsScrollBarManager.cxx.
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.
rMouseWindowPosition | The mouse position for which the scroll amount is calculated. |
rAutoScrollFunctor | Every time when the window is scrolled then this functor is executed. |
Definition at line 462 of file SlsScrollBarManager.cxx.
References CalcAutoScrollOffset(), maAutoScrollFunctor, mbIsAutoScrollActive, and RepeatAutoScroll().
Referenced by sd::slidesorter::controller::DragAndDropContext::UpdatePosition().
|
private |
Definition at line 408 of file SlsScrollBarManager.cxx.
References tools::Rectangle::Bottom(), VclPtr< class reference_type >::get(), sd::slidesorter::SlideSorter::GetContentWindow(), tools::Rectangle::GetHeight(), sd::slidesorter::view::SlideSorterView::GetModelArea(), vcl::Window::GetOutputSizePixel(), vcl::Window::GetPosPixel(), sd::slidesorter::SlideSorter::GetView(), sd::slidesorter::controller::gnHorizontalScrollFactor(), sd::slidesorter::controller::gnVerticalScrollFactor(), Size::Height(), tools::Rectangle::Left(), vcl::Window::LogicToPixel(), maAutoScrollOffset, maScrollBorder, mpHorizontalScrollBar, mrSlideSorter, tools::Rectangle::Right(), tools::Rectangle::Top(), Size::Width(), Point::X(), and Point::Y().
Referenced by AutoScroll().
void sd::slidesorter::controller::ScrollBarManager::clearAutoScrollFunctor | ( | ) |
Definition at line 507 of file SlsScrollBarManager.cxx.
References maAutoScrollFunctor.
Referenced by RepeatAutoScroll().
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.
|
private |
|
private |
|
private |
|
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.
rAvailableArea | The area in which the scroll bars, the scroll bar filler, and the SlideSorterView will be placed. |
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().
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.
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.
Definition at line 400 of file SlsScrollBarManager.cxx.
References mpHorizontalScrollBar.
Referenced by PlaceVerticalScrollBar().
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.
Definition at line 392 of file SlsScrollBarManager.cxx.
References mpVerticalScrollBar.
Referenced by PlaceHorizontalScrollBar().
|
private |
Definition at line 124 of file SlsScrollBarManager.cxx.
References GetVerticalScrollBarWidth(), Size::Height(), mnHorizontalPosition, and mpHorizontalScrollBar.
Referenced by 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.
rAvailableArea | The scroll bars will be placed inside this rectangle. It is expected to be given in pixel relative to its parent. |
bIsHorizontalScrollBarAllowed | Only when this flag is <TRUE> the horizontal scroll may be displayed. |
bIsVerticalScrollBarAllowed | Only when this flag is <TRUE> the horizontal scroll may be displayed. |
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().
|
private |
Definition at line 143 of file SlsScrollBarManager.cxx.
References GetHorizontalScrollBarHeight(), mnVerticalPosition, mpVerticalScrollBar, and Size::Width().
Referenced by PlaceScrollBars().
|
private |
Definition at line 481 of file SlsScrollBarManager.cxx.
References clearAutoScrollFunctor(), sd::slidesorter::SlideSorter::GetView(), sd::slidesorter::SlideSorter::GetViewShell(), Size::Height(), sd::slidesorter::view::SlideSorterView::InvalidatePageObjectVisibilities(), maAutoScrollFunctor, maAutoScrollOffset, maAutoScrollTimer, mbIsAutoScrollActive, mrSlideSorter, sd::ViewShell::Scroll(), Timer::Start(), and Size::Width().
Referenced by AutoScroll().
void sd::slidesorter::controller::ScrollBarManager::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.
eOrientation | Defines whether to scroll horizontally or vertically. |
nDistance | distance in slides. |
Definition at line 517 of file SlsScrollBarManager.cxx.
References Point::AdjustX(), Point::AdjustY(), tools::Rectangle::Bottom(), sd::slidesorter::controller::VisibleAreaManager::DeactivateCurrentSlideTracking(), sd::slidesorter::SlideSorter::GetController(), sd::slidesorter::view::Layouter::GetIndexAtPoint(), sd::slidesorter::view::SlideSorterView::GetLayouter(), sd::slidesorter::view::Layouter::GetPageObjectBox(), sd::slidesorter::view::Layouter::GetPageObjectSize(), sd::slidesorter::SlideSorter::GetView(), sd::slidesorter::controller::SlideSorterController::GetVisibleAreaManager(), Size::Height(), tools::Rectangle::Left(), mpHorizontalScrollBar, mpVerticalScrollBar, mrSlideSorter, nIndex, Orientation_Horizontal, Orientation_Vertical, tools::Rectangle::Right(), SetTopLeft(), Point::setX(), Point::setY(), tools::Rectangle::Top(), Size::Width(), Point::X(), and Point::Y().
Referenced by sd::slidesorter::controller::SlideSorterController::Command().
void sd::slidesorter::controller::ScrollBarManager::SetTopLeft | ( | const Point & | rNewTopLeft | ) |
Update the vertical and horizontal scroll bars so that the visible area has the given top and left values.
Definition at line 366 of file SlsScrollBarManager.cxx.
References sd::slidesorter::SlideSorter::GetContentWindow(), sd::slidesorter::SlideSorter::GetView(), sd::slidesorter::view::SlideSorterView::InvalidatePageObjectVisibilities(), mnHorizontalPosition, mnVerticalPosition, mpHorizontalScrollBar, mpVerticalScrollBar, mrSlideSorter, Point::X(), and Point::Y().
Referenced by Scroll().
|
private |
Definition at line 248 of file SlsScrollBarManager.cxx.
References VclPtr< class reference_type >::get(), sd::slidesorter::SlideSorter::GetContentWindow(), sd::Window::GetViewSize(), Size::Height(), vcl::Window::Invalidate(), mnHorizontalPosition, mnVerticalPosition, mrSlideSorter, sd::Window::SetWinViewPos(), sd::Window::UpdateMapMode(), and Size::Width().
Referenced by UpdateScrollBars().
void sd::slidesorter::controller::ScrollBarManager::StopAutoScroll | ( | ) |
Definition at line 475 of file SlsScrollBarManager.cxx.
References maAutoScrollTimer, mbIsAutoScrollActive, and Task::Stop().
Referenced by sd::slidesorter::controller::SelectionFunction::MouseButtonUp(), and sd::slidesorter::controller::DragAndDropContext::SetTargetSlideSorter().
|
private |
Typically called by DetermineScrollBarVisibilities() this method tests a specific configuration of the two scroll bars being visible or hidden.
Definition at line 323 of file SlsScrollBarManager.cxx.
References Size::AdjustHeight(), Size::AdjustWidth(), sd::slidesorter::view::SlideSorterView::GetLayouter(), sd::slidesorter::SlideSorter::GetModel(), sd::slidesorter::view::SlideSorterView::GetOrientation(), sd::slidesorter::model::SlideSorterModel::GetPageCount(), sd::slidesorter::model::SlideSorterModel::GetPageDescriptor(), tools::Rectangle::GetSize(), sd::slidesorter::view::Layouter::GetTotalBoundingBox(), sd::slidesorter::SlideSorter::GetView(), Size::Height(), mpContentWindow, mpHorizontalScrollBar, mpVerticalScrollBar, mrSlideSorter, sd::slidesorter::view::Layouter::Rearrange(), and Size::Width().
Referenced by DetermineScrollBarVisibilities().
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.
bScrollToCurrentPosition | When <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().
|
private |
Definition at line 195 of file SlsScrollBarManager.hxx.
Referenced by AutoScroll(), clearAutoScrollFunctor(), and RepeatAutoScroll().
|
private |
Definition at line 187 of file SlsScrollBarManager.hxx.
Referenced by CalcAutoScrollOffset(), and RepeatAutoScroll().
|
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().
|
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().
|
private |
Definition at line 188 of file SlsScrollBarManager.hxx.
Referenced by AutoScroll(), RepeatAutoScroll(), and StopAutoScroll().
|
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().
|
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().
|
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().
|
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().
|
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().
|
private |
Definition at line 161 of file SlsScrollBarManager.hxx.
Referenced by CalcAutoScrollOffset(), DetermineScrollBarVisibilities(), RepeatAutoScroll(), Scroll(), SetTopLeft(), SetWindowOrigin(), TestScrollBarVisibilities(), and UpdateScrollBars().