Use f32 for Padding
This commit is contained in:
parent
0872d078e2
commit
3320ac1126
12 changed files with 98 additions and 79 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue