diff --git a/CHANGELOG.md b/CHANGELOG.md index a51278f9..08093de0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Changed 🔧 + +* `ui.image` now takes `impl Into` as a `size` argument + + ## 0.5.0 - 2020-12-13 ### Added ⭐ diff --git a/egui/src/ui.rs b/egui/src/ui.rs index b4327eed..db4ded28 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -689,7 +689,7 @@ impl Ui { } /// Show an image here with the given size - pub fn image(&mut self, texture_id: TextureId, desired_size: Vec2) -> Response { + pub fn image(&mut self, texture_id: TextureId, desired_size: impl Into) -> Response { self.add(Image::new(texture_id, desired_size)) } } diff --git a/egui/src/widgets/image.rs b/egui/src/widgets/image.rs index cd7a9826..2098f1a4 100644 --- a/egui/src/widgets/image.rs +++ b/egui/src/widgets/image.rs @@ -10,11 +10,11 @@ pub struct Image { } impl Image { - pub fn new(texture_id: TextureId, desired_size: Vec2) -> Self { + pub fn new(texture_id: TextureId, desired_size: impl Into) -> Self { Self { texture_id, uv: Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), - desired_size, + desired_size: desired_size.into(), bg_fill: Default::default(), tint: color::WHITE, }