From a8e3583e70b76c530222cc22d6979591c96a81b9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 18 Mar 2024 16:20:08 +0300 Subject: [PATCH] refactor: move svg.rs to its own module directory --- tray/src/svg/mod.rs | 1 + tray/src/{svg.rs => svg/utils.rs} | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tray/src/svg/mod.rs rename tray/src/{svg.rs => svg/utils.rs} (97%) diff --git a/tray/src/svg/mod.rs b/tray/src/svg/mod.rs new file mode 100644 index 0000000..b5614dd --- /dev/null +++ b/tray/src/svg/mod.rs @@ -0,0 +1 @@ +pub mod utils; diff --git a/tray/src/svg.rs b/tray/src/svg/utils.rs similarity index 97% rename from tray/src/svg.rs rename to tray/src/svg/utils.rs index 1b55c28..20a194a 100644 --- a/tray/src/svg.rs +++ b/tray/src/svg/utils.rs @@ -1,5 +1,6 @@ use usvg::Tree; +// TODO: read the icon from a svg file instead of hardcoding it const MARK_WHITE_24: &'static str = r##" "##; @@ -10,7 +11,8 @@ pub fn load_icon(enabled: bool) -> Vec { false => vec![to_icon(&MARK_WHITE_24.replace("1.0", "0.4"))], } } -fn to_icon(svg_str: &str) -> ksni::Icon { + +pub fn to_icon(svg_str: &str) -> ksni::Icon { let rtree = Tree::from_str(svg_str, &usvg::Options::default().to_ref()).unwrap(); let pixmap_size = rtree.svg_node().size; let mut pixmap = tiny_skia::Pixmap::new(