Rename viewport to clip_bounds
This commit is contained in:
parent
43a7cc2222
commit
b526ce4958
11 changed files with 53 additions and 50 deletions
|
|
@ -64,7 +64,7 @@ impl text::Renderer for Null {
|
||||||
_paragraph: &Self::Paragraph,
|
_paragraph: &Self::Paragraph,
|
||||||
_position: Point,
|
_position: Point,
|
||||||
_color: Color,
|
_color: Color,
|
||||||
_viewport: Rectangle,
|
_clip_bounds: Rectangle,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ impl text::Renderer for Null {
|
||||||
_editor: &Self::Editor,
|
_editor: &Self::Editor,
|
||||||
_position: Point,
|
_position: Point,
|
||||||
_color: Color,
|
_color: Color,
|
||||||
_viewport: Rectangle,
|
_clip_bounds: Rectangle,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ impl text::Renderer for Null {
|
||||||
_paragraph: Text<'_, Self::Font>,
|
_paragraph: Text<'_, Self::Font>,
|
||||||
_position: Point,
|
_position: Point,
|
||||||
_color: Color,
|
_color: Color,
|
||||||
_viewport: Rectangle,
|
_clip_bounds: Rectangle,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ pub trait Renderer: crate::Renderer {
|
||||||
text: &Self::Paragraph,
|
text: &Self::Paragraph,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Draws the given [`Editor`] at the given position and with the given
|
/// Draws the given [`Editor`] at the given position and with the given
|
||||||
|
|
@ -212,7 +212,7 @@ pub trait Renderer: crate::Renderer {
|
||||||
editor: &Self::Editor,
|
editor: &Self::Editor,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Draws the given [`Text`] at the given position and with the given
|
/// Draws the given [`Text`] at the given position and with the given
|
||||||
|
|
@ -222,6 +222,6 @@ pub trait Renderer: crate::Renderer {
|
||||||
text: Text<'_, Self::Font>,
|
text: Text<'_, Self::Font>,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ pub enum Primitive<T> {
|
||||||
vertical_alignment: alignment::Vertical,
|
vertical_alignment: alignment::Vertical,
|
||||||
/// The shaping strategy of the text.
|
/// The shaping strategy of the text.
|
||||||
shaping: text::Shaping,
|
shaping: text::Shaping,
|
||||||
/// The viewport of the text.
|
/// The clip bounds of the text.
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
},
|
},
|
||||||
/// A paragraph primitive
|
/// A paragraph primitive
|
||||||
Paragraph {
|
Paragraph {
|
||||||
|
|
@ -43,8 +43,8 @@ pub enum Primitive<T> {
|
||||||
position: Point,
|
position: Point,
|
||||||
/// The color of the paragraph.
|
/// The color of the paragraph.
|
||||||
color: Color,
|
color: Color,
|
||||||
/// The viewport of the paragraph.
|
/// The clip bounds of the paragraph.
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
},
|
},
|
||||||
/// An editor primitive
|
/// An editor primitive
|
||||||
Editor {
|
Editor {
|
||||||
|
|
@ -54,8 +54,8 @@ pub enum Primitive<T> {
|
||||||
position: Point,
|
position: Point,
|
||||||
/// The color of the editor.
|
/// The color of the editor.
|
||||||
color: Color,
|
color: Color,
|
||||||
/// The viewport of the editor.
|
/// The clip bounds of the editor.
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
},
|
},
|
||||||
/// A quad primitive
|
/// A quad primitive
|
||||||
Quad {
|
Quad {
|
||||||
|
|
|
||||||
|
|
@ -164,13 +164,13 @@ where
|
||||||
paragraph: &Self::Paragraph,
|
paragraph: &Self::Paragraph,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
) {
|
) {
|
||||||
self.primitives.push(Primitive::Paragraph {
|
self.primitives.push(Primitive::Paragraph {
|
||||||
paragraph: paragraph.downgrade(),
|
paragraph: paragraph.downgrade(),
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
viewport,
|
clip_bounds,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,13 +179,13 @@ where
|
||||||
editor: &Self::Editor,
|
editor: &Self::Editor,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
) {
|
) {
|
||||||
self.primitives.push(Primitive::Editor {
|
self.primitives.push(Primitive::Editor {
|
||||||
editor: editor.downgrade(),
|
editor: editor.downgrade(),
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
viewport,
|
clip_bounds,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,7 +194,7 @@ where
|
||||||
text: Text<'_, Self::Font>,
|
text: Text<'_, Self::Font>,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
) {
|
) {
|
||||||
self.primitives.push(Primitive::Text {
|
self.primitives.push(Primitive::Text {
|
||||||
content: text.content.to_string(),
|
content: text.content.to_string(),
|
||||||
|
|
@ -206,7 +206,7 @@ where
|
||||||
horizontal_alignment: text.horizontal_alignment,
|
horizontal_alignment: text.horizontal_alignment,
|
||||||
vertical_alignment: text.vertical_alignment,
|
vertical_alignment: text.vertical_alignment,
|
||||||
shaping: text.shaping,
|
shaping: text.shaping,
|
||||||
viewport,
|
clip_bounds,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,12 +175,12 @@ impl<T> text::Renderer for Renderer<T> {
|
||||||
paragraph: &Self::Paragraph,
|
paragraph: &Self::Paragraph,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
) {
|
) {
|
||||||
delegate!(
|
delegate!(
|
||||||
self,
|
self,
|
||||||
renderer,
|
renderer,
|
||||||
renderer.fill_paragraph(paragraph, position, color, viewport)
|
renderer.fill_paragraph(paragraph, position, color, clip_bounds)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,12 +189,12 @@ impl<T> text::Renderer for Renderer<T> {
|
||||||
editor: &Self::Editor,
|
editor: &Self::Editor,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
) {
|
) {
|
||||||
delegate!(
|
delegate!(
|
||||||
self,
|
self,
|
||||||
renderer,
|
renderer,
|
||||||
renderer.fill_editor(editor, position, color, viewport)
|
renderer.fill_editor(editor, position, color, clip_bounds)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,12 +203,12 @@ impl<T> text::Renderer for Renderer<T> {
|
||||||
text: Text<'_, Self::Font>,
|
text: Text<'_, Self::Font>,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
) {
|
) {
|
||||||
delegate!(
|
delegate!(
|
||||||
self,
|
self,
|
||||||
renderer,
|
renderer,
|
||||||
renderer.fill_text(text, position, color, viewport)
|
renderer.fill_text(text, position, color, clip_bounds)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -361,9 +361,10 @@ impl Backend {
|
||||||
paragraph,
|
paragraph,
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
viewport,
|
clip_bounds: text_clip_bounds,
|
||||||
} => {
|
} => {
|
||||||
let physical_bounds = (*viewport + translation) * scale_factor;
|
let physical_bounds =
|
||||||
|
(*text_clip_bounds + translation) * scale_factor;
|
||||||
|
|
||||||
if !clip_bounds.intersects(&physical_bounds) {
|
if !clip_bounds.intersects(&physical_bounds) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -385,9 +386,10 @@ impl Backend {
|
||||||
editor,
|
editor,
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
viewport,
|
clip_bounds: text_clip_bounds,
|
||||||
} => {
|
} => {
|
||||||
let physical_bounds = (*viewport + translation) * scale_factor;
|
let physical_bounds =
|
||||||
|
(*text_clip_bounds + translation) * scale_factor;
|
||||||
|
|
||||||
if !clip_bounds.intersects(&physical_bounds) {
|
if !clip_bounds.intersects(&physical_bounds) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -415,9 +417,10 @@ impl Backend {
|
||||||
horizontal_alignment,
|
horizontal_alignment,
|
||||||
vertical_alignment,
|
vertical_alignment,
|
||||||
shaping,
|
shaping,
|
||||||
viewport,
|
clip_bounds: text_clip_bounds,
|
||||||
} => {
|
} => {
|
||||||
let physical_bounds = (*viewport + translation) * scale_factor;
|
let physical_bounds =
|
||||||
|
(*text_clip_bounds + translation) * scale_factor;
|
||||||
|
|
||||||
if !clip_bounds.intersects(&physical_bounds) {
|
if !clip_bounds.intersects(&physical_bounds) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ impl Frame {
|
||||||
horizontal_alignment: text.horizontal_alignment,
|
horizontal_alignment: text.horizontal_alignment,
|
||||||
vertical_alignment: text.vertical_alignment,
|
vertical_alignment: text.vertical_alignment,
|
||||||
shaping: text.shaping,
|
shaping: text.shaping,
|
||||||
viewport: bounds,
|
clip_bounds: Rectangle::with_size(Size::INFINITY),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,7 @@ impl Frame {
|
||||||
horizontal_alignment: text.horizontal_alignment,
|
horizontal_alignment: text.horizontal_alignment,
|
||||||
vertical_alignment: text.vertical_alignment,
|
vertical_alignment: text.vertical_alignment,
|
||||||
shaping: text.shaping,
|
shaping: text.shaping,
|
||||||
viewport: bounds,
|
clip_bounds: Rectangle::with_size(Size::INFINITY),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ impl<'a> Layer<'a> {
|
||||||
horizontal_alignment: alignment::Horizontal::Left,
|
horizontal_alignment: alignment::Horizontal::Left,
|
||||||
vertical_alignment: alignment::Vertical::Top,
|
vertical_alignment: alignment::Vertical::Top,
|
||||||
shaping: core::text::Shaping::Basic,
|
shaping: core::text::Shaping::Basic,
|
||||||
viewport: Rectangle::with_size(Size::INFINITY),
|
clip_bounds: Rectangle::with_size(Size::INFINITY),
|
||||||
};
|
};
|
||||||
|
|
||||||
overlay.text.push(Text::Cached(text.clone()));
|
overlay.text.push(Text::Cached(text.clone()));
|
||||||
|
|
@ -124,7 +124,7 @@ impl<'a> Layer<'a> {
|
||||||
paragraph,
|
paragraph,
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
viewport,
|
clip_bounds,
|
||||||
} => {
|
} => {
|
||||||
let layer = &mut layers[current_layer];
|
let layer = &mut layers[current_layer];
|
||||||
|
|
||||||
|
|
@ -132,14 +132,14 @@ impl<'a> Layer<'a> {
|
||||||
paragraph: paragraph.clone(),
|
paragraph: paragraph.clone(),
|
||||||
position: *position + translation,
|
position: *position + translation,
|
||||||
color: *color,
|
color: *color,
|
||||||
viewport: *viewport + translation,
|
clip_bounds: *clip_bounds + translation,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Primitive::Editor {
|
Primitive::Editor {
|
||||||
editor,
|
editor,
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
viewport,
|
clip_bounds,
|
||||||
} => {
|
} => {
|
||||||
let layer = &mut layers[current_layer];
|
let layer = &mut layers[current_layer];
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ impl<'a> Layer<'a> {
|
||||||
editor: editor.clone(),
|
editor: editor.clone(),
|
||||||
position: *position + translation,
|
position: *position + translation,
|
||||||
color: *color,
|
color: *color,
|
||||||
viewport: *viewport + translation,
|
clip_bounds: *clip_bounds + translation,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Primitive::Text {
|
Primitive::Text {
|
||||||
|
|
@ -160,7 +160,7 @@ impl<'a> Layer<'a> {
|
||||||
horizontal_alignment,
|
horizontal_alignment,
|
||||||
vertical_alignment,
|
vertical_alignment,
|
||||||
shaping,
|
shaping,
|
||||||
viewport,
|
clip_bounds,
|
||||||
} => {
|
} => {
|
||||||
let layer = &mut layers[current_layer];
|
let layer = &mut layers[current_layer];
|
||||||
|
|
||||||
|
|
@ -174,7 +174,7 @@ impl<'a> Layer<'a> {
|
||||||
horizontal_alignment: *horizontal_alignment,
|
horizontal_alignment: *horizontal_alignment,
|
||||||
vertical_alignment: *vertical_alignment,
|
vertical_alignment: *vertical_alignment,
|
||||||
shaping: *shaping,
|
shaping: *shaping,
|
||||||
viewport: *viewport + translation,
|
clip_bounds: *clip_bounds + translation,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ pub enum Text<'a> {
|
||||||
paragraph: paragraph::Weak,
|
paragraph: paragraph::Weak,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
},
|
},
|
||||||
/// An editor.
|
/// An editor.
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
|
@ -21,7 +21,7 @@ pub enum Text<'a> {
|
||||||
editor: editor::Weak,
|
editor: editor::Weak,
|
||||||
position: Point,
|
position: Point,
|
||||||
color: Color,
|
color: Color,
|
||||||
viewport: Rectangle,
|
clip_bounds: Rectangle,
|
||||||
},
|
},
|
||||||
/// A cached text.
|
/// A cached text.
|
||||||
Cached(Cached<'a>),
|
Cached(Cached<'a>),
|
||||||
|
|
@ -56,6 +56,6 @@ pub struct Cached<'a> {
|
||||||
/// The shaping strategy of the text.
|
/// The shaping strategy of the text.
|
||||||
pub shaping: text::Shaping,
|
pub shaping: text::Shaping,
|
||||||
|
|
||||||
/// The viewport of the text.
|
/// The clip bounds of the text.
|
||||||
pub viewport: Rectangle,
|
pub clip_bounds: Rectangle,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,12 +120,12 @@ impl Pipeline {
|
||||||
horizontal_alignment,
|
horizontal_alignment,
|
||||||
vertical_alignment,
|
vertical_alignment,
|
||||||
color,
|
color,
|
||||||
viewport,
|
clip_bounds,
|
||||||
) = match section {
|
) = match section {
|
||||||
Text::Paragraph {
|
Text::Paragraph {
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
viewport,
|
clip_bounds,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
use crate::core::text::Paragraph as _;
|
use crate::core::text::Paragraph as _;
|
||||||
|
|
@ -141,13 +141,13 @@ impl Pipeline {
|
||||||
paragraph.horizontal_alignment(),
|
paragraph.horizontal_alignment(),
|
||||||
paragraph.vertical_alignment(),
|
paragraph.vertical_alignment(),
|
||||||
*color,
|
*color,
|
||||||
*viewport,
|
*clip_bounds,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text::Editor {
|
Text::Editor {
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
viewport,
|
clip_bounds,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
use crate::core::text::Editor as _;
|
use crate::core::text::Editor as _;
|
||||||
|
|
@ -163,7 +163,7 @@ impl Pipeline {
|
||||||
alignment::Horizontal::Left,
|
alignment::Horizontal::Left,
|
||||||
alignment::Vertical::Top,
|
alignment::Vertical::Top,
|
||||||
*color,
|
*color,
|
||||||
*viewport,
|
*clip_bounds,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text::Cached(text) => {
|
Text::Cached(text) => {
|
||||||
|
|
@ -182,7 +182,7 @@ impl Pipeline {
|
||||||
text.horizontal_alignment,
|
text.horizontal_alignment,
|
||||||
text.vertical_alignment,
|
text.vertical_alignment,
|
||||||
text.color,
|
text.color,
|
||||||
text.viewport,
|
text.clip_bounds,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -206,7 +206,7 @@ impl Pipeline {
|
||||||
};
|
};
|
||||||
|
|
||||||
let clip_bounds =
|
let clip_bounds =
|
||||||
layer_bounds.intersection(&(viewport * scale_factor))?;
|
layer_bounds.intersection(&(clip_bounds * scale_factor))?;
|
||||||
|
|
||||||
Some(glyphon::TextArea {
|
Some(glyphon::TextArea {
|
||||||
buffer,
|
buffer,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue