diff options
author | 2025-02-09 06:38:48 +0100 | |
---|---|---|
committer | 2025-02-09 06:38:48 +0100 | |
commit | f3ae4266e9727940ba0d0e8469362923590916f4 (patch) | |
tree | 2a6871b981c083fe01b90511b58f510da7ed9ce2 | |
parent | ab236376a3f8f1ac3cdd8aeb0ffeee45e3de37e3 (diff) | |
download | iced-f3ae4266e9727940ba0d0e8469362923590916f4.tar.gz iced-f3ae4266e9727940ba0d0e8469362923590916f4.tar.bz2 iced-f3ae4266e9727940ba0d0e8469362923590916f4.zip |
Implement `From<u32>` instead of `u16` for `Length` and `Pixels`
-rw-r--r-- | core/src/length.rs | 6 | ||||
-rw-r--r-- | core/src/pixels.rs | 6 | ||||
-rw-r--r-- | examples/gallery/src/civitai.rs | 2 | ||||
-rw-r--r-- | examples/gallery/src/main.rs | 9 | ||||
-rw-r--r-- | examples/scrollable/src/main.rs | 12 | ||||
-rw-r--r-- | examples/tour/src/main.rs | 14 |
6 files changed, 23 insertions, 26 deletions
diff --git a/core/src/length.rs b/core/src/length.rs index 5f24169f..363833c4 100644 --- a/core/src/length.rs +++ b/core/src/length.rs @@ -77,8 +77,8 @@ impl From<f32> for Length { } } -impl From<u16> for Length { - fn from(units: u16) -> Self { - Length::Fixed(f32::from(units)) +impl From<u32> for Length { + fn from(units: u32) -> Self { + Length::Fixed(units as f32) } } diff --git a/core/src/pixels.rs b/core/src/pixels.rs index 7d6267cf..c87e2b31 100644 --- a/core/src/pixels.rs +++ b/core/src/pixels.rs @@ -20,9 +20,9 @@ impl From<f32> for Pixels { } } -impl From<u16> for Pixels { - fn from(amount: u16) -> Self { - Self(f32::from(amount)) +impl From<u32> for Pixels { + fn from(amount: u32) -> Self { + Self(amount as f32) } } diff --git a/examples/gallery/src/civitai.rs b/examples/gallery/src/civitai.rs index c394ef1d..457091e9 100644 --- a/examples/gallery/src/civitai.rs +++ b/examples/gallery/src/civitai.rs @@ -125,7 +125,7 @@ impl fmt::Debug for Rgba { #[derive(Debug, Clone, Copy)] pub enum Size { Original, - Thumbnail { width: u16 }, + Thumbnail { width: u32 }, } #[derive(Debug, Clone)] diff --git a/examples/gallery/src/main.rs b/examples/gallery/src/main.rs index 6175f396..3bc66382 100644 --- a/examples/gallery/src/main.rs +++ b/examples/gallery/src/main.rs @@ -97,10 +97,7 @@ impl Gallery { Task::batch(vec![ Task::perform( - image.clone().blurhash( - Preview::WIDTH as u32, - Preview::HEIGHT as u32, - ), + image.clone().blurhash(Preview::WIDTH, Preview::HEIGHT), move |result| Message::BlurhashDecoded(id, result), ), Task::perform( @@ -313,8 +310,8 @@ enum Preview { } impl Preview { - const WIDTH: u16 = 320; - const HEIGHT: u16 = 410; + const WIDTH: u32 = 320; + const HEIGHT: u32 = 410; fn blurhash(rgba: Rgba) -> Self { Self::Blurhash(Blurhash { diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs index 6359fb5a..fec4e1b4 100644 --- a/examples/scrollable/src/main.rs +++ b/examples/scrollable/src/main.rs @@ -21,9 +21,9 @@ pub fn main() -> iced::Result { struct ScrollableDemo { scrollable_direction: Direction, - scrollbar_width: u16, - scrollbar_margin: u16, - scroller_width: u16, + scrollbar_width: u32, + scrollbar_margin: u32, + scroller_width: u32, current_scroll_offset: scrollable::RelativeOffset, anchor: scrollable::Anchor, } @@ -39,9 +39,9 @@ enum Direction { enum Message { SwitchDirection(Direction), AlignmentChanged(scrollable::Anchor), - ScrollbarWidthChanged(u16), - ScrollbarMarginChanged(u16), - ScrollerWidthChanged(u16), + ScrollbarWidthChanged(u32), + ScrollbarMarginChanged(u32), + ScrollerWidthChanged(u32), ScrollToBeginning, ScrollToEnd, Scrolled(scrollable::Viewport), diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 32720c47..2ca1df44 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -24,12 +24,12 @@ pub struct Tour { screen: Screen, slider: u8, layout: Layout, - spacing: u16, - text_size: u16, + spacing: u32, + text_size: u32, text_color: Color, language: Option<Language>, toggler: bool, - image_width: u16, + image_width: u32, image_filter_method: image::FilterMethod, input_value: String, input_is_secure: bool, @@ -43,11 +43,11 @@ pub enum Message { NextPressed, SliderChanged(u8), LayoutChanged(Layout), - SpacingChanged(u16), - TextSizeChanged(u16), + SpacingChanged(u32), + TextSizeChanged(u32), TextColorChanged(Color), LanguageSelected(Language), - ImageWidthChanged(u16), + ImageWidthChanged(u32), ImageUseNearestToggled(bool), InputChanged(String), ToggleSecureInput(bool), @@ -537,7 +537,7 @@ impl Screen { } fn ferris<'a>( - width: u16, + width: u32, filter_method: image::FilterMethod, ) -> Container<'a, Message> { center_x( |