From 07fc321c0d36254dae85532271284401e5c2092e Mon Sep 17 00:00:00 2001 From: Martijn Laan <1092369+martijnlaan@users.noreply.github.com> Date: Sat, 15 Jun 2024 17:01:36 +0200 Subject: [PATCH] Add high DPI support to the squiggly indicator. --- Projects/Src/CompForm.pas | 12 +++++++----- Projects/Src/CompScintEdit.pas | 14 ++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Projects/Src/CompForm.pas b/Projects/Src/CompForm.pas index f41614a4e..c332fe4bb 100644 --- a/Projects/Src/CompForm.pas +++ b/Projects/Src/CompForm.pas @@ -544,7 +544,7 @@ TCompileForm = class(TUIStateForm) procedure UpdatePreprocMemos; procedure UpdateLineMarkers(const AMemo: TCompScintFileEdit; const Line: Integer); procedure UpdateMarginsIcons; - procedure UpdateMarginsWidths; + procedure UpdateMarginsAndSquigglyWidths; procedure UpdateMemosTabSetVisibility; procedure UpdateMenuBitmapsIfNeeded; procedure UpdateModifiedPanel; @@ -884,7 +884,7 @@ constructor TCompileForm.Create(AOwner: TComponent); FActiveMemo.Visible := True; FErrorMemo := FMainMemo; FStepMemo := FMainMemo; - UpdateMarginsWidths; + UpdateMarginsAndSquigglyWidths; FMemosStyler.Theme := FTheme; @@ -1032,7 +1032,7 @@ class procedure TCompileForm.AppOnException(Sender: TObject; E: Exception); procedure TCompileForm.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer); begin - UpdateMarginsWidths; + UpdateMarginsAndSquigglyWidths; UpdateMarginsIcons; UpdateOutputTabSetListsItemHeightAndDebugTimeWidth; UpdateStatusPanelHeight(StatusPanel.Height); @@ -3503,7 +3503,7 @@ procedure TCompileForm.UpdateMarginsIcons; end; end; -procedure TCompileForm.UpdateMarginsWidths; +procedure TCompileForm.UpdateMarginsAndSquigglyWidths; { Update the width of our two margins. Note: the width of the line numbers margin is fully handled by TScintEdit. Should be called at startup and after DPI change. } @@ -3511,9 +3511,11 @@ procedure TCompileForm.UpdateMarginsWidths; var IconMarkersWidth := ToCurrentPPI(18); { 3 pixel margin on both sides of the icon } var BaseChangeHistoryWidth := ToCurrentPPI(6); { 6 = 2 pixel bar with 2 pixel margin on both sides because: "SC_MARK_BAR ... takes ... 1/3 of the margin width" } var LeftBlankMarginWidth := ToCurrentPPI(2); { 2 pixel margin between gutter and the main text } + var SquigglyWidth := ToCurrentPPI(100); { 100 = 1 pixel } for var Memo in FMemos do - Memo.UpdateMarginsWidths(IconMarkersWidth, BaseChangeHistoryWidth, LeftBlankMarginWidth, 0); + Memo.UpdateMarginsAndSquigglyWidths(IconMarkersWidth, BaseChangeHistoryWidth, + LeftBlankMarginWidth, 0, SquigglyWidth); end; procedure TCompileForm.SplitPanelMouseMove(Sender: TObject; diff --git a/Projects/Src/CompScintEdit.pas b/Projects/Src/CompScintEdit.pas index 74b78437b..e40395af9 100644 --- a/Projects/Src/CompScintEdit.pas +++ b/Projects/Src/CompScintEdit.pas @@ -65,8 +65,9 @@ TCompScintEdit = class(TScintEdit) property Used: Boolean read FUsed write FUsed; procedure UpdateIndicators(const Ranges: TScintRangeList; const IndicatorNumber: TCompScintIndicatorNumber); - procedure UpdateMarginsWidths(const IconMarkersWidth, BaseChangeHistoryWidth, - LeftBlankMarginWidth, RightBlankMarginWidth: Integer); + procedure UpdateMarginsAndSquigglyWidths(const IconMarkersWidth, + BaseChangeHistoryWidth, LeftBlankMarginWidth, RightBlankMarginWidth, + SquigglyWidth: Integer); procedure UpdateThemeColorsAndStyleAttributes; end; @@ -149,8 +150,6 @@ procedure TCompScintEdit.CreateWnd; -3.6.6: Investigate SCFIND_CXX11REGEX: C++ 11 support built by default. Can be disabled by defining NO_CXX11_REGEX. Good (?) overview at: https://cplusplus.com/reference/regex/ECMAScript/ - -5.0.1: Review using SCI_INDICSETSTROKEWIDTH for high DPI support on - INDIC_SQUIGGLE. -5.2.3: "Applications should move to SCI_GETTEXTRANGEFULL, SCI_FINDTEXTFULL, and SCI_FORMATRANGEFULL from their predecessors as they will be deprecated." So our use of SCI_GETTEXTRANGE and SCI_FORMATRANGE needs @@ -265,8 +264,9 @@ procedure TCompScintEdit.UpdateIndicators(const Ranges: TScintRangeList; end; end; -procedure TCompScintEdit.UpdateMarginsWidths(const IconMarkersWidth, - BaseChangeHistoryWidth, LeftBlankMarginWidth, RightBlankMarginWidth: Integer); +procedure TCompScintEdit.UpdateMarginsAndSquigglyWidths(const IconMarkersWidth, + BaseChangeHistoryWidth, LeftBlankMarginWidth, RightBlankMarginWidth, + SquigglyWidth: Integer); begin Call(SCI_SETMARGINWIDTHN, 1, IconMarkersWidth); @@ -280,6 +280,8 @@ procedure TCompScintEdit.UpdateMarginsWidths(const IconMarkersWidth, { Note: the first parameter is unused so the value '0' doesn't mean anything below } Call(SCI_SETMARGINLEFT, 0, LeftBlankMarginWidth); Call(SCI_SETMARGINRIGHT, 0, RightBlankMarginWidth); + + Call(SCI_INDICSETSTROKEWIDTH, inSquiggly, SquigglyWidth); end; procedure TCompScintEdit.UpdateThemeColorsAndStyleAttributes;