include/vcl/salnativewidgets.hxx | 13 ++++++++++++- vcl/qt5/QtGraphics_Controls.cxx | 20 ++++++++++++++++++++ vcl/source/control/imivctl1.cxx | 8 +++----- vcl/source/control/tabctrl.cxx | 12 +++++++----- 4 files changed, 42 insertions(+), 11 deletions(-)
New commits: commit a82e98f60e37d1b1d507df6645588e19a82dc72e Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Jul 22 08:28:56 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 24 05:42:43 2024 +0200 tdf#161501 icon choice ctrl: Drop handling for WB_NOHIDESELECTION `WB_NOHIDESELECTION` never gets set for `SvxIconChoiceCtrl_Impl`, which is only used by `SvtIconChoiceCtrl` to implement the vertical tab bar. Therefore, drop handling for that flag to simplify code. Change-Id: I488edf6680f25dbafae61ec0435784d693d222b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170842 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx index ec1e5cd6772d..7dec9e192ec7 100644 --- a/vcl/source/control/imivctl1.cxx +++ b/vcl/source/control/imivctl1.cxx @@ -1023,8 +1023,6 @@ void SvxIconChoiceCtrl_Impl::PaintEntry(SvxIconChoiceCtrlEntry* pEntry, const Po tools::Rectangle aTextRect(CalcTextRect(pEntry, &rPos)); tools::Rectangle aBmpRect(CalcBmpRect(pEntry, &rPos)); - bool bActiveSelection = (0 != (nWinBits & WB_NOHIDESELECTION)) || pView->HasFocus(); - const bool bMouseHovered = pEntry == pCurHighlightFrame; const bool bSelected = pEntry->IsSelected(); if (bSelected) @@ -1034,7 +1032,7 @@ void SvxIconChoiceCtrl_Impl::PaintEntry(SvxIconChoiceCtrlEntry* pEntry, const Po // font fill colors that are attributed "hard" need corresponding "hard" // attributed highlight colors - if ((nWinBits & WB_NOHIDESELECTION) || pView->HasFocus()) + if (pView->HasFocus()) aNewFont.SetFillColor(rSettings.GetHighlightColor()); else aNewFont.SetFillColor(rSettings.GetDeactiveColor()); @@ -1096,7 +1094,7 @@ void SvxIconChoiceCtrl_Impl::PaintEntry(SvxIconChoiceCtrlEntry* pEntry, const Po else { vcl::RenderTools::DrawSelectionBackground(rRenderContext, *pView, aFocusRect, - bActiveSelection ? 1 : 2, false, false, false); + pView->HasFocus() ? 1 : 2, false, false, false); } } commit 92454bca2045b9e9ca636d086cb8520ccf03be22 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Jul 22 08:25:32 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 24 05:42:34 2024 +0200 tdf#161501 vcl: Make TabitemValue position-aware Add a new `TabBarPosition` enum that describes whether a tab bar is at the top, left, right, or bottom (relative to the tab page content) and make use of that for the new `meTabBarPosition` member for `TabitemValue` that gets used for drawing tab items via the native rendering API. Set the position accordingly for both the vertical tab control (`TabControl`) and `SvxIconChoiceCtrl_Impl`, which implements the tab bar for `VerticalTabControl`. For Qt-based VCL plugins, implement mapping to the corresponding `QTabBar::Shape`. [1] At least the Breeze Qt style uses that shape to decide whether on what side of the tab item to draw the selection/focus indicator. This change by itself doesn't yet make any visual difference for the Breeze style, as the "Top" value/ `QTabBar::RoundedNorth` is the default anyway, and `SvxIconChoiceCtrl_Impl` doesn't yet use the native drawing API for drawing focus/selection, but only for mousehover feedback. The plan is to implement that in a follow-up change. [1] https://doc.qt.io/qt-6/qtabbar.html#Shape-enum Change-Id: Idf1e41d3bc309d152a4a36d14e8617bd6429940c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170841 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/include/vcl/salnativewidgets.hxx b/include/vcl/salnativewidgets.hxx index aa856a16c35d..68fae745e757 100644 --- a/include/vcl/salnativewidgets.hxx +++ b/include/vcl/salnativewidgets.hxx @@ -384,16 +384,27 @@ namespace o3tl template<> struct typed_flags<TabitemFlags> : is_typed_flags<TabitemFlags, 0x0f> {}; } +/* Tab bar position (relative to content on the tab page). */ +enum class TabBarPosition +{ + Top, + Left, + Right, + Bottom +}; + class SAL_DLLPUBLIC_RTTI TabitemValue final : public ImplControlValue { public: TabitemFlags mnAlignment; tools::Rectangle maContentRect; + TabBarPosition meTabBarPosition; - TabitemValue(const tools::Rectangle &rContentRect) + TabitemValue(const tools::Rectangle &rContentRect, TabBarPosition eTabBarPosition) : ImplControlValue( ControlType::TabItem, 0 ) , mnAlignment(TabitemFlags::NONE) , maContentRect(rContentRect) + , meTabBarPosition(eTabBarPosition) { } virtual ~TabitemValue() override; diff --git a/vcl/qt5/QtGraphics_Controls.cxx b/vcl/qt5/QtGraphics_Controls.cxx index b24b46b28a8d..9dd0b3a4f61e 100644 --- a/vcl/qt5/QtGraphics_Controls.cxx +++ b/vcl/qt5/QtGraphics_Controls.cxx @@ -223,6 +223,24 @@ void QtGraphics_Controls::drawFrame(QStyle::PrimitiveElement element, QImage* im QApplication::style()->drawPrimitive(element, &option, &painter); } +static QTabBar::Shape lcl_mapTabBarPosition(TabBarPosition eTabPos) +{ + switch (eTabPos) + { + case TabBarPosition::Bottom: + return QTabBar::RoundedSouth; + case TabBarPosition::Left: + return QTabBar::RoundedWest; + case TabBarPosition::Right: + return QTabBar::RoundedEast; + case TabBarPosition::Top: + return QTabBar::RoundedNorth; + default: + assert(false && "Unhandled tab bar position"); + return QTabBar::RoundedNorth; + } +} + void QtGraphics_Controls::fillQStyleOptionTab(const ImplControlValue& value, QStyleOptionTab& sot) { const TabitemValue& rValue = static_cast<const TabitemValue&>(value); @@ -232,6 +250,8 @@ void QtGraphics_Controls::fillQStyleOptionTab(const ImplControlValue& value, QSt sot.position = rValue.isFirst() ? QStyleOptionTab::OnlyOneTab : QStyleOptionTab::End; else sot.position = QStyleOptionTab::Middle; + + sot.shape = lcl_mapTabBarPosition(rValue.meTabBarPosition); } void QtGraphics_Controls::fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& option, diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx index 20aeb9839a6c..ec1e5cd6772d 100644 --- a/vcl/source/control/imivctl1.cxx +++ b/vcl/source/control/imivctl1.cxx @@ -1112,7 +1112,7 @@ void SvxIconChoiceCtrl_Impl::PaintEntry(SvxIconChoiceCtrlEntry* pEntry, const Po if (bNativeOK) { ControlState nState = ControlState::ENABLED | ControlState::ROLLOVER; - TabitemValue tiValue(aRect); + TabitemValue tiValue(aRect, TabBarPosition::Left); bNativeOK = rRenderContext.DrawNativeControl(ControlType::TabItem, ControlPart::Entire, aRect, nState, tiValue, OUString()); } diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 5d57fa23a6b9..a0e24d8a37a0 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -242,8 +242,9 @@ Size TabControl::ImplGetItemSize( ImplTabItem* pItem, tools::Long nMaxWidth ) tools::Rectangle aCtrlRegion( Point( 0, 0 ), aSize ); tools::Rectangle aBoundingRgn, aContentRgn; const TabitemValue aControlValue(tools::Rectangle(TAB_ITEM_OFFSET_X, TAB_ITEM_OFFSET_Y, - aSize.Width() - TAB_ITEM_OFFSET_X * 2, - aSize.Height() - TAB_ITEM_OFFSET_Y * 2)); + aSize.Width() - TAB_ITEM_OFFSET_X * 2, + aSize.Height() - TAB_ITEM_OFFSET_Y * 2), + TabBarPosition::Top); if(GetNativeControlRegion( ControlType::TabItem, ControlPart::Entire, aCtrlRegion, ControlState::ENABLED, aControlValue, aBoundingRgn, aContentRgn ) ) @@ -875,9 +876,10 @@ void TabControl::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem co if ( bNativeOK ) { TabitemValue tiValue(tools::Rectangle(pItem->maRect.Left() + TAB_ITEM_OFFSET_X, - pItem->maRect.Top() + TAB_ITEM_OFFSET_Y, - pItem->maRect.Right() - TAB_ITEM_OFFSET_X, - pItem->maRect.Bottom() - TAB_ITEM_OFFSET_Y)); + pItem->maRect.Top() + TAB_ITEM_OFFSET_Y, + pItem->maRect.Right() - TAB_ITEM_OFFSET_X, + pItem->maRect.Bottom() - TAB_ITEM_OFFSET_Y), + TabBarPosition::Top); if (pItem->maRect.Left() < 5) tiValue.mnAlignment |= TabitemFlags::LeftAligned; if (pItem->maRect.Right() > mnLastWidth - 5)