Struct gemini_engine::elements::view::ScaleFitView
source · #[non_exhaustive]pub struct ScaleFitView {
pub view: View,
pub empty_row_count: isize,
}Expand description
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.view: ViewThe View that this struct wraps around
empty_row_count: isizeHow many rows to leave clear below the rendered view. You might want to set this if you have more than one line of text after rendered text
Implementations§
source§impl ScaleFitView
impl ScaleFitView
sourcepub fn new(background_char: ColChar) -> Self
pub fn new(background_char: ColChar) -> Self
Create a new ScaleFitView with the given background ColChar
Examples found in repository?
examples/self-resizing.rs (line 18)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
let mut scale_view = ScaleFitView::new(ColChar::BACKGROUND);
let mut text = Text::new(Vec2D::ZERO, "This is some centered text!", Modifier::None)
.with_align(TextAlign::Centered);
let mut sprite =
Sprite::new(Vec2D::ZERO, TEXTURE, Modifier::None).with_align(TextAlign2D::CENTERED);
loop {
text.pos = scale_view.intended_size() / 2;
sprite.pos = scale_view.intended_size() / 2;
sprite.pos.y -= 5;
scale_view.update();
scale_view.view.blit(&text, Wrapping::Wrap);
scale_view.view.blit(&sprite, Wrapping::Wrap);
let _ = scale_view.view.display_render();
sleep(Duration::from_millis(10));
}
}sourcepub const fn with_empty_row_count(self, empty_row_count: isize) -> Self
pub const fn with_empty_row_count(self, empty_row_count: isize) -> Self
Returns the ScaleFitView with the updated empty_row_count
sourcepub fn intended_size(&self) -> Vec2D
pub fn intended_size(&self) -> Vec2D
Returns the size of the terminal, with the y adjusted as intended using the empty_row_count property
§Panics
This will panic if termsize::get returns a None value.
Examples found in repository?
examples/self-resizing.rs (line 27)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
let mut scale_view = ScaleFitView::new(ColChar::BACKGROUND);
let mut text = Text::new(Vec2D::ZERO, "This is some centered text!", Modifier::None)
.with_align(TextAlign::Centered);
let mut sprite =
Sprite::new(Vec2D::ZERO, TEXTURE, Modifier::None).with_align(TextAlign2D::CENTERED);
loop {
text.pos = scale_view.intended_size() / 2;
sprite.pos = scale_view.intended_size() / 2;
sprite.pos.y -= 5;
scale_view.update();
scale_view.view.blit(&text, Wrapping::Wrap);
scale_view.view.blit(&sprite, Wrapping::Wrap);
let _ = scale_view.view.display_render();
sleep(Duration::from_millis(10));
}
}sourcepub fn update(&mut self)
pub fn update(&mut self)
Resize and clear the View
Examples found in repository?
examples/self-resizing.rs (line 31)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
let mut scale_view = ScaleFitView::new(ColChar::BACKGROUND);
let mut text = Text::new(Vec2D::ZERO, "This is some centered text!", Modifier::None)
.with_align(TextAlign::Centered);
let mut sprite =
Sprite::new(Vec2D::ZERO, TEXTURE, Modifier::None).with_align(TextAlign2D::CENTERED);
loop {
text.pos = scale_view.intended_size() / 2;
sprite.pos = scale_view.intended_size() / 2;
sprite.pos.y -= 5;
scale_view.update();
scale_view.view.blit(&text, Wrapping::Wrap);
scale_view.view.blit(&sprite, Wrapping::Wrap);
let _ = scale_view.view.display_render();
sleep(Duration::from_millis(10));
}
}Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for ScaleFitView
impl Send for ScaleFitView
impl Sync for ScaleFitView
impl Unpin for ScaleFitView
impl UnwindSafe for ScaleFitView
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more