mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 10:49:16 +02:00
SynEdit, Gutter: more PPI PreferedWidth fixes. Issue #33949
git-svn-id: trunk@58491 -
This commit is contained in:
parent
2948414ac2
commit
6680265b3f
@ -172,7 +172,9 @@ type
|
|||||||
procedure SetMouseActions(const AValue: TSynEditMouseActions);
|
procedure SetMouseActions(const AValue: TSynEditMouseActions);
|
||||||
protected
|
protected
|
||||||
function CreateMouseActions: TSynEditMouseInternalActions; virtual;
|
function CreateMouseActions: TSynEditMouseInternalActions; virtual;
|
||||||
function PreferedWidth: Integer; virtual;
|
function Scale96ToFont(const ASize: Integer): Integer;
|
||||||
|
function PreferedWidth: Integer; virtual; // at PPI 96
|
||||||
|
function PreferedWidthAtCurrentPPI: Integer; virtual;
|
||||||
procedure SetBounds(ALeft, ATop, AHeight: Integer);
|
procedure SetBounds(ALeft, ATop, AHeight: Integer);
|
||||||
procedure DoAutoSize;
|
procedure DoAutoSize;
|
||||||
procedure SetAutoSize(const AValue : boolean); virtual;
|
procedure SetAutoSize(const AValue : boolean); virtual;
|
||||||
@ -598,6 +600,11 @@ begin
|
|||||||
Result := 12;
|
Result := 12;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSynGutterPartBase.PreferedWidthAtCurrentPPI: Integer;
|
||||||
|
begin
|
||||||
|
Result := Scale96ToFont(PreferedWidth);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSynGutterPartBase.SetBounds(ALeft, ATop, AHeight: Integer);
|
procedure TSynGutterPartBase.SetBounds(ALeft, ATop, AHeight: Integer);
|
||||||
begin
|
begin
|
||||||
if (ALeft = FLeft) and (ATop = FTop) and (AHeight = FHeight) then
|
if (ALeft = FLeft) and (ATop = FTop) and (AHeight = FHeight) then
|
||||||
@ -612,9 +619,7 @@ procedure TSynGutterPartBase.DoAutoSize;
|
|||||||
var
|
var
|
||||||
NewWidth: Integer;
|
NewWidth: Integer;
|
||||||
begin
|
begin
|
||||||
NewWidth := PreferedWidth;
|
NewWidth := PreferedWidthAtCurrentPPI;
|
||||||
if FSynEdit<>nil then
|
|
||||||
NewWidth := FSynEdit.Scale96ToFont(NewWidth);
|
|
||||||
if FWidth = NewWidth then exit;
|
if FWidth = NewWidth then exit;
|
||||||
FWidth := NewWidth;
|
FWidth := NewWidth;
|
||||||
VisibilityOrSize;
|
VisibilityOrSize;
|
||||||
@ -663,6 +668,13 @@ begin
|
|||||||
Result := TSynEditMouseInternalActions.Create(Self);
|
Result := TSynEditMouseInternalActions.Create(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSynGutterPartBase.Scale96ToFont(const ASize: Integer): Integer;
|
||||||
|
begin
|
||||||
|
Result := ASize;
|
||||||
|
if SynEdit<>nil then
|
||||||
|
Result := SynEdit.Scale96ToFont(Result);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TSynGutterPartBase.Create(AOwner: TComponent);
|
constructor TSynGutterPartBase.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
FMarkupInfo := TSynSelectedColor.Create;
|
FMarkupInfo := TSynSelectedColor.Create;
|
||||||
|
@ -33,7 +33,7 @@ type
|
|||||||
function FormatLineNumber(Line: integer; IsDot: boolean): string;
|
function FormatLineNumber(Line: integer; IsDot: boolean): string;
|
||||||
protected
|
protected
|
||||||
procedure Init; override;
|
procedure Init; override;
|
||||||
function PreferedWidth: Integer; override;
|
function PreferedWidthAtCurrentPPI: Integer; override;
|
||||||
procedure LineCountChanged(Sender: TSynEditStrings; AIndex, ACount: Integer);
|
procedure LineCountChanged(Sender: TSynEditStrings; AIndex, ACount: Integer);
|
||||||
procedure BufferChanged(Sender: TObject);
|
procedure BufferChanged(Sender: TObject);
|
||||||
procedure FontChanged(Sender: TObject);
|
procedure FontChanged(Sender: TObject);
|
||||||
@ -172,7 +172,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynGutterLineNumber.PreferedWidth: Integer;
|
function TSynGutterLineNumber.PreferedWidthAtCurrentPPI: Integer;
|
||||||
begin
|
begin
|
||||||
Result := FAutoSizeDigitCount * FTextDrawer.CharWidth + 1;
|
Result := FAutoSizeDigitCount * FTextDrawer.CharWidth + 1;
|
||||||
end;
|
end;
|
||||||
|
@ -23,6 +23,7 @@ type
|
|||||||
FBookMarkOpt: TSynBookMarkOpt;
|
FBookMarkOpt: TSynBookMarkOpt;
|
||||||
procedure Init; override;
|
procedure Init; override;
|
||||||
function PreferedWidth: Integer; override;
|
function PreferedWidth: Integer; override;
|
||||||
|
function LeftMarginAtCurrentPPI: Integer;
|
||||||
function GetImgListRes(const ACanvas: TCanvas;
|
function GetImgListRes(const ACanvas: TCanvas;
|
||||||
const AImages: TCustomImageList): TScaledImageListResolution; virtual;
|
const AImages: TCustomImageList): TScaledImageListResolution; virtual;
|
||||||
// PaintMarks: True, if it has any Mark, that is *not* a bookmark
|
// PaintMarks: True, if it has any Mark, that is *not* a bookmark
|
||||||
@ -66,6 +67,11 @@ begin
|
|||||||
Result := 22 + FBookMarkOpt.LeftMargin
|
Result := 22 + FBookMarkOpt.LeftMargin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSynGutterMarks.LeftMarginAtCurrentPPI: Integer;
|
||||||
|
begin
|
||||||
|
Result := Scale96ToFont(FBookMarkOpt.LeftMargin);
|
||||||
|
end;
|
||||||
|
|
||||||
destructor TSynGutterMarks.Destroy;
|
destructor TSynGutterMarks.Destroy;
|
||||||
begin
|
begin
|
||||||
FreeAndNil(FInternalImage);
|
FreeAndNil(FInternalImage);
|
||||||
@ -134,7 +140,7 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
j: Integer;
|
j, lm: Integer;
|
||||||
MLine: TSynEditMarkLine;
|
MLine: TSynEditMarkLine;
|
||||||
MarkRect: TRect;
|
MarkRect: TRect;
|
||||||
LastMarkIsBookmark: Boolean;
|
LastMarkIsBookmark: Boolean;
|
||||||
@ -157,9 +163,10 @@ begin
|
|||||||
|
|
||||||
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
|
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
|
||||||
//Gutter.Paint always supplies AClip.Left = GutterPart.Left
|
//Gutter.Paint always supplies AClip.Left = GutterPart.Left
|
||||||
MarkRect := Rect(AClip.Left + FBookMarkOpt.LeftMargin,
|
lm := LeftMarginAtCurrentPPI;
|
||||||
|
MarkRect := Rect(AClip.Left + lm,
|
||||||
AClip.Top,
|
AClip.Top,
|
||||||
AClip.Left + FBookMarkOpt.LeftMargin + FColumnWidth,
|
AClip.Left + lm + FColumnWidth,
|
||||||
AClip.Top + LineHeight);
|
AClip.Top + LineHeight);
|
||||||
|
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ type
|
|||||||
protected
|
protected
|
||||||
procedure CheckTextBuffer; // Todo: Add a notification, when TextBuffer Changes
|
procedure CheckTextBuffer; // Todo: Add a notification, when TextBuffer Changes
|
||||||
Procedure PaintLine(aScreenLine: Integer; Canvas : TCanvas; AClip : TRect); override;
|
Procedure PaintLine(aScreenLine: Integer; Canvas : TCanvas; AClip : TRect); override;
|
||||||
function PreferedWidth: Integer; override;
|
function PreferedWidthAtCurrentPPI: Integer; override;
|
||||||
|
|
||||||
function GetImgListRes(const ACanvas: TCanvas;
|
function GetImgListRes(const ACanvas: TCanvas;
|
||||||
const AImages: TCustomImageList): TScaledImageListResolution; override;
|
const AImages: TCustomImageList): TScaledImageListResolution; override;
|
||||||
@ -2269,7 +2269,7 @@ var
|
|||||||
iTop := (LineHeight - img.Height) div 2;
|
iTop := (LineHeight - img.Height) div 2;
|
||||||
|
|
||||||
img.Draw
|
img.Draw
|
||||||
(Canvas, AClip.Left + FBookMarkOpt.LeftMargin + aGutterOffs * ColumnWidth,
|
(Canvas, AClip.Left + LeftMarginAtCurrentPPI + aGutterOffs * ColumnWidth,
|
||||||
AClip.Top + iTop, DebugMarksImageIndex, True);
|
AClip.Top + iTop, DebugMarksImageIndex, True);
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@ -2287,7 +2287,7 @@ begin
|
|||||||
DrawDebugMark(aScreenLine);
|
DrawDebugMark(aScreenLine);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TIDESynGutterMarks.PreferedWidth: Integer;
|
function TIDESynGutterMarks.PreferedWidthAtCurrentPPI: Integer;
|
||||||
var
|
var
|
||||||
img: TScaledImageListResolution;
|
img: TScaledImageListResolution;
|
||||||
begin
|
begin
|
||||||
@ -2295,9 +2295,9 @@ begin
|
|||||||
begin
|
begin
|
||||||
img := GetImgListRes(nil, SourceEditorMarks.ImgList);
|
img := GetImgListRes(nil, SourceEditorMarks.ImgList);
|
||||||
// + 1 => right margin
|
// + 1 => right margin
|
||||||
Result := SynEdit.ScaleFontTo96(img.Width) * 2 + FBookMarkOpt.LeftMargin + 1; // PreferedWidth needs width at 96 PPI
|
Result := img.Width * 2 + LeftMarginAtCurrentPPI + Scale96ToFont(1);
|
||||||
end else
|
end else
|
||||||
Result := inherited PreferedWidth;
|
Result := inherited PreferedWidthAtCurrentPPI;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TIDESynGutterMarks.Destroy;
|
destructor TIDESynGutterMarks.Destroy;
|
||||||
|
Loading…
Reference in New Issue
Block a user