include/vcl/tabctrl.hxx | 1 sfx2/source/notebookbar/NotebookbarTabControl.cxx | 6 ++-- vcl/source/control/tabctrl.cxx | 31 +++++++++------------- 3 files changed, 17 insertions(+), 21 deletions(-)
New commits: commit 59cba4298dae0caf0f1ba72a830d8f4edf48756d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Nov 21 12:16:18 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Nov 22 00:15:46 2024 +0100 notebookbar: Pass menu button as parent for its menu Use the Notebookbar menu button as parent for its menu. This also makes the button position be used as the reference. This allows to drop the now unused NotebookbarTabControlBase::GetHeaderHeight. Also, set the reference point to be at the bottom of the button, so the menu opens below it instead of approximately in the middle, which matches how other menu buttons behave. To test: Set "Tabbed" for the UI variant in "View" -> "User Interface", then click the "Hamburger menu" button in the notebookbar. Change-Id: I0717fad73ff7a42d2bdaaa53a73d055234003d3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176927 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx index 9ac3b334497e..28987536ad9c 100644 --- a/include/vcl/tabctrl.hxx +++ b/include/vcl/tabctrl.hxx @@ -190,7 +190,6 @@ public: Control* GetOpenMenu(); virtual Size calculateRequisition() const override; - static sal_uInt16 GetHeaderHeight(); protected: virtual bool ImplPlaceTabs( tools::Long nWidth ) override; diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx index 6b08a6a56e33..b8a82b8bb00f 100644 --- a/sfx2/source/notebookbar/NotebookbarTabControl.cxx +++ b/sfx2/source/notebookbar/NotebookbarTabControl.cxx @@ -349,8 +349,10 @@ IMPL_LINK(NotebookbarTabControl, OpenNotebookbarPopupMenu, NotebookBar*, pNotebo return; xPopupController->setPopupMenu(xPopupMenu); - Point aPos(pNotebookbar->GetSizePixel().getWidth(), NotebookbarTabControl::GetHeaderHeight() - ICON_SIZE + 10); - xPopupMenu->execute(pNotebookbar->GetComponentInterface(), + Control* pOpenMenuButton = GetOpenMenu(); + assert(pOpenMenuButton); + Point aPos(pOpenMenuButton->GetSizePixel().getWidth(), pOpenMenuButton->GetSizePixel().getHeight()); + xPopupMenu->execute(pOpenMenuButton->GetComponentInterface(), css::awt::Rectangle(aPos.X(), aPos.Y(), 1, 1), css::awt::PopupMenuDirection::EXECUTE_DOWN); diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 0cf5b5eac808..5aa5c831617c 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2306,11 +2306,6 @@ void NotebookbarTabControlBase::ImplActivateTabPage( bool bNext ) SelectTabPage( TabControl::GetPageId( nCurPos ) ); } -sal_uInt16 NotebookbarTabControlBase::GetHeaderHeight() -{ - return m_nHeaderHeight; -} - bool NotebookbarTabControlBase::ImplPlaceTabs( tools::Long nWidth ) { if ( nWidth <= 0 ) commit 11e857374fb44a1a24fb07948e3ee300f09b6a11 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Nov 21 09:49:34 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Nov 22 00:15:39 2024 +0100 vcl: Simplify NotebookbarTabControlBase::ImplActivateTabPage a bit Only set new value for nCurPos if there's a valid new page instead of always doing it and then reverting back to the old value. Change-Id: I25f56e34da6260ee7c586fa25a88ff813f7c26f3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176926 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index a4f968a5a5ab..0cf5b5eac808 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2282,31 +2282,27 @@ static bool lcl_isValidPage(const ImplTabItem& rItem) void NotebookbarTabControlBase::ImplActivateTabPage( bool bNext ) { - const sal_uInt16 nOldPos = GetPagePos(GetCurPageId()); - bool bFound = false; - sal_Int32 nCurPos = nOldPos; + sal_Int32 nCurPos = GetPagePos(GetCurPageId()); if (bNext) { - for (nCurPos++; nCurPos < GetPageCount(); nCurPos++) - if (lcl_isValidPage(mpTabCtrlData->maItemList[nCurPos])) + for (sal_Int32 nPos = nCurPos + 1; nPos < GetPageCount(); nPos++) + if (lcl_isValidPage(mpTabCtrlData->maItemList[nPos])) { - bFound = true; + nCurPos = nPos; break; } } else { - for (nCurPos--; nCurPos >= 0; nCurPos--) - if (lcl_isValidPage(mpTabCtrlData->maItemList[nCurPos])) + for (sal_Int32 nPos = nCurPos - 1; nPos >= 0; nPos--) + if (lcl_isValidPage(mpTabCtrlData->maItemList[nPos])) { - bFound = true; + nCurPos = nPos; break; } } - if (!bFound) - nCurPos = nOldPos; SelectTabPage( TabControl::GetPageId( nCurPos ) ); } commit 08c315e7b7a2198b36f956245453fad13f1ac6cc Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Nov 21 09:42:24 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Nov 22 00:15:33 2024 +0100 vcl: Don't use out param in addition to return value Let lcl_isValidPage simply return whether the tab item is "valid" and don't set the out param in addition, but let the callers do that, which is more straightforward. Change-Id: I35000d46899f457087c417e91ee1968aab7bd239 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176925 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 5e4c874d53bc..a4f968a5a5ab 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2275,11 +2275,9 @@ void NotebookbarTabControlBase::SetIconClickHdl( Link<NotebookBar*, void> aHdl ) m_aIconClickHdl = aHdl; } -static bool lcl_isValidPage(const ImplTabItem& rItem, bool& bFound) +static bool lcl_isValidPage(const ImplTabItem& rItem) { - if (rItem.m_bVisible && rItem.m_bEnabled) - bFound = true; - return bFound; + return rItem.m_bVisible && rItem.m_bEnabled; } void NotebookbarTabControlBase::ImplActivateTabPage( bool bNext ) @@ -2291,14 +2289,20 @@ void NotebookbarTabControlBase::ImplActivateTabPage( bool bNext ) if (bNext) { for (nCurPos++; nCurPos < GetPageCount(); nCurPos++) - if (lcl_isValidPage(mpTabCtrlData->maItemList[nCurPos], bFound)) + if (lcl_isValidPage(mpTabCtrlData->maItemList[nCurPos])) + { + bFound = true; break; + } } else { for (nCurPos--; nCurPos >= 0; nCurPos--) - if (lcl_isValidPage(mpTabCtrlData->maItemList[nCurPos], bFound)) + if (lcl_isValidPage(mpTabCtrlData->maItemList[nCurPos])) + { + bFound = true; break; + } } if (!bFound)