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

This class manages the focus of the slide sorter. More...

#include <SlsFocusManager.hxx>

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

Classes

class  FocusHider
 Create an instance of this class to temporarily hide the focus indicator. More...
 

Public Types

enum class  FocusMoveDirection {
  Left ,
  Right ,
  Up ,
  Down
}
 

Public Member Functions

 FocusManager (SlideSorter &rSlideSorter)
 Create a new focus manager that operates on the pages of the model associated with the given controller. More...
 
 ~FocusManager ()
 
void MoveFocus (FocusMoveDirection eDirection)
 Move the focus from the currently focused page to one that is displayed adjacent to it, either vertically or horizontally. More...
 
void ShowFocus (const bool bScrollToFocus=true)
 Show the focus indicator of the current slide. More...
 
void HideFocus ()
 Hide the focus indicator. More...
 
bool ToggleFocus ()
 Toggle the focused state of the current slide. More...
 
bool HasFocus () const
 Return whether the window managed by the called focus manager has the input focus of the application. More...
 
model::SharedPageDescriptor GetFocusedPageDescriptor () const
 Return the descriptor of the page that currently has the focus. More...
 
sal_Int32 GetFocusedPageIndex () const
 Return the index of the page that currently has the focus as it is accepted by the slide sorter model. More...
 
bool SetFocusedPage (const model::SharedPageDescriptor &rDescriptor)
 Set the focused page to the one described by the given page descriptor. More...
 
void SetFocusedPage (sal_Int32 nPageIndex)
 Set the focused page to the one described by the given page index. More...
 
bool SetFocusedPageFromCurrentPage ()
 Set the focused page to the one that is the current slide of the Slide Manager. More...
 
bool IsFocusShowing () const
 Return <TRUE> when the focus indicator is currently shown. More...
 
void AddFocusChangeListener (const Link< LinkParamNone *, void > &rListener)
 Add a listener that is called when the focus is shown or hidden or set to another page object. More...
 
void RemoveFocusChangeListener (const Link< LinkParamNone *, void > &rListener)
 Remove a focus change listener. More...
 

Private Member Functions

void HideFocusIndicator (const model::SharedPageDescriptor &rpDescriptor)
 Reset the focus state of the given descriptor and request a repaint so that the focus indicator is hidden. More...
 
void ShowFocusIndicator (const model::SharedPageDescriptor &rpDescriptor, const bool bScrollToFocus)
 Set the focus state of the given descriptor, scroll it into the visible area and request a repaint so that the focus indicator is made visible. More...
 
void NotifyFocusChangeListeners () const
 Call all currently registered listeners that a focus change has happened. More...
 

Private Attributes

SlideSortermrSlideSorter
 
sal_Int32 mnPageIndex
 Index of the page that may be focused. More...
 
bool mbPageIsFocused
 This flag indicates whether the page pointed to by mpFocusDescriptor has the focus. More...
 
::std::vector< Link< LinkParamNone *, void > > maFocusChangeListeners
 

Detailed Description

This class manages the focus of the slide sorter.

There is the focus page which is or is not focused. Initialized to point to the first page it can be set to other pages by using the MoveFocus() method. The focused state of the focus page can be toggled with the ToggleFocus() method.

Definition at line 41 of file SlsFocusManager.hxx.

Member Enumeration Documentation

◆ FocusMoveDirection

Enumerator
Left 
Right 
Up 
Down 

Definition at line 52 of file SlsFocusManager.hxx.

Constructor & Destructor Documentation

◆ FocusManager()

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

Create a new focus manager that operates on the pages of the model associated with the given controller.

The focus page is set to the first page. Focused state is off.

Definition at line 37 of file SlsFocusManager.cxx.

References sd::slidesorter::SlideSorter::GetModel(), sd::slidesorter::model::SlideSorterModel::GetPageCount(), mnPageIndex, and mrSlideSorter.

◆ ~FocusManager()

sd::slidesorter::controller::FocusManager::~FocusManager ( )

Definition at line 46 of file SlsFocusManager.cxx.

Member Function Documentation

◆ AddFocusChangeListener()

void sd::slidesorter::controller::FocusManager::AddFocusChangeListener ( const Link< LinkParamNone *, void > &  rListener)

Add a listener that is called when the focus is shown or hidden or set to another page object.

Parameters
rListenerWhen this method is called multiple times for the same listener the second and all following calls are ignored. Each listener is added only once.

Definition at line 203 of file SlsFocusManager.cxx.

References maFocusChangeListeners.

Referenced by accessibility::AccessibleSlideSorterView::Implementation::ConnectListeners().

◆ GetFocusedPageDescriptor()

model::SharedPageDescriptor sd::slidesorter::controller::FocusManager::GetFocusedPageDescriptor ( ) const

◆ GetFocusedPageIndex()

sal_Int32 sd::slidesorter::controller::FocusManager::GetFocusedPageIndex ( ) const
inline

Return the index of the page that currently has the focus as it is accepted by the slide sorter model.

Returns
When there is no page that currently has the focus then -1 is returned.

Definition at line 110 of file SlsFocusManager.hxx.

References mnPageIndex.

Referenced by accessibility::AccessibleSlideSorterObject::getAccessibleStateSet(), sd::slidesorter::controller::Clipboard::GetInsertionPosition(), and accessibility::IMPL_LINK_NOARG().

◆ HasFocus()

bool sd::slidesorter::controller::FocusManager::HasFocus ( ) const

Return whether the window managed by the called focus manager has the input focus of the application.

Definition at line 135 of file SlsFocusManager.cxx.

References sd::slidesorter::SlideSorter::GetContentWindow(), and mrSlideSorter.

Referenced by IsFocusShowing(), and sd::slidesorter::controller::SelectionFunction::KeyInput().

◆ HideFocus()

void sd::slidesorter::controller::FocusManager::HideFocus ( )

◆ HideFocusIndicator()

void sd::slidesorter::controller::FocusManager::HideFocusIndicator ( const model::SharedPageDescriptor rpDescriptor)
private

Reset the focus state of the given descriptor and request a repaint so that the focus indicator is hidden.

Parameters
pDescriptorWhen NULL is given then the call is ignored.

Definition at line 172 of file SlsFocusManager.cxx.

References sd::slidesorter::SlideSorter::GetView(), mrSlideSorter, NotifyFocusChangeListeners(), sd::slidesorter::view::SlideSorterView::SetState(), and sd::slidesorter::model::PageDescriptor::ST_Focused.

Referenced by HideFocus(), and MoveFocus().

◆ IsFocusShowing()

bool sd::slidesorter::controller::FocusManager::IsFocusShowing ( ) const

Return <TRUE> when the focus indicator is currently shown.

A prerequisite is that the window managed by this focus manager has the input focus as indicated by a <TRUE> return value of HasFocus(). It is not necessary that the focus indicator is visible. It may have been scrolled outside the visible area.

Definition at line 167 of file SlsFocusManager.cxx.

References HasFocus(), and mbPageIsFocused.

Referenced by sd::slidesorter::controller::SelectionManager::DeleteSelectedPages(), accessibility::AccessibleSlideSorterObject::getAccessibleStateSet(), sd::slidesorter::controller::Clipboard::GetInsertionPosition(), accessibility::IMPL_LINK_NOARG(), and sd::slidesorter::controller::SelectionFunction::KeyInput().

◆ MoveFocus()

void sd::slidesorter::controller::FocusManager::MoveFocus ( FocusMoveDirection  eDirection)

Move the focus from the currently focused page to one that is displayed adjacent to it, either vertically or horizontally.

Parameters
eDirectionDirection in which to move the focus. Wrap around is done differently when moving vertically or horizontally. Vertical wrap around takes place in the same column, i.e. when you are in the top row and move up you come out in the bottom row in the same column. Horizontal wrap around moves to the next (FocusMoveDirection::Right) or previous (FocusMoveDirection::Left) page. Moving to the right from the last page goes to the first page and vice versa. The current page index is set to the nearest valid page index.

Definition at line 50 of file SlsFocusManager.cxx.

References Down, sd::slidesorter::view::Layouter::GetColumnCount(), GetFocusedPageDescriptor(), sd::slidesorter::view::SlideSorterView::GetLayouter(), sd::slidesorter::SlideSorter::GetModel(), sd::slidesorter::model::SlideSorterModel::GetPageCount(), sd::slidesorter::SlideSorter::GetView(), HideFocusIndicator(), Left, mbPageIsFocused, mnPageIndex, mrSlideSorter, Right, ShowFocusIndicator(), and Up.

Referenced by sd::slidesorter::controller::SelectionFunction::MoveFocus().

◆ NotifyFocusChangeListeners()

void sd::slidesorter::controller::FocusManager::NotifyFocusChangeListeners ( ) const
private

Call all currently registered listeners that a focus change has happened.

The focus may be hidden or shown or moved from one page object to another.

Definition at line 218 of file SlsFocusManager.cxx.

References aListeners, and maFocusChangeListeners.

Referenced by HideFocusIndicator(), and ShowFocusIndicator().

◆ RemoveFocusChangeListener()

void sd::slidesorter::controller::FocusManager::RemoveFocusChangeListener ( const Link< LinkParamNone *, void > &  rListener)

Remove a focus change listener.

Parameters
rListenerIt is safe to pass a listener that was not added are has been removed previously. Such calls are ignored.

Definition at line 212 of file SlsFocusManager.cxx.

References maFocusChangeListeners.

Referenced by accessibility::AccessibleSlideSorterView::Implementation::ReleaseListeners().

◆ SetFocusedPage() [1/2]

bool sd::slidesorter::controller::FocusManager::SetFocusedPage ( const model::SharedPageDescriptor rDescriptor)

Set the focused page to the one described by the given page descriptor.

The visibility of the focus indicator is not modified.

Parameters
rDescriptorOne of the page descriptors that are currently managed by the SlideSorterModel.

Definition at line 145 of file SlsFocusManager.cxx.

References mnPageIndex.

Referenced by sd::slidesorter::controller::SelectionManager::DeleteSelectedPages(), sd::slidesorter::controller::SelectionFunction::GotoPage(), sd::slidesorter::controller::CurrentSlideManager::NotifyCurrentSlideChange(), and SetFocusedPageFromCurrentPage().

◆ SetFocusedPage() [2/2]

void sd::slidesorter::controller::FocusManager::SetFocusedPage ( sal_Int32  nPageIndex)

Set the focused page to the one described by the given page index.

The visibility of the focus indicator is not modified.

Parameters
nPageIndexA valid page index that is understood by the SlideSorterModel.

Definition at line 156 of file SlsFocusManager.cxx.

References mnPageIndex.

◆ SetFocusedPageFromCurrentPage()

bool sd::slidesorter::controller::FocusManager::SetFocusedPageFromCurrentPage ( )

◆ ShowFocus()

void sd::slidesorter::controller::FocusManager::ShowFocus ( const bool  bScrollToFocus = true)

Show the focus indicator of the current slide.

Parameters
bScrollToFocusWhen <TRUE> (the default) then the view is scrolled so that the focus rectangle lies inside its visible area.

Definition at line 111 of file SlsFocusManager.cxx.

References GetFocusedPageDescriptor(), mbPageIsFocused, and ShowFocusIndicator().

Referenced by accessibility::AccessibleSlideSorterView::Implementation::Activated(), sd::slidesorter::controller::SelectionFunction::KeyInput(), and ToggleFocus().

◆ ShowFocusIndicator()

void sd::slidesorter::controller::FocusManager::ShowFocusIndicator ( const model::SharedPageDescriptor rpDescriptor,
const bool  bScrollToFocus 
)
private

Set the focus state of the given descriptor, scroll it into the visible area and request a repaint so that the focus indicator is made visible.

Parameters
pDescriptorWhen NULL is given then the call is ignored.
bScrollToFocusWhen <TRUE> (the default) then the view is scrolled so that the focus rectangle lies inside its visible area.

Definition at line 183 of file SlsFocusManager.cxx.

References sd::slidesorter::SlideSorter::GetController(), sd::slidesorter::SlideSorter::GetView(), sd::slidesorter::controller::SlideSorterController::GetVisibleAreaManager(), mrSlideSorter, NotifyFocusChangeListeners(), sd::slidesorter::view::SlideSorterView::RequestRepaint(), sd::slidesorter::controller::VisibleAreaManager::RequestVisible(), sd::slidesorter::view::SlideSorterView::SetState(), and sd::slidesorter::model::PageDescriptor::ST_Focused.

Referenced by MoveFocus(), and ShowFocus().

◆ ToggleFocus()

bool sd::slidesorter::controller::FocusManager::ToggleFocus ( )

Toggle the focused state of the current slide.

Returns
Returns the focused state of the focus page after the call.

Definition at line 123 of file SlsFocusManager.cxx.

References HideFocus(), mbPageIsFocused, mnPageIndex, and ShowFocus().

Referenced by sd::slidesorter::controller::SelectionFunction::cancel(), and sd::slidesorter::controller::SelectionManager::DeleteSelectedPages().

Member Data Documentation

◆ maFocusChangeListeners

::std::vector<Link<LinkParamNone*, void> > sd::slidesorter::controller::FocusManager::maFocusChangeListeners
private

◆ mbPageIsFocused

bool sd::slidesorter::controller::FocusManager::mbPageIsFocused
private

This flag indicates whether the page pointed to by mpFocusDescriptor has the focus.

Definition at line 182 of file SlsFocusManager.hxx.

Referenced by HideFocus(), IsFocusShowing(), MoveFocus(), ShowFocus(), and ToggleFocus().

◆ mnPageIndex

sal_Int32 sd::slidesorter::controller::FocusManager::mnPageIndex
private

Index of the page that may be focused.

It is -1 when the model contains no page.

Definition at line 177 of file SlsFocusManager.hxx.

Referenced by FocusManager(), GetFocusedPageDescriptor(), GetFocusedPageIndex(), MoveFocus(), SetFocusedPage(), and ToggleFocus().

◆ mrSlideSorter

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

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