feat(native): add Tooltip widget
This commit is contained in:
parent
4de164dcc7
commit
a19f89d3a6
23 changed files with 580 additions and 18 deletions
|
|
@ -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;
|
||||
|
|
|
|||
37
graphics/src/widget/tooltip.rs
Normal file
37
graphics/src/widget/tooltip.rs
Normal file
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue