summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2023-09-06 17:03:26 +0200
committerAndreas Heinisch <andreas.heinisch@yahoo.de>2023-09-06 22:06:09 +0200
commit9a37652b79001bf5208841b9221dee851b9b6d0f (patch)
tree3829a008046c858b4f67f698e6b48acc2198355e /sfx2
parent4697d2bda1b37f9cf8b301f5bf044c2390f56333 (diff)
tdf#156959 - Remove pinned icons from thumbnail view item
Remove pinned icons from thumbnail view item and pushed it down to the recent documents view item. This avoids that the pinned icon will be shown in a simple thumbnail view, e.g., in the thumbnail view of the side pane in base. In addition, fixed an error with the number of elements in the thumbnail view in the start center when items are pinned, i.e., removed a spurious new line. Change-Id: I76026bfa9239f709aa60ff12efabe28cb09f0d76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156625 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/recentdocsviewitem.cxx51
-rw-r--r--sfx2/source/control/recentdocsviewitem.hxx8
-rw-r--r--sfx2/source/control/thumbnailview.cxx18
-rw-r--r--sfx2/source/control/thumbnailviewitem.cxx34
4 files changed, 65 insertions, 46 deletions
diff --git a/sfx2/source/control/recentdocsviewitem.cxx b/sfx2/source/control/recentdocsviewitem.cxx
index 240ef0c32d9d..2070a4efe46e 100644
--- a/sfx2/source/control/recentdocsviewitem.cxx
+++ b/sfx2/source/control/recentdocsviewitem.cxx
@@ -130,7 +130,11 @@ RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUStri
m_isReadOnly(isReadOnly),
m_bRemoveIconHighlighted(false),
m_aRemoveRecentBitmap(BMP_RECENTDOC_REMOVE),
- m_aRemoveRecentBitmapHighlighted(BMP_RECENTDOC_REMOVE_HIGHLIGHTED)
+ m_aRemoveRecentBitmapHighlighted(BMP_RECENTDOC_REMOVE_HIGHLIGHTED),
+ m_bPinned(isPinned),
+ m_bPinnedIconHighlighted(false),
+ m_aPinnedDocumentBitmap(BMP_PIN_DOC),
+ m_aPinnedDocumentBitmapHiglighted(BMP_PIN_DOC_HIGHLIGHTED)
{
OUString aTitle(rTitle);
INetURLObject aURLObj(rURL);
@@ -230,7 +234,6 @@ RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUStri
maTitle = aTitle;
maPreview1 = aThumbnail;
- mbPinned = isPinned;
}
::tools::Rectangle RecentDocsViewItem::updateHighlight(bool bVisible, const Point& rPoint)
@@ -252,6 +255,21 @@ RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUStri
m_bRemoveIconHighlighted = false;
}
+ if (bVisible && getPinnedIconArea().Contains(rPoint))
+ {
+ if (!m_bPinnedIconHighlighted)
+ aRect.Union(getPinnedIconArea());
+
+ m_bPinnedIconHighlighted = true;
+ }
+ else
+ {
+ if (m_bPinnedIconHighlighted)
+ aRect.Union(getPinnedIconArea());
+
+ m_bPinnedIconHighlighted = false;
+ }
+
return aRect;
}
@@ -265,6 +283,11 @@ RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUStri
aSize);
}
+::tools::Rectangle RecentDocsViewItem::getPinnedIconArea() const
+{
+ return ::tools::Rectangle(maPinPos, m_aPinnedDocumentBitmap.GetSizePixel());
+}
+
OUString RecentDocsViewItem::getHelpText() const
{
return m_sHelpText;
@@ -274,10 +297,10 @@ void RecentDocsViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProc
{
ThumbnailViewItem::Paint(pProcessor, pAttrs);
- // paint the remove icon when hovered
+ // paint the remove/pinned icon when hovered
if (isHighlighted())
{
- drawinglayer::primitive2d::Primitive2DContainer aSeq(1);
+ drawinglayer::primitive2d::Primitive2DContainer aSeq(2);
Point aIconPos(getRemoveIconArea().TopLeft());
@@ -285,6 +308,23 @@ void RecentDocsViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProc
m_bRemoveIconHighlighted ? m_aRemoveRecentBitmapHighlighted : m_aRemoveRecentBitmap,
B2DPoint(aIconPos.X(), aIconPos.Y())));
+ // tdf#38742 - draw pinned icon
+ const Point aPinnedIconPos(getPinnedIconArea().TopLeft());
+ aSeq[1] = drawinglayer::primitive2d::Primitive2DReference(new DiscreteBitmapPrimitive2D(
+ m_aPinnedDocumentBitmap, B2DPoint(aPinnedIconPos.X(), aPinnedIconPos.Y())));
+
+ pProcessor->process(aSeq);
+ }
+ // tdf#38742 - draw pinned icon if item is pinned
+ else if (m_bPinned)
+ {
+ drawinglayer::primitive2d::Primitive2DContainer aSeq(1);
+
+ const Point aPinnedIconPos(getPinnedIconArea().TopLeft());
+ aSeq[0] = drawinglayer::primitive2d::Primitive2DReference(new DiscreteBitmapPrimitive2D(
+ m_bPinnedIconHighlighted ? m_aPinnedDocumentBitmapHiglighted : m_aPinnedDocumentBitmap,
+ B2DPoint(aPinnedIconPos.X(), aPinnedIconPos.Y())));
+
pProcessor->process(aSeq);
}
}
@@ -300,8 +340,7 @@ void RecentDocsViewItem::MouseButtonUp(const MouseEvent& rMEvt)
return;
}
- const ::tools::Rectangle aPinPosRectangle(maPinPos, maPinnedDocumentBitmap.GetSizePixel());
- if (aPinPosRectangle.Contains(rMEvt.GetPosPixel()))
+ if (getPinnedIconArea().Contains(rMEvt.GetPosPixel()))
{
SvtHistoryOptions::TogglePinItem(EHistoryType::PickList, maURL);
mrParent.Reload();
diff --git a/sfx2/source/control/recentdocsviewitem.hxx b/sfx2/source/control/recentdocsviewitem.hxx
index 792e78ab9e05..9fd1b760b08f 100644
--- a/sfx2/source/control/recentdocsviewitem.hxx
+++ b/sfx2/source/control/recentdocsviewitem.hxx
@@ -43,11 +43,14 @@ public:
/// Called when the user clicks a document - it will open it.
void OpenDocument();
+ bool isPinned () const { return m_bPinned; }
+
private:
sfx2::RecentDocsView& mrParentView;
/// Return area where is the icon to remove document from the recent documents.
tools::Rectangle getRemoveIconArea() const;
+ tools::Rectangle getPinnedIconArea() const;
OUString maURL;
@@ -61,6 +64,11 @@ private:
BitmapEx m_aRemoveRecentBitmap;
BitmapEx m_aRemoveRecentBitmapHighlighted;
+
+ bool m_bPinned;
+ bool m_bPinnedIconHighlighted;
+ BitmapEx m_aPinnedDocumentBitmap;
+ BitmapEx m_aPinnedDocumentBitmapHiglighted;
};
#endif // INCLUDED_SFX2_RECENTDOCSVIEWITEM_HXX
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index b0cc1efefb27..65bc3d878df0 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/embed/XStorage.hpp>
#include <memory>
+#include "recentdocsviewitem.hxx"
using namespace basegfx;
using namespace basegfx::utils;
@@ -416,16 +417,19 @@ void ThumbnailView::CalculateItemPositions(bool bScrollBarUsed)
ThumbnailViewItem *const pItem = mFilteredItemList[i];
// tdf#38742 - show pinned items in a separate line
- if (bPinnedItems && !pItem->isPinned())
+ if (auto const pRecentDocsItem = dynamic_cast<RecentDocsViewItem*>(pItem))
{
- bPinnedItems = false;
- // Start a new line only if the entire line is not filled
- if ((nCurCount + 1) % mnCols && nCurCount > nFirstItem)
+ if (bPinnedItems && !pRecentDocsItem->isPinned())
{
- x = nStartX;
- y += mnItemHeight + nVItemSpace;
+ bPinnedItems = false;
+ // Start a new line only if the entire line is not filled
+ if (nCurCount % mnCols && nCurCount > nFirstItem)
+ {
+ x = nStartX;
+ y += mnItemHeight + nVItemSpace;
+ }
+ nCurCount = 0;
}
- nCurCount = 0;
}
if ((nCurCount >= nFirstItem) && (nCurCount < nLastItem))
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 9579889e7e9a..817b17427646 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -56,10 +56,6 @@ ThumbnailViewItem::ThumbnailViewItem(ThumbnailView& rView, sal_uInt16 nId)
, mbBorder(true)
, mbSelected(false)
, mbHover(false)
- , mbPinned(false)
- , mbPinnedDocumentHighlighted(false)
- , maPinnedDocumentBitmap(BMP_PIN_DOC)
- , maPinnedDocumentBitmapHiglighted(BMP_PIN_DOC_HIGHLIGHTED)
{
}
@@ -103,20 +99,6 @@ void ThumbnailViewItem::setHighlight (bool state)
setHighlight(false);
}
- const ::tools::Rectangle aPinPosRectangle(maPinPos, maPinnedDocumentBitmap.GetSizePixel());
- if (bVisible && aPinPosRectangle.Contains(rPoint))
- {
- if (!mbPinnedDocumentHighlighted)
- bNeedsPaint = true;
- mbPinnedDocumentHighlighted = true;
- }
- else
- {
- if (mbPinnedDocumentHighlighted)
- bNeedsPaint = true;
- mbPinnedDocumentHighlighted = false;
- }
-
if (bNeedsPaint)
return getDrawArea();
@@ -168,7 +150,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc
const ThumbnailItemAttributes *pAttrs)
{
BColor aFillColor = pAttrs->aFillColor;
- drawinglayer::primitive2d::Primitive2DContainer aSeq(5);
+ drawinglayer::primitive2d::Primitive2DContainer aSeq(4);
double fTransparence = 0.0;
// Draw background
@@ -202,20 +184,6 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc
false)
));
- // tdf#38742 - draw pinned icon
- if (mbPinned)
- {
- const BitmapEx& aBitmapEx
- = mbHover ? maPinnedDocumentBitmapHiglighted : maPinnedDocumentBitmap;
- aSeq[nPrimitive++] = drawinglayer::primitive2d::Primitive2DReference(
- new DiscreteBitmapPrimitive2D(aBitmapEx, B2DPoint(maPinPos.X(), maPinPos.Y())));
- }
- else if (mbHover)
- aSeq[nPrimitive++]
- = drawinglayer::primitive2d::Primitive2DReference(new DiscreteBitmapPrimitive2D(
- maPinnedDocumentBitmap, B2DPoint(maPinPos.X(), maPinPos.Y())));
-
-
if (mbBorder)
{
// draw thumbnail borders