summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-02-16 17:51:03 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-02-16 18:19:37 +0700
commit0aff444941f8b44b5a996dde4810ba6313f43a7e (patch)
tree9fc090eaf14211726263c76977798def0846618f
parent8b5c9dfa71f770281ca277163c320571c39ee572 (diff)
downloadiced-0aff444941f8b44b5a996dde4810ba6313f43a7e.tar.gz
iced-0aff444941f8b44b5a996dde4810ba6313f43a7e.tar.bz2
iced-0aff444941f8b44b5a996dde4810ba6313f43a7e.zip
Rename `Image::fit` to `content_fit`
... just for consistency!
Diffstat (limited to '')
-rw-r--r--examples/tour/src/main.rs4
-rw-r--r--native/src/widget/image.rs16
2 files changed, 12 insertions, 8 deletions
diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs
index 63062e7c..0c61add0 100644
--- a/examples/tour/src/main.rs
+++ b/examples/tour/src/main.rs
@@ -748,7 +748,7 @@ fn ferris<'a>(width: u16) -> Container<'a, StepMessage> {
))
}
.width(Length::Units(width))
- .fit(ContentFit::Contain),
+ .content_fit(ContentFit::Contain),
)
.width(Length::Fill)
.center_x()
@@ -769,7 +769,7 @@ fn logo<'a>(height: u16, fit: ContentFit) -> Container<'a, StepMessage> {
}
.width(Length::Fill)
.height(Length::Units(height))
- .fit(fit),
+ .content_fit(fit),
)
.width(Length::Fill)
.center_x()
diff --git a/native/src/widget/image.rs b/native/src/widget/image.rs
index f2b8ef2f..d83230f2 100644
--- a/native/src/widget/image.rs
+++ b/native/src/widget/image.rs
@@ -28,7 +28,7 @@ pub struct Image<Handle> {
handle: Handle,
width: Length,
height: Length,
- fit: ContentFit,
+ content_fit: ContentFit,
}
impl<Handle> Image<Handle> {
@@ -38,7 +38,7 @@ impl<Handle> Image<Handle> {
handle: handle.into(),
width: Length::Shrink,
height: Length::Shrink,
- fit: ContentFit::Contain,
+ content_fit: ContentFit::Contain,
}
}
@@ -57,8 +57,11 @@ impl<Handle> Image<Handle> {
/// Sets the [`ContentFit`] of the [`Image`].
///
/// Defaults to [`ContentFit::Contain`]
- pub fn fit(self, fit: ContentFit) -> Self {
- Self { fit, ..self }
+ pub fn content_fit(self, content_fit: ContentFit) -> Self {
+ Self {
+ content_fit,
+ ..self
+ }
}
}
@@ -91,7 +94,7 @@ where
.resolve(image_size);
// The uncropped size of the image when fit to the bounds above
- let full_size = self.fit.fit(image_size, raw_size);
+ let full_size = self.content_fit.fit(image_size, raw_size);
// Shrink the widget to fit the resized image, if requested
let final_size = Size {
@@ -120,7 +123,8 @@ where
let (width, height) = renderer.dimensions(&self.handle);
let image_size = Size::new(width as f32, height as f32);
- let adjusted_fit = self.fit.fit(image_size, layout.bounds().size());
+ let adjusted_fit =
+ self.content_fit.fit(image_size, layout.bounds().size());
let bounds = layout.bounds();
let render = |renderer: &mut Renderer| {