summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Yusuf Bera Ertan <y.bera003.06@protonmail.com>2020-07-28 18:07:46 +0300
committerLibravatar Yusuf Bera Ertan <y.bera003.06@protonmail.com>2021-02-15 19:37:46 +0300
commita19f89d3a6af2804f2ac4e30f6d639b56a9bebfd (patch)
tree313320abe39ade1214723521b6a5aff56ad2edef /graphics
parent4de164dcc7bc3524c8b20f9c734bc1a4ae4c83bc (diff)
downloadiced-a19f89d3a6af2804f2ac4e30f6d639b56a9bebfd.tar.gz
iced-a19f89d3a6af2804f2ac4e30f6d639b56a9bebfd.tar.bz2
iced-a19f89d3a6af2804f2ac4e30f6d639b56a9bebfd.zip
feat(native): add Tooltip widget
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/widget.rs3
-rw-r--r--graphics/src/widget/tooltip.rs37
2 files changed, 40 insertions, 0 deletions
diff --git a/graphics/src/widget.rs b/graphics/src/widget.rs
index 159ca91b..190ea9c0 100644
--- a/graphics/src/widget.rs
+++ b/graphics/src/widget.rs
@@ -20,6 +20,7 @@ pub mod scrollable;
pub mod slider;
pub mod svg;
pub mod text_input;
+pub mod tooltip;
mod column;
mod row;
@@ -48,6 +49,8 @@ pub use scrollable::Scrollable;
pub use slider::Slider;
#[doc(no_inline)]
pub use text_input::TextInput;
+#[doc(no_inline)]
+pub use tooltip::Tooltip;
pub use column::Column;
pub use image::Image;
diff --git a/graphics/src/widget/tooltip.rs b/graphics/src/widget/tooltip.rs
new file mode 100644
index 00000000..b5b0c558
--- /dev/null
+++ b/graphics/src/widget/tooltip.rs
@@ -0,0 +1,37 @@
+//! Decorate content and apply alignment.
+use crate::defaults::Defaults;
+use crate::{Backend, Renderer};
+use iced_native::{Element, Layout, Point, Rectangle};
+
+/// An element decorating some content.
+///
+/// This is an alias of an `iced_native` tooltip with a default
+/// `Renderer`.
+pub type Tooltip<'a, Message, Backend> =
+ iced_native::Tooltip<'a, Message, Renderer<Backend>>;
+
+impl<B> iced_native::tooltip::Renderer for Renderer<B>
+where
+ B: Backend,
+{
+ type Style = ();
+
+ fn draw<Message>(
+ &mut self,
+ defaults: &Defaults,
+ cursor_position: Point,
+ content: &Element<'_, Message, Self>,
+ content_layout: Layout<'_>,
+ viewport: &Rectangle,
+ ) -> Self::Output {
+ let (content, mouse_interaction) = content.draw(
+ self,
+ &defaults,
+ content_layout,
+ cursor_position,
+ viewport,
+ );
+
+ (content, mouse_interaction)
+ }
+}