Compare commits

..
Author SHA1 Message Date
Tanish Manku d1cb40332b Stack u2: #3077: collapse the nested if (clippy) 2026-11-19 15:42:50 -07:00
Tanish Mankuandgraficaeusebio-cloud b7d5ed3401 Stack u2: #1279: test that Options reset also brings back the status bar and command line
Carried over from #1283's test, which also covered the status bar.

Co-authored-by: graficaeusebio-cloud <224763601+graficaeusebio-cloud@users.noreply.github.com>
2026-11-19 15:19:53 -07:00
Tanish Manku 6b767073d8 Stack u2: #1279: Options reset keeps the user's shortcuts and remembered folders
The reset now rebuilds the whole interface state so hidden bars come back (#1240), but that
also dropped the user's keyboard shortcuts and the APPLOAD and .pgp folders, which the old
reset and Window > Reset Palettes keep.
2026-11-19 15:18:53 -07:00
Tanish Manku 7bcfe25938 Stack u2: #1452: a Chinese label for MENUBAR's Menu Bar
main requires a Chinese label for every command (chinese_menus_and_commands_are_fully_translated);
the new MENUBAR command's label had none.
2026-11-19 15:18:13 -07:00
Tanish Manku 3886fb952d Merge #3077 2026-11-19 15:17:16 -07:00
Tanish Manku 6c9eedd7e1 Merge #2443 2026-11-19 15:17:16 -07:00
Tanish Manku 6411c1a4ab Merge #1867 2026-11-19 15:17:15 -07:00
Tanish Manku 6f203fb64b Merge #1452 2026-11-19 15:17:15 -07:00
Tanish Manku a2d209e10b Merge #1279 2026-11-19 15:17:15 -07:00
midasmatterhorn cd226cdf0f ui: keep the in-window menu where the host has no native one 2026-11-14 17:18:20 +03:00
assamaralandClaude Opus 5.5 8d2c9d1a26 fix(app): a saved main window below the minimum size opens at the default size
On Windows app.ron can hold a 64x64 window (e.g. saved while minimized).
eframe restores it as is, so the next launch shows an unusable tiny window.
Such an entry is now dropped from app.ron before launch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:19:42 -03:00
Nicholas Gower 0156fd9b9f docking: follow the shared surface's stock tab menu and non-exhaustive node
The dock area's tab menu item is "Close Panel" in the pinned craft-ui, and
Node is non-exhaustive, so the accordion scan needs a catch-all arm.
2026-11-02 08:26:29 -08:00
Nicholas Gower df2a5131af i18n: the panel close button's accessible name translates as a whole
The header close button built its name by joining an English "Close" to
the translated panel label, so Spanish screen readers heard "Close Capas".
A single translatable "Close {panel}" template now carries both parts, and
the tooltip's "Close panel" joins the catalogs too. Spanish gets both
rows, Ukrainian (the reference catalog) is required to have them, and
docking.rs joins the scanned sources so future marked strings stay covered.

Regression test: a Spanish harness finds "Cerrar Capas" and "Cerrar
Propiedades" by accessible name, proves "Close Capas" is gone, and closes
Layers through the localized button.
2026-11-02 08:24:52 -08:00
Nicholas Gower 5644c6c946 docs: document the functions touched by #1838 2026-11-02 08:24:04 -08:00
Nicholas Gower 0fa45daf25 UI: a visible close button on every panel header (fixes #1838)
Every dockable panel header now carries an X beside its title, so closing
a palette no longer has to be discovered in the tab context menu. The
button queues the same Close action as that menu item.

Tab and floating group headers use the docking surface's header callback;
accordion title bars place the same button left of the stock collapse
control. The accessible name includes the panel ("Close Layers"), the
tooltip says "Close panel", and the drawing canvas stays unclosable.

Regression test: crates/ui-egui/tests/docking_workflows.rs. It opens the
External References tab and checks its button does not cover the title,
closes the default Layers accordion entry, closes a floating Properties
group, and still closes Layers through the context menu.
2026-11-02 08:23:33 -08:00
austin62jake a92fb047d8 Merge remote-tracking branch 'upstream/main' into fix/refmanager-menu-closes 2026-11-01 07:07:28 -06:00
midasmatterhorn 33dc795c5f ui: the options reset brings a hidden menu bar and tool bar back 2026-11-01 05:26:41 +03:00
Aldo Zarate 4255108429 Merge remote-tracking branch 'upstream/main' into feat/menubar-toolbar-cmds
# Conflicts:
#	crates/ui-egui/src/lib.rs
2026-10-31 14:08:28 -06:00
Aldo Zarate 0b585fa8cb Merge remote-tracking branch 'upstream/main' into feat/menubar-toolbar-cmds
# Conflicts:
#	crates/engine/src/lib.rs
2026-10-30 13:52:46 -06:00
austin62jakeandClaude Opus 5.5 21d9627840 fix(ui): Window > Reference Manager closes the open palette
Once the External References palette was open, Window > Reference
Manager only opened it again, so there was no obvious way to close it
(the tab's right-click Close Panel works but is easy to miss). The menu
item now closes the palette when it is open, as Window > QuickCalc does
for QuickCalc (#2001). Typed XREF still only opens it, as in AutoCAD,
and XREF with JSON parameters still only lists the references.

Fixes #2273.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 22:33:23 -05:00
Aldo ZarateandClaude Opus 5.5 1c611d610d Control API: the bars are synced after every request
A command a control request runs (MENUBAR, TOOLBAR, also through cmdline.key) may ask for a bar;
control::handle now applies that before the next request, so a later query or ui.set sees the
bars as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 10:29:46 -06:00
Aldo Zarate 076b7761a3 Merge remote-tracking branch 'upstream/main' into feat/menubar-toolbar-cmds 2026-10-28 10:26:55 -06:00
Aldo ZarateandClaude Opus 5.5 71a0ef2260 MENUBAR started from the interface offers the bar as shown now
CadApp::start syncs the bars before starting the command, as run and cmdline do, so MENUBAR's
default is the menu bar as the interface shows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 10:12:50 -06:00
Aldo ZarateandClaude Opus 5.5 4fadc54dbe MENUBAR/TOOLBAR: control-API calls see the bars as shown now
CadApp::run now syncs the bars before and after the engine runs, as the command line does,
so a bar query right after a ui.set reports the interface's current bars and a MENUBAR or
TOOLBAR request is applied at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 09:46:12 -06:00
Aldo ZarateandClaude Opus 5.5 9c2ebc0e12 MENUBAR/TOOLBAR: request each bar on its own
The request was both bars as one snapshot, so a tool bar change made between MENUBAR and the
UI applying it was undone. Each command now asks only for its own bar, and the UI applies only
the bars asked for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 09:25:10 -06:00
Aldo ZarateandClaude Opus 5.5 98240d82d0 MENUBAR/TOOLBAR: explicit imports for the wildcard-imports lint
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 08:03:36 -06:00
Aldo Zarate 1e1cf10a1c Merge remote-tracking branch 'upstream/main' into feat/menubar-toolbar-cmds 2026-10-28 08:02:57 -06:00
Aldo Zarate af460caac6 Merge remote-tracking branch 'upstream/main' into feat/menubar-toolbar-cmds 2026-10-26 19:34:20 -06:00
Aldo ZarateandClaude Opus 5.5 ad072e6cb0 MENUBAR and TOOLBAR at the command line bring hidden bars back (#1341)
On Windows and Linux the in-window menu bar is the only menu, so once it
was hidden there was no way back from the keyboard: MENUBAR and TOOLBAR,
which AutoCAD users type for this, were unknown commands.

MENUBAR asks "Enter new value for MENUBAR <1>:" (1 shows, 0 hides), and
TOOLBAR (alias -TOOLBAR) asks for Show or Hide, Show by default. The JSON
forms report or set the bars. The engine records the change and the UI
applies it, reporting what it shows every frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 10:54:43 -06:00
22 changed files with 677 additions and 105 deletions
+21 -50
View File
@@ -1,23 +1,21 @@
# CADCraft roadmap
**Stage: pre-alpha** · next: alpha, when the six rows of the [alpha gate](docs/roadmap.md#alpha-gate) pass (five fail today; the gate was revised on 2026-11-19 and its hours are not re-estimated yet)
**Stage: pre-alpha** · next: alpha, ~2 points (38% → 40% ready for real work) and ~125–190 Opus 5.5 hours away (the four failing core workflows of the [alpha gate](docs/roadmap.md#alpha-gate))
> **Last reviewed:** 2026-11-19 · **Last updated:** 2026-11-19 · **Change:** major (alpha gate revised from user reports: six rows, Windows first; Upcoming re-ranked into three priority tiers; previously minor: re-audit against main 41d9b5e95) · **Target:** Autodesk AutoCAD 2027
> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-10-24 · **Change:** minor (re-audit against main 41d9b5e95: language table, CI gate, open-PR count; previously: progress log: proxy objects keep their class through a save, #1812; previously minor: HATCHEDIT boundary add/remove progress) · **Target:** Autodesk AutoCAD 2027
CADCraft targets full parity with AutoCAD (2D drafting first, then annotation, layouts and
plotting, DWG, parametrics and 3D), plus what AutoCAD doesn't have: agent control over MCP, a
scriptable CLI, a web build, Linux and FreeBSD builds, and a free licence.
**Why pre-alpha:** five of the six rows of the [alpha gate](docs/roadmap.md#alpha-gate) fail. The gate
was revised on 2026-11-19 from what people report: about 525 of the issues open or closed in the
last 30 days come from people describing their own drawings, hardware or workflow, and the ones that
name a platform name Windows most (135; Linux 57, macOS 36, web 14). They report an app that
doesn't start on older graphics hardware, large or foreign DWG files that are refused, freeze or open
wrong, clicks lost while the mouse moves, layouts in the wrong units, and a menu bar or panels that
can't be brought back. Drafting, dimensioning and annotating a sheet nearly passes. Dynamic-block
authoring, editing an xref in place and exact ellipse and spline geometry had almost no reports behind
them and moved to the beta checklist. Ready for real work (≈ 38%, not re-scored since 2026-10-10) is
also under the ~40% alpha bar. Beta is ≈ 600–930 h away.
**Why pre-alpha:** four of AutoCAD's five core workflows fail the [alpha gate](docs/roadmap.md#alpha-gate).
Precise drafting still has approximate ellipse and spline intersections and a few stubbed prompt options
(object snap tracking, TRIM/EXTEND/OFFSET options and typed snap overrides have landed); dynamic blocks can't be
authored and xrefs can't be edited in place (the Block Editor, REFEDIT, dynamic block editing and XCLIP have landed);
plots go only to PDF, PNG and SVG files (plot styles and the Plot dialog have landed); and a DWG saved by
CADCraft drops what acadrust doesn't model and has never been checked in
AutoCAD. Dimensioning passes. Ready for real work (≈ 38%) is also under the ~40% alpha bar. Beta
is ≈ 600–930 h away.
## Headline numbers
@@ -27,7 +25,7 @@ also under the ~40% alpha bar. Beta is ≈ 600–930 h away.
| Ready for real work | **≈ 38%** | estimated ([target-app-parity.md](docs/target-app-parity.md)) |
| Mainstream practitioner (2D drafter) | **≈ 28%** (lower than the full number: file exchange, stability and interaction discounts multiply) | estimated ([target-app-parity.md](docs/target-app-parity.md#mainstream-practitioner)) |
| Essentials user | **≈ 46%** | estimated ([target-app-parity.md](docs/target-app-parity.md#essentials-user)) |
| Remaining to alpha | **≈ 125–190 h** (estimated 2026-10-10 for the previous gate; not re-estimated for the revised one) | estimated |
| Remaining to alpha | **≈ 125–190 h** (the gate rows) | estimated |
| Remaining to beta | **≈ 600–930 h** (≈ 150–250 h elapsed with 4–6 agents) | estimated |
| Remaining to full parity | **≈ 1,300–2,100 h** (≈ 330–550 h elapsed) | estimated |
@@ -107,43 +105,17 @@ Other languages shipped: Ukrainian (1,357 rows, the reference catalog, #36), Cze
## Upcoming
Ranked in three tiers; a higher tier goes first whenever it has work. Within a tier, a fix that is
already written and waiting in a pull request lands before new work starts, whoever wrote it. Detail
and the beta checklist are in [docs/roadmap.md](docs/roadmap.md).
Ranked; detail and the full beta checklist in [docs/roadmap.md](docs/roadmap.md).
**1. Urgent: security fixes, leaks, crashes and lost work.**
- The open findings of the security audit (#1919–#1935): check each against the input limits that
landed on 2026-11-11, close what is fixed and fix the rest. A crafted handle that makes new entities
overwrite existing ones (#1921) is fixed by #1276.
- Hostile-input fixes waiting in pull requests (#2820, #2821, #2765).
- Crashes and hangs with a reproduction: the web build on a large DXF (#1603), a DWG with 3D content
(#2174), startup on older graphics hardware (#1724, #1631, #3222).
**2. Parity with AutoCAD: the alpha gate rows, then the beta checklist (apart from its items named under tier 3).**
- It starts on common hardware (#1596, then an automatic fallback renderer).
- It opens the DWG and DXF files people already have: large files (#3102, #2633, #1088), layouts and
paper units (#1672, #2836), and a corpus of real files run in CI.
- Saving loses nothing and other CAD programs open the result (#2904, #1687, #3234, #2632).
- Input feels like AutoCAD for Windows: clicks while the mouse moves (#1001, #2092), right-click and
Space as Enter (#1387), double-click to edit text (#842).
- The prompt options that still say "not available yet", and TRIM/EXTEND depth.
- Layouts print at scale on a system printer, and the menu bar and panels can always be restored
(#3216, #1240).
- 714 pull requests are open (2026-11-19). About 230 are mergeable, pass CI and are small; they are
reviewed and landed in this order, the longest-waiting authors first within a row.
**3. Lower priority: affects fewer people and nothing breaks without it.**
- Dynamic-block authoring, editing an xref in place, exact ellipse and spline geometry, correct
polyline offsets.
- Prompt options that need 3D (DVIEW's camera options, -RENAME Material); 3D itself comes after 1.0,
but a file with 3D content must open safely (tier 1).
- Menu breadth against AutoCAD for Mac as a headline number.
Done since the last ranking: precision input (#379, #441, #60, #519), prompt options in TRIM/EXTEND,
OFFSET, ROTATE, PLINE, SPLINE, MTEXT and MLEADER (#397, #408, #547), autosave, recovery, AUDIT and
RECOVER on the desktop (#406, #416), xrefs (#525), groups (#417), the Block Editor (#824, #833, #885),
REFEDIT (#818), XCLIP (#2354), dynamic block references (#838–#883), and the Dimension Style Manager
(#1460).
1. Gate and land: CI runs `cargo xtask ci` on every PR since #1987 (fmt on main is fixed); land the 450 open PRs (2026-10-24) (15–25 h).
2. Stop losing data on save (DXF done, #528; native MULTILEADER, #459, and the save version, #421, done; through DWG, acadrust still drops some content) (30–45 h).
3. Real-file DWG/DXF corpus and a black-box check in AutoCAD (10–15 h + owner).
4. ~~Precision input: object snap tracking, extension/parallel snaps, FROM/M2P/TK, snap overrides,
editable dynamic input.~~ Done (#379, #441, #60, #519; `snap/tracking.rs`, `pointmod.rs`, `dyninput.rs`).
5. ~~Unstub prompt options in TRIM/EXTEND, OFFSET, ROTATE, PLINE, SPLINE, MTEXT, MLEADER.~~ Done (#397, #408, #547); the stubs left are in gaps F1.
6. ~~Autosave, recovery, AUDIT, RECOVER.~~ Done on the desktop (#406, #416); the web build has no autosave (gaps F4).
7. Exact ellipse/spline geometry and correct polyline offsets (30–50 h).
8. Xrefs, block editor, groups, then dynamic blocks (80–120 h): xrefs (#525), groups (#417), the Block Editor (#824, #833, #885), REFEDIT (#818), XCLIP and XCLIPFRAME (#2354) and dynamic block references (#838–#883) landed; left: dynamic-block authoring, editing an xref in place.
## Progress log
@@ -166,7 +138,6 @@ REFEDIT (#818), XCLIP (#2354), dynamic block references (#838–#883), and the D
| Date | Change | Summary |
|---|---|---|
| 2026-11-19 | major | Alpha gate revised from user reports (six rows, Windows first; block authoring, xref editing in place and exact curve geometry moved to beta); Upcoming re-ranked into three tiers: urgent (security, leaks, crashes, lost work), parity, lower priority; percentages and hours not re-scored |
| 2026-10-24 | minor | Re-audit against main 41d9b5e95: language table, CI gate and open-PR count re-checked against main 41d9b5e95 |
| 2026-10-21 | trivial | Progress log: proxy objects keep their class through a save (#1812) |
| 2026-10-14 | minor | Progress log: HATCHEDIT boundary add/remove |
+45 -4
View File
@@ -233,11 +233,38 @@ fn saved_window(app_ron: &str) -> bool {
ron::from_str::<std::collections::HashMap<String, String>>(app_ron).is_ok_and(|kv| kv.contains_key(WINDOW_KEY))
}
/// The window state from the last session is saved and will be restored (#2595).
/// The window state from the last session is saved and will be restored (#2595). A saved size
/// below the minimum (seen on Windows: 64×64 points, which eframe restores un-maximized and
/// unusable) is dropped first, so the window opens at its default size.
fn restores_window() -> bool {
eframe::storage_dir(APP_ID).and_then(|dir| std::fs::read_to_string(dir.join("app.ron")).ok()).is_some_and(|ron| saved_window(&ron))
let Some(path) = eframe::storage_dir(APP_ID).map(|dir| dir.join("app.ron")) else { return false };
let Ok(mut ron) = std::fs::read_to_string(&path) else { return false };
if let Some(fixed) = without_tiny_window(&ron)
&& std::fs::write(&path, &fixed).is_ok()
{
ron = fixed;
}
saved_window(&ron)
}
/// `app_ron` without its window entry when that entry's inner size is below `MIN_INNER_SIZE`;
/// `None` when there is nothing to drop (no entry, a usable size, or an unreadable file).
fn without_tiny_window(app_ron: &str) -> Option<String> {
let mut kv = ron::from_str::<std::collections::BTreeMap<String, String>>(app_ron).ok()?;
let w = kv.get(WINDOW_KEY)?;
let size = &w[w.find("inner_size_points:")?..];
let num = |k: &str| size[size.find(k)? + k.len()..].split([',', ')']).next()?.trim().parse::<f32>().ok();
let (x, y) = (num("x:")?, num("y:")?);
if x >= MIN_INNER_SIZE[0] && y >= MIN_INNER_SIZE[1] {
return None;
}
kv.remove(WINDOW_KEY);
ron::ser::to_string_pretty(&kv, ron::ser::PrettyConfig::default()).ok()
}
/// The smallest main window, in points.
const MIN_INNER_SIZE: [f32; 2] = [900.0, 560.0];
/// The main window: its size, title bar, placement and rendering needs. `restoring`: a window state
/// saved by the last session is restored instead of opening centred.
fn window_options(restoring: bool) -> eframe::NativeOptions {
@@ -245,7 +272,7 @@ fn window_options(restoring: bool) -> eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_title("CADCraft")
.with_inner_size([1600.0, 1000.0])
.with_min_inner_size([900.0, 560.0])
.with_min_inner_size(MIN_INNER_SIZE)
.with_drag_and_drop(true)
.with_fullsize_content_view(true)
.with_titlebar_shown(false)
@@ -403,6 +430,9 @@ fn main() -> eframe::Result {
app.ui = ui;
}
app.set_system_cursor_default(vars.system_cursor == Switch::On);
// macOS: CADCRAFT_NO_NATIVE_MENU=1 keeps the menus inside the window.
#[cfg(target_os = "macos")]
app.set_native_menus(vars.no_native_menu != Switch::On);
if let Some(error) = &workspace_error {
eprintln!("CADCraft workspace: {error}");
app.set_status(error);
@@ -481,7 +511,7 @@ fn main() -> eframe::Result {
#[cfg(test)]
mod tests {
use super::{filters_for_save, follow_desktop, saved_window, window_options};
use super::{filters_for_save, follow_desktop, saved_window, window_options, without_tiny_window};
#[test]
fn save_dialog_offers_dwg_with_the_drawing_format_first() {
@@ -525,6 +555,17 @@ mod tests {
assert!(!saved_window("not ron at all"));
}
/// A saved 64×64 window (below the minimum) is dropped; a usable one is kept.
#[test]
fn a_tiny_saved_window_is_dropped() {
let tiny = r#"{"window": "(normal_geometry:(outer_position_pixels:Some((x:0.0,y:0.0)),scale_factor:1.25,inner_size_points:(x:64.0,y:64.0)),fullscreen:false,maximized:true)", "cadcraft.prefs": "{}"}"#;
let fixed = without_tiny_window(tiny).expect("dropped");
assert!(!saved_window(&fixed) && fixed.contains("cadcraft.prefs"));
let ok = tiny.replace("x:64.0,y:64.0)),", "x:1600.0,y:1000.0)),");
assert_eq!(without_tiny_window(&ok), None);
assert_eq!(without_tiny_window("not ron"), None);
}
/// View ▸ Theme ▸ System on Linux: winit reports no theme, so the desktop's answer stands in;
/// without one (or where winit answers and the desktop doesn't) the input is left alone.
#[test]
+2
View File
@@ -22,6 +22,7 @@ pub(crate) mod groups;
pub(crate) mod hatch;
mod image;
mod inquiry;
pub mod interface;
mod layer;
mod layout;
mod lisp;
@@ -212,6 +213,7 @@ pub fn command_specs() -> &'static [CommandSpec] {
v.extend(inquiry::specs());
v.extend(settings::specs());
v.extend(options::specs());
v.extend(interface::specs());
v.extend(utility::specs());
v.extend(table::specs());
v.extend(tolerance::specs());
+134
View File
@@ -0,0 +1,134 @@
//! MENUBAR and TOOLBAR: show or hide the window's menu bar and tool bar from the command line, as
//! in AutoCAD. With the menu bar hidden on Windows and Linux (where it is the only menu), typing
//! these is the way back.
//!
//! The UI owns the bars: it reports what it shows in [`Session::bars_shown`] and applies
//! [`Session::bars_request`], which these commands set.
use serde_json::{Value, json};
use super::{CommandSpec, always, bad};
use crate::{Accept, Input, Interactive, Prompt, Result, Session, Step};
/// The interface bars MENUBAR and TOOLBAR control.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct InterfaceBars {
pub menubar: bool,
pub toolbar: bool,
}
impl Default for InterfaceBars {
fn default() -> Self {
InterfaceBars { menubar: true, toolbar: true }
}
}
/// A change MENUBAR or TOOLBAR asked for: only the bars a command set, so the UI leaves the other
/// as it is (it may have been changed since).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct BarsRequest {
pub menubar: Option<bool>,
pub toolbar: Option<bool>,
}
pub fn specs() -> Vec<CommandSpec> {
vec![
CommandSpec::new("menubar", "Menu Bar", run_menubar)
.params("{value?: 0|1} (1 shows the in-window menu bar, 0 hides it; without it, reports it)")
.enabled(always)
.noundo()
.interactive(|s| Ok(Box::new(MenubarM { current: s.bars_shown.menubar }))),
CommandSpec::new("toolbar", "Tool Bar", run_toolbar)
.alias(&["-toolbar"])
.params("{show?: bool} (without it, reports it)")
.enabled(always)
.noundo()
.interactive(|_| Ok(Box::new(ToolbarM))),
]
}
fn set_menubar(s: &mut Session, on: bool) {
s.bars_shown.menubar = on;
s.bars_request.menubar = Some(on);
}
fn set_toolbar(s: &mut Session, show: bool) {
s.bars_shown.toolbar = show;
s.bars_request.toolbar = Some(show);
}
fn run_menubar(s: &mut Session, p: &Value) -> Result<Value> {
let v = match p.get("value") {
None | Some(Value::Null) => return Ok(json!({ "value": u8::from(s.bars_shown.menubar) })),
Some(v) => v
.as_u64()
.or_else(|| v.as_str().and_then(|t| t.trim().parse().ok()))
.filter(|v| *v <= 1)
.ok_or_else(|| bad("menubar", "`value` must be 0 or 1"))?,
};
set_menubar(s, v == 1);
Ok(json!({ "value": v }))
}
fn run_toolbar(s: &mut Session, p: &Value) -> Result<Value> {
let Some(show) = p.get("show").filter(|v| !v.is_null()) else { return Ok(json!({ "show": s.bars_shown.toolbar })) };
let show = show.as_bool().ok_or_else(|| bad("toolbar", "`show` must be true or false"))?;
set_toolbar(s, show);
Ok(json!({ "show": show }))
}
/// Typed MENUBAR: "Enter new value for MENUBAR <1>:".
struct MenubarM {
current: bool,
}
impl Interactive for MenubarM {
fn name(&self) -> &'static str {
"MENUBAR"
}
fn prompt(&self, _s: &Session) -> Prompt {
Prompt::new("Enter new value for MENUBAR", Accept::NUMBER).default(u8::from(self.current).to_string())
}
fn input(&mut self, s: &mut Session, i: Input) -> Result<Step> {
match i {
Input::Enter => Ok(Step::Done),
Input::Text(t) => match run_menubar(s, &json!({ "value": t })) {
Ok(_) => Ok(Step::Done),
Err(_) => {
s.echo("Requires 0 or 1.");
Ok(Step::Continue)
}
},
_ => Ok(Step::Continue),
}
}
}
/// Typed TOOLBAR: "Enter tool bar option [Show/Hide] <Show>:" (CADCraft has one tool bar).
struct ToolbarM;
impl Interactive for ToolbarM {
fn name(&self) -> &'static str {
"TOOLBAR"
}
fn prompt(&self, _s: &Session) -> Prompt {
Prompt::new("Enter tool bar option", Accept::TEXT).kw(&["Show", "Hide"]).default("Show")
}
fn input(&mut self, s: &mut Session, i: Input) -> Result<Step> {
let word = match &i {
Input::Enter => "show".to_string(),
Input::Keyword(k) | Input::Text(k) => k.trim().to_ascii_lowercase(),
_ => return Ok(Step::Continue),
};
let show = if !word.is_empty() && "show".starts_with(&word) {
true
} else if !word.is_empty() && "hide".starts_with(&word) {
false
} else {
s.echo("Invalid option keyword.");
return Ok(Step::Continue);
};
run_toolbar(s, &json!({ "show": show }))?;
Ok(Step::Done)
}
}
+6
View File
@@ -156,6 +156,10 @@ pub struct Session {
lisp_last: Option<std::result::Result<lisp::value::Value, String>>,
/// What the last HATCHPICK kept (the Hatch and Gradient dialog's picks).
pub hatch_picks: Option<cmd::hatch::HatchPicks>,
/// The window's menu bar and tool bar as the UI shows them (it reports them every frame).
pub bars_shown: cmd::interface::InterfaceBars,
/// The bars MENUBAR or TOOLBAR asked to change, for the UI to apply.
pub bars_request: cmd::interface::BarsRequest,
/// The object named with a point for the input a prompt picking one object is taking
/// ([`Session::input_object`]): a pick at exactly that point picks that object
/// ([`Session::pick_object`]).
@@ -215,6 +219,8 @@ impl Session {
lisp: lisp::LispState::default(),
lisp_last: None,
hatch_picks: None,
bars_shown: Default::default(),
bars_request: Default::default(),
pick_hint: None,
}
}
+8
View File
@@ -308,6 +308,14 @@ fn key_from(name: &str) -> Option<egui::Key> {
}
pub fn handle(app: &mut CadApp, ctx: &egui::Context, req: &ControlRequest) -> Outcome {
let out = handle_request(app, ctx, req);
// A command the request ran may have asked for a bar (MENUBAR, TOOLBAR): apply it before
// the next request, so a later query or `ui.set` sees the bars as they are now.
app.sync_bars();
out
}
fn handle_request(app: &mut CadApp, ctx: &egui::Context, req: &ControlRequest) -> Outcome {
let p = &req.params;
let s = |k: &str| p.get(k).and_then(Value::as_str);
let f = |k: &str| p.get(k).and_then(Value::as_f64);
+94 -1
View File
@@ -316,6 +316,10 @@ pub fn command(app: &mut crate::CadApp, reset: bool, params: &Value) -> Result<V
}
/// Validate and repair the stored workspace, sync it with the app, and render the dock panels; a failed restore falls back to the default layout with a status message.
/// Draw the docked workspace: restore or fall back from the persisted layout, render every
/// panel body plus the header close buttons, and apply the resulting actions through
/// [`command`]. Bodies may dispatch commands, so the canonical workspace is published before
/// rendering while the layout snapshot stays immutable.
pub fn show(app: &mut crate::CadApp, ui: &mut egui::Ui) {
let t = crate::theme::Tokens::get();
let mut workspace = app.ui.docking.clone();
@@ -348,7 +352,33 @@ pub fn show(app: &mut crate::CadApp, ui: &mut egui::Ui) {
if let Some(panel) = app.raise_panel.take() {
area = area.raise_panel(panel);
}
let mut output = area.show_content(ui, &workspace.layout, &style, &mut Panels { app });
let (mut output, header_close) = {
let mut panels = Panels { app, close: None };
let output = area.show_content(ui, &workspace.layout, &style, &mut panels);
(output, panels.close)
};
// Accordion title bars are rendered by the shared surface without a header callback, so
// place the same close button over their title bar, left of the stock collapse control.
let mut close = header_close;
for panel in stack_panels(&workspace.layout) {
if !permissions(&panel).closable {
continue;
}
let Some(title) = ui.ctx().read_response(egui::Id::unique("cadcraft-docking").with(("tab", panel))) else { continue };
if !title.rect.is_positive() {
continue;
}
let rect = egui::Rect::from_center_size(
egui::pos2(title.rect.right() - 18.0 - CLOSE_BUTTON * 0.5 - 4.0, title.rect.center().y),
egui::vec2(CLOSE_BUTTON, CLOSE_BUTTON),
);
if close_button(ui, panel, rect) {
close = Some(panel);
}
}
if let Some(panel) = close {
output.actions.push(Action::Close { panel });
}
// Keys typed in a floating panel's own OS window run the main window's shortcuts and
// command line; files dropped on one open like files dropped on the main window.
app.forward_native_input(ui.ctx(), std::mem::take(&mut output.forwarded_events), output.forwarded_modifiers);
@@ -393,9 +423,55 @@ pub fn native_input_blocked(app: &crate::CadApp, ctx: &egui::Context) -> bool {
/// The panels' contents, names, size limits and icons for the dock area.
pub struct Panels<'a> {
pub app: &'a mut crate::CadApp,
/// The panel whose header close button was clicked this frame.
pub close: Option<Panel>,
}
/// Size of a panel header's close button, in points.
const CLOSE_BUTTON: f32 = 16.0;
/// The accessible name of a header's close button. One translated template carries both the
/// verb and the panel name, so a catalog translates the whole name instead of leaving an
/// English verb in front of a translated panel label.
fn close_label(panel: Panel) -> String {
crate::tf!("Close {panel}", panel = crate::i18n::t(panel.label()))
}
/// A visible close button for a panel header. It runs the same action as the tab context
/// menu's "Close panel"; the accessible name includes the panel so the headers stay distinct.
fn close_button(ui: &mut egui::Ui, panel: Panel, rect: egui::Rect) -> bool {
let t = crate::theme::Tokens::get();
let response = ui.interact(rect, egui::Id::unique("cadcraft-docking").with(("close", panel.id())), egui::Sense::click());
let label = close_label(panel);
crate::icons::describe_control(ui, &response, &label, None, false);
if response.hovered() {
ui.painter().rect_filled(rect.expand(2.0), 2.0, t.control_hover.gamma_multiply(0.6));
}
crate::icons::paint(ui.painter(), rect, crate::icons::Icon::Close, false);
response.on_hover_text(crate::tl!("Close panel")).clicked()
}
/// Panels whose title bar is an accordion entry rather than a tab group header.
fn stack_panels(layout: &Layout<Panel>) -> Vec<Panel> {
let mut panels = Vec::new();
let mut nodes: Vec<&Node<Panel>> = layout.root.iter().collect();
while let Some(node) = nodes.pop() {
match node {
Node::Split { first, second, .. } => {
nodes.push(first);
nodes.push(second);
}
Node::Stack { entries } => panels.extend(entries.iter().map(|entry| entry.panel)),
// Tab groups draw their own header; nothing else stacks an accordion entry.
_ => {}
}
}
panels
}
impl DockContent<Panel> for Panels<'_> {
/// Render `panel`'s existing view; Layers, Properties and External References scroll
/// independently, and the drawing canvas paints its own background before the view.
fn body(&mut self, ui: &mut egui::Ui, panel: &Panel) {
let app = &mut *self.app;
match panel {
@@ -445,6 +521,23 @@ impl DockContent<Panel> for Panels<'_> {
crate::icons::paint(painter, rect, icon, false);
true
}
/// Reserve header space for the close button only when `active` may be closed, so the
/// drawing view's title gets no empty gap.
fn group_header_width(&self, _panels: &[Panel], active: &Panel, _floating: bool, _strip_width: f32) -> f32 {
if permissions(active).closable { CLOSE_BUTTON + 8.0 } else { 0.0 }
}
/// Draw the close button at the right edge of a tab-group header and remember the panel
/// to close once the docking surface has returned, so layout changes stay outside rendering.
fn group_header(&mut self, ui: &mut egui::Ui, _panels: &[Panel], active: &Panel, _floating: bool) {
let header = ui.max_rect();
let rect = egui::Rect::from_center_size(
egui::pos2(header.right() - CLOSE_BUTTON * 0.5 - 4.0, header.center().y),
egui::vec2(CLOSE_BUTTON, CLOSE_BUTTON),
);
if close_button(ui, *active, rect) {
self.close = Some(*active);
}
}
}
fn panel_limits(panel: &Panel) -> PanelLimits {
+3
View File
@@ -139,11 +139,13 @@
Clip Viewport Delimitar ventana gráfica
Clipboard Portapapeles
Close Cerrar
Close {panel} Cerrar {panel}
Close All Cerrar todo
Close All Other Drawings Cerrar todos los demás dibujos
Close Array Editing Cerrar la edición de matriz
Close Comparison Cerrar comparación
Export Comparison Exportar comparación
Close panel Cerrar panel
Closed Cerrada
Coincident Coincidente
Collapse Palettes Contraer paletas
@@ -542,6 +544,7 @@
Measure Medir
Measure Distance Medir distancia
Measure Geometry Medir geometría
Menu Bar Barra de menús
Merge Cells Combinar celdas
Merged PRs PR integradas
Mid Between 2 Points Punto medio entre 2 puntos
1 # CADCraft Spanish interface catalog — original translations.
139
140
141
142
143
144
145
146
147
148
149
150
151
544
545
546
547
548
549
550
+1
View File
@@ -146,6 +146,7 @@ fn missing_marked_ui_literals(language: &str) -> BTreeSet<String> {
"chrome",
"cmdline",
"credits",
"docking",
"dialogs",
"hatchdlg",
"aliasdlg",
+3
View File
@@ -143,11 +143,13 @@
Xref Clip Frame Рамка обрізки зовнішнього посилання
Clipboard Буфер обміну
Close Закрити
Close {panel} Закрити {panel}
Close All Закрити всі
Close All Other Drawings Закрити всі інші креслення
Closed Замкнений
Close Comparison Закрити порівняння
Export Comparison Експортувати порівняння
Close panel Закрити панель
Coincident Збіг
Collapse Palettes Згорнути палітри
Collapse Tool Sets Згорнути набори інструментів
@@ -534,6 +536,7 @@
Measure Розмітити
Measure Distance Виміряти відстань
Measure Geometry Виміряти геометрію
Menu Bar Рядок меню
Merge Cells Об'єднати комірки
Merged PRs Об'єднані PR
Mid Between 2 Points Середина між 2 точками
1 # CADCraft Ukrainian interface catalog — original translations by @dmatviichuk.
143
144
145
146
147
148
149
150
151
152
153
154
155
536
537
538
539
540
541
542
+1
View File
@@ -928,6 +928,7 @@
Time 时间
To get started, create or open a drawing. 若要开始,请创建或打开一个图形。
Tool Bar 工具栏
Menu Bar 菜单栏
Tool Sets 工具集
Tools 工具
Torus 圆环体
1 # CADCraft Simplified Chinese interface catalog — original translations.
928
929
930
931
932
933
934
+85 -1
View File
@@ -283,6 +283,9 @@ pub struct CadApp {
pub system_animations: Option<bool>,
/// What `ui.system_cursor` goes back to when the interface is reset ([`Self::set_system_cursor_default`]).
pub system_cursor_default: bool,
/// Whether the host has a native menu bar: off where the menus stay in the window
/// ([`Self::set_native_menus`]).
pub native_menus: bool,
pub session: Session,
pub ui: UiState,
/// The interface's own preferences from the Options dialog ([`options`]).
@@ -381,6 +384,7 @@ impl CadApp {
system_languages: Vec::new(),
system_animations: None,
system_cursor_default: false,
native_menus: cfg!(target_os = "macos"),
session,
ui: UiState::default(),
options: options::UiOptions::default(),
@@ -588,7 +592,11 @@ impl CadApp {
if let Some(r) = menus::run_ui_command(self, id, &params) {
return r;
}
// The bars as the interface shows them now (a `ui.set` may have just changed one), and any
// MENUBAR or TOOLBAR request applied at once.
self.sync_bars();
let r = self.session.execute(id, &params).map_err(|e| e.to_string());
self.sync_bars();
if let Ok(v) = &r
&& let Some(m) = v.get("message").and_then(Value::as_str)
{
@@ -607,6 +615,7 @@ impl CadApp {
if menus::run_ui_command(self, name, &Value::Null).is_some() {
return;
}
self.sync_bars();
if let Err(e) = self.session.start(name) {
self.session.echo(e.to_string());
}
@@ -622,6 +631,7 @@ impl CadApp {
/// command or system variable) runs `fallback` instead: Enter on a partly typed name accepts
/// the highlighted AutoComplete suggestion.
pub fn cmdline_or(&mut self, text: &str, fallback: Option<&str>) -> Option<String> {
self.sync_bars();
if !self.session.prompting() {
let first = text.split_whitespace().next().unwrap_or("");
// `cmd {json}` is a programmatic call: the engine runs it with those parameters.
@@ -636,7 +646,9 @@ impl CadApp {
return None;
}
}
let e = match (self.session.cmdline(text), fallback) {
let r = self.session.cmdline(text);
self.sync_bars();
let e = match (r, fallback) {
(Ok(()), _) => return None,
(Err(cadcraft_engine::EngineError::UnknownCommand(_)), Some(f)) => return self.cmdline(f),
(Err(e), _) => e.to_string(),
@@ -645,6 +657,18 @@ impl CadApp {
Some(e)
}
/// Apply a menu bar / tool bar change MENUBAR or TOOLBAR asked for, and report the bars shown.
fn sync_bars(&mut self) {
let b = std::mem::take(&mut self.session.bars_request);
if let Some(on) = b.menubar {
self.ui.in_window_menu = on;
}
if let Some(show) = b.toolbar {
self.ui.show_toolbar = show;
}
self.session.bars_shown = cadcraft_engine::cmd::interface::InterfaceBars { menubar: self.ui.in_window_menu, toolbar: self.ui.show_toolbar };
}
/// The theme the interface shows now (the choice resolved against the OS appearance).
pub fn shown_theme(&self) -> egui::Theme {
self.shown_theme.unwrap_or_else(|| self.ui.theme.resolve(None))
@@ -731,6 +755,15 @@ impl CadApp {
}
}
/// Tell the interface whether the host has a native menu bar. Where it has none, the
/// in-window menu is the only menu, so it is shown and a reset keeps it.
pub fn set_native_menus(&mut self, on: bool) {
self.native_menus = on;
if !on {
self.ui.in_window_menu = true;
}
}
pub fn set_status(&mut self, s: impl Into<String>) {
self.status = Some((s.into(), now_ms()));
}
@@ -1087,6 +1120,7 @@ impl CadApp {
/// Draw one UI pass: title/toolbar, optional menu/status bar/file tabs, the standalone tool-set strip when a drawing is shown but Tool Sets is not docked, docking or the start page, and the floating overlays; record `frame_ms`. Runs on every pass, including one egui later discards.
fn draw(&mut self, ui: &mut egui::Ui) {
let t0 = now_ms();
self.sync_bars();
control::begin_frame(ui.ctx());
let t = theme::Tokens::get();
chrome::title_and_toolbar(self, ui);
@@ -1408,4 +1442,54 @@ mod tests {
let ui: UiState = serde_json::from_value(json!({ "saveFormat": "dwg" })).unwrap_or_default();
assert_eq!(ui.save_format, SaveFormat::Dwg);
}
#[test]
fn options_reset_brings_the_interface_back() {
// Hiding the interface (View/Window toggles) can leave no way back — on Windows the
// in-window menu bar is the only menu there is. Options > Reset must restore it (#1240).
let mut a = app();
a.run("ui.toggle.toolbar", json!({ "on": false })).unwrap();
a.run("ui.toggle.menubar", json!({ "on": cfg!(target_os = "macos") })).unwrap();
a.start("ui.hidepalettes");
assert!(!a.ui.show_toolbar && !a.ui.show_palettes && !a.ui.show_toolsets);
assert_eq!(a.ui.in_window_menu, cfg!(target_os = "macos"), "the test did not hide the menu bar");
a.run("options", json!({ "reset": true })).unwrap();
assert!(a.ui.show_toolbar, "the tool bar is still hidden");
assert!(a.ui.show_palettes, "the palettes are still hidden");
assert!(a.ui.show_toolsets);
assert_eq!(a.ui.in_window_menu, !cfg!(target_os = "macos"), "the menu bar did not come back");
}
#[test]
fn options_reset_keeps_the_menu_where_the_host_has_no_native_one() {
// With CADCRAFT_NO_NATIVE_MENU=1 the menus stay in the window: the host reports no native
// menu bar, so the in-window one is the only menu and the reset must leave it (#1240).
let mut a = app();
a.set_native_menus(false);
assert!(a.ui.in_window_menu, "the host's setting did not show the in-window menu");
a.run("ui.toggle.menubar", json!({ "on": false })).unwrap();
a.run("options", json!({ "reset": true })).unwrap();
assert!(a.ui.in_window_menu, "the only menu bar did not come back");
// Beside a native menu bar, the reset returns to the platform default.
a.set_native_menus(true);
a.run("ui.toggle.menubar", json!({ "on": true })).unwrap();
a.run("options", json!({ "reset": true })).unwrap();
assert!(!a.ui.in_window_menu, "the in-window menu is not the default beside a native one");
}
#[test]
fn options_reset_keeps_the_users_shortcuts_and_folders() {
// The reset brings hidden bars back (#1240); it must not also lose the user's own
// keyboard shortcuts or the folders the file pickers remember.
let mut a = app();
a.ui.shortcuts.insert("line".into(), "Ctrl+Shift+L".into());
a.ui.last_lisp_dir = Some("lisp-folder".into());
a.ui.last_pgp_dir = Some("pgp-folder".into());
a.run("ui.toggle.toolbar", json!({ "on": false })).unwrap();
a.run("options", json!({ "reset": true })).unwrap();
assert!(a.ui.show_toolbar, "the tool bar is still hidden");
assert_eq!(a.ui.shortcuts.get("line").map(String::as_str), Some("Ctrl+Shift+L"), "the reset lost a user shortcut");
assert_eq!(a.ui.last_lisp_dir.as_deref(), Some("lisp-folder"));
assert_eq!(a.ui.last_pgp_dir.as_deref(), Some("pgp-folder"));
}
}
+9 -2
View File
@@ -797,13 +797,20 @@ fn switch_on_hover(ctx: &egui::Context, titles: &[egui::Response]) {
}
}
/// Activate a menu command. QuickCalc toggles transparently; other items clear pending
/// command-line text and start their command interactively.
/// Activate a menu command. QuickCalc toggles transparently, and Reference Manager closes its
/// palette when it is open (typed XREF only opens it); other items clear pending command-line
/// text and start their command interactively.
pub fn activate(app: &mut CadApp, id: &str) {
if id == "ui.toggle.quickcalc" {
run_transparent(app, id);
return;
}
if id == "xref" && app.ui.docking.layout.contains(&crate::docking::Panel::ExternalRefs) {
if let Err(e) = crate::xrefs::close_palette(app) {
app.set_status(e);
}
return;
}
app.cmd.buffer.clear();
app.start(id);
}
+23 -6
View File
@@ -434,13 +434,30 @@ fn apply_right_click(o: &mut UiOptions, c: &UiChanges) {
/// The interface preferences back to their defaults (the interface language stays).
fn reset_ui(app: &mut CadApp) {
let d = crate::UiState::default();
app.ui.theme = d.theme;
app.ui.animations = d.animations;
app.ui.save_format = d.save_format;
app.ui.save_version = d.save_version;
// Everything interface, back to its defaults: a hidden menu bar, tool bar, palettes or
// panels and a rearranged panel layout come back — once the menu bar is hidden there may be
// no other way to reach the toggles (#1240). The interface language stays; the open dialog,
// the start tab, the recent files and the remembered folders are state, not preferences, and
// stay too. The user's keyboard shortcuts are their own customisation, which Window > Reset
// Palettes keeps as well: a reset meant to bring a bar back must not lose them.
let (language, dialog, start_tab) = (app.ui.interface_language, app.ui.dialog.take(), app.ui.start_tab);
let recent_files = std::mem::take(&mut app.ui.recent_files);
let shortcuts = std::mem::take(&mut app.ui.shortcuts);
let (last_lisp_dir, last_pgp_dir) = (app.ui.last_lisp_dir.take(), app.ui.last_pgp_dir.take());
app.ui = crate::UiState {
interface_language: language,
dialog,
start_tab,
recent_files,
shortcuts,
last_lisp_dir,
last_pgp_dir,
..Default::default()
};
// Where the host has no native menu bar the in-window one is the only menu: the reset must
// leave it in place (#1240).
app.ui.in_window_menu = !app.native_menus;
app.ui.system_cursor = app.system_cursor_default;
app.ui.history_lines = d.history_lines;
app.options = UiOptions::default();
}
+6
View File
@@ -42,6 +42,12 @@ fn open_palette(app: &mut CadApp) -> Result<Value, String> {
crate::docking::command(app, false, &json!({ "operation": "open", "panel": Panel::ExternalRefs.id() }))
}
/// Close the palette: Window ▸ Reference Manager while it is open, as Window ▸ QuickCalc closes
/// QuickCalc (#2273).
pub(crate) fn close_palette(app: &mut CadApp) -> Result<Value, String> {
crate::docking::command(app, false, &json!({ "operation": "close", "panel": Panel::ExternalRefs.id() }))
}
/// A picked file inside the host drawing's folder is attached by its relative path, so the
/// project folder can move.
fn relative_to_host(app: &CadApp, picked: &str) -> String {
+60 -1
View File
@@ -123,7 +123,7 @@ fn palette_icons_are_painted_in_code_and_shown_in_an_iconic_column() {
let ctx = egui::Context::default();
let mut paint = |panel: Panel| {
let mut painted = false;
let mut content = Panels { app: &mut app };
let mut content = Panels { app: &mut app, close: None };
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
let painter = ui.ctx().layer_painter(egui::LayerId::background());
let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(20.0, 20.0));
@@ -593,3 +593,62 @@ fn group_drag_bar_moves_the_whole_group_into_the_other_dock() {
assert_eq!(frames(layout), [[Panel::Canvas]]);
assert_eq!(h.state().session.doc().unwrap(), &document);
}
/// Guard that every closable panel header offers a visible close button: a docked tab group,
/// the default accordion stack, and a floating group. Each click must remove the panel, the
/// button must not cover the title, and the tab context menu must still close the same panel.
#[test]
fn every_panel_header_has_a_close_button_that_closes_like_the_context_menu() {
let mut h = harness(None, 1280.0, 1.0);
assert!(h.query_by_label("Close Tool Sets").is_some(), "docked tab headers show a close button");
assert!(h.query_by_label("Close Drawing").is_none(), "the drawing view is not a closable panel");
// External References opens as a tabbed pane; its button sits beside the title, not over it.
h.state_mut().run("ui.dock", json!({"operation":"open","panel":"externalReferences"})).unwrap();
h.run_steps(4);
assert!(h.state().ui.docking.layout.contains(&Panel::ExternalRefs));
let close = h.get_by_label("Close External References").rect();
let title = h.get_by_role_and_label(egui::accesskit::Role::Tab, "External References").rect();
assert!(!close.intersects(title), "the close button does not cover the panel title");
h.get_by_label("Close External References").click();
h.run_steps(4);
assert!(!h.state().ui.docking.layout.contains(&Panel::ExternalRefs));
// Accordion headers (the default Layers/Properties stack) get one too.
assert!(h.state().ui.docking.layout.contains(&Panel::Layers));
h.get_by_label("Close Layers").click();
h.run_steps(4);
assert!(!h.state().ui.docking.layout.contains(&Panel::Layers));
// The context menu still closes the same panel after it is reopened.
h.state_mut().run("ui.dock", json!({"operation":"open","panel":"layers"})).unwrap();
h.run_steps(4);
assert!(h.state().ui.docking.layout.contains(&Panel::Layers));
h.get_by_role_and_label(egui::accesskit::Role::Tab, "Layers").click_button(PointerButton::Secondary);
h.run_steps(3);
// The docking surface's stock tab menu item ("Close Panel"), not our tooltip.
h.get_by_label("Close Panel").click();
h.run_steps(4);
assert!(!h.state().ui.docking.layout.contains(&Panel::Layers));
// Floating panels get the same button in their group header.
h.state_mut().run("ui.dock", json!({"operation":"float","panel":"properties","rect":[400,250,300,350]})).unwrap();
h.run_steps(4);
h.get_by_label("Close Properties").click();
h.run_steps(4);
assert!(!h.state().ui.docking.layout.contains(&Panel::Properties));
}
/// The accessible name is one translated string, not an English verb glued to a translated
/// panel label: Spanish readers must hear "Cerrar Capas", never "Close Capas".
#[test]
fn spanish_close_button_accessible_name_is_localized_as_a_whole() {
let mut h = harness(None, 1280.0, 1.0);
h.state_mut().run("ui.language", json!({"lang": "es"})).unwrap();
h.run_steps(4);
assert!(h.query_by_label("Cerrar Capas").is_some(), "the accordion close button is named in Spanish");
assert!(h.query_by_label("Cerrar Propiedades").is_some(), "every panel's close button follows the language");
assert!(h.query_by_label("Close Capas").is_none(), "no English verb survives the translation");
h.get_by_label("Cerrar Capas").click();
h.run_steps(4);
assert!(!h.state().ui.docking.layout.contains(&Panel::Layers), "the localized name still closes its panel");
}
+19
View File
@@ -252,3 +252,22 @@ fn selection_highlight_settings_set_save_and_show_in_the_selection_tab() {
assert!(text.contains(label), "{label} missing from:\n{text}");
}
}
#[test]
fn reset_brings_back_hidden_menu_bar_toolbar_and_status_bar() {
// #1240: with the in-window menu bar, the toolbar and the status bar hidden, OPTIONS ▸ Reset
// to Defaults (typed, or from the right-click menu) is the way back.
let mut a = app();
let d = cadcraft_ui_egui::UiState::default();
a.ui.in_window_menu = !d.in_window_menu;
a.ui.show_toolbar = false;
a.ui.show_status_bar = false;
a.ui.show_command_line = false;
a.ui.show_palettes = false;
a.run("options", json!({"reset": true})).unwrap();
assert_eq!(a.ui.in_window_menu, d.in_window_menu);
assert_eq!(a.ui.show_toolbar, d.show_toolbar);
assert_eq!(a.ui.show_status_bar, d.show_status_bar);
assert_eq!(a.ui.show_command_line, d.show_command_line);
assert_eq!(a.ui.show_palettes, d.show_palettes);
}
+107
View File
@@ -0,0 +1,107 @@
//! MENUBAR and TOOLBAR at the command line bring a hidden menu bar and tool bar back (#1341):
//! on Windows and Linux the in-window menu bar is the only menu, so with it hidden typing these
//! is the way back, as in AutoCAD.
use cadcraft_engine::Session;
use cadcraft_ui_egui::{CadApp, Services};
use serde_json::json;
fn app() -> CadApp {
CadApp::new(Session::new(), Services::default())
}
#[test]
fn typed_menubar_shows_and_hides_the_menu_bar() {
let mut app = app();
app.ui.in_window_menu = false;
app.cmdline("MENUBAR");
assert_eq!(app.session.prompt_text(), "MENUBAR Enter new value for MENUBAR <0>:");
app.cmdline("1");
assert!(app.session.running.is_none());
assert!(app.ui.in_window_menu);
// 0 hides it again; anything else is refused and asked again.
app.cmdline("MENUBAR");
app.cmdline("2");
assert!(app.session.running.is_some(), "still asking");
app.cmdline("0");
assert!(!app.ui.in_window_menu);
}
#[test]
fn typed_toolbar_shows_the_tool_bar_by_default() {
let mut app = app();
app.ui.show_toolbar = false;
app.cmdline("TOOLBAR");
assert_eq!(app.session.prompt_text(), "TOOLBAR Enter tool bar option or [Show/Hide] <Show>:");
app.cmdline("");
assert!(app.ui.show_toolbar);
app.cmdline("TOOLBAR");
app.cmdline("H");
assert!(!app.ui.show_toolbar);
}
#[test]
fn the_json_forms_report_and_set_the_bars() {
let mut app = app();
app.ui.in_window_menu = true;
app.ui.show_toolbar = false;
app.cmdline("MENUBAR");
app.cmdline("");
assert_eq!(app.session.execute("menubar", &json!({})).unwrap(), json!({ "value": 1 }));
assert_eq!(app.session.execute("toolbar", &json!({})).unwrap(), json!({ "show": false }));
app.session.execute("toolbar", &json!({ "show": true })).unwrap();
app.cmdline("MENUBAR");
app.cmdline("");
assert!(app.ui.show_toolbar && app.ui.in_window_menu);
assert!(app.session.execute("menubar", &json!({ "value": 3 })).is_err());
}
/// MENUBAR changes only the menu bar: a tool bar change made before the request is applied
/// stays (a control-API `ui.set` can come between them).
#[test]
fn menubar_leaves_a_later_tool_bar_change() {
let mut app = app();
app.ui.in_window_menu = true;
app.ui.show_toolbar = true;
app.session.execute("menubar", &json!({ "value": 0 })).unwrap();
app.ui.show_toolbar = false;
app.cmdline("'REDRAW");
assert!(!app.ui.in_window_menu, "MENUBAR applied");
assert!(!app.ui.show_toolbar, "the tool bar keeps its later change");
}
/// A bar query through `CadApp::run` reports the bars as the interface shows them now, even when
/// a UI change came just before it with no frame drawn in between.
#[test]
fn a_bar_query_sees_a_ui_change_just_made() {
let mut app = app();
app.ui.show_toolbar = true;
assert_eq!(app.run("toolbar", json!({})).unwrap(), json!({ "show": true }));
app.ui.show_toolbar = false;
assert_eq!(app.run("toolbar", json!({})).unwrap(), json!({ "show": false }));
app.run("toolbar", json!({ "show": true })).unwrap();
assert!(app.ui.show_toolbar, "the request is applied at once");
}
#[test]
fn menubar_started_from_the_ui_offers_the_bar_as_shown_now() {
let mut app = app();
app.ui.in_window_menu = true;
app.cmdline("");
app.ui.in_window_menu = false;
app.start("menubar");
let prompt = app.session.prompt_text();
assert!(prompt.contains("<0>"), "{prompt}");
}
#[test]
fn enter_through_the_control_api_applies_the_bar_before_the_next_request() {
let mut app = app();
let ctx = egui::Context::default();
app.ui.show_toolbar = false;
app.start("toolbar");
let (req, _pending) = cadcraft_ui_egui::control::ControlRequest::new("cmdline.key", serde_json::json!({ "key": "enter" }));
cadcraft_ui_egui::control::handle(&mut app, &ctx, &req);
assert!(app.session.running.is_none());
assert!(app.ui.show_toolbar, "TOOLBAR's default Show is applied before the next request");
}
+18 -1
View File
@@ -5,7 +5,7 @@ use cadcraft_engine::Session;
use cadcraft_engine::cmd::file::{IoHooks, set_io};
use cadcraft_engine::doc::geom::Vec3;
use cadcraft_engine::doc::{Drawing, Entity, EntityKind, Handle, Layer, Line, XrefStatus};
use cadcraft_ui_egui::{CadApp, Services, docking::Panel};
use cadcraft_ui_egui::{CadApp, Services, docking::Panel, menus};
use egui::vec2;
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
@@ -71,6 +71,23 @@ fn xref_opens_the_palette_and_its_buttons_manage_the_xref() {
h.get_by_label("site");
}
/// Window ▸ Reference Manager closes the palette when it is open, like Window ▸ QuickCalc; typed,
/// XREF only ever opens it (#2273).
#[test]
fn the_window_menu_item_closes_an_open_palette() {
let mut app = CadApp::new(Session::default(), Services::default());
let open = |app: &CadApp| app.ui.docking.layout.contains(&Panel::ExternalRefs);
menus::activate(&mut app, "xref");
assert!(open(&app), "the menu item opens the palette");
menus::activate(&mut app, "xref");
assert!(!open(&app), "the menu item closes the open palette");
menus::activate(&mut app, "xref");
assert!(open(&app), "and opens it again");
assert!(app.cmdline("XREF").is_none());
assert!(app.cmdline("XR").is_none());
assert!(open(&app), "typed XREF keeps it open");
}
#[test]
fn json_xref_lists_and_never_opens_the_palette() {
let mut app = CadApp::new(Session::default(), Services::default());
+6
View File
@@ -144,6 +144,12 @@ The shortcut also works with text-field focus. Toggling preserves the running dr
and pending command-line input. The expression, history and calculator variables survive
closing/reopening within the same session; they are not saved across application restarts.
The External References palette (`externalReferences`) is not part of the default arrangement
either. Typed `XREF`/`XR` opens and activates it. **Window > Reference Manager** (also
`ui.menu.invoke` with `xref`) opens it too, but closes it when it is present, as Window >
QuickCalc does; closing leaves the running command and command-line input alone. `xref` with
JSON parameters lists the references and never opens or closes the palette.
Invoke these UI commands through `engine.execute`, for example `{"command":"ui.dock","params":{"operation":"float","panel":"layers","rect":[100,100,320,440]}}`.
Advanced `ui.dock` operations use the same validated transaction as pointer gestures:
+25 -38
View File
@@ -1,6 +1,6 @@
# CADCraft roadmap detail
> **Last reviewed:** 2026-11-19 · **Last updated:** 2026-11-19 · **Change:** major (alpha gate revised from user reports: six rows, Windows first; current focus re-ranked into three tiers; percentages and hours not re-scored; previously minor: re-audit against main 41d9b5e95) · **Target:** Autodesk AutoCAD 2027
> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-10-24 · **Change:** minor (re-audit against main 41d9b5e95: alpha-gate evidence, CI gate, beta checklist states, open-PR and catalog counts; percentages and hours not re-scored; previously: re-audit against main e707ab4d: alpha-gate evidence, beta checklist states and milestone notes; percentages and hours not re-scored) · **Target:** Autodesk AutoCAD 2027
Forward-looking plan: milestones with status, the current focus, and what comes next with
estimates. The summary is [ROADMAP.md](../ROADMAP.md); the work items behind every line are in
@@ -9,49 +9,37 @@ Opus 5.5 agent-hours.
## Current focus
Work is ranked in three tiers. A higher tier goes first whenever it has work. Within a tier, a fix
already written and waiting in a pull request lands before new work starts, first-party or not.
1. **Gate and land.** (`cargo fmt` on main is fixed, and `ci.yml` runs `cargo xtask ci` on every
pull request since #1987.) Review and land the 450 open PRs (2026-10-24), most of them community bug fixes
(S3). ≈ 15–25 h.
2. **Stop losing data on save** (FF1, FF2, FF7) and save DWG/DXF at a chosen version (FF3).
≈ 30–45 h.
3. **A real-file corpus** and a check of our output in AutoCAD (FF5, needs the owner).
4. ~~**Precision input:** object snap tracking, extension/parallel snaps, FROM/M2P/TK, typed snap
overrides, editable dynamic input (U1–U4).~~ Done (#379, #393, #441, #60, #519); U4 and the grip and selection leftovers (U5, U6) remain.
5. ~~**Unstub the prompt options** of the most-used commands (F1).~~ Done (#397, #408, #547, #558, #559); the stubs left are listed in F1.
6. ~~**Autosave, recovery, AUDIT, RECOVER** (F4).~~ Done on the desktop (#406, #416); F4 lists the web-build leftovers.
7. **The rest of the alpha gate:** ~~block editor and REFEDIT, xref attach (F2, F3), and plot styles
with a plot dialog and preview (F14)~~ landed (#824, #818, #525, #410, #160, #186); left: the precise-drafting gaps (approximate ellipse and spline intersections, prompt options that still print "not available yet"; U4, F1), dynamic-block authoring, editing an xref in place (F2, F3), and printing beyond files (F14, H3). ≈ 50–80 h.
1. **Urgent: security fixes, leaks, crashes and lost work.** The open security-audit findings
(#1919–#1935) are checked against the input limits that landed on 2026-11-11, then closed or
fixed; #1276 fixes the crafted-handle overwrite (#1921). Hostile-input fixes are waiting in
#2820, #2821 and #2765. Crashes and hangs with a reproduction come next: #1603 (web, large DXF),
#2174 (DWG with 3D content), #1724, #1631 and #3222 (startup).
2. **Parity with AutoCAD.** The failing [alpha gate](#alpha-gate) rows in their order, then the
[beta checklist](#beta-checklist), apart from the checklist items named under tier 3. 714 pull requests are open (2026-11-19); about 230 of them are
mergeable, pass CI and are small, and many already fix a gate row.
3. **Lower priority.** Work that affects fewer people and that nothing breaks without: dynamic-block
authoring, editing an xref in place, exact ellipse and spline geometry, prompt options that need
3D, and menu breadth as a number.
Done from the previous focus list: precision input (U1–U3; #379, #393, #441, #60, #519), the prompt
options of the most-used commands (#397, #408, #547, #558, #559), autosave, recovery, AUDIT and
RECOVER on the desktop (#406, #416), the Block Editor and REFEDIT, xref attach, plot styles with a plot
dialog and preview (#824, #818, #525, #410, #160, #186).
Items 2 and 7 are the open [alpha gate](#alpha-gate) rows.
## Alpha gate
What a drafter needs before CADCraft can be tried on real work. CADCraft is **pre-alpha** because five
of the six rows fail. Revised on 2026-11-19 from user reports: of the issues open or closed in the
last 30 days, about 525 describe the reporter's own drawings, hardware or workflow (98 of them relayed
from Discord), and the ones that name a platform name Windows 135 times, Linux 57, macOS 36 and the
web build 14. Main platform: Windows; macOS, Linux, FreeBSD and the web build stay supported. The
evidence has limits: there is no telemetry, and someone whose copy never starts rarely files an issue.
The core workflows a typical AutoCAD professional does every day. CADCraft is **pre-alpha** because four of the five fail the gate; the failing rows are
the alpha checklist. Main platform: macOS.
| Row | Passes? | Evidence | Passes when |
| Core workflow | Works end to end? | Evidence | Hours to pass |
|---|---|---|---|
| It starts on the hardware people have | **no** | Black window or a crash at startup on older Intel graphics, older macOS and some virtual machines (#1724, #1631, #3222, #1780); `CADCRAFT_STENCIL=0` is waiting in #1596; no automatic fallback renderer | It reaches a usable drawing area on Windows 10 and 11 with old integrated graphics, in a virtual machine, and on the supported macOS and Linux versions, choosing a fallback renderer by itself |
| It opens the DWG and DXF files people already have, correctly and in reasonable time | **no** | Large DWGs are refused at a size limit or freeze the window (#3102, #2633, #1088); layouts come in at the wrong scale or in the wrong units (#1672, #2836); a DWG with 3D content crashes or opens empty (#2174); the corpus holds four files, all written by CADCraft, and CI does not run it | A corpus of files made by AutoCAD and other CAD programs opens in CI with its objects, layouts, viewports and units right, compared with what the program that wrote it shows; a large file opens or says clearly why not; content we don't model is kept and never crashes |
| Saving loses nothing, and other CAD programs open the result | **no** | DXF keeps what we don't model (#528); other applications' objects are kept as proxies (#2917, #2919, #2654); through DWG, custom-class objects without data for the version written are still dropped; fixes for files AutoCAD or BricsCAD refuse are waiting (#2904, #1687, #3234); never checked against a corpus in AutoCAD | The corpus round-trips with every object kept and its geometry and properties unchanged, a save names anything it could not keep, and AutoCAD opens the saved files without a recovery prompt |
| Input feels like AutoCAD for Windows | **partial, blocking** | Running snaps, polar, ortho, coordinate entry, tracking, FROM/M2P/TK and dynamic input work; a click while the mouse moves can be lost (#1001, #2092), right-click and Space don't always act as Enter (#1387), a double-click doesn't edit TEXT in place (#842); fixes are waiting in pull requests | A click counts while the pointer moves; right-click and Space repeat or confirm as set in Options; a double-click edits text, multiline text and dimension text in place |
| Draft, dimension and annotate a sheet, with styles | partial, not blocking | All core DIM types, associativity, the Dimension Style Manager (#1460), TEXT/MTEXT, MLEADER, tables, the in-place MTEXT editor, blocks with attributes, xrefs, the Block Editor and REFEDIT work; a few prompt options still print "not available yet" ([gaps.md](gaps.md) F1); ellipse and spline intersections are approximate | No "not available yet" in the most-used draw, modify and annotate commands, apart from options that need 3D |
| Lay out and print a sheet at scale, and the interface can always be restored | **partial, blocking** | Layers, layouts, viewports, page setups, PDF output, plot styles, the Plot dialog, preview and PUBLISH work; a print can come out off scale (#3216); printers are reached only through PDF, PNG and SVG files (F14, H3); a hidden menu bar or closed panels can't always be brought back (#1240) | A metric sheet prints 1:1 on a system printer, and one command or key restores the menu bar and default panels from any state |
| Draw and modify precisely with object snaps and tracking | **partial, blocking** | Running snaps, polar, ortho, coordinate entry, object snap tracking, extension, parallel and apparent snaps (#379), FROM/M2P/TK and typed snap overrides, TRIM/EXTEND, OFFSET and ROTATE options (#397) work; ellipse/spline intersections approximate; a few prompt options still print "not available yet" ([ui-parity.md](ui-parity.md), [gaps.md](gaps.md) U4, F1) | 35–50 |
| Dimension and annotate | partial, not blocking | All core DIM types, associativity, DIMSTYLE variables (43 of ~80), TEXT/MTEXT, MLEADER (with MLEADEREDIT/ALIGN/COLLECT, #816), tables and the in-place MTEXT editor (#792) work; no DIMSTYLE dialog, MLEADER styles thin, no fields (F7, F9, F10). A drafter can dimension a sheet end to end | 0 for the gate (beta work) |
| Use blocks (insert library blocks, edit them, attributes, xrefs) | **partial, blocking** | Static BLOCK/INSERT/attributes, ATTSYNC, BATTMAN editing, xrefs (#525), the Block Editor (BEDIT/BSAVE/BCLOSE: every reference updates), REFEDIT (#818: a block reference is edited in place), XCLIP and XCLIPFRAME (#2354) and dynamic block references (visibility, distances, stretch and move actions, lookups, grips; #838–#883) work; an xref can't be edited in place, no dynamic-block authoring (F2, F3) | 35–55 |
| Layers, layouts and plotting a sheet | **partial, blocking** | Layers, layouts, viewports, page setups, PDF output, plot styles (CTB/STB, #410), the Plot dialog (#160), Plot Preview and PUBLISH (#186) and plotter devices (#564) work; printers only via PDF/PNG/SVG files (F14, H3) | 15–25 |
| Save DWG that AutoCAD opens without loss, and reopen others' DWGs | **no** | DXF keeps what we don't model (#528) and writes native MULTILEADERs (#459, not yet tested through DWG); through DWG, acadrust drops custom-class entities and objects and some foreign data (ACIS data of solids is kept, #781; damaged DWGs open partially, #859); never checked in AutoCAD; no real-file tests; a 10 MB DWG failed after ~2 min (#57) (FF1–FF6) | 40–60 + owner (real-file corpus, AutoCAD check) |
| **To alpha** | | | **≈ 125–190** |
Moved to the beta checklist on 2026-11-19, with the reports behind each: dynamic-block authoring (none),
editing an xref in place (one), exact ellipse and spline intersections (one).
Ready for real work is ≈ 38% (not re-scored since 2026-10-10), also under the ~40% alpha bar. The
≈ 125–190 h estimate was made for the previous gate and is not re-estimated for this one.
Ready for real work is ≈ 38%, also under the ~40% alpha bar; closing the gate rows lifts it past
40%.
## Beta checklist
@@ -114,7 +102,6 @@ AutoLISP surface, AI features with openly licensed local models, and every remai
| Date | Change | Summary |
|---|---|---|
| 2026-11-19 | major | Alpha gate revised from user reports: six rows (starts on common hardware; opens existing files; saves without loss; input feel; draft and annotate with styles; print at scale and a restorable interface), main platform Windows; dynamic-block authoring, xref editing in place and exact curve geometry counted under beta only; current focus re-ranked into three tiers; percentages and hours not re-scored |
| 2026-10-24 | minor | Re-audit against main 41d9b5e95: alpha-gate evidence, CI gate (#1987), beta-checklist states, open-PR and catalog counts re-checked against main 41d9b5e95; percentages and hours not re-scored |
| 2026-10-13 | minor | Re-audit against main e707ab4d: alpha-gate evidence for drafting, annotation, blocks and DWG rows; beta-checklist states for DWG/DXF, blocks and languages; current-focus items 4–7; milestone notes M1, M12, M13; percentages and hours not re-scored |
| 2026-10-12 | minor | Block Editor for static blocks landed: "Use blocks" evidence updated; status and hours unchanged (REFEDIT and dynamic blocks remain) |
+1 -1
View File
@@ -22,7 +22,7 @@ and the deep checklists are [geometry-parity.md](geometry-parity.md),
| Remaining to beta | **≈ 600–930 Opus 5.5 hours** | estimated |
| Remaining to full parity | **≈ 1,300–2,100 Opus 5.5 hours** | estimated |
Stage: **pre-alpha**. Five of the six rows of the [alpha gate](roadmap.md#alpha-gate) fail (starting on common hardware, opening the files people already have, saving without loss, input feel, printing at scale with an interface that can be restored; the gate was revised on 2026-11-19), and ready for real work is under the ~40% alpha bar. The ≈ 125–190 h to alpha was estimated for the previous gate and is not re-estimated.
Stage: **pre-alpha**. Four of the five core workflows fail the [alpha gate](roadmap.md#alpha-gate) (precise drafting with tracking, blocks, plotting, lossless DWG save), and ready for real work is under the ~40% alpha bar. Alpha is ≈ 125–190 h away.
## Readiness by audience