Prep mouse event handler to indicate dragging started

Change-Id: Icdb865e511047b166767ca9e87e808c308ad7643
Reviewed-on: https://gerrit.libreoffice.org/53324
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
This commit is contained in:
Katarina Behrens
2018-03-19 15:18:50 +01:00
parent 0252a39a95
commit 152faedebb
6 changed files with 40 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ public:
const std::function<void()>& rCloserAction);
void SetCloserVisible(const bool bIsCloserVisible);
tools::Rectangle GetDragArea() const;
virtual void DataChanged(const DataChangedEvent& rEvent) override;

View File

@@ -164,6 +164,8 @@ public:
void FadeIn();
void FadeOut();
tools::Rectangle GetDeckDragArea() const;
private:
SidebarController(
SidebarDockingWindow* pParentWindow,

View File

@@ -39,6 +39,9 @@ public:
virtual bool EventNotify(NotifyEvent& rEvent) override;
virtual bool Close() override;
void SetReadyToDrag( bool bStartDrag ) { mbIsReadyToDrag = bStartDrag; }
bool IsReadyToDrag() const { return mbIsReadyToDrag; }
using SfxDockingWindow::Close;
protected:
@@ -51,6 +54,7 @@ protected:
private:
::rtl::Reference<sfx2::sidebar::SidebarController> mpSidebarController;
bool mbIsReadyToDrag;
void DoDispose();
};

View File

@@ -18,6 +18,7 @@
*/
#include <sfx2/sidebar/DeckTitleBar.hxx>
#include <sfx2/sidebar/SidebarDockingWindow.hxx>
#include <sfx2/sidebar/Theme.hxx>
#include <sfx2/sfxresid.hxx>
#include <sfx2/strings.hrc>
@@ -81,6 +82,15 @@ tools::Rectangle DeckTitleBar::GetTitleArea (const tools::Rectangle& rTitleBarBo
rTitleBarBox.Bottom());
}
tools::Rectangle DeckTitleBar::GetDragArea() const
{
Image aGripImage (Theme::GetImage(Theme::Image_Grip));
return tools::Rectangle(0,0,
aGripImage.GetSizePixel().Width() + gaLeftGripPadding + gaRightGripPadding,
aGripImage.GetSizePixel().Height()
);
}
void DeckTitleBar::PaintDecoration(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rTitleBarBox*/)
{
Image aImage (Theme::GetImage(Theme::Image_Grip));

View File

@@ -1340,6 +1340,17 @@ void SidebarController::FadeIn()
mpSplitWindow->FadeIn();
}
tools::Rectangle SidebarController::GetDeckDragArea() const
{
tools::Rectangle aRect;
VclPtr<DeckTitleBar> pTitleBar = mpCurrentDeck->GetTitleBar();
if ( pTitleBar)
aRect = pTitleBar->GetDragArea();
return aRect;
}
void SidebarController::frameAction(const css::frame::FrameActionEvent& rEvent)
{
if (rEvent.Frame == mxFrame)

View File

@@ -23,6 +23,7 @@
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <tools/link.hxx>
#include <tools/gen.hxx>
using namespace css;
using namespace css::uno;
@@ -116,6 +117,17 @@ bool SidebarDockingWindow::EventNotify(NotifyEvent& rEvent)
if (MouseNotifyEvent::KEYINPUT == nType)
return true;
if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType)
{
const MouseEvent *mEvt = rEvent.GetMouseEvent();
if (mEvt->IsLeft())
{
tools::Rectangle aGrip = mpSidebarController->GetDeckDragArea();
if ( aGrip.IsInside( mEvt->GetPosPixel() ) )
SetReadyToDrag( true );
}
}
return SfxDockingWindow::EventNotify(rEvent);
}