Add configurable text color to textwrap
This commit is contained in:
parent
70f9ca4405
commit
38674c2580
|
@ -163,11 +163,18 @@ pub struct Layout {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Layout {
|
impl Layout {
|
||||||
pub fn draw(&self, cache: &TextCache, ctx: &DrawContext, scale: f32, line_height: f32) {
|
pub fn draw(
|
||||||
|
&self,
|
||||||
|
cache: &TextCache,
|
||||||
|
ctx: &DrawContext,
|
||||||
|
scale: f32,
|
||||||
|
line_height: f32,
|
||||||
|
color: Color,
|
||||||
|
) {
|
||||||
let mut cursor = Vec2::ZERO;
|
let mut cursor = Vec2::ZERO;
|
||||||
for line in self.lines.iter() {
|
for line in self.lines.iter() {
|
||||||
let ctx = ctx.with_offset(cursor);
|
let ctx = ctx.with_offset(cursor);
|
||||||
line.draw(cache, &ctx, scale);
|
line.draw(cache, &ctx, scale, color);
|
||||||
cursor.y += line_height;
|
cursor.y += line_height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,13 +215,12 @@ impl Line {
|
||||||
Self { fragments }
|
Self { fragments }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(&self, cache: &TextCache, ctx: &DrawContext, scale: f32) {
|
pub fn draw(&self, cache: &TextCache, ctx: &DrawContext, scale: f32, color: Color) {
|
||||||
let mut cursor = Vec2::ZERO;
|
let mut cursor = Vec2::ZERO;
|
||||||
for fragment in self.fragments.iter() {
|
for fragment in self.fragments.iter() {
|
||||||
if !fragment.hidden {
|
if !fragment.hidden {
|
||||||
let text = cache.get(fragment.text);
|
let text = cache.get(fragment.text);
|
||||||
let offset = cursor + fragment.offset;
|
let offset = cursor + fragment.offset;
|
||||||
let color = Color::WHITE;
|
|
||||||
ctx.draw_text_layout(text.layout, offset, scale, color);
|
ctx.draw_text_layout(text.layout, offset, scale, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue