1 | use tiny_skia::{Color, Pixmap}; |
2 | |
3 | #[cfg (any(feature = "crossfont" , feature = "ab_glyph" ))] |
4 | mod config; |
5 | #[cfg (any(feature = "crossfont" , feature = "ab_glyph" ))] |
6 | mod font_preference; |
7 | |
8 | #[cfg (feature = "crossfont" )] |
9 | mod crossfont_renderer; |
10 | |
11 | #[cfg (all(not(feature = "crossfont" ), feature = "ab_glyph" ))] |
12 | mod ab_glyph_renderer; |
13 | |
14 | #[cfg (all(not(feature = "crossfont" ), not(feature = "ab_glyph" )))] |
15 | mod dumb; |
16 | |
17 | #[derive (Debug)] |
18 | pub struct TitleText { |
19 | #[cfg (feature = "crossfont" )] |
20 | imp: crossfont_renderer::CrossfontTitleText, |
21 | #[cfg (all(not(feature = "crossfont" ), feature = "ab_glyph" ))] |
22 | imp: ab_glyph_renderer::AbGlyphTitleText, |
23 | #[cfg (all(not(feature = "crossfont" ), not(feature = "ab_glyph" )))] |
24 | imp: dumb::DumbTitleText, |
25 | } |
26 | |
27 | impl TitleText { |
28 | pub fn new(color: Color) -> Option<Self> { |
29 | #[cfg (feature = "crossfont" )] |
30 | return crossfont_renderer::CrossfontTitleText::new(color) |
31 | .ok() |
32 | .map(|imp| Self { imp }); |
33 | |
34 | #[cfg (all(not(feature = "crossfont" ), feature = "ab_glyph" ))] |
35 | return Some(Self { |
36 | imp: ab_glyph_renderer::AbGlyphTitleText::new(color), |
37 | }); |
38 | |
39 | #[cfg (all(not(feature = "crossfont" ), not(feature = "ab_glyph" )))] |
40 | { |
41 | let _ = color; |
42 | return None; |
43 | } |
44 | } |
45 | |
46 | pub fn update_scale(&mut self, scale: u32) { |
47 | self.imp.update_scale(scale) |
48 | } |
49 | |
50 | pub fn update_title(&mut self, title: impl Into<String>) { |
51 | self.imp.update_title(title) |
52 | } |
53 | |
54 | pub fn update_color(&mut self, color: Color) { |
55 | self.imp.update_color(color) |
56 | } |
57 | |
58 | pub fn pixmap(&self) -> Option<&Pixmap> { |
59 | self.imp.pixmap() |
60 | } |
61 | } |
62 | |