feat(ribbon): contextual Block Editor tab while editing a block

Opening the block editor brings up a Block Editor ribbon tab with
Edit / Save / Discard, Attribute Definition, and the geometric,
dimensional and parameter tools that drive parametric blocks. The tab
is only listed while a block editor session is open, and leaving the
session returns to the tab that was active before.

Refs #509

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-13 15:53:55 +03:00
1 parent 5dd05bca18
commit 9724447dd0
28 files changed
+126 -2

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
//! Contextual "Block Editor" ribbon tab, shown only while a BEDIT session is
//! open: saving or discarding the block, attribute definitions, and the
//! constraint tools that drive parametric blocks.
use crate::modules::parametric::ParametricModule;
use crate::modules::{CadModule, IconKind, ModuleEvent, RibbonGroup, RibbonItem, ToolDef};
pub struct BlockEditorModule;
impl CadModule for BlockEditorModule {
fn id(&self) -> &'static str {
"block_editor"
}
fn title(&self) -> &'static str {
"Block Editor"
}
fn ribbon_groups(&self) -> &[RibbonGroup] {
static GROUPS: std::sync::OnceLock<Vec<RibbonGroup>> = std::sync::OnceLock::new();
GROUPS.get_or_init(|| {
let command = |id: &'static str, label: &'static str, icon: &'static [u8]| {
RibbonItem::LargeTool(ToolDef {
id,
label,
icon: IconKind::Svg(icon),
event: ModuleEvent::Command(id.to_string()),
})
};
let mut groups = vec![
RibbonGroup {
title: "Open and Save",
tools: vec![
command(
"BEDIT",
"Edit Block",
include_bytes!("../../../assets/icons/edit_block.svg"),
),
command(
"BEDIT_SAVE",
"Save Block",
include_bytes!("../../../assets/icons/mt_ok.svg"),
),
command(
"BEDIT_DISCARD",
"Discard Block Edit",
include_bytes!("../../../assets/icons/mt_cancel.svg"),
),
],
},
RibbonGroup {
title: "Attributes",
tools: vec![command(
"ATTDEF",
"Attribute Definition",
include_bytes!("../../../assets/icons/attdef.svg"),
)],
},
];
// Parametric blocks are driven by the same constraints and
// parameters as the Parametric tab.
groups.extend(ParametricModule.ribbon_groups().iter().cloned());
groups
})
}
}
+1
View File
@@ -25,6 +25,7 @@ pub use ocs_plugin_api::ribbon::{
// ── Module declarations ───────────────────────────────────────────────────
pub mod annotate;
pub mod block_editor;
pub mod draw;
pub mod insert;
pub mod layout;
+1
View File
@@ -23,6 +23,7 @@ pub fn all_modules() -> Vec<Box<dyn CadModule>> {
Box::new(super::view::ViewModule),
Box::new(super::manage::ManageModule),
Box::new(super::layout::LayoutModule),
Box::new(super::block_editor::BlockEditorModule),
]
}