Add layout_opt and shape_opt getters to TextBufferLine
This commit is contained in:
parent
46a922194c
commit
88bd1c9235
2 changed files with 26 additions and 11 deletions
|
|
@ -6,8 +6,8 @@ pub struct TextBufferLine<'a> {
|
|||
text: String,
|
||||
attrs_list: AttrsList<'a>,
|
||||
wrap_simple: bool,
|
||||
pub(crate) shape_opt: Option<ShapeLine>,
|
||||
pub(crate) layout_opt: Option<Vec<LayoutLine>>,
|
||||
shape_opt: Option<ShapeLine>,
|
||||
layout_opt: Option<Vec<LayoutLine>>,
|
||||
}
|
||||
|
||||
impl<'a> TextBufferLine<'a> {
|
||||
|
|
@ -121,6 +121,11 @@ impl<'a> TextBufferLine<'a> {
|
|||
self.layout_opt = None;
|
||||
}
|
||||
|
||||
/// Reset only layout information
|
||||
pub fn reset_layout(&mut self) {
|
||||
self.layout_opt = None;
|
||||
}
|
||||
|
||||
/// Check if shaping and layout information is cleared
|
||||
pub fn is_reset(&self) -> bool {
|
||||
self.shape_opt.is_none()
|
||||
|
|
@ -135,6 +140,11 @@ impl<'a> TextBufferLine<'a> {
|
|||
self.shape_opt.as_ref().unwrap()
|
||||
}
|
||||
|
||||
/// Get line shaping cache
|
||||
pub fn shape_opt(&self) -> &Option<ShapeLine> {
|
||||
&self.shape_opt
|
||||
}
|
||||
|
||||
/// Layout line, will cache results
|
||||
pub fn layout(&mut self, font_system: &'a FontSystem<'a>, font_size: i32, width: i32) -> &[LayoutLine] {
|
||||
if self.layout_opt.is_none() {
|
||||
|
|
@ -152,4 +162,9 @@ impl<'a> TextBufferLine<'a> {
|
|||
}
|
||||
self.layout_opt.as_ref().unwrap()
|
||||
}
|
||||
|
||||
/// Get line layout cache
|
||||
pub fn layout_opt(&self) -> &Option<Vec<LayoutLine>> {
|
||||
&self.layout_opt
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue