summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-02-23 03:16:37 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-02-23 03:16:37 +0100
commit2f766b73413fe60cd881e139fa0e84a0f0134d91 (patch)
tree8f640e109dd4f87653dd853c40b57ad82d89ed07 /graphics
parent9f60a256fc909dda0c30e301020d03d7ec28d722 (diff)
downloadiced-2f766b73413fe60cd881e139fa0e84a0f0134d91.tar.gz
iced-2f766b73413fe60cd881e139fa0e84a0f0134d91.tar.bz2
iced-2f766b73413fe60cd881e139fa0e84a0f0134d91.zip
Introduce `Tooltip::gap` to control spacing
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/widget/tooltip.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/graphics/src/widget/tooltip.rs b/graphics/src/widget/tooltip.rs
index 0b4d1d2f..26b18507 100644
--- a/graphics/src/widget/tooltip.rs
+++ b/graphics/src/widget/tooltip.rs
@@ -30,6 +30,7 @@ where
content: &Element<'_, Message, Self>,
tooltip: &Text<Self>,
position: Position,
+ gap: u16,
) -> Self::Output {
let bounds = content_layout.bounds();
@@ -58,18 +59,21 @@ where
let y_center =
bounds.y + (bounds.height - tooltip_bounds.height) / 2.0;
+ let gap = f32::from(gap);
+
let offset = match position {
- Position::Top => {
- Vector::new(x_center, bounds.y - tooltip_bounds.height)
- }
+ Position::Top => Vector::new(
+ x_center,
+ bounds.y - tooltip_bounds.height - gap,
+ ),
Position::Bottom => {
- Vector::new(x_center, bounds.y + bounds.height)
+ Vector::new(x_center, bounds.y + bounds.height + gap)
}
Position::Left => {
- Vector::new(bounds.x - tooltip_bounds.width, y_center)
+ Vector::new(bounds.x - tooltip_bounds.width - gap, y_center)
}
Position::Right => {
- Vector::new(bounds.x + bounds.width, y_center)
+ Vector::new(bounds.x + bounds.width + gap, y_center)
}
Position::FollowCursor => Vector::new(
cursor_position.x,