Move Viewport to iced_graphics
This commit is contained in:
parent
750a441a8c
commit
a0ac09122a
5 changed files with 7 additions and 37 deletions
|
|
@ -8,14 +8,12 @@ mod backend;
|
|||
mod quad;
|
||||
mod text;
|
||||
mod triangle;
|
||||
mod viewport;
|
||||
|
||||
pub mod settings;
|
||||
pub mod widget;
|
||||
pub mod window;
|
||||
|
||||
pub use settings::Settings;
|
||||
pub use viewport::Viewport;
|
||||
|
||||
pub(crate) use backend::Backend;
|
||||
pub(crate) use iced_graphics::Transformation;
|
||||
|
|
@ -26,9 +24,10 @@ pub type Renderer = iced_graphics::Renderer<Backend>;
|
|||
#[doc(no_inline)]
|
||||
pub use widget::*;
|
||||
|
||||
pub type Element<'a, Message> = iced_native::Element<'a, Message, Renderer>;
|
||||
|
||||
pub use iced_graphics::Viewport;
|
||||
pub use iced_native::{
|
||||
Background, Color, Command, HorizontalAlignment, Length, Vector,
|
||||
VerticalAlignment,
|
||||
};
|
||||
|
||||
pub type Element<'a, Message> = iced_native::Element<'a, Message, Renderer>;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ mod defaults;
|
|||
mod primitive;
|
||||
mod renderer;
|
||||
mod transformation;
|
||||
mod viewport;
|
||||
mod widget;
|
||||
|
||||
pub mod backend;
|
||||
|
|
@ -15,3 +16,4 @@ pub use defaults::Defaults;
|
|||
pub use primitive::Primitive;
|
||||
pub use renderer::Renderer;
|
||||
pub use transformation::Transformation;
|
||||
pub use viewport::Viewport;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ impl Viewport {
|
|||
(self.width, self.height)
|
||||
}
|
||||
|
||||
pub(crate) fn transformation(&self) -> Transformation {
|
||||
pub fn transformation(&self) -> Transformation {
|
||||
self.transformation
|
||||
}
|
||||
}
|
||||
|
|
@ -36,15 +36,13 @@ mod backend;
|
|||
mod quad;
|
||||
mod target;
|
||||
mod text;
|
||||
mod viewport;
|
||||
|
||||
pub use iced_graphics::{Defaults, Primitive};
|
||||
pub use iced_graphics::{Defaults, Primitive, Viewport};
|
||||
pub use wgpu;
|
||||
|
||||
pub use backend::Backend;
|
||||
pub use settings::Settings;
|
||||
pub use target::Target;
|
||||
pub use viewport::Viewport;
|
||||
|
||||
#[doc(no_inline)]
|
||||
pub use widget::*;
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
use crate::Transformation;
|
||||
|
||||
/// A viewing region for displaying computer graphics.
|
||||
#[derive(Debug)]
|
||||
pub struct Viewport {
|
||||
width: u32,
|
||||
height: u32,
|
||||
transformation: Transformation,
|
||||
}
|
||||
|
||||
impl Viewport {
|
||||
/// Creates a new [`Viewport`] with the given dimensions.
|
||||
pub fn new(width: u32, height: u32) -> Viewport {
|
||||
Viewport {
|
||||
width,
|
||||
height,
|
||||
transformation: Transformation::orthographic(width, height),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the dimensions of the [`Viewport`].
|
||||
pub fn dimensions(&self) -> (u32, u32) {
|
||||
(self.width, self.height)
|
||||
}
|
||||
|
||||
pub(crate) fn transformation(&self) -> Transformation {
|
||||
self.transformation
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue