include/vcl/tabctrl.hxx | 5 + sfx2/source/notebookbar/NotebookBarPopupMenu.cxx | 5 + vcl/source/control/tabctrl.cxx | 74 +++++++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-)
New commits: commit d3c3dcb4d581544d9fabc3b4b9160cbc9443543d Author: Szymon KÅos <eszka...@gmail.com> Date: Thu Aug 4 16:58:48 2016 +0200 GSoC: notebookbar, position of popup menu Change-Id: Ia4491a8659c8e6532681f7fca83b432e311d79d6 Reviewed-on: https://gerrit.libreoffice.org/27881 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Szymon KÅos <eszka...@gmail.com> diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx index e162b19..4c57793 100644 --- a/include/vcl/tabctrl.hxx +++ b/include/vcl/tabctrl.hxx @@ -179,7 +179,7 @@ public: virtual void SetSizePixel(const Size& rNewSize) override; virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) override; - Size calculateRequisition() const; + virtual Size calculateRequisition() const; void setAllocation(const Size &rAllocation); void markLayoutDirty() @@ -207,6 +207,8 @@ public: virtual sal_uInt16 GetPageId( const Point& rPos ) const override; virtual void SelectTabPage( sal_uInt16 nPageId ) override; virtual void SetCurPageId( sal_uInt16 nPageId ) override; + virtual Size calculateRequisition() const override; + static sal_uInt16 GetHeaderHeight(); protected: virtual bool ImplPlaceTabs( long nWidth ) override; @@ -216,6 +218,7 @@ private: bool bLastContextWasSupported; vcl::EnumContext::Context eLastContext; Link<NotebookBar*,void> m_aIconClickHdl; + static sal_uInt16 m_nHeaderHeight; }; #endif // INCLUDED_VCL_TABCTRL_HXX diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx index a78b15c..72c4145 100644 --- a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx +++ b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx @@ -54,7 +54,10 @@ void NotebookBarPopupMenu::Execute(NotebookBar* pNotebookbar, { if (pNotebookbar) { - sal_uInt16 nSelected = PopupMenu::Execute(pNotebookbar, Point(0, 40)); + sal_uInt16 nTop = NotebookbarTabControl::GetHeaderHeight(); + sal_uInt16 nSelected = PopupMenu::Execute(pNotebookbar, + Rectangle(0, nTop, 0, nTop), + PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose); if (nSelected) { diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index d165f21..7b2c3f3 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2203,6 +2203,8 @@ FactoryFunction TabControl::GetUITestFactory() const VCL_BUILDER_FACTORY(NotebookbarTabControl); +sal_uInt16 NotebookbarTabControl::m_nHeaderHeight = 0; + NotebookbarTabControl::NotebookbarTabControl(vcl::Window* pParent, WinBits nStyle) : TabControl(pParent, nStyle) , bLastContextWasSupported(true) @@ -2285,6 +2287,11 @@ void NotebookbarTabControl::SetCurPageId( sal_uInt16 nPageId ) TabControl::SetCurPageId( nPageId ); } +sal_uInt16 NotebookbarTabControl::GetHeaderHeight() +{ + return m_nHeaderHeight; +} + bool NotebookbarTabControl::ImplPlaceTabs( long nWidth ) { if ( nWidth <= 0 ) @@ -2653,4 +2660,71 @@ void NotebookbarTabControl::ImplPaint(vcl::RenderContext& rRenderContext, const mbSmallInvalidate = true; } +Size NotebookbarTabControl::calculateRequisition() const +{ + Size aOptimalPageSize(0, 0); + + sal_uInt16 nOrigPageId = GetCurPageId(); + for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin(); + it != mpTabCtrlData->maItemList.end(); ++it ) + { + const TabPage *pPage = it->mpTabPage; + //it's a real nuisance if the page is not inserted yet :-( + //We need to force all tabs to exist to get overall optimal size for dialog + if (!pPage) + { + NotebookbarTabControl *pThis = const_cast<NotebookbarTabControl*>(this); + pThis->SetCurPageId(it->mnId); + pThis->ActivatePage(); + pPage = it->mpTabPage; + } + + if (!pPage) + continue; + + Size aPageSize(VclContainer::getLayoutRequisition(*pPage)); + + if (aPageSize.Width() > aOptimalPageSize.Width()) + aOptimalPageSize.Width() = aPageSize.Width(); + if (aPageSize.Height() > aOptimalPageSize.Height()) + aOptimalPageSize.Height() = aPageSize.Height(); + } + + //fdo#61940 If we were forced to activate pages in order to on-demand + //create them to get their optimal size, then switch back to the original + //page and re-activate it + if (nOrigPageId != GetCurPageId()) + { + NotebookbarTabControl *pThis = const_cast<NotebookbarTabControl*>(this); + pThis->SetCurPageId(nOrigPageId); + pThis->ActivatePage(); + } + + long nTabLabelsBottom = 0, nTabLabelsRight = 0; + for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin(); + it != mpTabCtrlData->maItemList.end(); ++it ) + { + NotebookbarTabControl* pThis = const_cast<NotebookbarTabControl*>(this); + + sal_uInt16 nPos = it - mpTabCtrlData->maItemList.begin(); + Rectangle aTabRect = pThis->ImplGetTabRect(nPos, aOptimalPageSize.Width(), LONG_MAX); + if (aTabRect.Bottom() > nTabLabelsBottom) + { + nTabLabelsBottom = aTabRect.Bottom(); + m_nHeaderHeight = aTabRect.Bottom(); + } + if (aTabRect.Right() > nTabLabelsRight) + nTabLabelsRight = aTabRect.Right(); + } + + Size aOptimalSize(aOptimalPageSize); + aOptimalSize.Height() += nTabLabelsBottom; + aOptimalSize.Width() = std::max(nTabLabelsRight, aOptimalSize.Width()); + + aOptimalSize.Width() += TAB_OFFSET * 2; + aOptimalSize.Height() += TAB_OFFSET * 2; + + return aOptimalSize; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits