SpkToolbar: Fix blurry fonts on macOS/cocoa. Patch by ChristianH, forum https://forum.lazarus.freepascal.org/index.php/topic,55123.msg409712/topicseen.html

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8054 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-06-23 16:56:56 +00:00
parent 550299d3ad
commit c1347e04e7

View File

@ -24,10 +24,13 @@ unit SpkToolbar;
interface
uses
{$IFDEF LCLCocoa}
CocoaGDIObjects, MacOSAll,
{$ENDIF}
LCLType, LMessages, LCLVersion, Graphics, SysUtils, Controls, Classes, Math,
Dialogs, Forms, Types, ExtCtrls, Menus, ImgList,
SpkGraphTools, SpkGUITools, SpkMath, spkt_Appearance, spkt_BaseItem, spkt_Const,
spkt_Dispatch, spkt_Tab, spkt_Pane, spkt_Types, spkt_Buttons, spkt_Tools;
spkt_Dispatch, spkt_Tab, spkt_Pane, spkt_Types;
type
{ Type describes regions of the toolbar which are used during handling
@ -1226,7 +1229,16 @@ begin
if not (FBufferValid) then
ValidateBuffer;
end;
self.canvas.draw(0, 0, FBuffer);
{$IFDEF LCLCocoa}
StretchBlt(
Canvas.Handle, 0, 0, Width, Height,
FBuffer.Canvas.Handle, 0, 0, FBuffer.Width, FBuffer.Height,
SRCCOPY
);
{$ELSE}
Canvas.Draw(0, 0, FBuffer);
{$ENDIF}
end;
procedure TSpkToolbar.DoOnResize;
@ -2185,6 +2197,9 @@ var
MenuButtonWidth: Integer;
AdditionalPadding: Boolean;
MenuButtonTextWidth: Integer;
{$IFDEF LCLCocoa}
scalefactor: Double;
{$ENDIF}
begin
if FInternalUpdating or FUpdating then
exit;
@ -2193,7 +2208,13 @@ begin
FBuffer.Free;
FBuffer := TBitmap.Create;
FBuffer.SetSize(self.Width, CalcToolbarHeight); //Height);
{$IFDEF LCLCocoa}
scalefactor := GetCanvasScaleFactor;
FBuffer.SetSize(round(scaleFactor*Width), round(scaleFactor*CalcToolbarHeight));
CGContextScaleCTM(TCocoaBitmapContext(FBuffer.Canvas.Handle).CGContext, scaleFactor, scaleFactor);
{$ELSE}
FBuffer.SetSize(Width, CalcToolbarHeight);
{$ENDIF}
SetBounds(Left, Top, FBuffer.Width, FBuffer.Height);
// *** Tabs ***