diff options
author | 2019-11-10 01:55:32 +0100 | |
---|---|---|
committer | 2019-11-10 01:55:32 +0100 | |
commit | 2303111e09d806ef2a652bddc2b73be6dccf6ae2 (patch) | |
tree | ba57c5a2fe67d8a58d4f9b32c2b32fee32932f06 /wgpu/src/renderer/widget/image.rs | |
parent | 839e039dbf2fb89dcb8c141503740777d2af2eb3 (diff) | |
download | iced-2303111e09d806ef2a652bddc2b73be6dccf6ae2.tar.gz iced-2303111e09d806ef2a652bddc2b73be6dccf6ae2.tar.bz2 iced-2303111e09d806ef2a652bddc2b73be6dccf6ae2.zip |
Draft new layout API
Diffstat (limited to 'wgpu/src/renderer/widget/image.rs')
-rw-r--r-- | wgpu/src/renderer/widget/image.rs | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/wgpu/src/renderer/widget/image.rs b/wgpu/src/renderer/widget/image.rs index 0e312706..ea9d19c7 100644 --- a/wgpu/src/renderer/widget/image.rs +++ b/wgpu/src/renderer/widget/image.rs @@ -1,28 +1,18 @@ use crate::{Primitive, Renderer}; -use iced_native::{image, Image, Layout, Length, MouseCursor, Node, Style}; +use iced_native::{image, layout, Image, Layout, MouseCursor, Rectangle}; impl image::Renderer for Renderer { - fn node(&self, image: &Image) -> Node { - let (width, height) = self.image_pipeline.dimensions(&image.path); - - let aspect_ratio = width as f32 / height as f32; - - let mut style = Style::default().align_self(image.align_self); - - // TODO: Deal with additional cases - style = match (image.width, image.height) { - (Length::Units(width), _) => style.width(image.width).height( - Length::Units((width as f32 / aspect_ratio).round() as u16), - ), - (_, _) => style - .width(Length::Units(width as u16)) - .height(Length::Units(height as u16)), - }; - - Node::new(style) + fn layout(&self, image: &Image, limits: &layout::Limits) -> Layout { + // TODO + Layout::new(Rectangle { + x: 0.0, + y: 0.0, + width: 0.0, + height: 0.0, + }) } - fn draw(&mut self, image: &Image, layout: Layout<'_>) -> Self::Output { + fn draw(&mut self, image: &Image, layout: &Layout) -> Self::Output { ( Primitive::Image { path: image.path.clone(), |