View Issue Details

IDProjectCategoryView StatusLast Update
0036879LazarusLCLpublic2020-04-08 20:15
ReporterCudaText man Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
OSubuntu 19.x x64 
Product Version2.0.7 (SVN) 
Summary0036879: Qt/Qt5 bad Canvas.StretchDraw
Descriptionafter last changes in qt/qt5 WS, ATTabs component cannot paint angled tabs.
to see
- install ATFlatControls from IDE online package manager / or from https://github.com/alexey-t/atflatcontrols
- run app/demo_tabs with qt/Qt5

pic added.
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetQT, QT5
Attached Files

Activities

CudaText man

2020-04-06 16:17

reporter  

tabz.png (4,694 bytes)   
tabz.png (4,694 bytes)   

Zeljan Rikalo

2020-04-06 16:22

developer   ~0121972

I've already written to the mailing list: please create simple example project so I don't need to install 3rd party components like ATxxxxx controls.

Zeljan Rikalo

2020-04-06 17:22

developer   ~0121975

I've tested with svn r60000 (only qt/qt5 widgetset part) (4.1.2019, so 15 months ago) and same problem persists with qt and qt5, so this has nothing to do with my recent changes with stretchMaskBlt(). (linux mint 19.2 64bit, Qt/Qt5).
Does your code work ok with cocoa ?

CudaText man

2020-04-06 22:40

reporter   ~0121988

Last edited: 2020-04-06 22:41

View 2 revisions

i've seen ATTabs code and see it paints triangle over old triangle. trinagle-1 overlaps trinagle-2. so 2 nearest tabs overlap. code gets old rect using Canvas.CopyRect, paints triangle over it. maybe CopyRect has bug.

CudaText man

2020-04-06 22:40

reporter   ~0121989

yes, code works ok with Cocoa. and with old Laz 2.1 with qt/qt5.

Zeljan Rikalo

2020-04-07 11:03

developer   ~0121996

@CudaText man, now with my internal changes in CopyRect() (TQtWidgetSet.StretchMaskBlt()) I have ok image, but problem is that background is black, but under gtk2 it's transparent, so it does not look ok yet.

CudaText man

2020-04-07 19:36

reporter   ~0122008

ok, waiting for qt/qt5 fixing.

Zeljan Rikalo

2020-04-07 21:28

developer   ~0122009

I've lost few hours because trusted in your code. You are painting outside of paint event somewhere in your code and using CopyRect() (or BitBlt, StretchBlt or StretchmaskBlt). Qt, Qt5, cocoa and carbon does not support painting outside of paint event.
This is my error log (only TATabs with 2 tabs are on the form).
It's clear here that you're copying something from TCustomcontrol to DestDC which is TBitmap in this case, but not inside paint event of TCustomControl.

ERROR: SrcDC NOT inside paintEvent...TQtViewPort FOwner TQtCustomControl LCLObject=ATTabs1:TATTabs
SrcRect=l=334,t=4,r=344,b=28 DstRect=l=0,t=0,r=50,b=120 destination is QImage with format QImageFormat_RGB32
ERROR: SrcDC NOT inside paintEvent...TQtViewPort FOwner TQtCustomControl LCLObject=ATTabs1:TATTabs
SrcRect=l=168,t=4,r=178,b=28 DstRect=l=0,t=0,r=50,b=120 destination is QImage with format QImageFormat_RGB32
ERROR: SrcDC NOT inside paintEvent...TQtViewPort FOwner TQtCustomControl LCLObject=ATTabs1:TATTabs
SrcRect=l=306,t=4,r=316,b=28 DstRect=l=0,t=0,r=50,b=120 destination is QImage with format QImageFormat_RGB32
ERROR: SrcDC NOT inside paintEvent...TQtViewPort FOwner TQtCustomControl LCLObject=ATTabs1:TATTabs
SrcRect=l=38,t=4,r=48,b=29 DstRect=l=0,t=0,r=50,b=125 destination is QImage with format QImageFormat_RGB32
ERROR: SrcDC NOT inside paintEvent...TQtViewPort FOwner TQtCustomControl LCLObject=ATTabs1:TATTabs
SrcRect=l=176,t=4,r=186,b=29 DstRect=l=0,t=0,r=50,b=125 destination is QImage with format QImageFormat_RGB32

Resolved as "no change required". Fix your code.

Zeljan Rikalo

2020-04-08 09:25

developer   ~0122014

Sorry, it was fault inside my debugging code. ATTabs does not paint outside of paint event

Zeljan Rikalo

2020-04-08 09:27

developer   ~0122015

It looks to me that you're missing mask on bitmap. Note that copy from screen is much different under X11 than windows.
If your window is obscured by some other window it won't work as expected.
Currently (in my trunk copy) I've hacked & cheated Qt to render widget (as in TQtWSWinControl.PaintTo()) instead of grabbing window and got result as in attached picture.
Triangles are there but they're not masked so you see white stuff around.
attabs_missing_mask.png (2,347 bytes)   
attabs_missing_mask.png (2,347 bytes)   

Zeljan Rikalo

2020-04-08 12:21

developer   ~0122025

Ok, I've found howto fix it inside ATTabs. CopyRect() from device isn't needed at all (it does exactly nothing).
1.Rename FBitmapAngle to FBitmapAngleL
2.Add FBitmapAngleR (create it same as FBitmapAngleL)
3.In DoPaintTabShape_R() use FBitmapAngleR instead of FBitmapAngleL.
4.In DrawTriangleRectFramed() add this:
    BitmapSetSize(b, ASizeX*AScale, ASizeY*AScale);
   // add this
    b.Canvas.Brush.Style := bsSolid;
    b.Canvas.Brush.Color := {$IFDEF MSWINDOWS}clWhite{$ELSE}clBlack{$ENDIF};
    b.Canvas.FillRect(0, 0, b.Width, b.Height);
    b.TransparentColor := {$IFDEF MSWINDOWS}clWhite{$ELSE}clBlack{$ENDIF};
    b.Transparent := true;

5.Remove below b.Canvas.CopyRect() .

Now your code will be even faster (at least under X11) and it will work correct.

Zeljan Rikalo

2020-04-08 12:26

developer   ~0122027

Last edited: 2020-04-08 12:26

View 2 revisions

See results in pictures. All are ok (except gtk3 but that's anothers story since gtk3 drawing isn't perfect yet).
EDIT: All screenshoots are maded after changes I've proposed.

attabs_gtk3.png (3,504 bytes)   
attabs_gtk3.png (3,504 bytes)   
attabs_win32_under_wine.png (2,595 bytes)   
attabs_win32_under_wine.png (2,595 bytes)   
attabs_gtk2.png (3,005 bytes)   
attabs_gtk2.png (3,005 bytes)   
attabs_qt5.png (3,237 bytes)   
attabs_qt5.png (3,237 bytes)   
attabs_qt4.png (3,278 bytes)   
attabs_qt4.png (3,278 bytes)   

CudaText man

2020-04-08 20:02

reporter   ~0122039

thanks for your fix. i added this fix to ATtabs.

Zeljan Rikalo

2020-04-08 20:15

developer   ~0122040

Please close if ok.

Issue History

Date Modified Username Field Change
2020-04-06 16:17 CudaText man New Issue
2020-04-06 16:17 CudaText man File Added: tabz.png
2020-04-06 16:22 Zeljan Rikalo Assigned To => Zeljan Rikalo
2020-04-06 16:22 Zeljan Rikalo Status new => assigned
2020-04-06 16:22 Zeljan Rikalo LazTarget => -
2020-04-06 16:22 Zeljan Rikalo Note Added: 0121972
2020-04-06 17:22 Zeljan Rikalo Status assigned => feedback
2020-04-06 17:22 Zeljan Rikalo Note Added: 0121975
2020-04-06 22:40 CudaText man Note Added: 0121988
2020-04-06 22:40 CudaText man Status feedback => assigned
2020-04-06 22:40 CudaText man Note Added: 0121989
2020-04-06 22:41 CudaText man Note Edited: 0121988 View Revisions
2020-04-07 11:03 Zeljan Rikalo Note Added: 0121996
2020-04-07 19:36 CudaText man Note Added: 0122008
2020-04-07 21:28 Zeljan Rikalo Status assigned => resolved
2020-04-07 21:28 Zeljan Rikalo Resolution open => no change required
2020-04-07 21:28 Zeljan Rikalo Widgetset QT, QT5 => QT, QT5
2020-04-07 21:28 Zeljan Rikalo Note Added: 0122009
2020-04-08 09:25 Zeljan Rikalo Status resolved => acknowledged
2020-04-08 09:25 Zeljan Rikalo Resolution no change required => reopened
2020-04-08 09:25 Zeljan Rikalo Note Added: 0122014
2020-04-08 09:27 Zeljan Rikalo File Added: attabs_missing_mask.png
2020-04-08 09:27 Zeljan Rikalo Note Added: 0122015
2020-04-08 12:21 Zeljan Rikalo Status acknowledged => feedback
2020-04-08 12:21 Zeljan Rikalo Note Added: 0122025
2020-04-08 12:26 Zeljan Rikalo File Added: attabs_gtk3.png
2020-04-08 12:26 Zeljan Rikalo File Added: attabs_win32_under_wine.png
2020-04-08 12:26 Zeljan Rikalo File Added: attabs_gtk2.png
2020-04-08 12:26 Zeljan Rikalo File Added: attabs_qt5.png
2020-04-08 12:26 Zeljan Rikalo File Added: attabs_qt4.png
2020-04-08 12:26 Zeljan Rikalo Note Added: 0122027
2020-04-08 12:26 Zeljan Rikalo Note Edited: 0122027 View Revisions
2020-04-08 20:02 CudaText man Note Added: 0122039
2020-04-08 20:02 CudaText man Status feedback => assigned
2020-04-08 20:15 Zeljan Rikalo Status assigned => resolved
2020-04-08 20:15 Zeljan Rikalo Resolution reopened => no change required
2020-04-08 20:15 Zeljan Rikalo Widgetset QT, QT5 => QT, QT5
2020-04-08 20:15 Zeljan Rikalo Note Added: 0122040