Menu

#1361 scale caret width for current DPI

Committed
closed
win32 (35)
5
2020-07-22
2020-06-08
Zufu Liu
No

Related to [bugs:#2063] caret is thin after window DPI increased, though application can handle this in WM_DPICHANGED, it maybe better to auto scale the width within Scintilla.

Here is my though by adding a new field effectiveCaretWidth.

// ScintillaWin
vs.effectiveCaretWidth = ::MulDiv(vs.caretWidth, dpi, USER_DEFAULT_SCREEN_DPI);

// ScintillaWin::CreateSystemCaret()
sysCaretWidth = vs.effectiveCaretWidth;

// EditView::DrawCarets()
rcCaret.right = rcCaret.left + vsDraw.effectiveCaretWidth;

// other code to sync vs.caretWidth and vs.effectiveCaretWidth.

Related

Bugs: #2063

Discussion

  • Zufu Liu

    Zufu Liu - 2020-06-08
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -3,7 +3,7 @@
     Here is my though by adding a new field effectiveCaretWidth.
     ```cpp
     // ScintillaWin
    -vs.effectiveCaretWidth = ::MulDiv(vs.caretWidth, dpi, uSystemDPI);
    +vs.effectiveCaretWidth = ::MulDiv(vs.caretWidth, dpi, USER_DEFAULT_SCREEN_DPI);
    
     // ScintillaWin::CreateSystemCaret()
     sysCaretWidth = vs.effectiveCaretWidth;
    
     
  • Neil Hodgson

    Neil Hodgson - 2020-06-08

    Since the caret is commonly a single pixel wide, scaling up to 2 pixels is a huge jump. Scaling the caret width automatically stops users and applications being able to choose whether to scale the caret and the points at which scaling occurs. The change magnifies the caret at 150% scaling which is not the point that I, and I suspect many others, would make the change. There is no way to specify a single pixel wide caret.

     
  • Zufu Liu

    Zufu Liu - 2020-06-09

    I also found this will complicate both application and Scintilla, especially when application set caret width to 2 or 3.

    How about increase the caret width limitation for SCI_SETCARETWIDTH, Windows accessibility allows 20 pixels caret width.
    If application scaling caret width them self, it will behaviors as expected.

     

    Last edit: Zufu Liu 2020-06-09
    • Neil Hodgson

      Neil Hodgson - 2020-06-09

      Windows accessibility allows 20 pixels caret width.

      Is that for an actual caret or is that for something more like a rectangular cursor? Where is this documented?

       
  • Neil Hodgson

    Neil Hodgson - 2020-06-11

    Since the caret is symmetric, making it wider makes it go more negative when at the start of the line. There may have been a problem here in the past, possibly with some buggy clipping.

    The current maximum can be increased but there could be bugs.

     
    • Zufu Liu

      Zufu Liu - 2020-06-13

      I find one bug: text under wider caret is not draw with inverted color.

       
      • Neil Hodgson

        Neil Hodgson - 2020-06-13

        Carets do not invert text in Scintilla.

         
  • Zufu Liu

    Zufu Liu - 2020-06-13

    screenshot is 10 px caret in Windows Notepad with purple text cursor indicator, 'W' is draw as two parts.

    patch is use ReleaseUnknown() in Platform_Finalise().

     
    • Neil Hodgson

      Neil Hodgson - 2020-06-15

      screenshot is 10 px caret in Windows Notepad with purple text cursor indicator, 'W' is draw as two parts.

      Horribly ugly.

      patch is use ReleaseUnknown() in Platform_Finalise().

      Committed with [986abc] .

       

      Related

      Commit: [986abc]

  • Zufu Liu

    Zufu Liu - 2020-06-16

    I don't find other bugs after increasing the upper limit for caret width to 20 (no change to caret drawing code, i.e. still treat as line caret like Visual Studio 2017/2019, however Visual Studio 2017/1029 supports text cursor indicator. I don't find the document on how to implement this, maybe some UI Automation control patterns need be implemented).

     
  • Neil Hodgson

    Neil Hodgson - 2020-06-17

    Committed [9f3c5a] to allow 20 pixel wide carets.

     

    Related

    Commit: [9f3c5a]

  • Neil Hodgson

    Neil Hodgson - 2020-07-22
    • status: open --> closed
     
  • Neil Hodgson

    Neil Hodgson - 2020-07-22
    • Group: Initial --> Committed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.