mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-29 04:26:55 -06:00
text, ui: borrow the app at the test call sites, and drop a redundant lifetime
Two things are one level deeper than the first pass at this review: - Nine of the call sites that pass the resolved language are inside test functions, where `app` is owned, so `crate::i18n::language(app)` needs `&app`. `cargo check --all-targets` (which compiles the test modules as well) is what reported them; a check without it does not, which is how they survived the first round. - `clippy -D warnings` rejects the explicit `'static` on `const KANA` / `const HAN`: a const already has one. On this branch `cargo fmt --all --check`, `cargo check -p effectcraft-ui-egui --all-targets`, `cargo clippy -p effectcraft-ui-egui --all-targets -- -D warnings` and `cargo test -p effectcraft-ui-egui` (40 targets, 113 lib tests) are clean.
This commit is contained in:
@@ -615,7 +615,7 @@ mod tests {
|
||||
fn long_press_type_keeps_the_tool_until_vertical_is_selected() {
|
||||
let mut app = EffectcraftApp::new(effectcraft_engine::Session::default());
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(app));
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(&app));
|
||||
frame(&mut app, &ctx, 0.0, vec![]);
|
||||
frame(&mut app, &ctx, 0.1, vec![]);
|
||||
let center = |element: &crate::automation::Element| {
|
||||
|
||||
@@ -2244,7 +2244,7 @@ mod tests {
|
||||
let mut app = EffectcraftApp::new(effectcraft_engine::Session::default());
|
||||
let ctx = egui::Context::default();
|
||||
let tokens = crate::theme::Tokens::for_kind(crate::theme::ThemeKind::Dark);
|
||||
crate::theme::install(&ctx, &tokens, language(app));
|
||||
crate::theme::install(&ctx, &tokens, language(&app));
|
||||
crate::panels::settings::open(&mut app, "general");
|
||||
let mut out = ctx.run_ui(egui::RawInput::default(), |_| {
|
||||
crate::panels::settings::show(&mut app, &ctx, &tokens);
|
||||
|
||||
@@ -548,7 +548,7 @@ mod tests {
|
||||
fn app() -> (EffectcraftApp, egui::Context) {
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = EffectcraftApp::new(effectcraft_engine::Session::default());
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(app));
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(&app));
|
||||
app.session.execute("comp.new", json!({"name": "Main", "width": 640, "height": 360})).unwrap();
|
||||
(app, ctx)
|
||||
}
|
||||
|
||||
@@ -844,7 +844,7 @@ mod tests {
|
||||
fn premiere_export_dialog() {
|
||||
let mut app = EffectcraftApp::new(effectcraft_engine::Session::default());
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(app));
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(&app));
|
||||
app.session.execute("comp.new", json!({"name": "Spot", "width": 64, "height": 36, "frameRate": 25, "duration": 1})).unwrap();
|
||||
app.session.execute("layer.newSolid", json!({"color": "#ff0000"})).unwrap();
|
||||
crate::menus::invoke(&mut app, &ctx, "file.exportTimeline", json!({})).unwrap();
|
||||
|
||||
@@ -540,7 +540,7 @@ mod tests {
|
||||
s.prefs.push_recent("/projects/Alpha.ecproj");
|
||||
let mut app = EffectcraftApp::new(s);
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(app));
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(&app));
|
||||
ctx.run_ui(Default::default(), |_| {}).textures_delta.clear();
|
||||
ctx.run_ui(Default::default(), |ui| {
|
||||
app.auto.begin_frame();
|
||||
@@ -573,7 +573,7 @@ mod tests {
|
||||
app.ui.start_screen = true;
|
||||
app.ui.home_learn = true;
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(app));
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(&app));
|
||||
let frame = |app: &mut EffectcraftApp| {
|
||||
ctx.run_ui(Default::default(), |ui| {
|
||||
app.auto.begin_frame();
|
||||
|
||||
@@ -194,7 +194,7 @@ mod tests {
|
||||
fn gallery_lists_renders_and_opens_templates() {
|
||||
let mut app = app_with_store();
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(app));
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(&app));
|
||||
// File ▸ New ▸ New Project from Template… opens the Templates tab.
|
||||
let ev = app.session.execute("file.newFromTemplate", json!({})).unwrap();
|
||||
assert_eq!(ev["frontend"], "file.newFromTemplate");
|
||||
@@ -250,7 +250,7 @@ mod tests {
|
||||
fn my_custom_rgb_dialog() {
|
||||
let mut app = app_with_store();
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(app));
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(&app));
|
||||
// Menu check marks follow the active comp's viewer.
|
||||
app.session.execute("comp.new", json!({"name": "C", "width": 64, "height": 48})).unwrap();
|
||||
let item = crate::menus::menu_items(&app).into_iter().find(|m| m.id == "view.customRgb").expect("menu item");
|
||||
|
||||
@@ -170,7 +170,7 @@ mod tests {
|
||||
fn app() -> (EffectcraftApp, egui::Context) {
|
||||
let ctx = egui::Context::default();
|
||||
let app = EffectcraftApp::new(effectcraft_engine::Session::default());
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(app));
|
||||
crate::theme::install(&ctx, &app.tokens, crate::i18n::language(&app));
|
||||
(app, ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -316,8 +316,8 @@ fn install_cjk_fallbacks(family_fonts: &mut FontDefinitions, language: &str) ->
|
||||
use effectcraft_text::fonts;
|
||||
// Kana is unambiguously Japanese; Han ideographs are shared, so the order decides which
|
||||
// language's face draws them.
|
||||
const KANA: (char, &'static str) = ('あ', "japanese-system");
|
||||
const HAN: (char, &'static str) = ('文', "chinese-system");
|
||||
const KANA: (char, &str) = ('あ', "japanese-system");
|
||||
const HAN: (char, &str) = ('文', "chinese-system");
|
||||
// Han text follows the interface language, not the operating system's locale.
|
||||
fonts::set_cjk_locale(cjk_locale(language));
|
||||
let base = fonts::resolve("Inter", "Regular").face;
|
||||
|
||||
Reference in New Issue
Block a user