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 <[email protected]>
This commit is contained in:
1 parent
c6152ef705
commit
3666c7fa69
85 files changed
+141
-141
No files matched your search
@@ -0,0 +1,13 @@
|
||||
// Color tool — ribbon definition.
|
||||
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "COLOR",
|
||||
label: "Color",
|
||||
icon: IconKind::Glyph("🎨"),
|
||||
event: ModuleEvent::Command("COLOR".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "LAYFRZ",
|
||||
label: "Layer Freeze",
|
||||
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/layers/layfrz.svg")),
|
||||
event: ModuleEvent::Command("LAYFRZ".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "LAYLCK",
|
||||
label: "Layer Lock",
|
||||
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/layers/laylck.svg")),
|
||||
event: ModuleEvent::Command("LAYLCK".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "LAYOFF",
|
||||
label: "Layer Off",
|
||||
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/layers/layoff.svg")),
|
||||
event: ModuleEvent::Command("LAYOFF".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "LAYON",
|
||||
label: "Turn All Layers On",
|
||||
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/layers/layon.svg")),
|
||||
event: ModuleEvent::Command("LAYON".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "LAYTHW",
|
||||
label: "Thaw All Layers",
|
||||
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/layers/laythw.svg")),
|
||||
event: ModuleEvent::Command("LAYTHW".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "LAYULK",
|
||||
label: "Layer Unlock",
|
||||
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/layers/layulk.svg")),
|
||||
event: ModuleEvent::Command("LAYULK".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "LAYMCUR",
|
||||
label: "Make Current",
|
||||
icon: IconKind::Svg(include_bytes!(
|
||||
"../../../../assets/icons/layers/laymcur.svg"
|
||||
)),
|
||||
event: ModuleEvent::Command("LAYMCUR".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Match Layer tool — ribbon definition + CadCommand implementation.
|
||||
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "LAYMATCH",
|
||||
label: "Match Layer",
|
||||
icon: IconKind::Svg(include_bytes!(
|
||||
"../../../../assets/icons/layers/laymatch.svg"
|
||||
)),
|
||||
event: ModuleEvent::Command("LAYMATCH".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
// ── CadCommand implementation ─────────────────────────────────────────────
|
||||
|
||||
use acadrust::Handle;
|
||||
use glam::Vec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
use crate::scene::model::wire_model::WireModel;
|
||||
|
||||
pub struct LayMatchCommand {
|
||||
dest_handles: Vec<Handle>,
|
||||
}
|
||||
|
||||
impl LayMatchCommand {
|
||||
pub fn new(dest: Vec<Handle>) -> Self {
|
||||
Self { dest_handles: dest }
|
||||
}
|
||||
}
|
||||
|
||||
impl CadCommand for LayMatchCommand {
|
||||
fn name(&self) -> &'static str {
|
||||
"LAYMATCH"
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
if self.dest_handles.is_empty() {
|
||||
"LAYMATCH Select objects to change layer:".into()
|
||||
} else {
|
||||
"LAYMATCH Select source object to match layer from:".into()
|
||||
}
|
||||
}
|
||||
|
||||
fn is_selection_gathering(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn on_selection_complete(&mut self, handles: Vec<Handle>) -> CmdResult {
|
||||
if handles.is_empty() {
|
||||
return CmdResult::NeedPoint;
|
||||
}
|
||||
if self.dest_handles.is_empty() {
|
||||
// Phase 1 complete — store destinations, move to phase 2.
|
||||
self.dest_handles = handles;
|
||||
CmdResult::NeedPoint
|
||||
} else {
|
||||
// Phase 2 complete — first handle is the source object.
|
||||
let src = handles[0];
|
||||
CmdResult::MatchEntityLayer {
|
||||
dest: std::mem::take(&mut self.dest_handles),
|
||||
src,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_point(&mut self, _pt: Vec3) -> CmdResult {
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
fn on_escape(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec<WireModel> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ── Autocomplete registry ─────────────────────────────────
|
||||
inventory::submit!(crate::command::CommandRegistration { names: &["LAYMATCH", "LAYMCH"] }); // LayMatchCommand
|
||||
@@ -0,0 +1,10 @@
|
||||
pub(super) mod color;
|
||||
pub(super) mod layfrz;
|
||||
pub(super) mod laylck;
|
||||
pub(super) mod layoff;
|
||||
pub(super) mod layon;
|
||||
pub(super) mod laythw;
|
||||
pub(super) mod layulk;
|
||||
pub(super) mod make_current;
|
||||
pub mod match_layer;
|
||||
pub(super) mod panel;
|
||||
@@ -0,0 +1,12 @@
|
||||
// Layers panel toggle — ribbon definition.
|
||||
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "LAYERS",
|
||||
label: "Layers",
|
||||
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/layers/panel.svg")),
|
||||
event: ModuleEvent::ToggleLayers,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user