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