Craft-family shell, native file dialogs, samples and one-click Solve (#46)

* Native file pickers, background opening, drag and drop and recent files

Open (models, SolidCraft designs and tagged meshes in one picker), Save, Save As, Write
Deck and Recover go through the host's file pickers (rfd in the desktop app, injected as
Services so the UI crate stays portable and tests answer them). Files open on a copy of the
session in a worker thread and replace it only on success; files dropped on the window or
named on the command line open the same way. A recent-files list, an unsaved-changes prompt,
Cmd/Ctrl+O/S/Shift+S. Programmatic calls never open a picker: ui.start opens the form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Samples and one-click Solve: results reachable from the window

file.sample {name} opens a ready-to-run sample (the two parts, the cantilever with static and
frequency steps, the bar impact) in place of the model; solve.run solves every step in order.
Help > Samples, the empty viewport's start screen and the Tools > Samples entry open them
(asking first over unsaved changes); Solve runs in the background like a file opening and the
Results tab comes up. --sample [parts|cantilever|impact] on the command line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* The Craft-family shell: title bar, workspace ribbon, browser, context panel, timeline

The window now follows SolidCraft's and VectorCraft's layout and themes:
- title bar with the mark, quick actions (File menu, save, undo, redo, Solve, search,
  theme, help), the model's document tab and the version; integrated under the macOS
  traffic lights, own caption buttons and resize zones elsewhere (titlebar.rs);
- workspaces (Prepare, Model, Analysis, Results) with their tabs, and panels of icon
  buttons whose labelled drop-downs list the whole catalogue, coming-soon entries greyed
  with their milestone; panels collapse, then go into a » menu, when narrow;
- the browser: geometry and mesh with eye toggles, definitions with counts, results;
- no permanent Commands list: command search (S, Cmd/Ctrl+K) and a command line;
- the context panel on the right only with context: the command form, results controls,
  the selected definition's properties with Edit and Delete;
- navigation bar and orientation gizmo in the viewport; the journal timeline at the bottom
  with undo positions;
- SolidCraft's light and dark tokens; craft-ui (IconButton, Tab, WidgetPalette).
Menus and the search are view state (ui.set {menu, palette}), so captures show them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Shell polish, docs and licences

Menus painted as the family's (flat File menu with recent files, decks and samples), the
legend sized to its text, two-line panel labels inside the ribbon, glyphs the UI font has,
offscreen captures without fade-in, ui.start runs in-window file actions (samples, recover,
solve) but never a native picker, ui.select. Control protocol, architecture, ROADMAP, AGENTS
and ATTRIBUTION updated; THIRD-PARTY-LICENSES.txt with craft-ui and rfd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Title bar mark from the application icon; fluid steps and domains in the shell

The title bar draws the app icon's bracket (assets/app-icon/icon-small.svg's faces) as
SolidCraft draws its mark; the window keeps its title-bar flags after the rebase.
solve.run solves fluid steps too (solve.fluid); the browser lists fluid domains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Simplify: cached per-frame data, one command per timeline roll, workspace setters

- Icon textures are kept per pixel size (the shell draws several sizes a frame; the cache
  used to clear on every size change and rasterise again).
- Opening a model or recovering one starts from an empty session instead of copying the
  current one; the replaced session is freed off the window thread.
- Element counts, timeline items, search results and the selected definition's properties
  are cached until what they show changes; timeline tooltips are built on hover; long lists
  in properties are summarised.
- edit.undo and edit.redo take a count: a timeline click is one command.
- solve.run dispatches on the step's procedure (no string round trip) and reports its name.
- The workspace and tab change together through UiState::select_tab/select_workspace
  (ui.set {workspace} alone now sticks); no per-frame syncing.
- One busy guard, Kind::verbs, a fit flag for background jobs, ModelApp::home_view, the title
  bar's actions as an enum, dead code removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Title bar: Solve and tools at the right end; no traffic-light inset in full screen

The owner's feedback on the title bar: Solve, search, theme and help sit at its right end
before the version; on macOS the left group (mark, name, quick actions) moves into the
traffic lights' room in full screen, where there are none, and back when leaving it. The
layout is a pure function (bar_layout) tested for both states, narrow windows and custom
caption buttons. ui.fullscreen {on} for agents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Caps labels in Inter SemiBold

egui has no bold weight of its default font, so the ribbon's tabs and panel labels, the
workspace switcher and its menu, menu headings, the browser header, the context panel's
headers and the Solve label were thin, especially in the light theme. They now use a label
font family: Inter SemiBold 4.1 (SIL OFL 1.1, unmodified, fonts/OFL.txt, ATTRIBUTION.md),
with egui's fonts as fallback, installed with the theme on the live and offscreen contexts.
theme::label_font falls back to the default font until the family is bound (fonts take
effect from the next pass), so nothing can panic. Panels widen to their label's longest word.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* docs: regenerate features.md after rebase

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

---------

Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-10-13 22:11:15 -04:00
1 parent 29ae46ff84
commit bf325bb234
87 files changed
+5068 -759

No files matched your search

+161
View File
@@ -0,0 +1,161 @@
//! The one place windows and panel headings are made, so every prompt and panel shares the same
//! width limits and heading bands.
//!
//! Adapted from SolidCraft's `crates/ui-egui/src/frame.rs` (MIT OR Apache-2.0), see
//! ATTRIBUTION.md.
use egui::{Align2, Ui, WidgetText, vec2};
/// Floating windows: prompts and panels, and those holding a table.
pub const WINDOW_MAX_W: f32 = 460.0;
pub const WINDOW_WIDE_MAX_W: f32 = 760.0;
/// How wide a window may get.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Width {
Normal,
Wide,
}
/// A floating window, centred on the screen, shrink-wrapped to its content up to its width limit.
pub fn window<'a>(ctx: &egui::Context, title: impl Into<WidgetText>, width: Width) -> egui::Window<'a> {
let max = match width {
Width::Normal => WINDOW_MAX_W,
Width::Wide => WINDOW_WIDE_MAX_W,
};
let c = ctx.content_rect().center();
egui::Window::new(title).collapsible(false).resizable(false).pivot(Align2::CENTER_CENTER).default_pos(c - vec2(0.0, 60.0)).max_width(max)
}
/// Heading levels inside a panel: its title, and the sections below it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Level {
/// The panel's title row (`Tokens::heading_bg`).
Title,
/// A section heading (`Tokens::subheading_bg`).
Section,
}
/// Horizontal inner margin of a heading band, on each side.
pub const HEADING_MARGIN: f32 = 4.0;
/// A heading row drawn on a band as wide as the panel; `add` lays out the row left to right.
pub fn heading<R>(ui: &mut Ui, t: &crate::theme::Tokens, level: Level, add: impl FnOnce(&mut Ui) -> R) -> R {
let fill = match level {
Level::Title => t.heading_bg,
Level::Section => t.subheading_bg,
};
let inner = (ui.available_width() - 2.0 * HEADING_MARGIN).max(0.0);
egui::Frame::new()
.fill(fill)
.corner_radius(3)
.inner_margin(egui::Margin::symmetric(HEADING_MARGIN as i8, 2))
.show(ui, |ui| {
ui.set_width(inner);
ui.horizontal(add).inner
})
.inner
}
/// A menu below `anchor`, open while [`crate::UiState::menu`] is `key` (so `ui.set {menu}` and
/// offscreen captures open it too). A click on one of its rows, a click outside or Escape closes
/// it. Returns where it was drawn.
pub fn menu<R>(
app: &mut crate::ModelApp,
ui: &Ui,
key: &str,
anchor: egui::Rect,
add: impl FnOnce(&mut crate::ModelApp, &mut Ui) -> R,
) -> Option<egui::Rect> {
popup(app, ui, key, anchor, egui::PopupCloseBehavior::CloseOnClick, add)
}
/// As [`menu`], but clicks inside keep it open (settings with checkboxes).
pub fn settings_menu<R>(
app: &mut crate::ModelApp,
ui: &Ui,
key: &str,
anchor: egui::Rect,
add: impl FnOnce(&mut crate::ModelApp, &mut Ui) -> R,
) -> Option<egui::Rect> {
popup(app, ui, key, anchor, egui::PopupCloseBehavior::CloseOnClickOutside, add)
}
fn popup<R>(
app: &mut crate::ModelApp,
ui: &Ui,
key: &str,
anchor: egui::Rect,
close: egui::PopupCloseBehavior,
add: impl FnOnce(&mut crate::ModelApp, &mut Ui) -> R,
) -> Option<egui::Rect> {
let mut open = app.ui.menu.as_deref() == Some(key);
if !open {
return None;
}
let id = egui::Id::new(("mc_menu", key));
let shown =
egui::Popup::new(id, ui.ctx().clone(), anchor, ui.layer_id()).kind(egui::PopupKind::Menu).open_bool(&mut open).close_behavior(close).show(
|ui| {
ui.set_min_width(200.0);
add(app, ui)
},
);
if (!open || ui.input(|i| i.key_pressed(egui::Key::Escape))) && app.ui.menu.as_deref() == Some(key) {
app.ui.menu = None;
}
shown.map(|r| r.response.rect)
}
/// A menu row's width and height.
pub const MENU_W: f32 = 240.0;
const MENU_ROW_H: f32 = 24.0;
/// A menu row: its label, and its shortcut (or a note) at the right; dimmed and inert when
/// disabled. Painted like the toolbar's drop-down rows.
pub fn menu_row(ui: &mut Ui, t: &crate::theme::Tokens, label: &str, right: Option<&str>, enabled: bool) -> egui::Response {
let (rect, resp) = ui.allocate_exact_size(vec2(MENU_W, MENU_ROW_H), if enabled { egui::Sense::click() } else { egui::Sense::hover() });
if resp.hovered() && enabled {
ui.painter().rect_filled(rect, 3.0, t.hover);
}
let font = egui::FontId::proportional(13.0);
let clip = rect.shrink2(vec2(8.0, 0.0));
ui.painter().with_clip_rect(clip).text(
egui::pos2(rect.left() + 10.0, rect.center().y),
Align2::LEFT_CENTER,
label,
font.clone(),
if enabled { t.text } else { t.text_dim },
);
if let Some(r) = right {
ui.painter().text(egui::pos2(rect.right() - 10.0, rect.center().y), Align2::RIGHT_CENTER, r, egui::FontId::proportional(12.0), t.text_dim);
}
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, label));
resp
}
/// A menu section's small heading.
pub fn menu_heading(ui: &mut Ui, t: &crate::theme::Tokens, text: &str) {
ui.add_space(2.0);
ui.label(egui::RichText::new(text).font(crate::theme::label_font(ui.ctx(), 10.5)).color(t.text_dim));
}
#[cfg(test)]
mod tests {
/// Windows are made in this file only, so none can skip the width limits.
#[test]
fn windows_come_from_the_frame_helper() {
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
let mut bad = Vec::new();
for e in std::fs::read_dir(&dir).unwrap() {
let p = e.unwrap().path();
if p.extension().is_some_and(|x| x == "rs") && p.file_name().is_some_and(|n| n != "frame.rs") {
let text = std::fs::read_to_string(&p).unwrap();
if text.contains(concat!("Window", "::new(")) {
bad.push(p.display().to_string());
}
}
}
assert!(bad.is_empty(), "use crate::frame::window instead of egui::Window::new in {bad:?}");
}
}