Skip to content

EditableText::visible_width#23717

Merged
alice-i-cecile merged 7 commits intobevyengine:mainfrom
ickshonpe:editable-text-visible-width
Apr 15, 2026
Merged

EditableText::visible_width#23717
alice-i-cecile merged 7 commits intobevyengine:mainfrom
ickshonpe:editable-text-visible-width

Conversation

@ickshonpe
Copy link
Copy Markdown
Contributor

@ickshonpe ickshonpe commented Apr 8, 2026

Objective

Horizontal equivalent of the visible_lines option.

Allow users to set the width of a text input widget by number of glyphs. Or for proportional fonts, where the glyph widths are non-uniform, it would use a multiple of the advance width for "0".

Solution

  • New visible_width: Option<f32> field on EditableText.
  • TextInputMeasure now has both a width and height field and both are Option<f32>.
  • update_editable_text_content_size calculates the width if visible_width is Some.
  • The width is calculated by multiplying the advance width of "0" by the visible_width (if set) and the current scale factor.

Testing

I altered the hex input in the feathers example to so it's sized to fit 10 characters (includes space for the cursor).

cargo run --example feathers --features="experimental_bevy_feathers"

@ickshonpe ickshonpe added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets A-Text Rendering and layout for characters D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Apr 9, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in UI Apr 9, 2026
@ickshonpe ickshonpe added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Apr 9, 2026
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

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

You have to resolve some merge conflicts with main into this since the feathers example has since been renamed to feathers_gallery

text_font.weight.into(),
));

let mut width = None;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: i’d find this easier to read if this was renamed to advance_width so that it mirrors what the function comment says above: "- node width as advance('0') * visible_width"

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 15, 2026
@alice-i-cecile
Copy link
Copy Markdown
Member

Fixed the merge conflicts for you :) The new feathers_gallery example is compiling and runs fine.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 15, 2026
Merged via the queue into bevyengine:main with commit 250a7c0 Apr 15, 2026
38 checks passed
@github-project-automation github-project-automation bot moved this from Needs SME Triage to Done in UI Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Text Rendering and layout for characters A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants