Cocoa: Pen properties are ignored when Canvas.Clipping is active
Original Reporter info from Mantis: wp @wpam
-
Reporter name:
Original Reporter info from Mantis: wp @wpam
- Reporter name:
Description:
Based on forum discussion https://forum.lazarus.freepascal.org/index.php/topic,50890 about line series in TAChart sometimes ignoriung their color in macOS/cocoa I found the issue that cocoa seem to ignore Pen properties such as Color, Width, PenStyle when clipping of the canvas is active.
Steps to reproduce:
Run attached demo project. It paints a horizontal red dashed thick line onto a Paintbox canvas. Clipping can be activated by checking the "Clipping" checkbox. When this checkbox is OFF the line runs with its set attributes across the Paintbox, as expected. But when the checkbox is ON the clipped line becomes black, thin and solid. This does not happen on Windows.
This is the relevant painting code used in the demo project:
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
with Paintbox1 do
begin
Canvas.Brush.Color := clWhite;
Canvas.FillRect(0, 0, Width, Height);
if Checkbox1.Checked then begin
Canvas.ClipRect := Rect(50, 50, Width-50, Height-50);
Canvas.Clipping := true;
end;
Canvas.Pen.Color := clRed;
Canvas.Pen.Width := 3;
Canvas.Pen.Style := psDash;
Canvas.Line(0, 100, Width, 100);
if Checkbox1.Checked then
Canvas.Clipping := false;
end;
end;
Mantis conversion info:
- Mantis ID: 37520
- OS: macOS
- OS Build: 10.14.3, 10.13.6
- Fixed in revision: 63702 (#f6796707)