Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more reference to whiskers-widgets in macro code #163

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions crates/whiskers-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn label_from_ident(ident: &Ident) -> String {
/// This is equivalent to:
/// ```ignore
/// #[derive(Sketch, serde::Serialize, serde::Deserialize)]
/// #[serde(crate = "::whiskers::prelude::serde")]
/// #[serde(crate = "::whiskers::exports::serde")]
/// ```
#[proc_macro_attribute]
pub fn sketch_app(_attr: TokenStream, item: TokenStream) -> TokenStream {
Expand All @@ -38,7 +38,7 @@ pub fn sketch_app(_attr: TokenStream, item: TokenStream) -> TokenStream {
/// This is equivalent to:
/// ```ignore
/// #[derive(Widget, serde::Serialize, serde::Deserialize)]
/// #[serde(crate = "::whiskers_widgets::exports::serde")]
/// #[serde(crate = "::whiskers::exports::serde")]
/// ```
#[proc_macro_attribute]
pub fn sketch_widget(_attr: TokenStream, item: TokenStream) -> TokenStream {
Expand Down Expand Up @@ -67,7 +67,7 @@ pub fn sketch_derive(input: TokenStream) -> TokenStream {
};

TokenStream::from(quote! {
impl whiskers_widgets::WidgetApp for #name {
impl ::whiskers::prelude::whiskers_widgets::WidgetApp for #name {
fn name(&self) -> String {
stringify!(#name).to_string()
}
Expand Down Expand Up @@ -104,9 +104,9 @@ fn process_struct(fields: Fields, name: &Ident, widget_name: &Ident) -> TokenStr
#[derive(Default)]
pub struct #widget_name;

impl whiskers_widgets::Widget<#name> for #widget_name {
impl ::whiskers::prelude::whiskers_widgets::Widget<#name> for #widget_name {
fn ui(&self, ui: &mut ::whiskers::exports::egui::Ui, label: &str, value: &mut #name) -> bool {
::whiskers_widgets::collapsing_header(ui, label.trim_end_matches(':'), "", true, |ui|{
::whiskers::prelude::whiskers_widgets::collapsing_header(ui, label.trim_end_matches(':'), "", true, |ui|{
#fields_ui
})
.unwrap_or(false)
Expand All @@ -117,7 +117,7 @@ fn process_struct(fields: Fields, name: &Ident, widget_name: &Ident) -> TokenStr
}
}

impl whiskers_widgets::WidgetMapper<#name> for #name {
impl ::whiskers::prelude::whiskers_widgets::WidgetMapper<#name> for #name {
type Type = #widget_name;
}
})
Expand Down Expand Up @@ -262,7 +262,7 @@ fn process_enum(
#[derive(Default)]
pub struct #widget_name;

impl whiskers_widgets::Widget<#name> for #widget_name {
impl ::whiskers::prelude::whiskers_widgets::Widget<#name> for #widget_name {
fn ui(&self, ui: &mut ::whiskers::exports::egui::Ui, label: &str, value: &mut #name) -> bool {
#pre_combo_code

Expand All @@ -279,7 +279,7 @@ fn process_enum(
}
}

impl whiskers_widgets::WidgetMapper<#name> for #name {
impl ::whiskers::prelude::whiskers_widgets::WidgetMapper<#name> for #name {
type Type = #widget_name;
}
};
Expand Down Expand Up @@ -355,15 +355,15 @@ fn process_enum(
#(
(
&mut |ui| {
<#field_types as whiskers_widgets::WidgetMapper<#field_types>>::Type::default()
<#field_types as ::whiskers::prelude::whiskers_widgets::WidgetMapper<#field_types>>::Type::default()
#chained_calls
.ui(
ui,
#field_labels,
#field_names,
)
},
&<#field_types as whiskers_widgets::WidgetMapper<#field_types>>::Type::use_grid,
&<#field_types as ::whiskers::prelude::whiskers_widgets::WidgetMapper<#field_types>>::Type::use_grid,
)
),*
}
Expand All @@ -390,7 +390,7 @@ fn process_enum(
#[derive(Default)]
pub struct #widget_name;

impl whiskers_widgets::Widget<#name> for #widget_name {
impl ::whiskers::prelude::whiskers_widgets::Widget<#name> for #widget_name {
fn ui(&self, ui: &mut ::whiskers::exports::egui::Ui, label: &str, value: &mut #name) -> bool {

// draw the UI for a bunch of fields, swapping the grid on and off based on grid support
Expand All @@ -417,7 +417,7 @@ fn process_enum(
}
}

let (header_changed, body_changed) = ::whiskers_widgets::enum_collapsing_header(
let (header_changed, body_changed) = ::whiskers::prelude::whiskers_widgets::enum_collapsing_header(
ui,
label,
value,
Expand Down Expand Up @@ -459,7 +459,7 @@ fn process_enum(
}
}

impl whiskers_widgets::WidgetMapper<#name> for #name {
impl ::whiskers::prelude::whiskers_widgets::WidgetMapper<#name> for #name {
type Type = #widget_name;
}
})
Expand Down Expand Up @@ -562,12 +562,12 @@ fn process_fields(
output.extend(quote! {
(
&|ui, obj| {
<#field_type as whiskers_widgets::WidgetMapper<#field_type>>::Type::default()
<#field_type as ::whiskers::prelude::whiskers_widgets::WidgetMapper<#field_type>>::Type::default()
#chained_call
.ui(ui, #formatted_label, &mut obj.#field_access)

},
&<#field_type as whiskers_widgets::WidgetMapper<#field_type>>::Type::use_grid,
&<#field_type as ::whiskers::prelude::whiskers_widgets::WidgetMapper<#field_type>>::Type::use_grid,
),
});
}
Expand Down
Loading