IASS: Support Mouse-Wheel Actions

The support for MouseWheel was missing. That showed
when using it in IASS the scroll commands were always
feeded to the SlideShow. Thus it was not possible
to e.g. scroll using MouseWheel in EditView when
IASS was active and SlideShow running.

This happens in ViewShell::HandleScrollCommand. It
needs to be made focus-dependent when IASS is active.

This is the same as already done for keyboard input,
so I consolidated this now to a method called
ViewShell::useInputForSlideShow() that does all the
necessary stuff and answers as needed. Using that
in various places: keyboard and MouseWheel, but also
adapted other places where the same has to happen,
mainly some gesture stuff.

Change-Id: I1a697e4b35b195695f1a5ea2305a3cee8851fa8d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165929
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
This commit is contained in:
Armin Le Grand (allotropia)
2024-04-10 18:22:23 +02:00
committed by Armin Le Grand
parent fe3a4bdf48
commit 614bcc5942
2 changed files with 54 additions and 29 deletions
+3
View File
@@ -547,6 +547,9 @@ private:
/** Create the rulers.
*/
void SetupRulers();
// IASS: Check if commands should be used for SlideShow
bool useInputForSlideShow() const;
};
SdrView* ViewShell::GetDrawView() const
+51 -29
View File
@@ -403,6 +403,34 @@ void ViewShell::Shutdown()
Exit ();
}
// IASS: Check if commands should be used for SlideShow
// This is the case when IASS is on, SlideShow is active
// and the SlideShow Window has the focus
bool ViewShell::useInputForSlideShow() const
{
rtl::Reference< SlideShow > xSlideShow(SlideShow::GetSlideShow(GetViewShellBase()));
if (!xSlideShow.is())
// no SlideShow, do not use
return false;
if (!xSlideShow->isRunning())
// SlideShow not running, do not use
return false;
if(!xSlideShow->IsInteractiveSlideshow())
// if IASS is deactivated, do what was done before when
// SlideSHow is running: use for SlideShow
return true;
// else, check if SlideShow Window has the focus
OutputDevice* pShOut(xSlideShow->getShowWindow());
vcl::Window* pShWin(pShOut ? pShOut->GetOwnerWindow() : nullptr);
// return true if we got the SlideShow Window and it has the focus
return nullptr != pShWin && pShWin->HasFocus();
}
bool ViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
{
bool bReturn(false);
@@ -418,20 +446,10 @@ bool ViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
const size_t OriCount = GetView()->GetMarkedObjectList().GetMarkCount();
if(!bReturn)
{
rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
const bool bSlideShowRunning(xSlideShow.is() && xSlideShow->isRunning());
bool bUseForSlideShow(bSlideShowRunning);
if(bSlideShowRunning && xSlideShow->IsInteractiveSlideshow())
{
// IASS
OutputDevice* pShOut(xSlideShow->getShowWindow());
vcl::Window* pShWin(pShOut ? pShOut->GetOwnerWindow() : nullptr);
bUseForSlideShow = pShWin && pShWin->HasFocus();
}
if(bUseForSlideShow) //IASS
if(useInputForSlideShow()) //IASS
{
// use for SlideShow
rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
bReturn = xSlideShow->keyInput(rKEvt);
}
else
@@ -689,9 +707,10 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
{
case CommandEventId::GestureSwipe:
{
rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
if (xSlideShow.is())
if(useInputForSlideShow()) //IASS
{
// use for SlideShow
rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
const CommandGestureSwipeData* pSwipeData = rCEvt.GetGestureSwipeData();
bDone = xSlideShow->swipe(*pSwipeData);
}
@@ -699,9 +718,10 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
break;
case CommandEventId::GestureLongPress:
{
rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
if (xSlideShow.is())
if(useInputForSlideShow()) //IASS
{
// use for SlideShow
rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
const CommandGestureLongPressData* pLongPressData = rCEvt.GetLongPressData();
bDone = xSlideShow->longpress(*pLongPressData);
}
@@ -713,17 +733,21 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
Reference< XSlideShowController > xSlideShowController( SlideShow::GetSlideShowController(GetViewShellBase() ) );
if( xSlideShowController.is() )
{
// We ignore zooming with control+mouse wheel.
const CommandWheelData* pData = rCEvt.GetWheelData();
if( pData && !pData->GetModifier() && ( pData->GetMode() == CommandWheelMode::SCROLL ) && !pData->IsHorz() )
if(useInputForSlideShow()) //IASS
{
::tools::Long nDelta = pData->GetDelta();
if( nDelta > 0 )
xSlideShowController->gotoPreviousSlide();
else if( nDelta < 0 )
xSlideShowController->gotoNextEffect();
// use for SlideShow
// We ignore zooming with control+mouse wheel.
const CommandWheelData* pData = rCEvt.GetWheelData();
if( pData && !pData->GetModifier() && ( pData->GetMode() == CommandWheelMode::SCROLL ) && !pData->IsHorz() )
{
::tools::Long nDelta = pData->GetDelta();
if( nDelta > 0 )
xSlideShowController->gotoPreviousSlide();
else if( nDelta < 0 )
xSlideShowController->gotoNextEffect();
}
break;
}
break;
}
}
[[fallthrough]];
@@ -782,8 +806,6 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
{
const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData();
Reference<XSlideShowController> xSlideShowController(SlideShow::GetSlideShowController(GetViewShellBase()));
if (pData->meEventType == GestureEventZoomType::Begin)
{
mfLastZoomScale = pData->mfScaleDelta;
@@ -796,7 +818,7 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
double deltaBetweenEvents = (pData->mfScaleDelta - mfLastZoomScale) / mfLastZoomScale;
mfLastZoomScale = pData->mfScaleDelta;
if (!GetDocSh()->IsUIActive() && !xSlideShowController.is())
if (!GetDocSh()->IsUIActive() && !useInputForSlideShow()) //IASS
{
const ::tools::Long nOldZoom = GetActiveWindow()->GetZoom();
::tools::Long nNewZoom;