summaryrefslogtreecommitdiffstats
path: root/native/src/widget/tooltip.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-17 16:09:49 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-17 16:09:49 +0100
commit3320ac1126750ed1c462d4f1ff81a59c74d1e9fb (patch)
tree1bc13717cc9ea27cfdae3912745d2b52ec0c6330 /native/src/widget/tooltip.rs
parent0872d078e2e3200e2aa2f5ee0005c34fff9effb7 (diff)
downloadiced-3320ac1126750ed1c462d4f1ff81a59c74d1e9fb.tar.gz
iced-3320ac1126750ed1c462d4f1ff81a59c74d1e9fb.tar.bz2
iced-3320ac1126750ed1c462d4f1ff81a59c74d1e9fb.zip
Use `f32` for `Padding`
Diffstat (limited to 'native/src/widget/tooltip.rs')
-rw-r--r--native/src/widget/tooltip.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/native/src/widget/tooltip.rs b/native/src/widget/tooltip.rs
index 955586aa..2a24c055 100644
--- a/native/src/widget/tooltip.rs
+++ b/native/src/widget/tooltip.rs
@@ -25,8 +25,8 @@ where
content: Element<'a, Message, Renderer>,
tooltip: Text<'a, Renderer>,
position: Position,
- gap: u16,
- padding: u16,
+ gap: f32,
+ padding: f32,
snap_within_viewport: bool,
style: <Renderer::Theme as container::StyleSheet>::Style,
}
@@ -37,7 +37,7 @@ where
Renderer::Theme: container::StyleSheet + widget::text::StyleSheet,
{
/// The default padding of a [`Tooltip`] drawn by this renderer.
- const DEFAULT_PADDING: u16 = 5;
+ const DEFAULT_PADDING: f32 = 5.0;
/// Creates a new [`Tooltip`].
///
@@ -51,7 +51,7 @@ where
content: content.into(),
tooltip: Text::new(tooltip),
position,
- gap: 0,
+ gap: 0.0,
padding: Self::DEFAULT_PADDING,
snap_within_viewport: true,
style: Default::default(),
@@ -73,14 +73,14 @@ where
}
/// Sets the gap between the content and its [`Tooltip`].
- pub fn gap(mut self, gap: u16) -> Self {
- self.gap = gap;
+ pub fn gap(mut self, gap: impl Into<Pixels>) -> Self {
+ self.gap = gap.into().0;
self
}
/// Sets the padding of the [`Tooltip`].
- pub fn padding(mut self, padding: u16) -> Self {
- self.padding = padding;
+ pub fn padding(mut self, padding: impl Into<Pixels>) -> Self {
+ self.padding = padding.into().0;
self
}
@@ -272,8 +272,8 @@ pub fn draw<Renderer>(
cursor_position: Point,
viewport: &Rectangle,
position: Position,
- gap: u16,
- padding: u16,
+ gap: f32,
+ padding: f32,
snap_within_viewport: bool,
style: &<Renderer::Theme as container::StyleSheet>::Style,
layout_text: impl FnOnce(&Renderer, &layout::Limits) -> layout::Node,
@@ -293,7 +293,6 @@ pub fn draw<Renderer>(
let bounds = layout.bounds();
if bounds.contains(cursor_position) {
- let gap = f32::from(gap);
let style = theme.appearance(style);
let defaults = renderer::Style {
@@ -311,7 +310,6 @@ pub fn draw<Renderer>(
.pad(Padding::new(padding)),
);
- let padding = f32::from(padding);
let text_bounds = text_layout.bounds();
let x_center = bounds.x + (bounds.width - text_bounds.width) / 2.0;
let y_center = bounds.y + (bounds.height - text_bounds.height) / 2.0;