Automation: ribbon tab and dropdown actions; _PDFIMPORTFILE takes a path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-09-24 19:10:41 +03:00
1 parent 28853cd32e
commit c9426a5d6d
3 files changed
+38

No files matched your search

+11
View File
@@ -669,6 +669,17 @@ impl OpenCADStudio {
"_PDFIMPORTFILE" => {
return Some(Task::done(Message::PdfImportPick));
}
// A file named after it skips the picker.
cmd if cmd.starts_with("_PDFIMPORTFILE ") => {
let path = cmd["_PDFIMPORTFILE ".len()..].trim().trim_matches('"').to_string();
match std::fs::read(&path) {
Ok(bytes) => {
crate::scene::model::pdf_raster::register_source(&path, std::sync::Arc::new(bytes));
self.open_pdf_import_file(&path);
}
Err(_) => self.command_line.push_error(&format!("{path} not found.")),
}
}
"PDFCLIP" | "CLIP" => {
use crate::command::CadCommand;
let command = crate::modules::insert::pdf_clip::PdfClipCommand::new(cmd == "CLIP");
+12
View File
@@ -50,6 +50,8 @@ pub(super) const NAMES: &[&str] = &[
"pdf_dialog_ok",
"pdf_layer_toggle",
"pdf_page_select",
"ribbon_tab",
"ribbon_dropdown",
"close_document",
"toggle_properties",
"toggle_layers",
@@ -683,6 +685,16 @@ impl OpenCADStudio {
state.selected = pages;
return Ok(Task::none());
}
// Bring a ribbon tab forward by module id ("pdf_underlay" for the
// contextual underlay tab).
"ribbon_tab" => {
let id = string(req, "value")?;
if !self.ribbon.select_by_id(id) {
return Err(failure("no_tab", "No such ribbon tab"));
}
return Ok(Task::none());
}
"ribbon_dropdown" => Message::ToggleRibbonDropdown(string(req, "value")?.into()),
"pdf_dialog_ok" => {
use crate::ui::window::pdf_dialogs::PdfDialogMsg;
Message::PdfDialog(match self.active_modal {
+15
View File
@@ -180,6 +180,21 @@ impl Ribbon {
self.underlay_ctx.as_mut()
}
/// Select a tab by its module id; "pdf_underlay" is the contextual tab.
pub fn select_by_id(&mut self, id: &str) -> bool {
if id == "pdf_underlay" {
self.select_underlay_tab();
return self.underlay_tab_active;
}
match self.modules.iter().position(|m| m.id() == id) {
Some(index) => {
self.select(index);
true
}
None => false,
}
}
pub fn select_underlay_tab(&mut self) {
if self.underlay_ctx.is_some() {
self.underlay_tab_active = true;