Merge 6026653775
into 33bed5dd70
This commit is contained in:
commit
f820e2ffdc
@ -91,6 +91,12 @@ impl ComputedTextBlock {
|
||||
pub fn buffer(&self) -> &CosmicBuffer {
|
||||
&self.buffer
|
||||
}
|
||||
|
||||
/// Flag the text block for rerendering.
|
||||
/// Automatically unset
|
||||
pub fn set_needs_rerender(&mut self) {
|
||||
self.needs_rerender = true;
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ComputedTextBlock {
|
||||
|
@ -33,15 +33,12 @@ use tracing::error;
|
||||
pub struct TextNodeFlags {
|
||||
/// If set then a new measure function for the text node will be created.
|
||||
needs_measure_fn: bool,
|
||||
/// If set then the text will be recomputed.
|
||||
needs_recompute: bool,
|
||||
}
|
||||
|
||||
impl Default for TextNodeFlags {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
needs_measure_fn: true,
|
||||
needs_recompute: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -245,7 +242,7 @@ fn create_text_measure<'a>(
|
||||
|
||||
// Text measure func created successfully, so set `TextNodeFlags` to schedule a recompute
|
||||
text_flags.needs_measure_fn = false;
|
||||
text_flags.needs_recompute = true;
|
||||
computed.set_needs_rerender();
|
||||
}
|
||||
Err(TextError::NoSuchFont) => {
|
||||
// Try again next frame
|
||||
@ -319,7 +316,7 @@ fn queue_text(
|
||||
inverse_scale_factor: f32,
|
||||
block: &TextLayout,
|
||||
node: Ref<ComputedNode>,
|
||||
mut text_flags: Mut<TextNodeFlags>,
|
||||
text_flags: &TextNodeFlags,
|
||||
text_layout_info: Mut<TextLayoutInfo>,
|
||||
computed: &mut ComputedTextBlock,
|
||||
text_reader: &mut TextUiReader,
|
||||
@ -356,7 +353,7 @@ fn queue_text(
|
||||
) {
|
||||
Err(TextError::NoSuchFont) => {
|
||||
// There was an error processing the text layout, try again next frame
|
||||
text_flags.needs_recompute = true;
|
||||
computed.set_needs_rerender();
|
||||
}
|
||||
Err(e @ (TextError::FailedToAddGlyph(_) | TextError::FailedToGetGlyphImage(_))) => {
|
||||
panic!("Fatal error when processing text: {e}.");
|
||||
@ -364,7 +361,6 @@ fn queue_text(
|
||||
Ok(()) => {
|
||||
text_layout_info.size.x = scale_value(text_layout_info.size.x, inverse_scale_factor);
|
||||
text_layout_info.size.y = scale_value(text_layout_info.size.y, inverse_scale_factor);
|
||||
text_flags.needs_recompute = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -388,7 +384,7 @@ pub fn text_system(
|
||||
Ref<ComputedNode>,
|
||||
&TextLayout,
|
||||
&mut TextLayoutInfo,
|
||||
&mut TextNodeFlags,
|
||||
&TextNodeFlags,
|
||||
&mut ComputedTextBlock,
|
||||
)>,
|
||||
mut text_reader: TextUiReader,
|
||||
@ -396,7 +392,7 @@ pub fn text_system(
|
||||
mut swash_cache: ResMut<SwashCache>,
|
||||
) {
|
||||
for (entity, node, block, text_layout_info, text_flags, mut computed) in &mut text_query {
|
||||
if node.is_changed() || text_flags.needs_recompute {
|
||||
if node.is_changed() || computed.needs_rerender() {
|
||||
queue_text(
|
||||
entity,
|
||||
&fonts,
|
||||
|
Loading…
Reference in New Issue
Block a user