Kaydet (Commit) 14abbc6e authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

tdf#82009 TreeList move painting of drag target into Paint func.

When we drag a entry in TreeListBox, we execute a PaintDDCursor
which paints a "cursor" of a possible drag target (for example
to show where the entry will be moved to if we want to change the
order). The problem with this fuction is that it paints a line
directlly at that location, and that it uses invert raster
operation to draw a line. So to hide the line it just needs to
draw again. On MacOS this invertion causes a problem and draws
the whole area black, which is the cause of this bug.

So instead of inverting the drawing of the drag target cursor
has now been moved into the main Paint method, where it redraws
the whole entry, and if present, also the drag target cursor.
This means that all we need to do is Invalidate the entry,
which then just gets redrawn in a normal Paint pass.

One exception is still MacOS, which doesn't invalidate the entry,
but redraws the entry directly. DnD is MacOS is a bit different
as it is not async (if I understand correctly) so the invalidate
has no effect.

Change-Id: I8542f47940a3b90114ea4bbbac57fd303ca3434b
Reviewed-on: https://gerrit.libreoffice.org/70521
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst cf09ec89
...@@ -292,7 +292,7 @@ public: ...@@ -292,7 +292,7 @@ public:
void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop = false ); void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop = false );
void ScrollToAbsPos( long nPos ); void ScrollToAbsPos( long nPos );
void PaintDDCursor( SvTreeListEntry* ); void PaintDDCursor(SvTreeListEntry* pEntry, bool bShow);
// Images // Images
inline Image& implGetImageLocation( const ImageType _eType ); inline Image& implGetImageLocation( const ImageType _eType );
......
...@@ -51,6 +51,8 @@ class VCL_DLLPUBLIC SvViewDataEntry ...@@ -51,6 +51,8 @@ class VCL_DLLPUBLIC SvViewDataEntry
bool mbExpanded:1; bool mbExpanded:1;
bool mbFocused:1; bool mbFocused:1;
bool mbSelectable:1; bool mbSelectable:1;
bool mbDragTarget:1;
tools::Rectangle maPaintRectangle; tools::Rectangle maPaintRectangle;
public: public:
...@@ -63,11 +65,16 @@ public: ...@@ -63,11 +65,16 @@ public:
bool IsExpanded() const { return mbExpanded;} bool IsExpanded() const { return mbExpanded;}
bool HasFocus() const { return mbFocused;} bool HasFocus() const { return mbFocused;}
bool IsSelectable() const { return mbSelectable;} bool IsSelectable() const { return mbSelectable;}
bool IsDragTarget() const { return mbDragTarget;}
void SetFocus( bool bFocus ); void SetFocus( bool bFocus );
void SetSelected( bool bSelected ); void SetSelected( bool bSelected );
void SetHighlighted( bool bHighlighted ); void SetHighlighted( bool bHighlighted );
void SetExpanded( bool bExpanded ); void SetExpanded( bool bExpanded );
void SetSelectable( bool bSelectable ); void SetSelectable( bool bSelectable );
void SetDragTarget( bool bDragTarget )
{
mbDragTarget = bDragTarget;
}
void Init(size_t nSize); void Init(size_t nSize);
......
...@@ -2874,23 +2874,20 @@ IMPL_LINK_NOARG(SvImpLBox, BeginDragHdl, Timer *, void) ...@@ -2874,23 +2874,20 @@ IMPL_LINK_NOARG(SvImpLBox, BeginDragHdl, Timer *, void)
pView->StartDrag( 0, aAsyncBeginDragPos ); pView->StartDrag( 0, aAsyncBeginDragPos );
} }
void SvImpLBox::PaintDDCursor( SvTreeListEntry* pInsertionPos ) void SvImpLBox::PaintDDCursor(SvTreeListEntry* pEntry, bool bShow)
{ {
long nY; if (pEntry)
if( pInsertionPos )
{ {
nY = GetEntryLine( pInsertionPos );
nY += pView->GetEntryHeight(); SvViewDataEntry* pViewData = pView->GetViewData(pEntry);
pViewData->SetDragTarget(bShow);
#ifdef MACOSX
// in MacOS we need to draw directly (as we are synchronuous) or no invalidation happens
pView->PaintEntry1(*pEntry, GetEntryLine(pEntry), *pView);
#else
InvalidateEntry(pEntry);
#endif
} }
else
nY = 1;
RasterOp eOldOp = pView->GetRasterOp();
pView->SetRasterOp( RasterOp::Invert );
Color aOldLineColor = pView->GetLineColor();
pView->SetLineColor( COL_BLACK );
pView->DrawLine( Point( 0, nY ), Point( aOutputSize.Width(), nY ) );
pView->SetLineColor( aOldLineColor );
pView->SetRasterOp( eOldOp );
} }
void SvImpLBox::Command( const CommandEvent& rCEvt ) void SvImpLBox::Command( const CommandEvent& rCEvt )
......
...@@ -687,7 +687,7 @@ void SvTreeListBox::ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow) ...@@ -687,7 +687,7 @@ void SvTreeListBox::ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow)
return; return;
if ( !bShow && !(nImpFlags & SvTreeListBoxFlags::TARGEMPH_VIS) ) if ( !bShow && !(nImpFlags & SvTreeListBoxFlags::TARGEMPH_VIS) )
return; return;
pImpl->PaintDDCursor( pEntry ); pImpl->PaintDDCursor( pEntry, bShow);
if( bShow ) if( bShow )
nImpFlags |= SvTreeListBoxFlags::TARGEMPH_VIS; nImpFlags |= SvTreeListBoxFlags::TARGEMPH_VIS;
else else
...@@ -2585,7 +2585,6 @@ void SvTreeListBox::InvalidateEntry(SvTreeListEntry* pEntry) ...@@ -2585,7 +2585,6 @@ void SvTreeListBox::InvalidateEntry(SvTreeListEntry* pEntry)
void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::RenderContext& rRenderContext) void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::RenderContext& rRenderContext)
{ {
tools::Rectangle aRect; // multi purpose tools::Rectangle aRect; // multi purpose
bool bHorSBar = pImpl->HasHorScrollBar(); bool bHorSBar = pImpl->HasHorScrollBar();
...@@ -2772,6 +2771,15 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render ...@@ -2772,6 +2771,15 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render
nCurTab++; nCurTab++;
} }
if (pViewDataEntry->IsDragTarget())
{
rRenderContext.Push();
rRenderContext.SetLineColor(rSettings.GetDeactiveColor());
rRenderContext.SetFillColor(rSettings.GetDeactiveColor());
rRenderContext.DrawRect(tools::Rectangle(Point(0, nLine + nTempEntryHeight - 2), Size(nWidth, 2)));
rRenderContext.Pop();
}
if (bCurFontIsSel || rEntry.GetTextColor()) if (bCurFontIsSel || rEntry.GetTextColor())
{ {
rRenderContext.SetTextColor(aBackupTextColor); rRenderContext.SetTextColor(aBackupTextColor);
......
...@@ -26,6 +26,7 @@ SvViewDataEntry::SvViewDataEntry() : ...@@ -26,6 +26,7 @@ SvViewDataEntry::SvViewDataEntry() :
mbExpanded(false), mbExpanded(false),
mbFocused(false), mbFocused(false),
mbSelectable(true), mbSelectable(true),
mbDragTarget(false),
maPaintRectangle() maPaintRectangle()
{ {
} }
...@@ -37,6 +38,7 @@ SvViewDataEntry::SvViewDataEntry( const SvViewDataEntry& rData ) : ...@@ -37,6 +38,7 @@ SvViewDataEntry::SvViewDataEntry( const SvViewDataEntry& rData ) :
mbExpanded(rData.mbExpanded), mbExpanded(rData.mbExpanded),
mbFocused(false), mbFocused(false),
mbSelectable(rData.mbSelectable), mbSelectable(rData.mbSelectable),
mbDragTarget(false),
maPaintRectangle(rData.maPaintRectangle) maPaintRectangle(rData.maPaintRectangle)
{ {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment