forked from 1b-agent/opencadstudio-upstream
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:
1 parent
ad5d2a8599
commit
612bb26a8c
28 files changed
+112
-21
No files matched your search
Generated
+1
-1
@@ -4206,7 +4206,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "opencadcodec"
|
||||
version = "0.5.5"
|
||||
source = "git+https://github.com/ramox81/cadcodec.git?rev=19aec85#19aec855cf38d1dbdaf32d09c69343fc479bfbf9"
|
||||
source = "git+https://github.com/ramox81/cadcodec.git?rev=3f5d40a#3f5d40a82368cd2dd5e5c44388f8630647ff3533"
|
||||
dependencies = [
|
||||
"ahash 0.8.12",
|
||||
"anyhow",
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ block2 = "0.5"
|
||||
objc2-foundation = { version = "0.2", features = ["NSArray", "NSURL", "NSString", "NSObject", "NSNotification", "NSThread", "NSEnumerator"] }
|
||||
|
||||
[patch."https://github.com/HakanSeven12/opencadcodec.git"]
|
||||
opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "19aec85" }
|
||||
opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "3f5d40a" }
|
||||
|
||||
[patch.crates-io]
|
||||
iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" }
|
||||
|
||||
@@ -4406,6 +4406,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4393,6 +4393,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4391,6 +4391,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4392,6 +4392,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4394,6 +4394,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4395,6 +4395,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4394,6 +4394,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4393,6 +4393,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4394,6 +4394,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4382,6 +4382,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4393,6 +4393,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4393,6 +4393,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4382,6 +4382,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4393,6 +4393,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4392,6 +4392,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4393,6 +4393,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4394,6 +4394,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4395,6 +4395,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4354,6 +4354,7 @@ view =
|
||||
.ss-subset-name = Alt küme adı
|
||||
.ss-new-sheet-location = Yeni sayfa konumu
|
||||
.ss-remove-subset = Alt Kümeyi Kaldır
|
||||
.ss-rename-subset = Alt Kümeyi Yeniden Adlandır...
|
||||
.ss-remove-sheet = Sayfayı Kaldır
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Çizim içeren bir veya daha fazla klasör belirtmenizi sağlar. Bu çizimlerdeki düzenler sayfa kümesine otomatik olarak aktarılabilir.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Alt kümesi ve sayfası olmayan bir sayfa kümesi oluşturur.
|
||||
|
||||
@@ -4377,6 +4377,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -4389,6 +4389,7 @@ view =
|
||||
.ss-subset-name = Subset name
|
||||
.ss-new-sheet-location = New sheet location
|
||||
.ss-remove-subset = Remove Subset
|
||||
.ss-rename-subset = Rename Subset...
|
||||
.ss-remove-sheet = Remove Sheet
|
||||
.ss-lets-you-specify-one-or-more-folders-containing-drawings-the = Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set.
|
||||
.ss-creates-a-sheet-set-with-no-subsets-or-sheets = Creates a sheet set with no subsets or sheets.
|
||||
|
||||
@@ -254,6 +254,32 @@ impl OpenCADStudio {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Reload every open set whose `.dst` was changed by someone else.
|
||||
fn poll_sheet_sets(&mut self) {
|
||||
let mut changed = false;
|
||||
for db in &mut self.sheet_set.sets {
|
||||
let Some(path) = db.path.clone() else {
|
||||
continue;
|
||||
};
|
||||
let Ok(modified) = std::fs::metadata(&path).and_then(|m| m.modified()) else {
|
||||
continue;
|
||||
};
|
||||
let key = ss::path_key(&path);
|
||||
if self.sheet_set.seen.insert(key, modified).is_none_or(|t| t == modified) {
|
||||
continue;
|
||||
}
|
||||
if let Ok(fresh) = SheetSetDatabase::read(&path) {
|
||||
if fresh.root != db.root {
|
||||
*db = fresh;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if changed {
|
||||
self.sheet_sets_changed();
|
||||
}
|
||||
}
|
||||
|
||||
/// Write the current set back to its `.dst`.
|
||||
fn save_current_sheet_set(&mut self) {
|
||||
let Some(db) = self.sheet_set.db_mut() else {
|
||||
@@ -358,6 +384,7 @@ impl OpenCADStudio {
|
||||
self.sheet_set.collapsed.insert(id);
|
||||
}
|
||||
}
|
||||
SheetSetMsg::Poll => self.poll_sheet_sets(),
|
||||
SheetSetMsg::Refresh => {
|
||||
if let Some(path) = self.sheet_set.db().and_then(|db| db.path.clone()) {
|
||||
match SheetSetDatabase::read(&path) {
|
||||
@@ -513,6 +540,15 @@ impl OpenCADStudio {
|
||||
let Some(db) = self.sheet_set.db() else {
|
||||
return Task::none();
|
||||
};
|
||||
// On a sheet, New Sheet and Import work on the subset holding it.
|
||||
let id = match action {
|
||||
MenuAction::NewSheet | MenuAction::ImportLayout
|
||||
if db.find(&id).and_then(ComponentKind::of) == Some(ComponentKind::Sheet) =>
|
||||
{
|
||||
db.parent_of(&id).map_or(id, |p| p.id().to_string())
|
||||
}
|
||||
_ => id,
|
||||
};
|
||||
match action {
|
||||
MenuAction::Open => return self.open_sheet(&id),
|
||||
MenuAction::NewSheet => {
|
||||
@@ -1098,11 +1134,12 @@ impl OpenCADStudio {
|
||||
if let Err(e) = crate::io::save(&scene.document, &path) {
|
||||
self.command_line.push_error(&format!("{file}: {e}"));
|
||||
}
|
||||
// The new sheet is not opened ("Open in drawing editor" is off by default).
|
||||
self.close_active_modal();
|
||||
self.sheet_set.current = Some(f.set);
|
||||
self.sheet_set.selected = Some(sheet.clone());
|
||||
self.sheet_set.selected = Some(sheet);
|
||||
self.sheet_sets_changed();
|
||||
self.open_sheet(&sheet)
|
||||
Task::none()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2644,6 +2644,16 @@ impl OpenCADStudio {
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let plugin_drain = Subscription::none();
|
||||
// Open sheet sets reload when their .dst changes on disk.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let sheet_set_poll = if self.sheet_set.sets.is_empty() {
|
||||
Subscription::none()
|
||||
} else {
|
||||
iced::time::every(std::time::Duration::from_secs(1))
|
||||
.map(|_| Message::SheetSet(crate::ui::window::sheet_set::SheetSetMsg::Poll))
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let sheet_set_poll = Subscription::none();
|
||||
let hatch_pattern_keys = if self.tabs[self.active_tab]
|
||||
.properties
|
||||
.hatch_pattern_picker_open
|
||||
@@ -2845,6 +2855,7 @@ impl OpenCADStudio {
|
||||
web_fonts,
|
||||
autosave,
|
||||
plugin_drain,
|
||||
sheet_set_poll,
|
||||
single_instance,
|
||||
hatch_pattern_keys,
|
||||
keyboard_events,
|
||||
|
||||
@@ -49,6 +49,7 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
|
||||
"Subset name" => Some(("view", "ss-subset-name")),
|
||||
"New sheet location" => Some(("view", "ss-new-sheet-location")),
|
||||
"Remove Subset" => Some(("view", "ss-remove-subset")),
|
||||
"Rename Subset..." => Some(("view", "ss-rename-subset")),
|
||||
"Remove Sheet" => Some(("view", "ss-remove-sheet")),
|
||||
"Lets you specify one or more folders containing drawings. The layouts from these drawings can be automatically imported into the sheet set." => Some(("view", "ss-lets-you-specify-one-or-more-folders-containing-drawings-the")),
|
||||
"Creates a sheet set with no subsets or sheets." => Some(("view", "ss-creates-a-sheet-set-with-no-subsets-or-sheets")),
|
||||
|
||||
@@ -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
@@ -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>(
|
||||
|
||||
Reference in new issue
Block a user