forked from 1b-agent/opencadstudio-upstream
Add named parameters, UI scale setting, OPTIONS/OP dispatch, and help manual
Named parameters (docs/named_parameters_design.md, stages 3-4): - ParameterTable (src/scene/named_parameters.rs): a document-wide table of named formulas, each resolved through a shared expression evaluator with cross-parameter references, cycle detection, and division-by-zero/parse error reporting. SketchConstraint::driving_param becomes DrivingValue (Literal | Named) instead of a bare f64, resolved at solve time by sketch_solve::build_constraint via Scene::named_parameters. - Persistence (src/scene/named_parameters_persist.rs): same lazy XRecord model sketch_persist.rs already established, synced around open/save. Bumps the sketch-constraint XRecord's own format version (1 -> 2) since DrivingValue's shape doesn't line up with a version-1 blob's bytes. - PARAMETERS command and its editor (src/ui/window/named_parameters.rs): add/remove/edit rows, live validation, duplicate-name detection: Apply defines the table and re-solves every constraint scope with a named-parameter-driven constraint (command_driver.rs). Distance/Angle constraint prompts (modules/draw/constrain/value.rs) now accept either a literal or an existing parameter's name, mirroring how the constraint's own value prompt already worked. - Undo scope-down carried over from this project's own established pattern (constraint-system stage 9): the geometry an Apply moves is one undo step, but the parameter table edit itself has no undo entry yet — a documented follow-up, not a silent gap. UI scale setting (src/app/settings.rs, app/mod.rs, ui/window/options.rs): a whole-interface scale percentage (50-200%), wired directly into iced's own per-window scale_factor hook rather than per-panel font-size plumbing, so it applies immediately to every panel, dialog, and the ribbon at once. Persisted alongside the existing lineweight-display-scale setting. OPTIONS/OP command dispatch (app/commands/view.rs, app/commands/mod.rs): OPTIONS was registered for autocomplete but had no dispatch arm — the Start-tab welcome screen's own button was the only way to reach it. Found live-testing the UI-scale setting, unrelated to that feature itself. "OP" is AutoCAD's own short alias. help/: a new self-contained static user-help manual (manual.md as the authored source, tools/build_help.py splits it into the committed static HTML pages plus search index) — not yet wired into the application. 64 new/updated tests across the named-parameters and constraint-prompt changes. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
e2d39b049d
commit
7cddf31bcb
47 files changed
+4136
-52
No files matched your search
@@ -0,0 +1,190 @@
|
||||
:root {
|
||||
color-scheme: light dark;
|
||||
--accent: #1677d2;
|
||||
--accent-strong: #075cae;
|
||||
--accent-soft: #eaf4ff;
|
||||
--canvas: #ffffff;
|
||||
--chrome: rgba(20, 27, 37, 0.96);
|
||||
--line: #d7dee7;
|
||||
--muted: #617083;
|
||||
--sidebar: #f4f7fa;
|
||||
--text: #16202c;
|
||||
--warning: #fff4cc;
|
||||
--danger: #a62b2b;
|
||||
--sidebar-width: 286px;
|
||||
--topbar-height: 62px;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
html { scroll-padding-top: calc(var(--topbar-height) + 20px); }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--canvas);
|
||||
color: var(--text);
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 1.62;
|
||||
}
|
||||
|
||||
a { color: var(--accent-strong); text-decoration-thickness: .08em; text-underline-offset: .16em; }
|
||||
a:hover { color: var(--accent); }
|
||||
a:focus-visible, button:focus-visible, input:focus-visible {
|
||||
outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
position: fixed;
|
||||
inset: 0 0 auto;
|
||||
z-index: 30;
|
||||
height: var(--topbar-height);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 0 18px;
|
||||
background: var(--chrome);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, .13);
|
||||
backdrop-filter: blur(16px);
|
||||
}
|
||||
|
||||
.brand { min-width: 190px; color: #fff; font-size: 18px; font-weight: 720; text-decoration: none; }
|
||||
.brand:hover { color: #fff; }
|
||||
.nav-toggle {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
font-size: 22px;
|
||||
}
|
||||
.nav-toggle:hover { background: rgba(255, 255, 255, .12); }
|
||||
|
||||
.search-shell { position: relative; width: min(520px, 55vw); margin-left: auto; }
|
||||
.help-search {
|
||||
width: 100%;
|
||||
height: 38px;
|
||||
padding: 0 42px 0 13px;
|
||||
border: 1px solid rgba(255, 255, 255, .24);
|
||||
border-radius: 9px;
|
||||
background: rgba(255, 255, 255, .11);
|
||||
color: #fff;
|
||||
font: inherit;
|
||||
}
|
||||
.help-search::placeholder { color: rgba(255, 255, 255, .68); }
|
||||
.search-key { position: absolute; top: 8px; right: 10px; color: rgba(255, 255, 255, .64); font-size: 13px; }
|
||||
.search-results {
|
||||
position: absolute;
|
||||
top: 44px;
|
||||
right: 0;
|
||||
width: min(620px, calc(100vw - 24px));
|
||||
max-height: min(70vh, 560px);
|
||||
overflow: auto;
|
||||
margin: 0;
|
||||
padding: 7px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
background: var(--canvas);
|
||||
box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
|
||||
list-style: none;
|
||||
}
|
||||
.search-results[hidden] { display: none; }
|
||||
.search-results a { display: block; padding: 10px 11px; border-radius: 7px; color: var(--text); text-decoration: none; }
|
||||
.search-results a:hover, .search-results a[aria-selected="true"] { background: var(--accent-soft); }
|
||||
.search-results strong { display: block; color: var(--accent-strong); }
|
||||
.search-results span { display: block; color: var(--muted); font-size: 13px; }
|
||||
.search-empty { padding: 12px; color: var(--muted); }
|
||||
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
z-index: 20;
|
||||
inset: var(--topbar-height) auto 0 0;
|
||||
width: var(--sidebar-width);
|
||||
padding: 16px 13px 36px;
|
||||
overflow: auto;
|
||||
background: var(--sidebar);
|
||||
border-right: 1px solid var(--line);
|
||||
transition: transform 180ms ease;
|
||||
}
|
||||
body.nav-collapsed .sidebar { transform: translateX(-100%); }
|
||||
.sidebar details, .sidebar > div { margin: 3px 0; border-radius: 8px; }
|
||||
.sidebar details.current-topic, .sidebar > div.current-topic { background: var(--canvas); box-shadow: 0 0 0 1px var(--line); }
|
||||
.sidebar summary { padding: 7px 9px; font-weight: 680; cursor: pointer; }
|
||||
.sidebar .chapter-link { display: block; padding: 7px 9px; font-weight: 680; }
|
||||
.sidebar ul { margin: 0; padding: 0 9px 9px 27px; list-style: none; }
|
||||
.sidebar li { margin: 2px 0; line-height: 1.35; }
|
||||
.sidebar li a { display: block; padding: 3px 0; color: var(--text); font-size: 13px; text-decoration: none; }
|
||||
.sidebar li a:hover { color: var(--accent); }
|
||||
|
||||
#main-content {
|
||||
min-height: 100vh;
|
||||
margin-left: var(--sidebar-width);
|
||||
padding: calc(var(--topbar-height) + 38px) 34px 70px;
|
||||
transition: margin-left 180ms ease;
|
||||
}
|
||||
body.nav-collapsed #main-content { margin-left: 0; }
|
||||
.content-wrap { max-width: 940px; margin: 0 auto; }
|
||||
.page-kicker { margin: 0; color: var(--accent-strong); font-size: 12px; font-weight: 760; letter-spacing: .09em; text-transform: uppercase; }
|
||||
.content-title { margin: 3px 0 30px; font-size: clamp(34px, 6vw, 52px); line-height: 1.06; letter-spacing: -.035em; }
|
||||
|
||||
h2 { margin: 44px 0 17px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); font-size: 23px; line-height: 1.3; }
|
||||
h3 { margin: 34px 0 8px; font-size: 19px; line-height: 1.35; }
|
||||
p { margin: 9px 0 16px; }
|
||||
ul, ol { padding-left: 26px; }
|
||||
li { margin: 5px 0; }
|
||||
code, pre { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
|
||||
code { color: #a0440c; font-size: .91em; }
|
||||
blockquote {
|
||||
margin: 18px 0;
|
||||
padding: 12px 15px;
|
||||
border: 1px solid color-mix(in srgb, #d5a000 45%, var(--line));
|
||||
border-left: 4px solid #d5a000;
|
||||
border-radius: 8px;
|
||||
background: var(--warning);
|
||||
color: #503f05;
|
||||
}
|
||||
blockquote p { margin: 0; }
|
||||
|
||||
.page-navigation { display: flex; justify-content: space-between; gap: 20px; margin-top: 58px; padding-top: 18px; border-top: 1px solid var(--line); }
|
||||
.page-navigation a:last-child { margin-left: auto; }
|
||||
.date-footer { margin-top: 34px; color: var(--muted); font-size: 13px; text-align: center; }
|
||||
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.brand { min-width: 0; font-size: 16px; }
|
||||
.search-shell { width: min(48vw, 420px); }
|
||||
.search-key { display: none; }
|
||||
.sidebar { box-shadow: 12px 0 34px rgba(0, 0, 0, .22); }
|
||||
body:not(.nav-open) .sidebar { transform: translateX(-100%); }
|
||||
body.nav-open .sidebar { transform: translateX(0); }
|
||||
#main-content, body.nav-collapsed #main-content { margin-left: 0; padding: calc(var(--topbar-height) + 28px) 18px 52px; }
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--accent: #66b6ff;
|
||||
--accent-strong: #8bc7ff;
|
||||
--accent-soft: #17344f;
|
||||
--canvas: #161b22;
|
||||
--chrome: rgba(14, 18, 24, .96);
|
||||
--line: #374252;
|
||||
--muted: #9eabba;
|
||||
--sidebar: #1d242d;
|
||||
--text: #eef3f8;
|
||||
--warning: #423819;
|
||||
}
|
||||
code { color: #ffae79; }
|
||||
blockquote { color: #f5e6ad; }
|
||||
}
|
||||
|
||||
@media print {
|
||||
.topbar, .sidebar, .page-navigation { display: none !important; }
|
||||
#main-content { margin: 0; padding: 0; }
|
||||
body { color: #000; background: #fff; font-size: 11pt; }
|
||||
a { color: inherit; }
|
||||
h2, h3 { break-after: avoid; }
|
||||
blockquote { break-inside: avoid; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
.hero {
|
||||
margin: 0 0 38px;
|
||||
padding: clamp(25px, 6vw, 56px);
|
||||
border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
|
||||
border-radius: 18px;
|
||||
background:
|
||||
linear-gradient(115deg, color-mix(in srgb, var(--accent-soft) 82%, var(--canvas)), var(--canvas));
|
||||
}
|
||||
.hero .eyebrow { margin: 0; color: var(--accent-strong); font-size: 12px; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }
|
||||
.hero h2 { margin: 8px 0 14px; padding: 0; border: 0; font-size: clamp(28px, 5vw, 44px); line-height: 1.08; letter-spacing: -.03em; }
|
||||
.hero p:last-child { max-width: 720px; margin-bottom: 0; font-size: 17px; }
|
||||
.chapter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
||||
.chapter-card { min-height: 130px; display: flex; flex-direction: column; gap: 7px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
|
||||
.chapter-card:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
|
||||
.chapter-card strong { color: var(--accent-strong); font-size: 18px; }
|
||||
.chapter-card span { color: var(--muted); }
|
||||
.quick-paths { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 28px; }
|
||||
.quick-paths a { padding: 12px; border: 1px solid var(--line); border-radius: 9px; text-align: center; text-decoration: none; }
|
||||
.quick-paths a:hover { background: var(--accent-soft); }
|
||||
@media (max-width: 640px) {
|
||||
.chapter-grid, .quick-paths { grid-template-columns: 1fr; }
|
||||
.chapter-card { min-height: 0; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Help images
|
||||
|
||||
Place optimized screenshots and workflow illustrations in this directory.
|
||||
|
||||
Use descriptive lowercase filenames, include meaningful alternative text in
|
||||
`manual.md`, crop away unrelated desktop content, and avoid confidential drawing
|
||||
names or paths. Prefer WebP or optimized PNG and keep each image at the smallest
|
||||
resolution that remains legible on a high-density display.
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const body = document.body;
|
||||
const toggle = document.querySelector(".nav-toggle");
|
||||
const sidebar = document.getElementById("help-sidebar");
|
||||
const search = document.getElementById("help-search");
|
||||
const results = document.getElementById("search-results");
|
||||
const mobile = window.matchMedia("(max-width: 760px)");
|
||||
let selected = -1;
|
||||
|
||||
function syncToggle() {
|
||||
const expanded = mobile.matches
|
||||
? body.classList.contains("nav-open")
|
||||
: !body.classList.contains("nav-collapsed");
|
||||
toggle?.setAttribute("aria-expanded", String(expanded));
|
||||
}
|
||||
|
||||
toggle?.addEventListener("click", function () {
|
||||
body.classList.toggle(mobile.matches ? "nav-open" : "nav-collapsed");
|
||||
syncToggle();
|
||||
});
|
||||
|
||||
sidebar?.addEventListener("click", function (event) {
|
||||
if (mobile.matches && event.target.closest("a")) {
|
||||
body.classList.remove("nav-open");
|
||||
syncToggle();
|
||||
}
|
||||
});
|
||||
|
||||
mobile.addEventListener("change", function () {
|
||||
body.classList.remove("nav-open");
|
||||
syncToggle();
|
||||
});
|
||||
|
||||
function hideResults() {
|
||||
results.hidden = true;
|
||||
results.innerHTML = "";
|
||||
selected = -1;
|
||||
search?.setAttribute("aria-expanded", "false");
|
||||
}
|
||||
|
||||
function renderResults(query) {
|
||||
const terms = query.toLocaleLowerCase().trim().split(/\s+/).filter(Boolean);
|
||||
if (!terms.length) {
|
||||
hideResults();
|
||||
return;
|
||||
}
|
||||
|
||||
const matches = (window.OCS_HELP_INDEX || []).map(function (entry) {
|
||||
const title = entry.title.toLocaleLowerCase();
|
||||
const text = entry.text.toLocaleLowerCase();
|
||||
const score = terms.reduce(function (total, term) {
|
||||
if (!text.includes(term) && !title.includes(term)) return -1000;
|
||||
return total + (title.includes(term) ? 8 : 1);
|
||||
}, 0);
|
||||
return { entry: entry, score: score };
|
||||
}).filter(function (item) { return item.score >= 0; })
|
||||
.sort(function (a, b) { return b.score - a.score || a.entry.title.localeCompare(b.entry.title); })
|
||||
.slice(0, 12);
|
||||
|
||||
results.innerHTML = "";
|
||||
if (!matches.length) {
|
||||
const empty = document.createElement("li");
|
||||
empty.className = "search-empty";
|
||||
empty.textContent = "No matching help topics.";
|
||||
results.appendChild(empty);
|
||||
} else {
|
||||
matches.forEach(function (item) {
|
||||
const li = document.createElement("li");
|
||||
const link = document.createElement("a");
|
||||
link.href = item.entry.url;
|
||||
const strong = document.createElement("strong");
|
||||
strong.textContent = item.entry.title;
|
||||
const detail = document.createElement("span");
|
||||
detail.textContent = item.entry.chapter;
|
||||
link.append(strong, detail);
|
||||
li.appendChild(link);
|
||||
results.appendChild(li);
|
||||
});
|
||||
}
|
||||
results.hidden = false;
|
||||
search.setAttribute("aria-expanded", "true");
|
||||
selected = -1;
|
||||
}
|
||||
|
||||
search?.addEventListener("input", function () { renderResults(search.value); });
|
||||
search?.addEventListener("keydown", function (event) {
|
||||
const links = Array.from(results.querySelectorAll("a"));
|
||||
if (event.key === "Escape") {
|
||||
search.value = "";
|
||||
hideResults();
|
||||
return;
|
||||
}
|
||||
if (!links.length || !["ArrowDown", "ArrowUp", "Enter"].includes(event.key)) return;
|
||||
event.preventDefault();
|
||||
if (event.key === "Enter" && selected >= 0) {
|
||||
links[selected].click();
|
||||
return;
|
||||
}
|
||||
if (event.key === "ArrowDown") selected = (selected + 1) % links.length;
|
||||
if (event.key === "ArrowUp") selected = selected < 0 ? links.length - 1 : (selected - 1 + links.length) % links.length;
|
||||
links.forEach(function (link, index) { link.setAttribute("aria-selected", String(index === selected)); });
|
||||
links[selected]?.scrollIntoView({ block: "nearest" });
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", function (event) {
|
||||
const shortcut = event.key === "/" || ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k");
|
||||
if (shortcut && document.activeElement !== search) {
|
||||
event.preventDefault();
|
||||
search?.focus();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("click", function (event) {
|
||||
if (!event.target.closest(".search-shell")) hideResults();
|
||||
});
|
||||
|
||||
syncToggle();
|
||||
}());
|
||||
Reference in new issue
Block a user