Page MenuHome

UI: 3D Text Caret
ClosedPublic

Authored by Harley Acheson (harley) on Aug 27 2022, 7:04 PM.
Tokens
"100" token, awarded by zhendai."Love" token, awarded by hitrpr."Love" token, awarded by vollstock2."Love" token, awarded by Mujsoye."Like" token, awarded by AlexeyAdamitsky."Love" token, awarded by HEYPictures."Like" token, awarded by Endertainer007."Love" token, awarded by gilberto_rodrigues."Love" token, awarded by HooglyBoogly."Love" token, awarded by lone_noel."Like" token, awarded by ncotrb."Love" token, awarded by pablovazquez."Love" token, awarded by billreynish."Like" token, awarded by marcuspollio."Like" token, awarded by Fracture128."Like" token, awarded by TheRedWaxPolice."Love" token, awarded by hamza.elbarmaki."Love" token, awarded by manitwo.

Details

Summary

Changes to the text caret (cursor) when editing Text objects in the
3D Viewport.


When editing 3D text the caret (cursor) is shown as a grey rectangle. It is too wide to indicate a singular insertion point, is positioned on the baseline, and is too tall. The selection box is even taller. Overlapping portions of letters are darkened, which looks reversed:

This patch changes it so that it is narrower, to better indicate an insertion point. Draws using the same theme colors as regular text inputs. It is less tall and starts below the descenders. Selection boxes are the same size. Overlapping portions of letters are lightened:

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Aug 27 2022, 7:04 PM
Harley Acheson (harley) created this revision.
Harley Acheson (harley) edited the summary of this revision. (Show Details)Aug 27 2022, 8:29 PM
Harley Acheson (harley) planned changes to this revision.Aug 28 2022, 12:08 AM

Had to adjust the selection box size too.

Hi Harley,

Thanks for working on this, it looks cool !
Do you think it possible to adapt the height of the caret to the font and the line spacing (in Paragraph > Spacing) ?
Currently it looks so (line spacing ≠ 1.0) :

Harley Acheson (harley) planned changes to this revision.Aug 28 2022, 5:12 PM

I see problems with line height versus line spacing.

@marcuspollio (marcuspollio) - Do you think it possible to adapt the height of the caret to the font and the line spacing (in Paragraph > Spacing) ?

I think it is doing this correctly now.

Brecht Van Lommel (brecht) requested changes to this revision.Aug 29 2022, 4:17 PM

The height still seems off with the default text for me:

The color is brighter than how it shows in the rest of the UI and preferences. I guess there is some difference in color management or blending? Would be good to get it matching.

This revision now requires changes to proceed.Aug 29 2022, 4:17 PM

@Brecht Van Lommel (brecht) - The height still seems off with the default text for me...

It now seems to be a nice size. Following with default text on top, and some oddballs below:

The color is brighter than how it shows in the rest of the UI and preferences. I guess there is some difference in color management or blending? Would be good to get it matching.

I have had no luck tracking that down. Although, to be fair, there is a lot in this area (engine overlays) that mystify me.

There seems to be a missing colorspace conversion, but also the text cursor color is not actually the same theme color as the text selection color in buttons.

Here's a quick hack to get it to match the selection: P3165

But a full solution probably involves a new theme color, and changes to draw the cursor and selection in different colors?

@Brecht Van Lommel (brecht)) - There seems to be a missing colorspace conversion...

Ah... that makes sense. I wouldn't have guessed it just needed that one function call.

Here's a quick hack to get it to match the selection

Yes, that color is much nicer if we are just going to use one color for both cursor and selection.

But a full solution probably involves a new theme color, and changes to draw the cursor and selection in different colors?

We could probably do without a new theme color, but I think we'd require someone smarter than me to get another overlay pass in for that. We probably have other volunteers that could easily do so, but not sure who off the top of my head.

Harley Acheson (harley) edited the summary of this revision. (Show Details)Sep 1 2022, 12:40 AM

Maybe @Yash Dabhade (yashdabhade) ?
Would be cool to have these different changes from Summer of Code and yours @Harley Acheson (harley) working well together !

By the way, just tested your latest changes, it is really nice !
Just missing is a way to know where is the caret when you do a text selection, for instance in LibreOffice Writer:

@marcuspollio (marcuspollio) - Just missing is a way to know where is the caret when you do a text selection...

Yes, that is exactly the issue, because both are currently drawn together with the same color.

Right now we can differentiate between caret and selection there because it currently uses a light color with opacity of 0.5. Therefore the overlap between the two results in something brighter. If we instead use UI theme colors the opacity value is 1.0 and we don't get that effect.

But I'm not very familiar with the code in engine overlays so it is not clear to me how to do this properly. And I'd prefer that little things like this be done by volunteer devs.

Harley Acheson (harley) edited the summary of this revision. (Show Details)

Now using separate colors for selection and caret. Using the same theme colors as regular text inputs.

Consistent use of "cursor", instead of adding "caret". Improved comments.

Brecht Van Lommel (brecht) requested changes to this revision.Sep 2 2022, 5:23 PM

Looks good, just one more comment.

source/blender/draw/engines/overlay/overlay_edit_text.c
211

If we are going to use the text button selection color, we should also be using its selected text color to ensure it's visible on top of the selection in all themes.

This revision now requires changes to proceed.Sep 2 2022, 5:23 PM

@Brecht Van Lommel (brecht) - If we are going to use the text button selection color, we should also be using its selected text color to ensure it's visible on top of the selection in all themes.

Done.

Harley Acheson (harley) marked an inline comment as done.Sep 2 2022, 6:47 PM
This revision is now accepted and ready to land.Sep 2 2022, 8:56 PM
This revision was automatically updated to reflect the committed changes.

Thank you @Harley Acheson (harley) for your work on this, such an amazing improvement!

Kind regards.