diff options
| author | 2021-06-01 19:59:02 +0700 | |
|---|---|---|
| committer | 2021-06-01 19:59:02 +0700 | |
| commit | aab2176802b6d745a7eab76ec13762b5b4ddf782 (patch) | |
| tree | 3d1655b36aa8d7151c878e1879c03c8271a466a5 /graphics/src/overlay | |
| parent | a9eb591628017caaf7aa9af505d1206f7a143a9a (diff) | |
| parent | 8a3b71df8b619571ce0a972826cb5a3987b66b3d (diff) | |
| download | iced-aab2176802b6d745a7eab76ec13762b5b4ddf782.tar.gz iced-aab2176802b6d745a7eab76ec13762b5b4ddf782.tar.bz2 iced-aab2176802b6d745a7eab76ec13762b5b4ddf782.zip  | |
Merge pull request #630 from blefevre/asymmetric-padding
Add support for asymmetrical padding
Diffstat (limited to '')
| -rw-r--r-- | graphics/src/overlay/menu.rs | 12 | 
1 files changed, 6 insertions, 6 deletions
diff --git a/graphics/src/overlay/menu.rs b/graphics/src/overlay/menu.rs index ffe998c5..9e91a0ef 100644 --- a/graphics/src/overlay/menu.rs +++ b/graphics/src/overlay/menu.rs @@ -2,8 +2,8 @@  use crate::backend::{self, Backend};  use crate::{Primitive, Renderer};  use iced_native::{ -    mouse, overlay, Color, Font, HorizontalAlignment, Point, Rectangle, -    VerticalAlignment, +    mouse, overlay, Color, Font, HorizontalAlignment, Padding, Point, +    Rectangle, VerticalAlignment,  };  pub use iced_style::menu::Style; @@ -45,7 +45,7 @@ where          viewport: &Rectangle,          options: &[T],          hovered_option: Option<usize>, -        padding: u16, +        padding: Padding,          text_size: u16,          font: Font,          style: &Style, @@ -53,7 +53,7 @@ where          use std::f32;          let is_mouse_over = bounds.contains(cursor_position); -        let option_height = text_size as usize + padding as usize * 2; +        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 * 2), +                height: f32::from(text_size + padding.vertical()),              };              if is_selected { @@ -88,7 +88,7 @@ where              primitives.push(Primitive::Text {                  content: option.to_string(),                  bounds: Rectangle { -                    x: bounds.x + f32::from(padding), +                    x: bounds.x + padding.left as f32,                      y: bounds.center_y(),                      width: f32::INFINITY,                      ..bounds  | 
