summaryrefslogtreecommitdiff
path: root/vcl/source/app/salvtables.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-02-25 17:03:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-02-26 20:57:31 +0100
commita5a71c7bb58a16a64c586c3ea142e0dd88cf7104 (patch)
treebe9545002fd9b32441b14f04505f0f4c1f05171d /vcl/source/app/salvtables.cxx
parentbbb3f36877807a5f6106956d7497f281169d9421 (diff)
drop intermediate vcl container for these welded floating toplevels
Change-Id: I4a528485de62a0e0acabd41abf6872e2f0e1710e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111567 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/app/salvtables.cxx')
-rw-r--r--vcl/source/app/salvtables.cxx62
1 files changed, 62 insertions, 0 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 7bb05907ecba..6c86215bd808 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -6611,6 +6611,54 @@ IMPL_LINK(SalInstanceEntryTreeView, AutocompleteHdl, Edit&, rEdit, void)
}
}
+namespace
+{
+class SalInstancePopover : public SalInstanceContainer, public virtual weld::Popover
+{
+private:
+ VclPtr<DockingWindow> m_xPopover;
+
+ DECL_LINK(PopupModeEndHdl, FloatingWindow*, void);
+
+public:
+ SalInstancePopover(DockingWindow* pPopover, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+ : SalInstanceContainer(pPopover, pBuilder, bTakeOwnership)
+ , m_xPopover(pPopover)
+ {
+ }
+
+ virtual void popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect) override
+ {
+ SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pParent);
+ assert(pVclWidget);
+ vcl::Window* pWidget = pVclWidget->getWidget();
+
+ tools::Rectangle aRect;
+ Point aPt = pWidget->OutputToScreenPixel(rRect.TopLeft());
+ aRect.SetLeft(aPt.X());
+ aRect.SetTop(aPt.Y());
+ aPt = pWidget->OutputToScreenPixel(rRect.BottomRight());
+ aRect.SetRight(aPt.X());
+ aRect.SetBottom(aPt.Y());
+
+ FloatWinPopupFlags nFlags = FloatWinPopupFlags::Down | FloatWinPopupFlags::GrabFocus;
+ m_xPopover->EnableDocking();
+ DockingManager* pDockingManager = vcl::Window::GetDockingManager();
+ pDockingManager->SetPopupModeEndHdl(m_xPopover,
+ LINK(this, SalInstancePopover, PopupModeEndHdl));
+ pDockingManager->StartPopupMode(m_xPopover, aRect, nFlags);
+ }
+
+ virtual void popdown() override
+ {
+ vcl::Window::GetDockingManager()->EndPopupMode(m_xPopover);
+ m_xPopover->EnableDocking(false);
+ }
+};
+}
+
+IMPL_LINK_NOARG(SalInstancePopover, PopupModeEndHdl, FloatingWindow*, void) { signal_closed(); }
+
SalInstanceBuilder::SalInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot,
const OUString& rUIFile,
const css::uno::Reference<css::frame::XFrame>& rFrame)
@@ -6922,6 +6970,20 @@ std::unique_ptr<weld::Menu> SalInstanceBuilder::weld_menu(const OString& id)
return pMenu ? std::make_unique<SalInstanceMenu>(pMenu, true) : nullptr;
}
+std::unique_ptr<weld::Popover> SalInstanceBuilder::weld_popover(const OString& id)
+{
+ DockingWindow* pDockingWindow = m_xBuilder->get<DockingWindow>(id);
+ std::unique_ptr<weld::Popover> pRet(
+ pDockingWindow ? new SalInstancePopover(pDockingWindow, this, false) : nullptr);
+ if (pDockingWindow)
+ {
+ assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
+ m_aOwnedToplevel.set(pDockingWindow);
+ m_xBuilder->drop_ownership(pDockingWindow);
+ }
+ return pRet;
+}
+
std::unique_ptr<weld::Toolbar> SalInstanceBuilder::weld_toolbar(const OString& id)
{
ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id);