Sheet sets: reference menu order, new sheets stay closed, .dst reload, navigation fields

The tree menus follow the reference per row kind (New Sheet / Import on a
sheet work on its subset, Remove Subset only while empty, Rename Subset),
a new sheet is not opened, an open set reloads when its .dst changes on
disk, ViewportScale placeholders take the version of their format and
the codec pin moves to the revision with navigation fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-05 10:53:45 +03:00
1 parent ad5d2a8599
commit 612bb26a8c
28 files changed
+112 -21

No files matched your search

+6 -2
View File
@@ -328,14 +328,18 @@ impl FieldDialogState {
FieldKind::SheetSetPlaceholder => {
let (label, target, version) = PLACEHOLDER_TYPES[self.ss_placeholder.min(PLACEHOLDER_TYPES.len() - 1)];
let target = if label == "Custom" { format!("{target}{}", self.ss_custom) } else { target.to_string() };
let base = format!("\\AcSm{version} {target}");
if label == "ViewportScale" {
// The version follows the format, as for PlotScale.
let version = codec::fields::PLOT_SCALE_FORMATS
.get(self.ss_scale_format)
.map_or("", |(_, code)| if code.starts_with("\\AcVar.16.2") { ".16.2" } else { "" });
let base = format!("\\AcSm{version} {target}");
match viewport_scale_picture(self.ss_scale_format) {
f if f.is_empty() => (base, vec![]),
f => (format!("{base} {f}"), vec![]),
}
} else {
(case(base), vec![])
(case(format!("\\AcSm{version} {target}")), vec![])
}
}
FieldKind::BlockPlaceholder => {
+32 -15
View File
@@ -63,6 +63,8 @@ pub struct SheetSetManager {
pub found: String,
/// The open dialog (shown in the `SheetSet` modal).
pub dialog: Option<SsDialog>,
/// Last seen modification time of each open `.dst` (by path key).
pub seen: std::collections::HashMap<String, std::time::SystemTime>,
}
impl SheetSetManager {
@@ -99,6 +101,8 @@ pub enum SheetSetMsg {
Activate(String),
Menu(String, MenuAction),
Refresh,
/// Once a second: reload sets whose `.dst` changed on disk.
Poll,
/// A `.dst` picked by Open (or given by automation).
OpenPicked(Option<std::path::PathBuf>),
/// A drawing picked by Import Layout as Sheet.
@@ -322,23 +326,35 @@ fn menu_separator() -> Element<'static, Message> {
}
/// A row's right-click menu.
fn row_menu(id: String, kind: ComponentKind) -> Element<'static, Message> {
/// The reference's order per row kind; a sheet's New Sheet / Import work on
/// its subset, and only an empty subset can be removed.
fn row_menu(id: String, kind: ComponentKind, empty: bool) -> Element<'static, Message> {
let entry = |label: &str, action: MenuAction, on: bool| {
menu_entry(t!(label).into_owned(), on.then(|| msg(SheetSetMsg::Menu(id.clone(), action))))
};
let sheet = kind == ComponentKind::Sheet;
let mut items = vec![
entry("Open", MenuAction::Open, sheet),
menu_separator(),
entry("New Sheet...", MenuAction::NewSheet, !sheet),
entry("New Subset...", MenuAction::NewSubset, !sheet),
entry("Import Layout as Sheet...", MenuAction::ImportLayout, !sheet),
menu_separator(),
entry("Rename & Renumber...", MenuAction::Rename, sheet),
entry(if kind == ComponentKind::Subset { "Remove Subset" } else { "Remove Sheet" }, MenuAction::Remove, kind != ComponentKind::SheetSet),
];
if kind == ComponentKind::SheetSet {
items.push(entry("Close Sheet Set", MenuAction::Close, true));
let mut items = Vec::new();
match kind {
ComponentKind::SheetSet => items.extend([entry("Close Sheet Set", MenuAction::Close, true), menu_separator()]),
ComponentKind::Sheet => items.extend([entry("Open", MenuAction::Open, true), menu_separator()]),
ComponentKind::Subset => {}
}
items.push(entry("New Sheet...", MenuAction::NewSheet, true));
if kind != ComponentKind::Sheet {
items.push(entry("New Subset...", MenuAction::NewSubset, true));
}
items.push(entry("Import Layout as Sheet...", MenuAction::ImportLayout, true));
match kind {
ComponentKind::SheetSet => {}
ComponentKind::Subset => items.extend([
menu_separator(),
entry("Rename Subset...", MenuAction::Properties, true),
entry("Remove Subset", MenuAction::Remove, empty),
]),
ComponentKind::Sheet => items.extend([
menu_separator(),
entry("Rename & Renumber...", MenuAction::Rename, true),
entry("Remove Sheet", MenuAction::Remove, true),
]),
}
items.push(menu_separator());
items.push(entry("Properties...", MenuAction::Properties, true));
@@ -391,7 +407,8 @@ fn tree_row<'a>(
}))
.on_press(msg(SheetSetMsg::Select(id.clone())))
.on_double_click(msg(SheetSetMsg::Activate(id.clone())));
iced_aw::ContextMenu::new(area, move || row_menu(id.clone(), kind)).into()
let empty = !el.children.iter().any(|c| matches!(ComponentKind::of(c), Some(ComponentKind::Subset | ComponentKind::Sheet)));
iced_aw::ContextMenu::new(area, move || row_menu(id.clone(), kind, empty)).into()
}
fn push_tree<'a>(