tessera_ui_basic_components/pipelines/text/
command.rs

1use tessera_ui::DrawCommand;
2
3use super::TextData;
4
5#[derive(Debug, Clone, PartialEq)]
6pub struct TextCommand {
7    pub data: TextData,
8}
9
10impl DrawCommand for TextCommand {
11    fn barrier(&self) -> Option<tessera_ui::BarrierRequirement> {
12        // No specific barrier requirements for text commands
13        None
14    }
15}
16
17/// Describes size constraints for a text draw
18#[derive(Debug, PartialEq, Clone)]
19pub struct TextConstraint {
20    /// Maximum width of the text
21    /// If None, it will be calculated by the text renderer
22    pub max_width: Option<f32>,
23    /// Maximum height of the text
24    /// If None, it will be calculated by the text renderer
25    pub max_height: Option<f32>,
26}
27
28impl std::hash::Hash for TextConstraint {
29    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
30        if let Some(w) = self.max_width {
31            w.to_bits().hash(state);
32        } else {
33            0u32.hash(state); // Hash a constant for None
34        }
35        if let Some(h) = self.max_height {
36            h.to_bits().hash(state);
37        } else {
38            0u32.hash(state); // Hash a constant for None
39        }
40    }
41}
42
43impl TextConstraint {
44    /// Creates a new `TextConstraint` with no limits.
45    pub const NONE: Self = Self {
46        max_width: None,
47        max_height: None,
48    };
49}