godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.63k stars 21.1k forks source link

caret on LineEdit is sometimes invisible when app is scaled, solution of caret size=2 looks ugly as width keeps changing #95026

Open tobydjones opened 2 months ago

tobydjones commented 2 months ago

Tested versions

System information

Godot v4.2.2.stable - Windows 10.0.19045 - GLES3 (Compatibility) - AMD Radeon RX 6600 (Advanced Micro Devices, Inc.; 31.0.24033.1003) - Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 Threads)

Issue description

My project has the following settings: Viewport Width: 1920 Wiewport Height: 1080 Stretch Mode: canvas_items Stretch Aspect: keep Scale: 1

When I run the project, it's scaled to my monitor: 1680x1050 The problem is that in a LineEdit the cursor is sometimes invisible, as the scale is <1

The workaround I found elsewhere (https://github.com/godotengine/godot/issues/58133) was to make the caret width = 2. This does indeed fix the problem, but I find it ugly that the cursor changes width while typing.

godot caret issue

A better solution would be for Godot to always show the cursor as at least 1 pixel wide.

Steps to reproduce

Create a project and set project settings to:

Create a LineEdit Run project and resize screen to be smaller than project Width/Height Type a line of "i" and at some point the cursor will disappear. Change the default theme so the caret width = 2 Run project again, resize screen again, type "i"s and at some point the cursor will become thinner.

Minimal reproduction project (MRP)

N/A

Calinou commented 2 months ago

We should find a way for the caret width to be rounded to the nearest integer after canvas_items scaling occurs, as line drawing needs to use integer widths.

Alternatively, we could allow enabling antialiasing for the caret, but this will make it look blurry at non-integer scale factors, so it may not be a good idea. Carets are generally expected to be as crisp as possible so you can spot them easily.