diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-11-27 21:18:56 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-11-28 11:14:30 +0100 |
commit | 50cec31d5fa77ebc04f35e57718a02d328562417 (patch) | |
tree | 2d2015be040396c5a8e922397bd1c67f12680be8 /sd/source | |
parent | b98ff21fa7132a3eb606a6441f5ebd0162453baa (diff) |
weld Snap Line context menu
Change-Id: Ic4ea546f66eae7acb0427686be8981e2e8231c77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125955
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/inc/DrawViewShell.hxx | 13 | ||||
-rw-r--r-- | sd/source/ui/view/drviews4.cxx | 40 |
2 files changed, 20 insertions, 33 deletions
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 27b46a008fcb..44bb83d44979 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -471,19 +471,18 @@ private: can not be selected the index of the snap line/point for which the popup menu is opened has to be passed to the processing slot handlers. This can be done only by manually showing the popup menu. + @param pParent + The parent for the context menu. + @param rRect + The location at which to display the context menu. @param rPageView The page view is used to access the help lines. @param nSnapLineIndex Index of the snap line or snap point for which to show the context menu. - @param rMouseLocation - The mouse location defines the location at which to display the - context menu. */ - void ShowSnapLineContextMenu ( - SdrPageView& rPageView, - const sal_uInt16 nSnapLineIndex, - const Point& rMouseLocation); + void ShowSnapLineContextMenu(weld::Window* pParent, const ::tools::Rectangle& rRect, + SdrPageView& rPageView, const sal_uInt16 nSnapLineIndex); using ViewShell::Notify; diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx index 8c0a9282e33a..f4114361ccb0 100644 --- a/sd/source/ui/view/drviews4.cxx +++ b/sd/source/ui/view/drviews4.cxx @@ -574,7 +574,9 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) // helper line if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow()->GetOutDev(), nHelpLine, pPV) ) { - ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel()); + ::tools::Rectangle aRect(rCEvt.GetMousePosPixel(), Size(10, 10)); + weld::Window* pParent = weld::GetPopupParent(*pWin, aRect); + ShowSnapLineContextMenu(pParent, aRect, *pPV, nHelpLine); return; } // is gluepoint under cursor marked? @@ -928,41 +930,27 @@ void DrawViewShell::UnlockInput() mnLockCount--; } -void DrawViewShell::ShowSnapLineContextMenu ( - SdrPageView& rPageView, - const sal_uInt16 nSnapLineIndex, - const Point& rMouseLocation) +void DrawViewShell::ShowSnapLineContextMenu(weld::Window* pParent, const ::tools::Rectangle& rRect, + SdrPageView& rPageView, const sal_uInt16 nSnapLineIndex) { const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]); - ScopedVclPtrInstance<PopupMenu> pMenu; + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/simpress/ui/snapmenu.ui")); + std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu")); if (rHelpLine.GetKind() == SdrHelpLineKind::Point) { - pMenu->InsertItem( - SID_SET_SNAPITEM, - SdResId(STR_POPUP_EDIT_SNAPPOINT)); - pMenu->InsertSeparator(); - pMenu->InsertItem( - SID_DELETE_SNAPITEM, - SdResId(STR_POPUP_DELETE_SNAPPOINT)); + xMenu->append(OUString::number(SID_SET_SNAPITEM), SdResId(STR_POPUP_EDIT_SNAPPOINT)); + xMenu->append_separator("separator"); + xMenu->append(OUString::number(SID_DELETE_SNAPITEM), SdResId(STR_POPUP_DELETE_SNAPPOINT)); } else { - pMenu->InsertItem( - SID_SET_SNAPITEM, - SdResId(STR_POPUP_EDIT_SNAPLINE)); - pMenu->InsertSeparator(); - pMenu->InsertItem( - SID_DELETE_SNAPITEM, - SdResId(STR_POPUP_DELETE_SNAPLINE)); + xMenu->append(OUString::number(SID_SET_SNAPITEM), SdResId(STR_POPUP_EDIT_SNAPLINE)); + xMenu->append_separator("separator"); + xMenu->append(OUString::number(SID_DELETE_SNAPITEM), SdResId(STR_POPUP_DELETE_SNAPLINE)); } - pMenu->RemoveDisabledEntries(false); - - const sal_uInt16 nResult = pMenu->Execute( - GetActiveWindow(), - ::tools::Rectangle(rMouseLocation, Size(10,10)), - PopupMenuFlags::ExecuteDown); + const int nResult = xMenu->popup_at_rect(pParent, rRect).toInt32(); switch (nResult) { case SID_SET_SNAPITEM: |