summaryrefslogtreecommitdiffstats
path: root/graphics/src/overlay
diff options
context:
space:
mode:
authorLibravatar Ben LeFevre <ben@lefev.dev>2020-11-23 17:19:21 +0000
committerLibravatar Héctor Ramón <hector@lich.io>2021-06-01 19:05:39 +0700
commitfe0a27c56d9d75fb521e69352259f1d737402a20 (patch)
treef7f77430b63983717036a81e734276123d139ca6 /graphics/src/overlay
parenta9eb591628017caaf7aa9af505d1206f7a143a9a (diff)
downloadiced-fe0a27c56d9d75fb521e69352259f1d737402a20.tar.gz
iced-fe0a27c56d9d75fb521e69352259f1d737402a20.tar.bz2
iced-fe0a27c56d9d75fb521e69352259f1d737402a20.zip
Add support for asymmetrical padding
Diffstat (limited to 'graphics/src/overlay')
-rw-r--r--graphics/src/overlay/menu.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/graphics/src/overlay/menu.rs b/graphics/src/overlay/menu.rs
index ffe998c5..443f1746 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.top + padding.bottom) 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.top + padding.bottom),
};
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