Skip to content

Commit

Permalink
Add high DPI support to the squiggly indicator.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Jun 15, 2024
1 parent 2bebe74 commit 07fc321
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 7 additions & 5 deletions Projects/Src/CompForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -884,7 +884,7 @@ constructor TCompileForm.Create(AOwner: TComponent);
FActiveMemo.Visible := True;
FErrorMemo := FMainMemo;
FStepMemo := FMainMemo;
UpdateMarginsWidths;
UpdateMarginsAndSquigglyWidths;

FMemosStyler.Theme := FTheme;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -3503,17 +3503,19 @@ 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. }
begin
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;
Expand Down
14 changes: 8 additions & 6 deletions Projects/Src/CompScintEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -149,8 +150,6 @@ procedure TCompScintEdit.CreateWnd;
-3.6.6: Investigate SCFIND_CXX11REGEX: C++ 11 <regex> 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
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down

0 comments on commit 07fc321

Please sign in to comment.