Skip to content

Commit

Permalink
Remove egui_material_icons proc macro and generate the code via scrip…
Browse files Browse the repository at this point in the history
…t instead
  • Loading branch information
lucasmerlin committed Oct 2, 2024
1 parent d638bea commit bf7b563
Show file tree
Hide file tree
Showing 9 changed files with 3,691 additions and 34 deletions.
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ thumbhash = ["dep:egui_thumbhash"]
tokio = ["egui_suspense/tokio", "egui_infinite_scroll/tokio"]
virtual_list = ["dep:egui_virtual_list"]
material_icons = ["dep:egui_material_icons"]
material_icons_proc_macro = ["dep:material_icons_proc_macro"]

[dependencies]
egui_animation = { workspace = true, optional = true }
Expand All @@ -65,7 +64,6 @@ egui_suspense = { workspace = true, optional = true }
egui_thumbhash = { workspace = true, optional = true }
egui_virtual_list = { workspace = true, optional = true }
egui_material_icons = { workspace = true, optional = true }
material_icons_proc_macro = { workspace = true, optional = true }


[workspace]
Expand All @@ -86,7 +84,6 @@ egui_virtual_list = { path = "./crates/egui_virtual_list", version = "0.4.0" }
egui_infinite_scroll = { path = "./crates/egui_infinite_scroll", version = "0.4.0" }
egui_thumbhash = { path = "./crates/egui_thumbhash", version = "0.4.0" }
egui_material_icons = { path = "./crates/egui_material_icons", version = "0.1.0" }
material_icons_proc_macro = { path = "./crates/material_icons_proc_macro", version = "0.1.0" }
hello_egui = { path = ".", version = "0.5.0" }

egui = { version = "0.29", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion crates/egui_material_icons/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ repository = "https://github.com/lucasmerlin/hello_egui/tree/main/crates/egui_ma

[dependencies]
egui.workspace = true
material_icons_proc_macro.workspace = true

[dev-dependencies]
eframe = { workspace = true, default-features = true }
Expand Down
3 changes: 3 additions & 0 deletions crates/egui_material_icons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ egui_material_icons::initialize(&cc.egui_ctx);
// later in some ui:
ui.button(egui_material_icons::icons::ICON_ADD);
```

Currently this provides the rounded icons, I could also add a feature to enable different variants.
If you need this just open an issue.
17 changes: 12 additions & 5 deletions crates/material_icons_proc_macro/src/lib.rs → crates/egui_material_icons/gen_codepoints.rs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use proc_macro::TokenStream;
#!/usr/bin/env rust-script
//! This script generates the `src/icons.rs` file from the `MaterialSymbolsRounded-Regular.codepoints` file.
//! Install the `rust-script` crate with `cargo install rust-script` to run this script.
use std::collections::HashSet;
use std::path::PathBuf;

#[proc_macro]
pub fn code_points(_item: TokenStream) -> TokenStream {
let codepoints = include_str!("../MaterialSymbolsRounded-Regular.codepoints");
pub fn main() {
let codepoints = include_str!("./MaterialSymbolsRounded-Regular.codepoints");

let mut names = HashSet::new();

Expand Down Expand Up @@ -32,5 +35,9 @@ pub fn code_points(_item: TokenStream) -> TokenStream {
})
.collect();

code.parse().unwrap()
let file = PathBuf::try_from(file!()).unwrap();
let icons = file.parent().unwrap().join("src").join("icons.rs");
std::fs::write(icons, code).unwrap();

println!("Generated src/icons.rs");
}
Loading

0 comments on commit bf7b563

Please sign in to comment.