The fix looks good to me.

  Thanks,
  Alexandr.

On 4/9/2015 11:58 AM, Semyon Sadetsky wrote:
Hi Alexander,

The case you've described means user overrides the default behavior but sets an incorrect value. In my opinion it is ok if the value fallbacks to the default in this scenario. Imagine the situation when user wants to have the same default right margin in all platforms (currently caret.width is set only in Windows) he can achieve that by setting client property to negative value and then the internal default value will be used everywhere. Without that possibility he would need to set the specific value explicitly.

--Semyon

On 4/9/2015 11:44 AM, Alexander Scherbatiy wrote:
On 4/1/2015 5:45 PM, Semyon Sadetsky wrote:
Hi Sergey,

I have added reading of the client property. It will also allow user to adjust the right margin for caret. The test scenario is also extended.

the updated webrev: http://cr.openjdk.java.net/~ssadetsky/6866751/webrev.01/

If c.getClientProperty("caretWidth") is negative should UIManager.get("Caret.width") or DEFAULT_CARET_MARGIN be used?

  Thanks,
  Alexandr.


--Semyon


On 3/24/2015 9:10 AM, Semyon Sadetsky wrote:
Hi Sergey,

On 3/23/2015 5:41 PM, Sergey Bylokhov wrote:
Hi, Semyon.
It seems that "Caret.width" is platform specific property, right? (looks like it is initialized on windows only).
It can be set on any platform. If it is not set we take 1px which is the default cursor width.

What happens if the user will set the size/aspect of the caret via "putClientProperty" after the fix?
It depends on specific Cursor implementation.

It seems that correct width of the caret can be obtained via DefaultCaret.getCaretWidth (It takes into account both properties: aspectRatio/caretWidth). Probably we can push implementation of this method to the Caret class itself(in jdk9) or at least share the code somehow? Note that we can initialize caretWidth for each L&F by default to 1(or to Caret.width) if this value is correct, so the user will be able take current value which is used by Swing.
DefaultCaret.getCaretWidth(height) has package visibility.
DefaultCaret implementation can be retired by API JTextComponet.setCaret(Caret). So what you've proposed is not a complete solution as well. An introduction a new method in the Caret interface is too drastic change. And I'm not sure that font height can be the only parameter for all possible Caret implementations.

1px seems a good solution for the issue because caret width=1px in 99.9% cases. Currently under the System LnF we don't see this 1px caret at all on platforms. That solution will be a great improvment.

For specific situations like custom caret aspect ratio and custom caret shape I'm not sure. If we add the full right text padding for such situations users who already use custom carets may not expect such behavior. It can be too noticeable change when all text components will receive large right padding.

--Semyon


23.03.15 14:57, Semyon Sadetsky wrote:
+description
Cursor size is added to any text control preferred width.

On 3/23/2015 2:33 PM, Semyon Sadetsky wrote:
Hello,

Please review JDK9 fix.

webrev: http://cr.openjdk.java.net/~alexsch/semyon-sadetsky/6866751/webrev.00/
bug: https://bugs.openjdk.java.net/browse/JDK-6866751

Thanks!
--Semyon








Reply via email to