Implement From<u32> instead of u16 for Length and Pixels
This commit is contained in:
parent
ab236376a3
commit
f3ae4266e9
6 changed files with 23 additions and 26 deletions
|
|
@ -77,8 +77,8 @@ impl From<f32> for Length {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u16> for Length {
|
impl From<u32> for Length {
|
||||||
fn from(units: u16) -> Self {
|
fn from(units: u32) -> Self {
|
||||||
Length::Fixed(f32::from(units))
|
Length::Fixed(units as f32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ impl From<f32> for Pixels {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u16> for Pixels {
|
impl From<u32> for Pixels {
|
||||||
fn from(amount: u16) -> Self {
|
fn from(amount: u32) -> Self {
|
||||||
Self(f32::from(amount))
|
Self(amount as f32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ impl fmt::Debug for Rgba {
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum Size {
|
pub enum Size {
|
||||||
Original,
|
Original,
|
||||||
Thumbnail { width: u16 },
|
Thumbnail { width: u32 },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
||||||
|
|
@ -97,10 +97,7 @@ impl Gallery {
|
||||||
|
|
||||||
Task::batch(vec![
|
Task::batch(vec![
|
||||||
Task::perform(
|
Task::perform(
|
||||||
image.clone().blurhash(
|
image.clone().blurhash(Preview::WIDTH, Preview::HEIGHT),
|
||||||
Preview::WIDTH as u32,
|
|
||||||
Preview::HEIGHT as u32,
|
|
||||||
),
|
|
||||||
move |result| Message::BlurhashDecoded(id, result),
|
move |result| Message::BlurhashDecoded(id, result),
|
||||||
),
|
),
|
||||||
Task::perform(
|
Task::perform(
|
||||||
|
|
@ -313,8 +310,8 @@ enum Preview {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Preview {
|
impl Preview {
|
||||||
const WIDTH: u16 = 320;
|
const WIDTH: u32 = 320;
|
||||||
const HEIGHT: u16 = 410;
|
const HEIGHT: u32 = 410;
|
||||||
|
|
||||||
fn blurhash(rgba: Rgba) -> Self {
|
fn blurhash(rgba: Rgba) -> Self {
|
||||||
Self::Blurhash(Blurhash {
|
Self::Blurhash(Blurhash {
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ pub fn main() -> iced::Result {
|
||||||
|
|
||||||
struct ScrollableDemo {
|
struct ScrollableDemo {
|
||||||
scrollable_direction: Direction,
|
scrollable_direction: Direction,
|
||||||
scrollbar_width: u16,
|
scrollbar_width: u32,
|
||||||
scrollbar_margin: u16,
|
scrollbar_margin: u32,
|
||||||
scroller_width: u16,
|
scroller_width: u32,
|
||||||
current_scroll_offset: scrollable::RelativeOffset,
|
current_scroll_offset: scrollable::RelativeOffset,
|
||||||
anchor: scrollable::Anchor,
|
anchor: scrollable::Anchor,
|
||||||
}
|
}
|
||||||
|
|
@ -39,9 +39,9 @@ enum Direction {
|
||||||
enum Message {
|
enum Message {
|
||||||
SwitchDirection(Direction),
|
SwitchDirection(Direction),
|
||||||
AlignmentChanged(scrollable::Anchor),
|
AlignmentChanged(scrollable::Anchor),
|
||||||
ScrollbarWidthChanged(u16),
|
ScrollbarWidthChanged(u32),
|
||||||
ScrollbarMarginChanged(u16),
|
ScrollbarMarginChanged(u32),
|
||||||
ScrollerWidthChanged(u16),
|
ScrollerWidthChanged(u32),
|
||||||
ScrollToBeginning,
|
ScrollToBeginning,
|
||||||
ScrollToEnd,
|
ScrollToEnd,
|
||||||
Scrolled(scrollable::Viewport),
|
Scrolled(scrollable::Viewport),
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,12 @@ pub struct Tour {
|
||||||
screen: Screen,
|
screen: Screen,
|
||||||
slider: u8,
|
slider: u8,
|
||||||
layout: Layout,
|
layout: Layout,
|
||||||
spacing: u16,
|
spacing: u32,
|
||||||
text_size: u16,
|
text_size: u32,
|
||||||
text_color: Color,
|
text_color: Color,
|
||||||
language: Option<Language>,
|
language: Option<Language>,
|
||||||
toggler: bool,
|
toggler: bool,
|
||||||
image_width: u16,
|
image_width: u32,
|
||||||
image_filter_method: image::FilterMethod,
|
image_filter_method: image::FilterMethod,
|
||||||
input_value: String,
|
input_value: String,
|
||||||
input_is_secure: bool,
|
input_is_secure: bool,
|
||||||
|
|
@ -43,11 +43,11 @@ pub enum Message {
|
||||||
NextPressed,
|
NextPressed,
|
||||||
SliderChanged(u8),
|
SliderChanged(u8),
|
||||||
LayoutChanged(Layout),
|
LayoutChanged(Layout),
|
||||||
SpacingChanged(u16),
|
SpacingChanged(u32),
|
||||||
TextSizeChanged(u16),
|
TextSizeChanged(u32),
|
||||||
TextColorChanged(Color),
|
TextColorChanged(Color),
|
||||||
LanguageSelected(Language),
|
LanguageSelected(Language),
|
||||||
ImageWidthChanged(u16),
|
ImageWidthChanged(u32),
|
||||||
ImageUseNearestToggled(bool),
|
ImageUseNearestToggled(bool),
|
||||||
InputChanged(String),
|
InputChanged(String),
|
||||||
ToggleSecureInput(bool),
|
ToggleSecureInput(bool),
|
||||||
|
|
@ -537,7 +537,7 @@ impl Screen {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ferris<'a>(
|
fn ferris<'a>(
|
||||||
width: u16,
|
width: u32,
|
||||||
filter_method: image::FilterMethod,
|
filter_method: image::FilterMethod,
|
||||||
) -> Container<'a, Message> {
|
) -> Container<'a, Message> {
|
||||||
center_x(
|
center_x(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue