Skip to main content

ferroui_base/media/
text_decorations.rs

1use crate::media::{TextDecoration, TextDecorationCollection, TextDecorationLocation};
2
3/// Defines a set of commonly used text decorations.
4pub struct TextDecorations;
5
6fn create(location: TextDecorationLocation) -> TextDecorationCollection {
7    let text_decoration = TextDecoration::new();
8    text_decoration.set_location(location);
9    TextDecorationCollection::from_items([text_decoration])
10}
11
12macro_rules! text_decorations {
13    ($(#[$meta:meta])* $name:ident, $location:ident) => {
14        $(#[$meta])*
15        pub fn $name() -> TextDecorationCollection {
16            crate::ferro_thread_local! {
17                static VALUE: TextDecorationCollection = create(TextDecorationLocation::$location);
18            }
19            VALUE.with(Clone::clone)
20        }
21    };
22}
23
24impl TextDecorations {
25    text_decorations!(
26        /// Gets a value containing a single underline.
27        underline, Underline
28    );
29
30    text_decorations!(
31        /// Gets a value containing a single strikethrough.
32        strikethrough, Strikethrough
33    );
34
35    text_decorations!(
36        /// Gets a value containing a single overline.
37        overline, Overline
38    );
39
40    text_decorations!(
41        /// Gets a value containing a single baseline.
42        baseline, Baseline
43    );
44}