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 interface
uses uses
{$IFDEF LCLCocoa}
CocoaGDIObjects, MacOSAll,
{$ENDIF}
LCLType, LMessages, LCLVersion, Graphics, SysUtils, Controls, Classes, Math, LCLType, LMessages, LCLVersion, Graphics, SysUtils, Controls, Classes, Math,
Dialogs, Forms, Types, ExtCtrls, Menus, ImgList, Dialogs, Forms, Types, ExtCtrls, Menus, ImgList,
SpkGraphTools, SpkGUITools, SpkMath, spkt_Appearance, spkt_BaseItem, spkt_Const, 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
{ Type describes regions of the toolbar which are used during handling { Type describes regions of the toolbar which are used during handling
@ -1226,7 +1229,16 @@ begin
if not (FBufferValid) then if not (FBufferValid) then
ValidateBuffer; ValidateBuffer;
end; 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; end;
procedure TSpkToolbar.DoOnResize; procedure TSpkToolbar.DoOnResize;
@ -2185,6 +2197,9 @@ var
MenuButtonWidth: Integer; MenuButtonWidth: Integer;
AdditionalPadding: Boolean; AdditionalPadding: Boolean;
MenuButtonTextWidth: Integer; MenuButtonTextWidth: Integer;
{$IFDEF LCLCocoa}
scalefactor: Double;
{$ENDIF}
begin begin
if FInternalUpdating or FUpdating then if FInternalUpdating or FUpdating then
exit; exit;
@ -2193,7 +2208,13 @@ begin
FBuffer.Free; FBuffer.Free;
FBuffer := TBitmap.Create; 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); SetBounds(Left, Top, FBuffer.Width, FBuffer.Height);
// *** Tabs *** // *** Tabs ***