diff --git a/include/sfx2/thumbnailview.hxx b/include/sfx2/thumbnailview.hxx index fe4196f44519..70260a5bfd1a 100644 --- a/include/sfx2/thumbnailview.hxx +++ b/include/sfx2/thumbnailview.hxx @@ -303,12 +303,15 @@ protected: tools::Long mnVItemSpace; // Vertical spacing between rows, -1 to use excess unused height split up between items tools::Long mnVisLines; tools::Long mnLines; + tools::Long mnPinnedSeparatorY; // tdf#38742 - vertical position of the separator line between pinned/unpinned items + tools::Long mnPinnedSeparatorMargin; // tdf#38742 - horizontal margin of the pinned separator sal_uInt16 mnCols; sal_uInt16 mnFirstLine; bool mbScroll : 1; // Whether we need to scroll bool mbAllowVScrollBar : 1; // Whether to show a visible scrollbar bool mbHasVisibleItems : 1; + bool mbHasPinnedSeparator : 1; // tdf#38742 - whether to draw a separator line after the pinned items bool mbShowTooltips : 1; bool mbDrawMnemonics : 1; bool mbSelectOnFocus : 1; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index bd983abbd97f..6ca8a550536d 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -283,8 +283,11 @@ void ThumbnailView::ImplInit() mnLines = 0; mnFirstLine = 0; mnCols = 0; + mnPinnedSeparatorY = 0; + mnPinnedSeparatorMargin = 0; mbScroll = false; mbHasVisibleItems = false; + mbHasPinnedSeparator = false; mbShowTooltips = false; mbDrawMnemonics = false; mbAllowMultiSelection = true; @@ -526,6 +529,16 @@ void ThumbnailView::CalculateItemPositions(bool bScrollBarUsed) y += mnItemHeight + nVItemSpace; } + // tdf#38742 - calculate the position for the separator line between pinned/unpinned items + mbHasPinnedSeparator = nCurCountVisible && nItemCountPinned < nItemCount; + if (mbHasPinnedSeparator) + { + // separator line is drawn at the center above the first unpinned row + mnPinnedSeparatorY = y - nVItemSpace / 2; + // separator line is aligned with the first and last document thumbnails in the row + mnPinnedSeparatorMargin = nStartX; + } + // tdf#164102 - adjust first item only if there are any pinned items if (const auto nRemainingPinnedSlots = nItemCountPinned % mnCols) { @@ -980,6 +993,16 @@ void ThumbnailView::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rec continue; pItem->Paint(pProcessor.get(), *mpItemAttrs); } + + // tdf#38742 - draw a separator line between the pinned/unpinned items using left/right margin + if (mbHasPinnedSeparator) + { + rRenderContext.SetLineColor( + rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor()); + rRenderContext.DrawLine( + Point(mnPinnedSeparatorMargin, mnPinnedSeparatorY), + Point(GetOutputSizePixel().Width() - mnPinnedSeparatorMargin, mnPinnedSeparatorY)); + } } void ThumbnailView::GetFocus()