pub(crate) mod serial;
use crate::{ Border, Color, Theme };
use iced_native::{
widget::{
container::{
Appearance, StyleSheet,
},
},
};
#[derive(Clone, Copy, Debug)]
pub struct Tooltip {
pub background: Color,
pub text: Color,
pub border: Border,
}
impl Tooltip {
pub(crate) fn create(serial: &serial::Tooltip, theme: &Theme) -> Result<Self, ()> {
let background = match theme.color.get(&serial.background) {
Some(color) => *color,
_ => return Err(()),
};
let text = match theme.color.get(&serial.text) {
Some(color) => *color,
_ => return Err(()),
};
let border = match theme.border.get(&serial.border) {
Some(border) => *border,
_ => return Err(()),
};
Ok( Tooltip { background, text, border } )
}
}
impl StyleSheet for Tooltip {
type Style = iced::Theme;
fn appearance(&self, _: &Self::Style) -> Appearance {
Appearance {
text_color: None,
background: Some( self.background.into() ),
border_radius: self.border.radius,
border_width: self.border.width,
border_color: self.border.color.into(),
}
}
}