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