summaryrefslogtreecommitdiffstats
path: root/wgpu/src/renderer/widget/image.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2019-11-24 11:34:30 +0100
committerLibravatar GitHub <noreply@github.com>2019-11-24 11:34:30 +0100
commit149fd2aa1fa86858c7c1dcec8fd844caa78cec94 (patch)
treea199cf8d2caaf6aa60e48e93d6dd0688969d43b0 /wgpu/src/renderer/widget/image.rs
parent9712b319bb7a32848001b96bd84977430f14b623 (diff)
parent47196c9007d12d3b3e0036ffabe3bf6d14ff4523 (diff)
downloadiced-149fd2aa1fa86858c7c1dcec8fd844caa78cec94.tar.gz
iced-149fd2aa1fa86858c7c1dcec8fd844caa78cec94.tar.bz2
iced-149fd2aa1fa86858c7c1dcec8fd844caa78cec94.zip
Merge pull request #65 from hecrj/improvement/docs
Documentation
Diffstat (limited to 'wgpu/src/renderer/widget/image.rs')
-rw-r--r--wgpu/src/renderer/widget/image.rs29
1 files changed, 5 insertions, 24 deletions
diff --git a/wgpu/src/renderer/widget/image.rs b/wgpu/src/renderer/widget/image.rs
index 0afb11e3..0006dde1 100644
--- a/wgpu/src/renderer/widget/image.rs
+++ b/wgpu/src/renderer/widget/image.rs
@@ -1,34 +1,15 @@
use crate::{Primitive, Renderer};
-use iced_native::{image, layout, Image, Layout, Length, MouseCursor, Size};
+use iced_native::{image, Layout, MouseCursor};
impl image::Renderer for Renderer {
- fn layout(&self, image: &Image, limits: &layout::Limits) -> layout::Node {
- let (width, height) = self.image_pipeline.dimensions(&image.path);
-
- let aspect_ratio = width as f32 / height as f32;
-
- // TODO: Deal with additional cases
- let (width, height) = match (image.width, image.height) {
- (Length::Units(width), _) => (
- image.width,
- Length::Units((width as f32 / aspect_ratio).round() as u16),
- ),
- (_, _) => {
- (Length::Units(width as u16), Length::Units(height as u16))
- }
- };
-
- let mut size = limits.width(width).height(height).resolve(Size::ZERO);
-
- size.height = size.width / aspect_ratio;
-
- layout::Node::new(size)
+ fn dimensions(&self, path: &str) -> (u32, u32) {
+ self.image_pipeline.dimensions(path)
}
- fn draw(&mut self, image: &Image, layout: Layout<'_>) -> Self::Output {
+ fn draw(&mut self, path: &str, layout: Layout<'_>) -> Self::Output {
(
Primitive::Image {
- path: image.path.clone(),
+ path: String::from(path),
bounds: layout.bounds(),
},
MouseCursor::OutOfBounds,