From 96b179ccfcd4cd365476ece6d9a4f87373e6cf7f Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 2 Nov 2026 04:15:55 +0700 Subject: [PATCH] Start window: new, open or a recent project at launch The app opens on the sample project, which left no obvious place to pick a project. A start window now offers New project, Open, the recent projects and Continue with the sample project, with Show at startup (also Settings > Interface > Start window). It opens at launch in the desktop and web apps, but not when a file is given on the command line or the app runs with --control. Labels translated into the other nine UI languages; a UI test covers New project, Continue and the startup setting. --- README.md | 2 +- apps/texturecraft-web/src/web.rs | 1 + apps/texturecraft/src/main.rs | 3 ++ crates/ui-egui/src/i18n/ar.rs | 4 ++ crates/ui-egui/src/i18n/de.rs | 4 ++ crates/ui-egui/src/i18n/es.rs | 4 ++ crates/ui-egui/src/i18n/fr.rs | 4 ++ crates/ui-egui/src/i18n/it.rs | 4 ++ crates/ui-egui/src/i18n/ja.rs | 4 ++ crates/ui-egui/src/i18n/ko.rs | 4 ++ crates/ui-egui/src/i18n/pt_br.rs | 4 ++ crates/ui-egui/src/i18n/zh_hans.rs | 4 ++ crates/ui-egui/src/state.rs | 6 +++ crates/ui-egui/src/windows.rs | 70 ++++++++++++++++++++++++++++ crates/ui-egui/tests/start_window.rs | 30 ++++++++++++ docs/features.md | 2 + 16 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/tests/start_window.rs diff --git a/README.md b/README.md index e6a08036..b9772d80 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ cd apps/texturecraft-web && trunk serve # web build cargo xtask ci # fmt, clippy, tests, layering, wasm ``` -You need Rust 1.95 or newer. The app opens with a baked sample project; **File ▸ New project** starts +You need Rust 1.95 or newer. The app opens with a baked sample project and a start window (new project, open, recent projects); **File ▸ New project** starts from a built-in mesh, a project template or your own mesh file (UVs are generated if it has none). Japanese, Chinese, Korean and Arabic interface text uses the fonts of diff --git a/apps/texturecraft-web/src/web.rs b/apps/texturecraft-web/src/web.rs index 96bbc70c..37752314 100644 --- a/apps/texturecraft-web/src/web.rs +++ b/apps/texturecraft-web/src/web.rs @@ -54,6 +54,7 @@ async fn run(canvas: web_sys::HtmlCanvasElement) -> Result<(), String> { options, Box::new(|cc| { let mut app = TextureCraftApp::new(cc, session); + app.ui.windows.start = app.ui.prefs.start_window; if let Some(rs) = &cc.wgpu_render_state { let backend = rs.adapter.get_info().backend; log::info!("TextureCraft: wgpu backend {backend:?}"); diff --git a/apps/texturecraft/src/main.rs b/apps/texturecraft/src/main.rs index e1cbb6c2..905a9d85 100644 --- a/apps/texturecraft/src/main.rs +++ b/apps/texturecraft/src/main.rs @@ -170,6 +170,8 @@ fn main() { let viewport = title_bar.viewport(viewport); let options = eframe::NativeOptions { viewport, renderer: eframe::Renderer::Wgpu, persistence_path, ..Default::default() }; let control = args.control; + // The start window offers new, open and recent projects, unless a file was given or a script drives the app. + let start = args.file.is_none() && control.is_none(); let r = eframe::run_native( APP_NAME, options, @@ -181,6 +183,7 @@ fn main() { let window_frame = window_frame::service(cc, matches!(title_bar, TitleBar::App(_))); let mut app = TextureCraftApp::new(cc, session); app.title_bar = title_bar; + app.ui.windows.start = start && app.ui.prefs.start_window; if let Some(port) = control { app.control = Some(control_server::start(port, cc.egui_ctx.clone())); } diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rs index 0320cbf7..3b2c060a 100644 --- a/crates/ui-egui/src/i18n/ar.rs +++ b/crates/ui-egui/src/i18n/ar.rs @@ -924,4 +924,8 @@ pub const TABLE: &[(&str, &str)] = &[ "Use the operating system's window frame and buttons instead of TextureCraft's own title bar", "استخدام إطار وأزرار نافذة نظام التشغيل بدلاً من شريط عنوان TextureCraft الخاص", ), + ("Start window", "نافذة البدء"), + ("Show at startup", "إظهار عند بدء التشغيل"), + ("Continue with the sample project", "المتابعة مع المشروع النموذجي"), + ("No recent projects yet", "لا توجد مشاريع حديثة بعد"), ]; diff --git a/crates/ui-egui/src/i18n/de.rs b/crates/ui-egui/src/i18n/de.rs index ce534a6f..fb59610b 100644 --- a/crates/ui-egui/src/i18n/de.rs +++ b/crates/ui-egui/src/i18n/de.rs @@ -979,4 +979,8 @@ pub const TABLE: &[(&str, &str)] = &[ "Use the operating system's window frame and buttons instead of TextureCraft's own title bar", "Fensterrahmen und Fenstertasten des Betriebssystems statt der eigenen Titelleiste von TextureCraft verwenden", ), + ("Start window", "Startfenster"), + ("Show at startup", "Beim Start anzeigen"), + ("Continue with the sample project", "Mit dem Beispielprojekt fortfahren"), + ("No recent projects yet", "Noch keine zuletzt geöffneten Projekte"), ]; diff --git a/crates/ui-egui/src/i18n/es.rs b/crates/ui-egui/src/i18n/es.rs index 2b57afd8..fbb8cef2 100644 --- a/crates/ui-egui/src/i18n/es.rs +++ b/crates/ui-egui/src/i18n/es.rs @@ -964,4 +964,8 @@ pub const TABLE: &[(&str, &str)] = &[ "Use the operating system's window frame and buttons instead of TextureCraft's own title bar", "Usar el marco y los botones de ventana del sistema operativo en lugar de la barra de título propia de TextureCraft", ), + ("Start window", "Ventana de inicio"), + ("Show at startup", "Mostrar al iniciar"), + ("Continue with the sample project", "Continuar con el proyecto de ejemplo"), + ("No recent projects yet", "Aún no hay proyectos recientes"), ]; diff --git a/crates/ui-egui/src/i18n/fr.rs b/crates/ui-egui/src/i18n/fr.rs index 0e72b031..f24a379f 100644 --- a/crates/ui-egui/src/i18n/fr.rs +++ b/crates/ui-egui/src/i18n/fr.rs @@ -979,4 +979,8 @@ pub const TABLE: &[(&str, &str)] = &[ "Use the operating system's window frame and buttons instead of TextureCraft's own title bar", "Utiliser le cadre et les boutons de fenêtre du système d'exploitation au lieu de la barre de titre de TextureCraft", ), + ("Start window", "Fenêtre de démarrage"), + ("Show at startup", "Afficher au démarrage"), + ("Continue with the sample project", "Continuer avec le projet d'exemple"), + ("No recent projects yet", "Aucun projet récent pour l'instant"), ]; diff --git a/crates/ui-egui/src/i18n/it.rs b/crates/ui-egui/src/i18n/it.rs index 9260b188..00d2706a 100644 --- a/crates/ui-egui/src/i18n/it.rs +++ b/crates/ui-egui/src/i18n/it.rs @@ -973,4 +973,8 @@ pub const TABLE: &[(&str, &str)] = &[ "Use the operating system's window frame and buttons instead of TextureCraft's own title bar", "Usa la cornice e i pulsanti della finestra del sistema operativo invece della barra del titolo di TextureCraft", ), + ("Start window", "Finestra iniziale"), + ("Show at startup", "Mostra all'avvio"), + ("Continue with the sample project", "Continua con il progetto di esempio"), + ("No recent projects yet", "Ancora nessun progetto recente"), ]; diff --git a/crates/ui-egui/src/i18n/ja.rs b/crates/ui-egui/src/i18n/ja.rs index 2e333ab9..845812ce 100644 --- a/crates/ui-egui/src/i18n/ja.rs +++ b/crates/ui-egui/src/i18n/ja.rs @@ -946,4 +946,8 @@ pub const TABLE: &[(&str, &str)] = &[ "Use the operating system's window frame and buttons instead of TextureCraft's own title bar", "TextureCraft 独自のタイトルバーの代わりに、OS のウィンドウ枠とボタンを使います", ), + ("Start window", "スタートウィンドウ"), + ("Show at startup", "起動時に表示"), + ("Continue with the sample project", "サンプルプロジェクトで続ける"), + ("No recent projects yet", "最近のプロジェクトはまだありません"), ]; diff --git a/crates/ui-egui/src/i18n/ko.rs b/crates/ui-egui/src/i18n/ko.rs index 3945c9a9..efec5624 100644 --- a/crates/ui-egui/src/i18n/ko.rs +++ b/crates/ui-egui/src/i18n/ko.rs @@ -931,4 +931,8 @@ pub const TABLE: &[(&str, &str)] = &[ "Use the operating system's window frame and buttons instead of TextureCraft's own title bar", "TextureCraft 자체 제목 표시줄 대신 운영 체제의 창 테두리와 버튼을 사용합니다", ), + ("Start window", "시작 창"), + ("Show at startup", "시작 시 표시"), + ("Continue with the sample project", "샘플 프로젝트로 계속"), + ("No recent projects yet", "아직 최근 프로젝트가 없습니다"), ]; diff --git a/crates/ui-egui/src/i18n/pt_br.rs b/crates/ui-egui/src/i18n/pt_br.rs index 788df7f9..ff1268ee 100644 --- a/crates/ui-egui/src/i18n/pt_br.rs +++ b/crates/ui-egui/src/i18n/pt_br.rs @@ -961,4 +961,8 @@ pub const TABLE: &[(&str, &str)] = &[ "Use the operating system's window frame and buttons instead of TextureCraft's own title bar", "Usar a moldura e os botões de janela do sistema operacional em vez da barra de título própria do TextureCraft", ), + ("Start window", "Janela inicial"), + ("Show at startup", "Mostrar ao iniciar"), + ("Continue with the sample project", "Continuar com o projeto de exemplo"), + ("No recent projects yet", "Nenhum projeto recente ainda"), ]; diff --git a/crates/ui-egui/src/i18n/zh_hans.rs b/crates/ui-egui/src/i18n/zh_hans.rs index 3de5246c..c44cf1b6 100644 --- a/crates/ui-egui/src/i18n/zh_hans.rs +++ b/crates/ui-egui/src/i18n/zh_hans.rs @@ -877,4 +877,8 @@ pub const TABLE: &[(&str, &str)] = &[ "Use the operating system's window frame and buttons instead of TextureCraft's own title bar", "使用操作系统的窗口边框和按钮,而不是 TextureCraft 自己的标题栏", ), + ("Start window", "启动窗口"), + ("Show at startup", "启动时显示"), + ("Continue with the sample project", "继续使用示例项目"), + ("No recent projects yet", "暂无最近的项目"), ]; diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 2e137e13..cfae41bc 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -61,6 +61,9 @@ pub struct Windows { /// Browser File › Export Mesh: the download format choice. #[serde(default)] pub export_mesh: bool, + /// The start window: new, open, recent projects (the app opens it at launch). + #[serde(skip)] + pub start: bool, } /// Edit › Settings. @@ -82,6 +85,8 @@ pub struct Prefs { pub accent: crate::theme::Accent, /// The system draws the window's title bar instead of TextureCraft (desktop; read at startup). pub system_title_bar: bool, + /// Show the start window at launch. + pub start_window: bool, } impl Default for Prefs { @@ -94,6 +99,7 @@ impl Default for Prefs { brightness: crate::theme::Brightness::default(), accent: crate::theme::Accent::default(), system_title_bar: false, + start_window: true, } } } diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 2ecafdd6..eab0046e 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -18,6 +18,7 @@ use crate::theme::{Accent, Brightness, Tokens, caption}; use crate::widgets::{color_swatch, combo, icon_button, primary_button, slider}; pub fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { + start(app, ctx); new_project(app, ctx); about(app, ctx); settings(app, ctx); @@ -236,6 +237,72 @@ pub(crate) fn history(app: &mut TextureCraftApp, ui: &mut Ui) { }); } +/// What the start window was asked for. +enum Start { + Menu(&'static str), + Recent(String), + Close, +} + +/// The start window: a new project, a project file or a recent one, or the sample that is open. +fn start(app: &mut TextureCraftApp, ctx: &egui::Context) { + if !app.ui.windows.start { + return; + } + let tk = Tokens::get(ctx); + let mut open = true; + let mut action = None; + dialog("start", "TextureCraft", &mut open).min_width(380.0).show(ctx, |ui| { + ui.horizontal(|ui| { + if ui.add(primary_button(ui, tr("New project..."))).clicked() { + action = Some(Start::Menu("ui.newProject")); + } + if ui.button(tr("Open...")).clicked() { + action = Some(Start::Menu("file.open")); + } + }); + if file_dialogs_available() { + ui.add_space(8.0); + ui.label(caption(tr("Recent projects"))); + if app.ui.recent.is_empty() { + ui.label(RichText::new(tr("No recent projects yet")).color(tk.text_dim)); + } + for path in &app.ui.recent { + let name = std::path::Path::new(path).file_name().and_then(|n| n.to_str()).unwrap_or(path); + if ui + .add(egui::Button::selectable(false, format!("{} {name}", ic::FILE)).min_size(vec2(ui.available_width(), 0.0))) + .on_hover_text(path) + .clicked() + { + action = Some(Start::Recent(path.clone())); + } + } + } + ui.add_space(8.0); + ui.separator(); + ui.horizontal(|ui| { + ui.checkbox(&mut app.ui.prefs.start_window, tr("Show at startup")); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if ui.button(tr("Continue with the sample project")).clicked() { + action = Some(Start::Close); + } + }); + }); + }); + if let Some(a) = action { + app.ui.windows.start = false; + match a { + Start::Menu(id) => crate::menus::invoke(app, ctx, id), + #[cfg(not(target_arch = "wasm32"))] + Start::Recent(path) => open_path(app, &path), + _ => {} + } + } + if !open { + app.ui.windows.start = false; + } +} + fn new_project(app: &mut TextureCraftApp, ctx: &egui::Context) { if !app.ui.windows.new_project { return; @@ -408,6 +475,9 @@ fn settings(app: &mut TextureCraftApp, ctx: &egui::Context) { .on_hover_text(tr("Use the operating system's window frame and buttons instead of TextureCraft's own title bar")); ui.end_row(); } + ui.label(tr("Start window")); + ui.checkbox(&mut p.start_window, tr("Show at startup")); + ui.end_row(); }); ui.add_space(8.0); ui.label(caption(tr("Viewport"))); diff --git a/crates/ui-egui/tests/start_window.rs b/crates/ui-egui/tests/start_window.rs new file mode 100644 index 00000000..9c5415b4 --- /dev/null +++ b/crates/ui-egui/tests/start_window.rs @@ -0,0 +1,30 @@ +//! The start window: New project opens its dialog, Continue keeps the open project, and the +//! startup choice is a setting. + +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable; +use texturecraft_ui_egui::TextureCraftApp; + +fn harness() -> Harness<'static, TextureCraftApp> { + let session = texturecraft_engine::sample_session(256, 64).unwrap(); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + h.state_mut().ui.windows.start = true; + h.run_steps(3); + h +} + +#[test] +fn start_window_choices() { + let mut h = harness(); + h.get_by_label("New project...").click(); + h.run_steps(3); + assert!(!h.state().ui.windows.start && h.state().ui.windows.new_project, "New project opens its dialog"); + + let mut h = harness(); + h.get_by_label("Show at startup").click(); + h.get_by_label("Continue with the sample project").click(); + h.run_steps(3); + assert!(!h.state().ui.windows.start && !h.state().ui.windows.new_project); + assert!(!h.state().ui.prefs.start_window, "unticked: not shown next time"); + assert_eq!(h.state().session.doc.project.texture_sets.len(), 2, "the sample stays open"); +} diff --git a/docs/features.md b/docs/features.md index cbec3d46..34c4e70f 100644 --- a/docs/features.md +++ b/docs/features.md @@ -103,6 +103,8 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA strip, and Settings › Interface › System title bar for the system's frame instead. - **Dockable, tabbed and floating panels**, saved layouts, and panels that reopen where you closed them. +- A **start window** at launch: a new project, a project file, a recent project or the sample + (Settings › Interface › Start window). - A **shortcut editor** with conflict detection, and every shortcut shown in its tooltip. - **10 languages:** English, French, German, Spanish, Portuguese, Italian, Japanese, Chinese, Korean and Arabic, switchable live.