|
| 1 | +diff --git a/components/virtualtreeview/laz.virtualtrees.pas b/components/virtualtreeview/laz.virtualtrees.pas |
| 2 | +--- a/components/virtualtreeview/laz.virtualtrees.pas |
| 3 | ++++ b/components/virtualtreeview/laz.virtualtrees.pas |
| 4 | +@@ -9244,9 +9244,7 @@ procedure TVirtualTreeColumns.PaintHeader(DC: HDC; const R: TRect; HOffset: Integer); |
| 5 | + var |
| 6 | + VisibleFixedWidth: Integer; |
| 7 | + RTLOffset: Integer; |
| 8 | +- {$ifdef LCLCocoa} |
| 9 | + sc : Double; |
| 10 | +- {$endif} |
| 11 | + |
| 12 | + procedure PaintFixedArea; |
| 13 | + |
| 14 | +@@ -9258,20 +9256,16 @@ procedure TVirtualTreeColumns.PaintHeader(DC: HDC; const R: TRect; HOffset: Integer); |
| 15 | + end; |
| 16 | + |
| 17 | + begin |
| 18 | ++ if Assigned(Header) and Assigned(Header.TreeView) then |
| 19 | ++ sc := Header.Treeview.GetCanvasScaleFactor |
| 20 | ++ else |
| 21 | ++ sc := 1.0; |
| 22 | + // Adjust size of the header bitmap |
| 23 | + with TWithSafeRect(FHeader.Treeview.FHeaderRect) do |
| 24 | + begin |
| 25 | +- FHeaderBitmap.Width := Max(Right, R.Right - R.Left); |
| 26 | +- FHeaderBitmap.Height := Bottom; |
| 27 | +- {$ifdef LCLCocoa} |
| 28 | +- if Assigned(Header) and Assigned(Header.TreeView) then |
| 29 | +- sc := Header.Treeview.GetCanvasScaleFactor |
| 30 | +- else |
| 31 | +- sc := 1.0; |
| 32 | +- FHeaderBitmap.Width := Round(FHeaderBitmap.Width * sc); |
| 33 | +- FHeaderBitmap.Height := Round(FHeaderBitmap.Height * sc); |
| 34 | +- CGContextScaleCTM(TCocoaBitmapContext(FHeaderBitmap.Canvas.Handle).CGContext, sc, sc); |
| 35 | +- {$endif} |
| 36 | ++ FHeaderBitmap.Clear; |
| 37 | ++ FHeaderBitmap.SetSize(Round(Max(Right, R.Right - R.Left) * sc), Round(Bottom * sc)); |
| 38 | ++ LCLIntf.SetCanvasScaleFactor(FHeaderBitmap.Canvas.Handle, sc); |
| 39 | + end; |
| 40 | + |
| 41 | + VisibleFixedWidth := GetVisibleFixedWidth; |
| 42 | +@@ -9296,15 +9290,7 @@ begin |
| 43 | + |
| 44 | + // Blit the result to target. |
| 45 | + with TWithSafeRect(R) do |
| 46 | +- {$ifdef LCLCocoa} |
| 47 | +- StretchBlt(DC, Left, Top, Right - Left, Bottom - Top, |
| 48 | +- FHeaderBitmap.Canvas.Handle, |
| 49 | +- Left, Top, |
| 50 | +- FHeaderBitmap.Width, FHeaderBitmap.Height, |
| 51 | +- SRCCOPY); |
| 52 | +- {$else} |
| 53 | +- BitBlt(DC, Left, Top, Right - Left, Bottom - Top, FHeaderBitmap.Canvas.Handle, Left, Top, SRCCOPY); |
| 54 | +- {$endif} |
| 55 | ++ BitBlt(DC, Left, Top, Round((Right - Left) * sc), Round((Bottom - Top) * sc), FHeaderBitmap.Canvas.Handle, Left, Top, SRCCOPY); |
| 56 | + end; |
| 57 | + |
| 58 | + //---------------------------------------------------------------------------------------------------------------------- |
| 59 | +@@ -30671,18 +30657,9 @@ var |
| 60 | + CellIsTouchingClientRight: Boolean; |
| 61 | + CellIsInLastColumn: Boolean; |
| 62 | + ColumnIsFixed: Boolean; |
| 63 | +- |
| 64 | +- {$ifdef LCLCocoa} |
| 65 | +- sc: Double; // the retina scale. 1.0 for no-retina |
| 66 | +- cg: CGContextRef; // tracking the Context of Bitmap |
| 67 | +- cglast: CGContextRef; // the last Context of Bitmap. |
| 68 | +- // The scale is applied only when the context changes |
| 69 | +- {$endif} |
| 70 | ++ ScaleFactor: double; |
| 71 | + begin |
| 72 | +- {$ifdef LCLCocoa} |
| 73 | +- cglast := nil; |
| 74 | +- sc := GetCanvasScaleFactor; |
| 75 | +- {$endif} |
| 76 | ++ ScaleFactor := GetCanvasScaleFactor; |
| 77 | + {$ifdef DEBUG_VTV}Logger.EnterMethod([lcPaint],'PaintTree');{$endif} |
| 78 | + {$ifdef DEBUG_VTV}Logger.Send([lcPaint, lcHeaderOffset],'Window',Window);{$endif} |
| 79 | + {$ifdef DEBUG_VTV}Logger.Send([lcPaint, lcHeaderOffset],'Target',Target);{$endif} |
| 80 | +@@ -30725,12 +30702,9 @@ begin |
| 81 | + else |
| 82 | + NodeBitmap.PixelFormat := PixelFormat; |
| 83 | + |
| 84 | +- {$ifdef LCLCocoa} |
| 85 | +- NodeBitmap.Width := Round(PaintWidth*sc); |
| 86 | +- cg := TCocoaBitmapContext(NodeBitmap.Canvas.Handle).CGContext; |
| 87 | +- {$else} |
| 88 | +- NodeBitmap.Width := PaintWidth; |
| 89 | +- {$endif} |
| 90 | ++ NodeBitmap.Width := Round(PaintWidth * ScaleFactor); |
| 91 | ++ NodeBitmap.Height := 1; |
| 92 | ++ LCLIntf.SetCanvasScaleFactor(NodeBitmap.Canvas.Handle, ScaleFactor); |
| 93 | + |
| 94 | + // Make sure the buffer bitmap and target bitmap use the same transformation mode. |
| 95 | + {$ifndef Gtk} |
| 96 | +@@ -30849,19 +30823,9 @@ begin |
| 97 | + if Height < PaintInfo.Node.NodeHeight then |
| 98 | + begin |
| 99 | + // Avoid that the VCL copies the bitmap while changing its height. |
| 100 | +- {$ifdef LCLCocoa} |
| 101 | +- if Height > 0 then SetSize(1,1); // can't go to 0, must keep canvas |
| 102 | +- SetSize(Round(PaintWidth*sc), Round(PaintInfo.Node.NodeHeight * sc)); |
| 103 | +- cg := TCocoaBitmapContext(NodeBitmap.Canvas.Handle).CGContext; |
| 104 | +- if cglast <> cg then |
| 105 | +- begin |
| 106 | +- CGContextScaleCTM(cg, sc, sc); |
| 107 | +- cglast := cg; |
| 108 | +- end; |
| 109 | +- {$else} |
| 110 | + if Height > 0 then SetSize(1,1); // can't go to 0, must keep canvas |
| 111 | +- SetSize(PaintWidth, PaintInfo.Node.NodeHeight); |
| 112 | +- {$endif} |
| 113 | ++ SetSize(Round(PaintWidth * ScaleFactor), Round(PaintInfo.Node.NodeHeight * ScaleFactor)); |
| 114 | ++ LCLIntf.SetCanvasScaleFactor(NodeBitmap.Canvas.Handle, ScaleFactor); |
| 115 | + {$ifdef UseSetCanvasOrigin} |
| 116 | + SetCanvasOrigin(Canvas, Window.Left, 0); |
| 117 | + {$else} |
| 118 | +@@ -31182,25 +31146,9 @@ begin |
| 119 | + if not (poUnbuffered in PaintOptions) then |
| 120 | + with TWithSafeRect(TargetRect), NodeBitmap do |
| 121 | + begin |
| 122 | +- {$ifdef LCLCocoa} |
| 123 | +- StretchBlt( |
| 124 | +- TargetCanvas.Handle, |
| 125 | +- Left, |
| 126 | +- Top + YCorrect, |
| 127 | +- PaintWidth, |
| 128 | +- PaintInfo.Node.NodeHeight - YCorrect, |
| 129 | +- Canvas.Handle, |
| 130 | +- Window.Left, |
| 131 | +- Round(YCorrect * sc), |
| 132 | +- NodeBitmap.Width, |
| 133 | +- Round(PaintInfo.Node.NodeHeight * sc) - Round(YCorrect * sc), |
| 134 | +- SRCCOPY |
| 135 | +- ); |
| 136 | +- {$else} |
| 137 | + BitBlt(TargetCanvas.Handle, Left, |
| 138 | +- Top {$ifdef ManualClipNeeded} + YCorrect{$endif}, Width, PaintInfo.Node.NodeHeight, Canvas.Handle, Window.Left, |
| 139 | ++ Top {$ifdef ManualClipNeeded} + YCorrect{$endif}, Round(Width * ScaleFactor), Round(PaintInfo.Node.NodeHeight * ScaleFactor), Canvas.Handle, Window.Left, |
| 140 | + {$ifdef ManualClipNeeded}YCorrect{$else}0{$endif}, SRCCOPY); |
| 141 | +- {$endif} |
| 142 | + end; |
| 143 | + end; |
| 144 | + end; |
| 145 | +@@ -31241,8 +31189,9 @@ begin |
| 146 | + // Avoid unnecessary copying of bitmap content. This will destroy the DC handle too. |
| 147 | + NodeBitmap.Height := 0; |
| 148 | + NodeBitmap.PixelFormat := pf32Bit; |
| 149 | +- NodeBitmap.Width := TargetRect.Right - TargetRect.Left; |
| 150 | +- NodeBitmap.Height := TargetRect.Bottom - TargetRect.Top; |
| 151 | ++ NodeBitmap.Width := Round((TargetRect.Right - TargetRect.Left) * ScaleFactor); |
| 152 | ++ NodeBitmap.Height := Round((TargetRect.Bottom - TargetRect.Top) * ScaleFactor); |
| 153 | ++ LCLIntf.SetCanvasScaleFactor(NodeBitmap.Canvas.Handle, ScaleFactor); |
| 154 | + end; |
| 155 | + |
| 156 | + {$ifdef DEBUG_VTV}Logger.Send([lcPaintDetails],'NodeBitmap.Handle after changing height to background',NodeBitmap.Handle);{$endif} |
0 commit comments