summaryrefslogtreecommitdiffstats
path: root/wgpu/src/renderer/widget/image.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-21 13:47:20 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-21 13:47:20 +0100
commit65eb218d3d7ba52b2869a586a1480eeb3c8f84e4 (patch)
tree644f27f40f2f4b8ee1abe7743aac426297503eea /wgpu/src/renderer/widget/image.rs
parentd3553adf278e5b616fbd885f321faa83a4d24b56 (diff)
downloadiced-65eb218d3d7ba52b2869a586a1480eeb3c8f84e4.tar.gz
iced-65eb218d3d7ba52b2869a586a1480eeb3c8f84e4.tar.bz2
iced-65eb218d3d7ba52b2869a586a1480eeb3c8f84e4.zip
Move widgets from `core` to `native` and `web`
Also made fields private and improved `Renderer` traits.
Diffstat (limited to 'wgpu/src/renderer/widget/image.rs')
-rw-r--r--wgpu/src/renderer/widget/image.rs25
1 files changed, 3 insertions, 22 deletions
diff --git a/wgpu/src/renderer/widget/image.rs b/wgpu/src/renderer/widget/image.rs
index 0afb11e3..fe594365 100644
--- a/wgpu/src/renderer/widget/image.rs
+++ b/wgpu/src/renderer/widget/image.rs
@@ -1,28 +1,9 @@
use crate::{Primitive, Renderer};
-use iced_native::{image, layout, Image, Layout, Length, MouseCursor, Size};
+use iced_native::{image, 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 {