Skip to content

Improve the message overlay in the 3D editor#105497

Open
Calinou wants to merge 1 commit intogodotengine:masterfrom
Calinou:3d-editor-improve-message-overlay
Open

Improve the message overlay in the 3D editor#105497
Calinou wants to merge 1 commit intogodotengine:masterfrom
Calinou:3d-editor-improve-message-overlay

Conversation

@Calinou
Copy link
Member

@Calinou Calinou commented Apr 17, 2025

This makes the overall experience closer to Blender.

  • Use a fixed-width font1, fixed decimal count and tab characters to ensure displaying rapidly changing numbers doesn't cause reflowing.
  • Add padding for negative numbers to further reduce reflows when a number goes from a negative to a positive value and vice versa.
  • Improve coordinate display to be more readable.
  • Use the m suffix for "meter" like in the inspector, and ° for degrees.
  • Use a font outline to make the text more readable on bright backgrounds.
  • Use sentence case and don't end messages with a period.

These changes can be ported to the 2D editor once we reach an agreement on them.

Preview

3d_editor_message_overlay.mp4

image

image

image

Footnotes

  1. If we used a default editor font with fixed-width numbers, we could keep using a proportional font for letters. Many other places in the editor would benefit from this, including the View Information/View Frame Time panels and the inspector. This exists as an OpenType stylistic alternate in some fonts like Inter, but Noto Sans does not have this alternate.

@passivestar
Copy link
Contributor

I like sentence case and suffixes but I'm not sure about other changes. There's too much padding and too much contrast. Comparison with blender:

111

Paddings make numbers clump with wrong labels ("0.000m" is visually closer to "Z" than to "Y"). It would make sense to leave space for at most one extra character (-), and you'll need extra space after each component to better separate them, like what blender does. There's also no space before the total distance rn

As for contrast #fff and #000 is just too much. Readability is important but on bright background pure black #000 outline has the opposite effect and makes it somewhat harder to read, imo it shouldn't be pure black. Semitransparent maybe

@Calinou
Copy link
Member Author

Calinou commented Apr 29, 2025

@passivestar I've pushed an updated version with improved padding and reduced contrast for the outline. See OP for updated screenshots.

Ideally, I'd use a thin space character () between the number and the m suffix, but I don't think this can be done with a fixed-width font. When I tried it, it was rendered as if there was no space at all.

Edit: It works if using TextServerAdvanced (the default), it just doesn't render if using TextServerFallback. @bruvzg Should we have a fallback to handle thin (possibly non-breaking) spaces?

image

Compare this with no space at all:

image

If you want, I can incorporate this into the PR.

@Calinou Calinou force-pushed the 3d-editor-improve-message-overlay branch from 1cdbebe to aeac773 Compare April 29, 2025 21:12
@Calinou Calinou requested review from a team as code owners April 29, 2025 21:12
Copy link
Member

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random addendum: This PR would further hammer in that 3D uses meters. There's some bits of the class reference I've seen that still assume the unit of measurement is generic (as was the case in 3.x).

@Calinou Calinou force-pushed the 3d-editor-improve-message-overlay branch 2 times, most recently from 2c74699 to 1f7442c Compare April 29, 2025 21:59
@bruvzg
Copy link
Member

bruvzg commented Apr 30, 2025

Should we have a fallback to handle thin (possibly non-breaking) spaces?

NBSP should be already supported (in terms of line breaking). Fallback server simply pulls glyph advances from the font. I guess we can add an hardcoded x * normal_space overrides for the special spaces.

@bruvzg
Copy link
Member

bruvzg commented May 15, 2025

I guess we can add an hardcoded x * normal_space overrides for the special spaces.

diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp
index 5828991321..f72b154597 100644
--- a/modules/text_server_fb/text_server_fb.cpp
+++ b/modules/text_server_fb/text_server_fb.cpp
@@ -4754,7 +4754,8 @@ bool TextServerFallback::_shaped_text_shape(const RID &p_shaped) {
 				gl.end = j + 1;
 				gl.count = 1;
 				gl.font_size = span.font_size;
-				gl.index = (int32_t)sd->text[j - sd->start]; // Use codepoint.
+				int32_t codepoint = (int32_t)sd->text[j - sd->start];
+				gl.index = codepoint; // Use codepoint.
 				if (gl.index == 0x0009 || gl.index == 0x000b) {
 					gl.index = 0x0020;
 				}
@@ -4786,9 +4787,25 @@ bool TextServerFallback::_shaped_text_shape(const RID &p_shaped) {
 				if (gl.font_rid.is_valid()) {
 					double scale = _font_get_scale(gl.font_rid, gl.font_size);
 					bool subpos = (scale != 1.0) || (_font_get_subpixel_positioning(gl.font_rid) == SUBPIXEL_POSITIONING_ONE_HALF) || (_font_get_subpixel_positioning(gl.font_rid) == SUBPIXEL_POSITIONING_ONE_QUARTER) || (_font_get_subpixel_positioning(gl.font_rid) == SUBPIXEL_POSITIONING_AUTO && gl.font_size <= SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE);
-					if (sd->text[j - sd->start] != 0 && !is_linebreak(sd->text[j - sd->start])) {
+					if (codepoint != 0 && !is_linebreak(codepoint)) {
 						if (sd->orientation == ORIENTATION_HORIZONTAL) {
-							gl.advance = _font_get_glyph_advance(gl.font_rid, gl.font_size, gl.index).x;
+							if (codepoint == 0x2000 || codepoint == 0x2002) {
+								gl.advance = gl.font_size * 0.5;
+							} else if (codepoint == 0x2001 || codepoint == 0x2003) {
+								gl.advance = gl.font_size;
+							} else if (codepoint == 0x2004) {
+								gl.advance = gl.font_size * 0.33333333333;
+							} else if (codepoint == 0x2005) {
+								gl.advance = gl.font_size * 0.25;
+							} else if (codepoint == 0x2006) {
+								gl.advance = gl.font_size * 0.16666666666;
+							} else if (codepoint == 0x2009 || codepoint == 0x202f) {
+								gl.advance = gl.font_size * 0.2;
+							} else if (codepoint == 0x200a) {
+								gl.advance = gl.font_size * 0.125;
+							} else {
+								gl.advance = _font_get_glyph_advance(gl.font_rid, gl.font_size, gl.index).x;
+							}
 							gl.x_off = 0;
 							gl.y_off = _font_get_baseline_offset(gl.font_rid) * (double)(_font_get_ascent(gl.font_rid, gl.font_size) + _font_get_descent(gl.font_rid, gl.font_size));
 							sd->ascent = MAX(sd->ascent, _font_get_ascent(gl.font_rid, gl.font_size) + _font_get_spacing(gl.font_rid, SPACING_TOP));
@@ -4803,7 +4820,7 @@ bool TextServerFallback::_shaped_text_shape(const RID &p_shaped) {
 					}
 					if (j < sd->end - 1) {
 						// Do not add extra spacing to the last glyph of the string.
-						if (is_whitespace(sd->text[j - sd->start])) {
+						if (is_whitespace(codepoint)) {
 							gl.advance += sd->extra_spacing[SPACING_SPACE] + _font_get_spacing(gl.font_rid, SPACING_SPACE);
 						} else {
 							gl.advance += sd->extra_spacing[SPACING_GLYPH] + _font_get_spacing(gl.font_rid, SPACING_GLYPH);

Something like this seems to give results (right) similar to TextServerAdvanced (left), but not sure if extra handling should be added to fallback text server, it intended to me minimal.
Screenshot 2025-05-15 at 10 40 48

This makes the overall experience closer to Blender.

- Use a fixed-width font, fixed decimal count and tab characters
  to ensure displaying rapidly changing numbers doesn't cause reflowing.
- Add padding for negative numbers to further reduce reflows when a
  number goes from a negative to a positive value and vice versa.
- Improve coordinate display to be more readable.
- Use the `m` suffix for "meter" like in the inspector, and `°` for degrees.
- Use a font outline to make the text more readable on bright backgrounds.
- Use sentence case and don't end messages with a period.
@Calinou Calinou force-pushed the 3d-editor-improve-message-overlay branch from 1f7442c to 66f45b8 Compare May 15, 2025 21:35
@Calinou Calinou requested a review from a team as a code owner May 15, 2025 21:35
@Repiteo Repiteo requested a review from a team as a code owner February 17, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments