diff --git a/crates/egui-actions/Cargo.toml b/crates/egui-actions/Cargo.toml deleted file mode 100644 index 8c91f32..0000000 --- a/crates/egui-actions/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Topola contributors -# -# SPDX-License-Identifier: MIT - -[package] -name = "egui-actions" -version = "0.1.0" -edition = "2021" - -[lib] -proc-macro = true - -[dependencies] -egui = "0.29" -proc-macro2 = "1.0" -quote = "1.0" -syn = "2.0" diff --git a/crates/egui-actions/src/implementation.rs b/crates/egui-actions/src/implementation.rs deleted file mode 100644 index b56bf10..0000000 --- a/crates/egui-actions/src/implementation.rs +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: 2025 Topola contributors -// -// SPDX-License-Identifier: MIT - -use proc_macro2::TokenStream; -use quote::quote; -use syn::{Data, DeriveInput, Field, Fields}; - -pub(super) fn impl_derive_actions(input: &DeriveInput) -> TokenStream { - let name = &input.ident; - let new_body = impl_new_body(&input.data); - - quote! { - impl #name { - pub fn new(tr: &Translator) -> Self { - #new_body - } - } - } -} - -pub(super) fn impl_new_body(data: &Data) -> TokenStream { - match data { - Data::Struct(data) => match &data.fields { - Fields::Named(fields) => { - let fields = fields.named.iter().map(impl_new_field); - - quote! { - Self { - #(#fields)* - } - } - } - _ => unimplemented!(), - }, - _ => unimplemented!(), - } -} - -pub(super) fn impl_new_field(field: &Field) -> TokenStream { - let name = &field.ident; - let typ = &field.ty; - - quote! { - #name: #typ::new(tr), - } -} diff --git a/crates/egui-actions/src/lib.rs b/crates/egui-actions/src/lib.rs deleted file mode 100644 index 4220e57..0000000 --- a/crates/egui-actions/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Topola contributors -// -// SPDX-License-Identifier: MIT - -use proc_macro::TokenStream; -use syn::DeriveInput; - -mod implementation; - -#[proc_macro_derive(Actions)] -pub fn derive_actions(input: TokenStream) -> TokenStream { - let input = syn::parse_macro_input!(input as DeriveInput); - implementation::impl_derive_actions(&input).into() -} diff --git a/crates/topola-egui/Cargo.toml b/crates/topola-egui/Cargo.toml index 0671db4..b98b204 100644 --- a/crates/topola-egui/Cargo.toml +++ b/crates/topola-egui/Cargo.toml @@ -17,7 +17,6 @@ xdg-portal = ["rfd/async-std", "rfd/xdg-portal"] [dependencies] derive-getters.workspace = true egui = "0.29" -egui-actions.path = "../egui-actions" fluent-templates = "0.11" geo.workspace = true icu_experimental = "0.2" diff --git a/crates/topola-egui/src/action.rs b/crates/topola-egui/src/action.rs index fbddc57..6effe39 100644 --- a/crates/topola-egui/src/action.rs +++ b/crates/topola-egui/src/action.rs @@ -32,6 +32,7 @@ impl Action { ) } + #[inline] pub fn into_trigger(self) -> Trigger { Trigger { action: self, @@ -39,6 +40,7 @@ impl Action { } } + #[inline(always)] pub fn into_switch(self) -> Switch { Switch { action: self } } diff --git a/crates/topola-egui/src/actions.rs b/crates/topola-egui/src/actions.rs index e760d8a..c9dfbdc 100644 --- a/crates/topola-egui/src/actions.rs +++ b/crates/topola-egui/src/actions.rs @@ -8,7 +8,6 @@ use crate::{ }; use egui::{Context, Ui}; -use egui_actions::Actions; use topola::autorouter::AutorouterOptions; pub struct FileActions { @@ -300,7 +299,6 @@ impl HelpActions { } } -#[derive(Actions)] pub struct Actions { pub file: FileActions, pub edit: EditActions, @@ -309,3 +307,16 @@ pub struct Actions { pub inspect: InspectActions, pub help: HelpActions, } + +impl Actions { + pub fn new(tr: &Translator) -> Self { + Self { + file: FileActions::new(tr), + edit: EditActions::new(tr), + place: PlaceActions::new(tr), + route: RouteActions::new(tr), + inspect: InspectActions::new(tr), + help: HelpActions::new(tr), + } + } +} diff --git a/crates/topola-egui/src/menu_bar.rs b/crates/topola-egui/src/menu_bar.rs index b8b5232..1caeeed 100644 --- a/crates/topola-egui/src/menu_bar.rs +++ b/crates/topola-egui/src/menu_bar.rs @@ -15,6 +15,7 @@ use topola::{ }; use crate::{ + action::{Action, Switch, Trigger}, actions::Actions, app::{execute, handle_file}, translator::Translator,