From 152faedebbfed3d0c3b5e465a25ef4dba030072c Mon Sep 17 00:00:00 2001 From: Katarina Behrens Date: Mon, 19 Mar 2018 15:18:50 +0100 Subject: Prep mouse event handler to indicate dragging started Change-Id: Icdb865e511047b166767ca9e87e808c308ad7643 Reviewed-on: https://gerrit.libreoffice.org/53324 Tested-by: Jenkins Reviewed-by: Katarina Behrens --- include/sfx2/sidebar/DeckTitleBar.hxx | 1 + include/sfx2/sidebar/SidebarController.hxx | 2 ++ include/sfx2/sidebar/SidebarDockingWindow.hxx | 4 ++++ sfx2/source/sidebar/DeckTitleBar.cxx | 10 ++++++++++ sfx2/source/sidebar/SidebarController.cxx | 11 +++++++++++ sfx2/source/sidebar/SidebarDockingWindow.cxx | 12 ++++++++++++ 6 files changed, 40 insertions(+) diff --git a/include/sfx2/sidebar/DeckTitleBar.hxx b/include/sfx2/sidebar/DeckTitleBar.hxx index 3542cd45e0fb..59f15bf1ef93 100644 --- a/include/sfx2/sidebar/DeckTitleBar.hxx +++ b/include/sfx2/sidebar/DeckTitleBar.hxx @@ -31,6 +31,7 @@ public: const std::function& rCloserAction); void SetCloserVisible(const bool bIsCloserVisible); + tools::Rectangle GetDragArea() const; virtual void DataChanged(const DataChangedEvent& rEvent) override; diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx index 50e91097ca67..33cdfc395200 100644 --- a/include/sfx2/sidebar/SidebarController.hxx +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -164,6 +164,8 @@ public: void FadeIn(); void FadeOut(); + tools::Rectangle GetDeckDragArea() const; + private: SidebarController( SidebarDockingWindow* pParentWindow, diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx index 2bff73a3eb77..2df114e1c585 100644 --- a/include/sfx2/sidebar/SidebarDockingWindow.hxx +++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx @@ -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 mpSidebarController; + bool mbIsReadyToDrag; void DoDispose(); }; diff --git a/sfx2/source/sidebar/DeckTitleBar.cxx b/sfx2/source/sidebar/DeckTitleBar.cxx index e241b76b079d..891efe8b031c 100644 --- a/sfx2/source/sidebar/DeckTitleBar.cxx +++ b/sfx2/source/sidebar/DeckTitleBar.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -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)); diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index b205559c6326..5763fe49db02 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -1340,6 +1340,17 @@ void SidebarController::FadeIn() mpSplitWindow->FadeIn(); } +tools::Rectangle SidebarController::GetDeckDragArea() const +{ + tools::Rectangle aRect; + + VclPtr pTitleBar = mpCurrentDeck->GetTitleBar(); + if ( pTitleBar) + aRect = pTitleBar->GetDragArea(); + + return aRect; +} + void SidebarController::frameAction(const css::frame::FrameActionEvent& rEvent) { if (rEvent.Frame == mxFrame) diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx index 15a3e3340ff1..11ebe7614e0a 100644 --- a/sfx2/source/sidebar/SidebarDockingWindow.cxx +++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx @@ -23,6 +23,7 @@ #include #include #include +#include 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); } -- cgit v1.2.3