forked from 1b-agent/opencadstudio-upstream
refactor(modules): rename home module to draw, restore first-tab order
The Home tab was already titled "Draw"; rename the module to match:
folder modules/home → modules/draw, HomeModule → DrawModule, id "home"
→ "draw". The inner draw/ command folder is kept (modules::draw::draw).
Update build.rs PRIORITY ("home" → "draw") so the tab returns to the
front of the ribbon; registry.rs regenerates accordingly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
c6152ef705
commit
3666c7fa69
85 files changed
+141
-141
No files matched your search
@@ -0,0 +1,64 @@
|
||||
// Paste tool — ribbon definition + CadCommand implementation.
|
||||
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "PASTECLIP",
|
||||
label: "Paste",
|
||||
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/paste.svg")),
|
||||
event: ModuleEvent::Command("PASTECLIP".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
// ── CadCommand implementation ─────────────────────────────────────────────
|
||||
|
||||
use acadrust::Handle;
|
||||
use glam::Vec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
use crate::scene::model::wire_model::WireModel;
|
||||
|
||||
pub struct PasteCommand {
|
||||
/// Wire models of the clipboard entities (used for preview).
|
||||
wires: Vec<WireModel>,
|
||||
/// Centroid of the clipboard entities (offset origin for translation).
|
||||
centroid: Vec3,
|
||||
}
|
||||
|
||||
impl PasteCommand {
|
||||
pub fn new(wires: Vec<WireModel>, centroid: Vec3) -> Self {
|
||||
Self { wires, centroid }
|
||||
}
|
||||
}
|
||||
|
||||
impl CadCommand for PasteCommand {
|
||||
fn name(&self) -> &'static str {
|
||||
"PASTECLIP"
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
"PASTECLIP Pick insertion point:".into()
|
||||
}
|
||||
|
||||
fn on_point(&mut self, pt: Vec3) -> CmdResult {
|
||||
CmdResult::PasteClipboard { base_pt: pt }
|
||||
}
|
||||
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
|
||||
fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec<WireModel> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> {
|
||||
let delta = pt - self.centroid;
|
||||
self.wires.iter().map(|w| w.translated(delta)).collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ── Autocomplete registry ─────────────────────────────────
|
||||
inventory::submit!(crate::command::CommandRegistration { names: &["PASTECLIP", "PC"] }); // PasteCommand
|
||||
Reference in new issue
Block a user