mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-27 16:49:15 +01:00
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.
This commit is contained in:
1 parent
0788317deb
commit
96b179ccfc
16 files changed
+149
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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:?}");
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -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", "لا توجد مشاريع حديثة بعد"),
|
||||
];
|
||||
@@ -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"),
|
||||
];
|
||||
@@ -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"),
|
||||
];
|
||||
@@ -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"),
|
||||
];
|
||||
@@ -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"),
|
||||
];
|
||||
@@ -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", "最近のプロジェクトはまだありません"),
|
||||
];
|
||||
@@ -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", "아직 최근 프로젝트가 없습니다"),
|
||||
];
|
||||
@@ -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"),
|
||||
];
|
||||
@@ -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", "暂无最近的项目"),
|
||||
];
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")));
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user