View Issue Details

IDProjectCategoryView StatusLast Update
0037857LazarusIDEpublic2021-03-11 22:17
ReporterSven Barth Assigned ToMartin Friebe  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformX86_64OSWindows NT 
Product Version2.1 (SVN) 
Fixed in Version2.2 
Summary0037857: HighDPI: Small bookmark bullet in editor preview
DescriptionWhen using Lazarus on a High DPI system (Windows 10 200%) the bookmark bullet points in the gutter of the editor preview inside the settings are not scaled up. The same bullet points in the normal source editor have the correct size.
TagsNo tags attached.
Fixed in Revision64778
LazTarget2.2
Widgetset
Attached Files

Relationships

related to 0037975 closedwp Lazarus HighDPI: Dots for changed register values not scaled correctly 
related to 0038064 resolvedwp Lazarus CCR HighDPI: spktoolbar, in scaled screen 

Activities

Sven Barth

2020-10-02 22:16

manager  

Juha Manninen

2021-03-10 10:06

developer   ~0129540

I found the place in code where the imagelist for bookmark icons is created :
 function TEditorGeneralOptionsFrame.DefaultBookmarkImages: TImageList;
It is called from AddPreviewEdit which is also used for TEditorDisplayOptionsFrame.

Q: Can it be replaced with an ImageList type that supports scaling directly, or does it require custom drawing?

wp

2021-03-10 15:24

developer   ~0129548

Last edited: 2021-03-10 15:29

View 2 revisions

What is missing is setting DefaultBookmarkImages.Scaled to true - this activates rescaling of the images whenever resolution changes. However, this alone upscales the 11x11 default image which will become pixelated. You must also register the other image sizes by calling DefaultBookmarkImages.RegisterResolutions([11, 16, 22, 33]) - the numbers are the pixel sizes of the image sizes found in the images/sourceeditor folder for the bookmark* images. I don't how the ImageList can be convinced to load the four sizes of each image from the resources. But we can load only the largest image (33x33 pixels --> 300%) and let the ImageList do the downward stretchdraw itself which results in stunning quality.

function TEditorGeneralOptionsFrame.DefaultBookmarkImages: TImageList;
var
  i: integer;
begin
  if FDefaultBookmarkImages = nil then
  begin
    FDefaultBookmarkImages := TImageList.Create(Self);
    FDefaultBookmarkImages.Width := 11;
    FDefaultBookmarkImages.Height := 11;
    FDefaultBookmarkImages.RegisterResolutions([11, 16, 22, 33]); // <---- added
    FDefaultBookmarkImages.Scaled := true; // <--- added
    for i in TBookmarkNumRange do
      FDefaultBookmarkImages.AddResourceName(HInstance, 'bookmark' + IntToStr(i) + '_300'); // <--- '_300' added
  end;
  Result := FDefaultBookmarkImages;
end;

Martin Friebe

2021-03-10 17:32

manager   ~0129550

Can someone test the attached patch, please?
edit_opt_scale.diff (2,152 bytes)   
diff --git a/ide/frames/editor_general_options.pas b/ide/frames/editor_general_options.pas
index bda7759a75..5dd44146a7 100644
--- a/ide/frames/editor_general_options.pas
+++ b/ide/frames/editor_general_options.pas
@@ -27,7 +27,7 @@
 uses
   Classes, SysUtils, math,
   // LCL
-  LCLProc, LCLType, StdCtrls, Controls, Graphics,
+  LCLProc, LCLType, StdCtrls, Controls, Graphics, ImgList,
   // LazControls
   DividerBevel,
   // SynEdit
@@ -35,7 +35,7 @@
   // IdeIntf
   IDEOptionsIntf, IDEOptEditorIntf, IDEUtils, SrcEditorIntf,
   // IDE
-  EditorOptions, LazarusIDEStrConsts;
+  EditorOptions, LazarusIDEStrConsts, SourceMarks;
 
 type
   TPreviewEditor = TSynEdit;
@@ -90,11 +90,10 @@   TEditorGeneralOptionsFrame = class(TAbstractIDEOptionsEditor)
     procedure ScrollPastEndFileCheckBoxChange(Sender: TObject);
     procedure ScrollPastEndLineCheckBoxChange(Sender: TObject);
   private
-    FDefaultBookmarkImages: TImageList;
     FDialog: TAbstractOptionsEditorDialog;
     FPasExtendedKeywordsMode: Boolean;
     FPasStringKeywordMode: TSynPasStringMode;
-    function DefaultBookmarkImages: TImageList;
+    function DefaultBookmarkImages: TCustomImageList;
     procedure SetExtendedKeywordsMode(const AValue: Boolean);
     procedure SetStringKeywordMode(const AValue: TSynPasStringMode);
   protected
@@ -423,19 +422,9 @@ procedure TEditorGeneralOptionsFrame.ScrollPastEndLineCheckBoxChange(
   SetPreviewOption(ScrollPastEndLineCheckBox.Checked, eoScrollPastEoL);
 end;
 
-function TEditorGeneralOptionsFrame.DefaultBookmarkImages: TImageList;
-var
-  i: integer;
+function TEditorGeneralOptionsFrame.DefaultBookmarkImages: TCustomImageList;
 begin
-  if FDefaultBookmarkImages = nil then
-  begin
-    FDefaultBookmarkImages := TImageList.Create(Self);
-    FDefaultBookmarkImages.Width := 11;
-    FDefaultBookmarkImages.Height := 11;
-    for i in TBookmarkNumRange do
-      FDefaultBookmarkImages.AddResourceName(HInstance, 'bookmark' + IntToStr(i));
-  end;
-  Result := FDefaultBookmarkImages;
+  Result := SourceEditorMarks.ImgList;
 end;
 
 procedure TEditorGeneralOptionsFrame.SetExtendedKeywordsMode(const AValue: Boolean);
edit_opt_scale.diff (2,152 bytes)   

wp

2021-03-10 18:38

developer   ~0129553

Perfect (Win 7 @144 ppi)

Martin Friebe

2021-03-10 19:36

manager   ~0129557

Please close if ok

Sven Barth

2021-03-11 22:17

manager   ~0129582

Looks good. :)

Issue History

Date Modified Username Field Change
2020-10-02 22:16 Sven Barth New Issue
2020-10-02 22:16 Sven Barth File Added: lazarus-highdpi-font-preview.png
2021-02-28 22:13 Juha Manninen Relationship added related to 0037975
2021-03-08 08:32 Juha Manninen Relationship added related to 0038064
2021-03-10 10:06 Juha Manninen Note Added: 0129540
2021-03-10 15:24 wp Note Added: 0129548
2021-03-10 15:29 wp Note Edited: 0129548 View Revisions
2021-03-10 17:29 Martin Friebe Assigned To => Martin Friebe
2021-03-10 17:29 Martin Friebe Status new => assigned
2021-03-10 17:32 Martin Friebe Note Added: 0129550
2021-03-10 17:32 Martin Friebe File Added: edit_opt_scale.diff
2021-03-10 17:33 Martin Friebe Status assigned => feedback
2021-03-10 17:33 Martin Friebe LazTarget => -
2021-03-10 18:38 wp Note Added: 0129553
2021-03-10 19:36 Martin Friebe Status feedback => resolved
2021-03-10 19:36 Martin Friebe Resolution open => fixed
2021-03-10 19:36 Martin Friebe Fixed in Version => 2.2
2021-03-10 19:36 Martin Friebe Fixed in Revision => 64778
2021-03-10 19:36 Martin Friebe LazTarget - => 2.2
2021-03-10 19:36 Martin Friebe Widgetset Win32/Win64 =>
2021-03-10 19:36 Martin Friebe Note Added: 0129557
2021-03-11 22:17 Sven Barth Status resolved => closed
2021-03-11 22:17 Sven Barth Note Added: 0129582