pop-os / cosmic-text

Pure Rust multi-line text handling
https://pop-os.github.io/cosmic-text/cosmic_text/
Apache License 2.0
1.61k stars 105 forks source link

Change `opt_color` of a `BufferLine` without triggering a reshape / relayout #69

Open hecrj opened 1 year ago

hecrj commented 1 year ago

The main use case here is being able to reuse a Buffer both for layout and drawing. iced does not know the color of the text during layout.

Color doesn't really affect anything but drawing, right? It seems it'd make more sense to provide a list of color spans as an argument to draw? Or maybe we could change BufferLine::set_attrs_list to not trigger a reset if only the colors differ?

https://github.com/pop-os/cosmic-text/blob/f92a2058cf88274616a9dfd0fc578d13c4b3a962/src/buffer_line.rs#L69-L72

genusistimelord commented 1 year ago

I would say we shouldn't need to rerun the layout if the colors change since this doesn't affect the layout itself. The only parts in Attr that affect the layout would be those that would be family, stretch, style and weight. Meta And Color should just be Update-able somehow.