diff options
author | 2021-06-01 19:21:43 +0700 | |
---|---|---|
committer | 2021-06-01 19:21:43 +0700 | |
commit | b94cd7a2a83d81769d31f6379539089ce68cbdcd (patch) | |
tree | 63aac7f69dff9bb9f195e04d16c6a4f5b57b8683 | |
parent | 2e17d7860b6f857315f14341813645ca980a15df (diff) | |
download | iced-b94cd7a2a83d81769d31f6379539089ce68cbdcd.tar.gz iced-b94cd7a2a83d81769d31f6379539089ce68cbdcd.tar.bz2 iced-b94cd7a2a83d81769d31f6379539089ce68cbdcd.zip |
Use `Padding::horizontal` and `Padding::vertical` helpers
-rw-r--r-- | core/src/size.rs | 4 | ||||
-rw-r--r-- | graphics/src/overlay/menu.rs | 4 | ||||
-rw-r--r-- | graphics/src/widget/pick_list.rs | 3 | ||||
-rw-r--r-- | native/src/layout/limits.rs | 4 | ||||
-rw-r--r-- | native/src/overlay/menu.rs | 9 |
5 files changed, 10 insertions, 14 deletions
diff --git a/core/src/size.rs b/core/src/size.rs index 712caee2..6745c6c8 100644 --- a/core/src/size.rs +++ b/core/src/size.rs @@ -30,8 +30,8 @@ impl Size { /// Increments the [`Size`] to account for the given padding. pub fn pad(&self, padding: Padding) -> Self { Size { - width: self.width + (padding.left + padding.right) as f32, - height: self.height + (padding.top + padding.bottom) as f32, + width: self.width + padding.horizontal() as f32, + height: self.height + padding.vertical() as f32, } } } diff --git a/graphics/src/overlay/menu.rs b/graphics/src/overlay/menu.rs index 443f1746..9e91a0ef 100644 --- a/graphics/src/overlay/menu.rs +++ b/graphics/src/overlay/menu.rs @@ -53,7 +53,7 @@ where use std::f32; let is_mouse_over = bounds.contains(cursor_position); - let option_height = (text_size + padding.top + padding.bottom) as usize; + let option_height = (text_size + padding.vertical()) as usize; let mut primitives = Vec::new(); @@ -72,7 +72,7 @@ where x: bounds.x, y: bounds.y + (option_height * i) as f32, width: bounds.width, - height: f32::from(text_size + padding.top + padding.bottom), + height: f32::from(text_size + padding.vertical()), }; if is_selected { diff --git a/graphics/src/widget/pick_list.rs b/graphics/src/widget/pick_list.rs index c6fbcf76..32dfbdf9 100644 --- a/graphics/src/widget/pick_list.rs +++ b/graphics/src/widget/pick_list.rs @@ -57,8 +57,7 @@ where font: B::ICON_FONT, size: bounds.height * style.icon_size, bounds: Rectangle { - x: bounds.x + bounds.width - - f32::from(padding.left + padding.right), + x: bounds.x + bounds.width - f32::from(padding.horizontal()), y: bounds.center_y(), ..bounds }, diff --git a/native/src/layout/limits.rs b/native/src/layout/limits.rs index 0057e3ba..6d5f6563 100644 --- a/native/src/layout/limits.rs +++ b/native/src/layout/limits.rs @@ -119,8 +119,8 @@ impl Limits { /// Shrinks the current [`Limits`] to account for the given padding. pub fn pad(&self, padding: Padding) -> Limits { self.shrink(Size::new( - (padding.left + padding.right) as f32, - (padding.top + padding.bottom) as f32, + padding.horizontal() as f32, + padding.vertical() as f32, )) } diff --git a/native/src/overlay/menu.rs b/native/src/overlay/menu.rs index d4375a1d..b5ed07c7 100644 --- a/native/src/overlay/menu.rs +++ b/native/src/overlay/menu.rs @@ -299,7 +299,7 @@ where let size = { let intrinsic = Size::new( 0.0, - f32::from(text_size + self.padding.top + self.padding.bottom) + f32::from(text_size + self.padding.vertical()) * self.options.len() as f32, ); @@ -364,11 +364,8 @@ where *self.hovered_option = Some( ((cursor_position.y - bounds.y) - / f32::from( - text_size - + self.padding.top - + self.padding.bottom, - )) as usize, + / f32::from(text_size + self.padding.vertical())) + as usize, ); if let Some(index) = *self.hovered_option { |