veloren_voxygen/ui/ice/component/
tooltip.rs1use crate::ui::ice as ui;
2use iced::{Container, Element, Text};
3use ui::{
4 style,
5 widget::{Tooltip, TooltipManager},
6};
7
8#[derive(Copy, Clone)]
10pub struct Style {
11 pub container: style::container::Style,
12 pub text_color: iced::Color,
13 pub text_size: u16,
14 pub padding: u16,
15}
16
17pub fn text<'a, M: 'a>(text: &str, style: Style) -> Element<'a, M, ui::IcedRenderer> {
19 Container::new(
20 Text::new(text)
21 .color(style.text_color)
22 .size(style.text_size),
23 )
24 .style(style.container)
25 .padding(style.padding)
26 .into()
27}
28
29pub trait WithTooltip<'a, M, R: ui::widget::tooltip::Renderer> {
30 fn with_tooltip<H>(self, manager: &'a TooltipManager, hover_content: H) -> Tooltip<'a, M, R>
31 where
32 H: 'a + FnMut() -> Element<'a, M, R>;
33}
34
35impl<'a, M, R: ui::widget::tooltip::Renderer, E: Into<Element<'a, M, R>>> WithTooltip<'a, M, R>
36 for E
37{
38 fn with_tooltip<H>(self, manager: &'a TooltipManager, hover_content: H) -> Tooltip<'a, M, R>
39 where
40 H: 'a + FnMut() -> Element<'a, M, R>,
41 {
42 Tooltip::new(self, hover_content, manager)
43 }
44}