bevy icon indicating copy to clipboard operation
bevy copied to clipboard

make TextLayoutInfo a Component

Open yrns opened this issue 3 years ago • 1 comments

Objective

Make TextLayoutInfo more accessible as a component, rather than internal to TextPipeline. I am working on a plugin that manipulates these and there is no (mutable) access to them right now.

Solution

This changes TextPipeline::queue_text to return TextLayoutInfo's rather than storing them in a map internally. text2d_system and text_system now take the returned TextLayoutInfo and store it as a component of the entity. I considered adding an accessor to TextPipeline (e.g. get_glyphs_mut) but this seems like it might be a little faster, and also has the added benefit of cleaning itself up when entities are removed. Right now nothing is ever removed from the glyphs map.

Changelog

Removed DefaultTextPipeline. TextPipeline no longer has a generic key type. TextPipeline::queue_text returns TextLayoutInfo directly.

Migration Guide

This might break a third-party crate? I could restore the orginal TextPipeline API as a wrapper around what's in this PR.

yrns avatar Apr 11 '22 23:04 yrns

Brought this up-to-date with the main branch. I wish github displayed the diffs in such a way that it was clearer most of the changed lines are just indentation changes due to removing the surrounding if let conditionals.

yrns avatar Aug 02 '22 22:08 yrns

More merge conflicts :( Sorry @yrns; I was on vacation. If you fix those up for us I'll merge it ASAP.

alice-i-cecile avatar Sep 03 '22 17:09 alice-i-cecile

Merged and tested the ui example.

yrns avatar Sep 06 '22 19:09 yrns

Thanks!

bors r+

alice-i-cecile avatar Sep 06 '22 20:09 alice-i-cecile