mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 09:08:11 +00:00
Restore generated imaging stories to registry
This commit is contained in:
@@ -111,6 +111,14 @@ pub(super) fn check(cx: &Cx<'_>, out: &mut Vec<Finding>) {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn detects_story_attributes_inside_repeated_macro_expansions() {
|
||||
let source = r#"macro_rules! stories { ($($name:ident),*) => { $( #[story(Widget, covers = [])] fn $name() {} )* }; }"#;
|
||||
let file = syn::parse_file(source).expect("valid macro definition");
|
||||
let syn::Item::Macro(item) = &file.items[0] else { panic!("expected macro definition") };
|
||||
assert!(has_registration(item.mac.tokens.clone()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detects_hidden_registrations_and_allows_unregistered_derive() {
|
||||
let hidden = TokenStream::from_str("#[derive(Component)] struct A; #[trial] fn t() {} ").unwrap_or_default();
|
||||
|
||||
@@ -157,28 +157,62 @@ fn layer_style_styles(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
host(ui, data, || page_of(&[EffectKind::DropShadow], Some(LayerStylePage::Styles)), &rgb(&words))
|
||||
}
|
||||
|
||||
/// One story per effect kind: the dialog on that effect's page.
|
||||
macro_rules! effect_stories {
|
||||
($($name:ident => $kind:ident),* $(,)?) => {
|
||||
$(
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn $name(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::$kind], None), &rgb(&words))
|
||||
}
|
||||
)*
|
||||
};
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_bevel_emboss(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::BevelEmboss], None), &rgb(&words))
|
||||
}
|
||||
|
||||
effect_stories! {
|
||||
layer_style_bevel_emboss => BevelEmboss,
|
||||
layer_style_stroke => Stroke,
|
||||
layer_style_inner_shadow => InnerShadow,
|
||||
layer_style_inner_glow => InnerGlow,
|
||||
layer_style_satin => Satin,
|
||||
layer_style_color_overlay => ColorOverlay,
|
||||
layer_style_gradient_overlay => GradientOverlay,
|
||||
layer_style_pattern_overlay => PatternOverlay,
|
||||
layer_style_outer_glow => OuterGlow,
|
||||
layer_style_drop_shadow => DropShadow,
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_stroke(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::Stroke], None), &rgb(&words))
|
||||
}
|
||||
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_inner_shadow(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::InnerShadow], None), &rgb(&words))
|
||||
}
|
||||
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_inner_glow(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::InnerGlow], None), &rgb(&words))
|
||||
}
|
||||
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_satin(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::Satin], None), &rgb(&words))
|
||||
}
|
||||
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_color_overlay(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::ColorOverlay], None), &rgb(&words))
|
||||
}
|
||||
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_gradient_overlay(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::GradientOverlay], None), &rgb(&words))
|
||||
}
|
||||
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_pattern_overlay(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::PatternOverlay], None), &rgb(&words))
|
||||
}
|
||||
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_outer_glow(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::OuterGlow], None), &rgb(&words))
|
||||
}
|
||||
|
||||
#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)]
|
||||
fn layer_style_drop_shadow(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<LayerStyleStoryWords>();
|
||||
host(ui, data, || page_of(&[EffectKind::DropShadow], None), &rgb(&words))
|
||||
}
|
||||
|
||||
@@ -81,27 +81,35 @@ fn viewing(view: MaskViewMode) -> SelectMaskSettings {
|
||||
SelectMaskSettings { view, ..SelectMaskSettings::default() }
|
||||
}
|
||||
|
||||
/// One story per view: the workspace with that view chosen.
|
||||
macro_rules! view_story {
|
||||
($name:ident, $view:expr) => {
|
||||
#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)]
|
||||
fn $name(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
show_workspace(ui, data, viewing($view), false)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[story(SelectMaskWorkspace, covers = [Default], drive = Drive::Never)]
|
||||
fn workspace(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
show_workspace(ui, data, SelectMaskSettings::default(), false)
|
||||
}
|
||||
|
||||
view_story!(view_marching_ants, MaskViewMode::MarchingAnts);
|
||||
view_story!(view_overlay, MaskViewMode::Overlay);
|
||||
view_story!(view_on_black, MaskViewMode::OnBlack);
|
||||
view_story!(view_on_white, MaskViewMode::OnWhite);
|
||||
view_story!(view_black_and_white, MaskViewMode::BlackAndWhite);
|
||||
view_story!(view_on_layers, MaskViewMode::OnLayers);
|
||||
#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)]
|
||||
fn view_marching_ants(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
show_workspace(ui, data, viewing(MaskViewMode::MarchingAnts), false)
|
||||
}
|
||||
#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)]
|
||||
fn view_overlay(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
show_workspace(ui, data, viewing(MaskViewMode::Overlay), false)
|
||||
}
|
||||
#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)]
|
||||
fn view_on_black(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
show_workspace(ui, data, viewing(MaskViewMode::OnBlack), false)
|
||||
}
|
||||
#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)]
|
||||
fn view_on_white(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
show_workspace(ui, data, viewing(MaskViewMode::OnWhite), false)
|
||||
}
|
||||
#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)]
|
||||
fn view_black_and_white(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
show_workspace(ui, data, viewing(MaskViewMode::BlackAndWhite), false)
|
||||
}
|
||||
#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)]
|
||||
fn view_on_layers(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
show_workspace(ui, data, viewing(MaskViewMode::OnLayers), false)
|
||||
}
|
||||
|
||||
#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)]
|
||||
fn workspace_with_refinements(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
|
||||
Reference in New Issue
Block a user