forked from 1b-agent/opencadstudio-upstream
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:
1 parent
5dd05bca18
commit
9724447dd0
28 files changed
+126
-2
No files matched your search
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = الإضافات
|
.plugins = الإضافات
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = محرر الكتل
|
||||||
.draw = رسم
|
.draw = رسم
|
||||||
.parametric = بارامتري
|
.parametric = بارامتري
|
||||||
.annotate = تعليقات توضيحية
|
.annotate = تعليقات توضيحية
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Приставки
|
.plugins = Приставки
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Редактор на блокове
|
||||||
.draw = Чертане
|
.draw = Чертане
|
||||||
.parametric = Параметричен
|
.parametric = Параметричен
|
||||||
.annotate = Анотиране
|
.annotate = Анотиране
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Zásuvné moduly
|
.plugins = Zásuvné moduly
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Editor bloků
|
||||||
.draw = Kreslení
|
.draw = Kreslení
|
||||||
.parametric = Parametrické
|
.parametric = Parametrické
|
||||||
.annotate = Poznámky
|
.annotate = Poznámky
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Plug-ins
|
.plugins = Plug-ins
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Blockeditor
|
||||||
.draw = Zeichnen
|
.draw = Zeichnen
|
||||||
.parametric = Parametrisch
|
.parametric = Parametrisch
|
||||||
.annotate = Beschriften
|
.annotate = Beschriften
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Πρόσθετα
|
.plugins = Πρόσθετα
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Επεξεργαστής μπλοκ
|
||||||
.draw = Σχεδίαση
|
.draw = Σχεδίαση
|
||||||
.parametric = Παραμετρικό
|
.parametric = Παραμετρικό
|
||||||
.annotate = Επισημείωση
|
.annotate = Επισημείωση
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Plugins
|
.plugins = Plugins
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Block Editor
|
||||||
.draw = Draw
|
.draw = Draw
|
||||||
.parametric = Parametric
|
.parametric = Parametric
|
||||||
.annotate = Annotate
|
.annotate = Annotate
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Complementos
|
.plugins = Complementos
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Editor de bloques
|
||||||
.draw = Dibujo
|
.draw = Dibujo
|
||||||
.parametric = Paramétrico
|
.parametric = Paramétrico
|
||||||
.annotate = Anotar
|
.annotate = Anotar
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Liitännäiset
|
.plugins = Liitännäiset
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Lohkoeditori
|
||||||
.draw = Piirrä
|
.draw = Piirrä
|
||||||
.parametric = Parametrinen
|
.parametric = Parametrinen
|
||||||
.annotate = Merkinnät
|
.annotate = Merkinnät
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Extensions
|
.plugins = Extensions
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Éditeur de blocs
|
||||||
.draw = Dessin
|
.draw = Dessin
|
||||||
.parametric = Paramétrique
|
.parametric = Paramétrique
|
||||||
.annotate = Annoter
|
.annotate = Annoter
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = प्लग-इन
|
.plugins = प्लग-इन
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = ब्लॉक संपादक
|
||||||
.draw = ड्रॉ
|
.draw = ड्रॉ
|
||||||
.parametric = पैरामीट्रिक
|
.parametric = पैरामीट्रिक
|
||||||
.annotate = एनोटेट
|
.annotate = एनोटेट
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Bővítmények
|
.plugins = Bővítmények
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Blokkszerkesztő
|
||||||
.draw = Rajz
|
.draw = Rajz
|
||||||
.parametric = Parametrikus
|
.parametric = Parametrikus
|
||||||
.annotate = Feliratozás
|
.annotate = Feliratozás
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Plugin
|
.plugins = Plugin
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Editor blocchi
|
||||||
.draw = Disegno
|
.draw = Disegno
|
||||||
.parametric = Parametrico
|
.parametric = Parametrico
|
||||||
.annotate = Annotazione
|
.annotate = Annotazione
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = プラグイン
|
.plugins = プラグイン
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = ブロック エディタ
|
||||||
.draw = 作図
|
.draw = 作図
|
||||||
.parametric = パラメトリック
|
.parametric = パラメトリック
|
||||||
.annotate = 注釈
|
.annotate = 注釈
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = 플러그인
|
.plugins = 플러그인
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = 블록 편집기
|
||||||
.draw = 그리기
|
.draw = 그리기
|
||||||
.parametric = 파라메트릭
|
.parametric = 파라메트릭
|
||||||
.annotate = 주석
|
.annotate = 주석
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = ປລັກອິນ
|
.plugins = ປລັກອິນ
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = ຕົວແກ້ໄຂບລັອກ
|
||||||
.draw = ແຕ້ມ
|
.draw = ແຕ້ມ
|
||||||
.parametric = ພາຣາມີຕຣິກ
|
.parametric = ພາຣາມີຕຣິກ
|
||||||
.annotate = ຄຳອະທິບາຍ
|
.annotate = ຄຳອະທິບາຍ
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Plug-ins
|
.plugins = Plug-ins
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Blokeditor
|
||||||
.draw = Tekenen
|
.draw = Tekenen
|
||||||
.parametric = Parametrisch
|
.parametric = Parametrisch
|
||||||
.annotate = Annoteren
|
.annotate = Annoteren
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Wtyczki
|
.plugins = Wtyczki
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Edytor bloków
|
||||||
.draw = Rysowanie
|
.draw = Rysowanie
|
||||||
.parametric = Parametryczne
|
.parametric = Parametryczne
|
||||||
.annotate = Opisy
|
.annotate = Opisy
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Plugins
|
.plugins = Plugins
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Editor de blocos
|
||||||
.draw = Desenhar
|
.draw = Desenhar
|
||||||
.parametric = Paramétrico
|
.parametric = Paramétrico
|
||||||
.annotate = Anotar
|
.annotate = Anotar
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Модули
|
.plugins = Модули
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Редактор блоков
|
||||||
.draw = Начертить
|
.draw = Начертить
|
||||||
.parametric = Параметрический
|
.parametric = Параметрический
|
||||||
.annotate = Аннотации
|
.annotate = Аннотации
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = Eklentiler
|
.plugins = Eklentiler
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = Blok Düzenleyici
|
||||||
.draw = Çizim
|
.draw = Çizim
|
||||||
.parametric = Parametrik
|
.parametric = Parametrik
|
||||||
.annotate = Açıklama
|
.annotate = Açıklama
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = 插件
|
.plugins = 插件
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = 块编辑器
|
||||||
.draw = 绘制
|
.draw = 绘制
|
||||||
.parametric = 参数化
|
.parametric = 参数化
|
||||||
.annotate = 注释
|
.annotate = 注释
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ action =
|
|||||||
.plugins = 外掛程式
|
.plugins = 外掛程式
|
||||||
|
|
||||||
ribbon-tab =
|
ribbon-tab =
|
||||||
|
.block-editor = 圖塊編輯器
|
||||||
.draw = 繪製
|
.draw = 繪製
|
||||||
.parametric = 參數化
|
.parametric = 參數化
|
||||||
.annotate = 註解
|
.annotate = 註解
|
||||||
|
|||||||
@@ -339,6 +339,11 @@ impl OpenCADStudio {
|
|||||||
self.sync_underlay_tab();
|
self.sync_underlay_tab();
|
||||||
}
|
}
|
||||||
self.sync_frame_dropdown();
|
self.sync_frame_dropdown();
|
||||||
|
let block_editing = self
|
||||||
|
.tabs
|
||||||
|
.get(self.active_tab)
|
||||||
|
.is_some_and(|tab| tab.active_block_edit.is_some());
|
||||||
|
self.ribbon.set_block_editing(block_editing);
|
||||||
task
|
task
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ pub fn ribbon_module_title(id: &str, fallback: &str) -> String {
|
|||||||
"layout" => crate::tr!("ribbon-tab", "layout"),
|
"layout" => crate::tr!("ribbon-tab", "layout"),
|
||||||
"manage" => crate::tr!("ribbon-tab", "manage"),
|
"manage" => crate::tr!("ribbon-tab", "manage"),
|
||||||
"view" => crate::tr!("ribbon-tab", "view"),
|
"view" => crate::tr!("ribbon-tab", "view"),
|
||||||
|
"block_editor" => crate::tr!("ribbon-tab", "block-editor"),
|
||||||
_ => fallback.to_string(),
|
_ => fallback.to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@ pub use ocs_plugin_api::ribbon::{
|
|||||||
// ── Module declarations ───────────────────────────────────────────────────
|
// ── Module declarations ───────────────────────────────────────────────────
|
||||||
|
|
||||||
pub mod annotate;
|
pub mod annotate;
|
||||||
|
pub mod block_editor;
|
||||||
pub mod draw;
|
pub mod draw;
|
||||||
pub mod insert;
|
pub mod insert;
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ pub fn all_modules() -> Vec<Box<dyn CadModule>> {
|
|||||||
Box::new(super::view::ViewModule),
|
Box::new(super::view::ViewModule),
|
||||||
Box::new(super::manage::ManageModule),
|
Box::new(super::manage::ManageModule),
|
||||||
Box::new(super::layout::LayoutModule),
|
Box::new(super::layout::LayoutModule),
|
||||||
|
Box::new(super::block_editor::BlockEditorModule),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-2
@@ -117,6 +117,9 @@ pub struct Ribbon {
|
|||||||
xref_ctx: bool,
|
xref_ctx: bool,
|
||||||
/// Only point clouds are selected: whether the first shows its crops.
|
/// Only point clouds are selected: whether the first shows its crops.
|
||||||
point_cloud_ctx: Option<bool>,
|
point_cloud_ctx: Option<bool>,
|
||||||
|
/// A block editor session is open: the tab that was active before the
|
||||||
|
/// Block Editor tab took over.
|
||||||
|
block_editing: Option<usize>,
|
||||||
/// XDWGFADECTL as the Reference slide-out shows it (negative = off).
|
/// XDWGFADECTL as the Reference slide-out shows it (negative = off).
|
||||||
pub xref_fade: i32,
|
pub xref_fade: i32,
|
||||||
}
|
}
|
||||||
@@ -219,6 +222,7 @@ impl Ribbon {
|
|||||||
underlay_ctx: None,
|
underlay_ctx: None,
|
||||||
xref_ctx: false,
|
xref_ctx: false,
|
||||||
point_cloud_ctx: None,
|
point_cloud_ctx: None,
|
||||||
|
block_editing: None,
|
||||||
xref_fade: 50,
|
xref_fade: 50,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,6 +297,28 @@ impl Ribbon {
|
|||||||
self.available_linetypes = items;
|
self.available_linetypes = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Show the Block Editor tab while a block is being edited, and return to
|
||||||
|
/// the previous tab when the editing ends.
|
||||||
|
pub fn set_block_editing(&mut self, editing: bool) {
|
||||||
|
let Some(index) = self.modules.iter().position(|module| module.id() == "block_editor")
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
match (editing, self.block_editing) {
|
||||||
|
(true, None) => {
|
||||||
|
self.block_editing = Some(self.active);
|
||||||
|
self.active = index;
|
||||||
|
}
|
||||||
|
(false, Some(previous)) => {
|
||||||
|
self.block_editing = None;
|
||||||
|
if self.active == index {
|
||||||
|
self.active = previous.min(self.modules.len().saturating_sub(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn select(&mut self, index: usize) {
|
pub fn select(&mut self, index: usize) {
|
||||||
if index < self.modules.len() {
|
if index < self.modules.len() {
|
||||||
self.active = index;
|
self.active = index;
|
||||||
@@ -550,12 +576,14 @@ impl Ribbon {
|
|||||||
|mut acc, (i, module)| {
|
|mut acc, (i, module)| {
|
||||||
// The Layout module no longer has a ribbon tab — its paper-space
|
// The Layout module no longer has a ribbon tab — its paper-space
|
||||||
// tools live in the right-edge side toolbar (see ui::side_toolbar).
|
// tools live in the right-edge side toolbar (see ui::side_toolbar).
|
||||||
if module.id() == "layout" {
|
if module.id() == "layout"
|
||||||
|
|| (module.id() == "block_editor" && self.block_editing.is_none())
|
||||||
|
{
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_active = i == self.active;
|
let is_active = i == self.active;
|
||||||
let is_contextual = module.id() == "layout";
|
let is_contextual = matches!(module.id(), "layout" | "block_editor");
|
||||||
let holds_tool = holding_tab == Some(i);
|
let holds_tool = holding_tab == Some(i);
|
||||||
let btn = container(
|
let btn = container(
|
||||||
button(
|
button(
|
||||||
|
|||||||
Reference in new issue
Block a user