summaryrefslogtreecommitdiffstats
path: root/native/src/widget/tooltip.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-02-24 00:59:29 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-02-24 00:59:29 +0100
commit2736e4ca35f17a92768f0be682acf6da3b574cb6 (patch)
treec2525b87ea5d50d1241caa5c3d9e59f396418b3f /native/src/widget/tooltip.rs
parent5e2743361bf0a2e10c0e14638a9b2818c9e5e364 (diff)
downloadiced-2736e4ca35f17a92768f0be682acf6da3b574cb6.tar.gz
iced-2736e4ca35f17a92768f0be682acf6da3b574cb6.tar.bz2
iced-2736e4ca35f17a92768f0be682acf6da3b574cb6.zip
Hide `Text` as an implementation detail of `Tooltip`
Diffstat (limited to 'native/src/widget/tooltip.rs')
-rw-r--r--native/src/widget/tooltip.rs30
1 files changed, 22 insertions, 8 deletions
diff --git a/native/src/widget/tooltip.rs b/native/src/widget/tooltip.rs
index 56559827..ab07868c 100644
--- a/native/src/widget/tooltip.rs
+++ b/native/src/widget/tooltip.rs
@@ -30,12 +30,12 @@ where
/// [`Tooltip`]: struct.Tooltip.html
pub fn new(
content: impl Into<Element<'a, Message, Renderer>>,
- tooltip: Text<Renderer>,
+ tooltip: impl ToString,
position: Position,
) -> Self {
Tooltip {
content: content.into(),
- tooltip,
+ tooltip: Text::new(tooltip.to_string()),
position,
style: Default::default(),
gap: 0,
@@ -43,12 +43,17 @@ where
}
}
- /// Sets the style of the [`Tooltip`].
- pub fn style(
- mut self,
- style: impl Into<<Renderer as container::Renderer>::Style>,
- ) -> Self {
- self.style = style.into();
+ /// Sets the size of the text of the [`Tooltip`].
+ pub fn size(mut self, size: u16) -> Self {
+ self.tooltip = self.tooltip.size(size);
+ self
+ }
+
+ /// Sets the font of the [`Tooltip`].
+ ///
+ /// [`Font`]: Renderer::Font
+ pub fn font(mut self, font: impl Into<Renderer::Font>) -> Self {
+ self.tooltip = self.tooltip.font(font);
self
}
@@ -63,6 +68,15 @@ where
self.padding = padding;
self
}
+
+ /// Sets the style of the [`Tooltip`].
+ pub fn style(
+ mut self,
+ style: impl Into<<Renderer as container::Renderer>::Style>,
+ ) -> Self {
+ self.style = style.into();
+ self
+ }
}
/// The position of the tooltip. Defaults to following the cursor.