New tab: no stale fillet preview, and + always opens a tab (#1533)

Co-Authored-By: Pablo López <pablopeza@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-10-15 19:01:04 -04:00
1 parent 7160ff7beb
commit 1b5c2b5847
3 files changed
+67 -3

No files matched your search

+35 -2
View File
@@ -99,7 +99,7 @@ fn swap_in(app: &mut SolveApp, slot: DocSlot) -> DocSlot {
app.cancel_view_animation();
app.viewport.orbit_snap = None;
app.viewport.orbit_free = None;
app.preview = crate::preview::PreviewState::default();
app.preview.reset();
app.viewport.hover = None;
app.menu.props = None;
crate::sketch_attachment_ui::clear(app);
@@ -199,6 +199,24 @@ pub fn new_design(app: &mut SolveApp) {
}
}
/// The tab strip's +: always a new tab, except over the blank design the start page covers
/// (a launch), which New takes as [`new_design`] does.
pub fn new_tab(app: &mut SolveApp) {
if app.file_picker_busy() {
return;
}
if app.home.open && active_is_blank(app) {
new_design(app);
return;
}
app.home.open = false;
if let Err(e) = open_tab(app, Session::default()) {
app.set_status(e, true);
} else {
crate::prefs::apply_new_design(app);
}
}
/// Before opening a file: a fresh tab unless the active design is blank. The empty design,
/// new or already showing, takes Units of new designs so a cancelled open is not millimetres
/// when the preference says otherwise.
@@ -455,7 +473,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
// A file loading into the window keeps the tabs as they are (dragging still moves it).
let idle = !app.file_load.busy();
if presp.on_hover_text("New Design (Ctrl+N)").clicked() && idle {
new_design(app);
new_tab(app);
}
match (shut, pick) {
_ if !idle => {}
@@ -703,6 +721,21 @@ mod tests {
assert!(active_is_blank(&a) && a.home.open);
}
/// The tab strip's + opens a tab every time, an empty design's included; over the start
/// page's blank design (a launch) it uses that design.
#[test]
fn plus_opens_a_tab_every_time() {
let mut a = app();
a.home.open = true;
new_tab(&mut a);
assert_eq!(a.docs.count(), 1, "the launch's blank design is used");
assert!(!a.home.open);
new_tab(&mut a);
new_tab(&mut a);
assert_eq!(a.docs.count(), 3);
assert_eq!(a.docs.active, 2);
}
/// Quitting asks once per design with unsaved changes: Don't Save moves on (and keeps no
/// recovery copy), Save saves and moves on, and the app quits after the last answer.
#[test]