Clip text to viewport bounds instead of layout bounds
This commit is contained in:
parent
99899d49cc
commit
936d480267
23 changed files with 177 additions and 115 deletions
|
|
@ -14,24 +14,26 @@ use std::sync::Arc;
|
|||
pub enum Primitive<T> {
|
||||
/// A text primitive
|
||||
Text {
|
||||
/// The contents of the text
|
||||
/// The contents of the text.
|
||||
content: String,
|
||||
/// The bounds of the text
|
||||
/// The bounds of the text.
|
||||
bounds: Rectangle,
|
||||
/// The color of the text
|
||||
/// The color of the text.
|
||||
color: Color,
|
||||
/// The size of the text in logical pixels
|
||||
/// The size of the text in logical pixels.
|
||||
size: Pixels,
|
||||
/// The line height of the text
|
||||
/// The line height of the text.
|
||||
line_height: text::LineHeight,
|
||||
/// The font of the text
|
||||
/// The font of the text.
|
||||
font: Font,
|
||||
/// The horizontal alignment of the text
|
||||
/// The horizontal alignment of the text.
|
||||
horizontal_alignment: alignment::Horizontal,
|
||||
/// The vertical alignment of the text
|
||||
/// The vertical alignment of the text.
|
||||
vertical_alignment: alignment::Vertical,
|
||||
/// The shaping strategy of the text.
|
||||
shaping: text::Shaping,
|
||||
/// The viewport of the text.
|
||||
viewport: Rectangle,
|
||||
},
|
||||
/// A paragraph primitive
|
||||
Paragraph {
|
||||
|
|
@ -41,15 +43,19 @@ pub enum Primitive<T> {
|
|||
position: Point,
|
||||
/// The color of the paragraph.
|
||||
color: Color,
|
||||
/// The viewport of the paragraph.
|
||||
viewport: Rectangle,
|
||||
},
|
||||
/// An editor primitive
|
||||
Editor {
|
||||
/// The [`editor::Weak`] reference.
|
||||
editor: editor::Weak,
|
||||
/// The position of the paragraph.
|
||||
/// The position of the editor.
|
||||
position: Point,
|
||||
/// The color of the paragraph.
|
||||
/// The color of the editor.
|
||||
color: Color,
|
||||
/// The viewport of the editor.
|
||||
viewport: Rectangle,
|
||||
},
|
||||
/// A quad primitive
|
||||
Quad {
|
||||
|
|
|
|||
|
|
@ -164,11 +164,13 @@ where
|
|||
paragraph: &Self::Paragraph,
|
||||
position: Point,
|
||||
color: Color,
|
||||
viewport: Rectangle,
|
||||
) {
|
||||
self.primitives.push(Primitive::Paragraph {
|
||||
paragraph: paragraph.downgrade(),
|
||||
position,
|
||||
color,
|
||||
viewport,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -177,11 +179,13 @@ where
|
|||
editor: &Self::Editor,
|
||||
position: Point,
|
||||
color: Color,
|
||||
viewport: Rectangle,
|
||||
) {
|
||||
self.primitives.push(Primitive::Editor {
|
||||
editor: editor.downgrade(),
|
||||
position,
|
||||
color,
|
||||
viewport,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -190,6 +194,7 @@ where
|
|||
text: Text<'_, Self::Font>,
|
||||
position: Point,
|
||||
color: Color,
|
||||
viewport: Rectangle,
|
||||
) {
|
||||
self.primitives.push(Primitive::Text {
|
||||
content: text.content.to_string(),
|
||||
|
|
@ -201,6 +206,7 @@ where
|
|||
horizontal_alignment: text.horizontal_alignment,
|
||||
vertical_alignment: text.vertical_alignment,
|
||||
shaping: text.shaping,
|
||||
viewport,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue