Rename image module to content_fit in iced_core

Since we are just exposing the `ContentFit` type and not the module `image` at all.
This commit is contained in:
Héctor Ramón Jiménez 2022-02-16 17:28:04 +07:00
parent ca1fcdaf14
commit c6486978de
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 11 additions and 11 deletions

View file

@ -1,8 +1,7 @@
//! Control the fit of some content (like an image) within a space //! Control the fit of some content (like an image) within a space.
use crate::Size; use crate::Size;
/// How the image should scale to fit the bounding box of the widget /// The strategy used to fit the contents of a widget to its bounding box.
/// ///
/// Each variant of this enum is a strategy that can be applied for resolving /// Each variant of this enum is a strategy that can be applied for resolving
/// differences in aspect ratio and size between the image being displayed and /// differences in aspect ratio and size between the image being displayed and
@ -14,7 +13,7 @@ use crate::Size;
/// [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit /// [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
pub enum ContentFit { pub enum ContentFit {
/// Scale as big as it can be without needing to crop or hide parts /// Scale as big as it can be without needing to crop or hide parts.
/// ///
/// The image will be scaled (preserving aspect ratio) so that it just fits /// The image will be scaled (preserving aspect ratio) so that it just fits
/// within the window. This won't distort the image or crop/hide any edges, /// within the window. This won't distort the image or crop/hide any edges,
@ -26,7 +25,7 @@ pub enum ContentFit {
/// screen. /// screen.
Contain, Contain,
/// Scale the image to cover all of the bounding box, cropping if needed /// Scale the image to cover all of the bounding box, cropping if needed.
/// ///
/// This doesn't distort the image, and it ensures that the widget's area is /// This doesn't distort the image, and it ensures that the widget's area is
/// completely covered, but it might crop off a bit of the edges of the /// completely covered, but it might crop off a bit of the edges of the
@ -38,14 +37,14 @@ pub enum ContentFit {
/// important. /// important.
Cover, Cover,
/// Distort the image so the widget is 100% covered without cropping /// Distort the image so the widget is 100% covered without cropping.
/// ///
/// This stretches the image to fit the widget, without any whitespace or /// This stretches the image to fit the widget, without any whitespace or
/// cropping. However, because of the stretch, the image may look distorted /// cropping. However, because of the stretch, the image may look distorted
/// or elongated, particularly when there's a mismatch of aspect ratios. /// or elongated, particularly when there's a mismatch of aspect ratios.
Fill, Fill,
/// Don't resize or scale the image at all /// Don't resize or scale the image at all.
/// ///
/// This will not apply any transformations to the provided image, but also /// This will not apply any transformations to the provided image, but also
/// means that unless you do the math yourself, the widget's area will not /// means that unless you do the math yourself, the widget's area will not
@ -54,7 +53,8 @@ pub enum ContentFit {
/// This is best for when you've sized the image yourself. /// This is best for when you've sized the image yourself.
None, None,
/// Scale the image down if it's too big for the space, but never scale it up /// Scale the image down if it's too big for the space, but never scale it
/// up.
/// ///
/// This works much like [`Contain`](Self::Contain), except that if the /// This works much like [`Contain`](Self::Contain), except that if the
/// image would have been scaled up, it keeps its original resolution to /// image would have been scaled up, it keeps its original resolution to
@ -63,7 +63,7 @@ pub enum ContentFit {
} }
impl ContentFit { impl ContentFit {
/// Attempt to apply the given fit for a content size within some bounds /// Attempt to apply the given fit for a content size within some bounds.
/// ///
/// The returned value is the recommended scaled size of the content. /// The returned value is the recommended scaled size of the content.
pub fn fit(&self, content: Size, bounds: Size) -> Size { pub fn fit(&self, content: Size, bounds: Size) -> Size {

View file

@ -21,8 +21,8 @@ pub mod time;
mod background; mod background;
mod color; mod color;
mod content_fit;
mod font; mod font;
mod image;
mod length; mod length;
mod padding; mod padding;
mod point; mod point;
@ -33,8 +33,8 @@ mod vector;
pub use alignment::Alignment; pub use alignment::Alignment;
pub use background::Background; pub use background::Background;
pub use color::Color; pub use color::Color;
pub use content_fit::ContentFit;
pub use font::Font; pub use font::Font;
pub use image::ContentFit;
pub use length::Length; pub use length::Length;
pub use padding::Padding; pub use padding::Padding;
pub use point::Point; pub use point::Point;