feat(ribbon): add layer isolation tools

Closes #589
This commit is contained in:
Hakan Seven committed 2026-07-30 18:07:06 +03:00
1 parent c9aab122f0
commit 02d15f5d23
7 files changed
+81 -7

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="64" height="64">
<!-- Muted surrounding layers -->
<line x1="2" y1="5" x2="22" y2="5"
stroke="#777777" stroke-width="2.25" stroke-linecap="round"
stroke-dasharray="3 3"/>
<line x1="2" y1="19" x2="22" y2="19"
stroke="#777777" stroke-width="2.25" stroke-linecap="round"
stroke-dasharray="3 3"/>
<!-- The selected layer remains visible -->
<line x1="2" y1="12" x2="22" y2="12"
stroke="#4cc9f0" stroke-width="2.25" stroke-linecap="round"/>
<circle cx="12" cy="12" r="2.5"
fill="#4cc9f0" stroke="#e0e0e0" stroke-width="1.25"/>
<!-- Focus brackets -->
<path d="M6 9V7H9 M15 7H18V9 M18 15V17H15 M9 17H6V15"
fill="none" stroke="#f0c040" stroke-width="1.75"
stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 854 B

+13
View File
@@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="64" height="64">
<!-- Restored layer stack -->
<line x1="2" y1="5" x2="22" y2="5"
stroke="#e0e0e0" stroke-width="2.25" stroke-linecap="round"/>
<line x1="2" y1="12" x2="22" y2="12"
stroke="#4cc9f0" stroke-width="2.25" stroke-linecap="round"/>
<line x1="2" y1="19" x2="22" y2="19"
stroke="#e0e0e0" stroke-width="2.25" stroke-linecap="round"/>
<!-- Outward arrows indicate restoring the isolated layers -->
<path d="M8 9L5 6L2 9 M16 15L19 18L22 15"
fill="none" stroke="#f0c040" stroke-width="1.75"
stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 671 B

+12
View File
@@ -0,0 +1,12 @@
use crate::modules::{IconKind, ModuleEvent, ToolDef};
pub fn tool() -> ToolDef {
ToolDef {
id: "LAYISO",
label: "Isolate Layer",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/layers/layiso.svg"
)),
event: ModuleEvent::Command("LAYISO".to_string()),
}
}
+12
View File
@@ -0,0 +1,12 @@
use crate::modules::{IconKind, ModuleEvent, ToolDef};
pub fn tool() -> ToolDef {
ToolDef {
id: "LAYUNISO",
label: "Unisolate Layers",
icon: IconKind::Svg(include_bytes!(
"../../../../assets/icons/layers/layuniso.svg"
)),
event: ModuleEvent::Command("LAYUNISO".to_string()),
}
}
+2
View File
@@ -1,9 +1,11 @@
pub(super) mod color;
pub(super) mod layfrz;
pub(super) mod layiso;
pub(super) mod laylck;
pub(super) mod layoff;
pub(super) mod layon;
pub(super) mod laythw;
pub(super) mod layuniso;
pub(super) mod layulk;
pub(super) mod make_current;
pub mod match_layer;
+4 -1
View File
@@ -34,7 +34,8 @@ impl CadModule for DrawModule {
use draw::{arc, circle, ellipse, hatch, line, polyline, shapes};
use groups::{group, ungroup};
use layers::{
layfrz, laylck, layoff, layon, laythw, layulk, make_current, match_layer, panel,
layfrz, layiso, laylck, layoff, layon, laythw, layulk, layuniso, make_current,
match_layer, panel,
};
use modify::{
array, copy, delete, explode, fillet, mirror, offset, rotate, scale, stretch,
@@ -182,12 +183,14 @@ impl CadModule for DrawModule {
layfrz::tool(),
laylck::tool(),
make_current::tool(),
layiso::tool(),
],
row3: vec![
layon::tool(),
laythw::tool(),
layulk::tool(),
match_layer::tool(),
layuniso::tool(),
],
},
],
+20 -6
View File
@@ -613,10 +613,17 @@ pub(super) fn render_large<'a>(
*id, *icon, None, items, *default, active_tool, open_dd, last_cmd,
dim,
)
}
}
RibbonItem::LayerComboGroup { row2, row3 } => {
const COMBO_W: f32 = LARGE_W * 2.5;
const TOOL_BUTTON_W: f32 = 26.0;
const TOOL_SPACING: f32 = 2.0;
const GROUP_PADDING: f32 = 8.0;
let tool_count = row2.len().max(row3.len()) as f32;
let tools_w = tool_count * TOOL_BUTTON_W
+ (tool_count - 1.0).max(0.0) * TOOL_SPACING
+ GROUP_PADDING;
let combo_w = (LARGE_W * 2.5).max(tools_w);
let info = layer_infos.iter().find(|l| l.name == active_layer);
let lc = info.map(|l| l.color).unwrap_or(Color::WHITE);
@@ -641,8 +648,15 @@ pub(super) fn render_large<'a>(
.width(12)
.height(12);
const ICONS_USED: f32 = 14.0 + 14.0 + 14.0 + 12.0 + 10.0 + 5.0 * 4.0 + 16.0 + 16.0;
let name_w = (COMBO_W - ICONS_USED).max(40.0);
const FIXED_COMBO_W: f32 =
14.0 * 3.0 + 12.0 + 9.0 + 4.0 * 4.0 + 8.0 * 2.0;
let name_w = (combo_w - FIXED_COMBO_W).max(24.0);
// About 6 px per glyph at 11 px. The dropdown itself keeps the
// complete layer name available; only its closed ribbon label is
// shortened to preserve the fixed row height.
let name_budget = ((name_w / 6.0) as usize).max(4);
let active_layer_label =
crate::ui::text_util::elide(active_layer, name_budget);
let combo_btn = button(
row![
@@ -650,7 +664,7 @@ pub(super) fn render_large<'a>(
freeze_icon,
lock_icon,
swatch,
container(text(active_layer).size(11))
container(text(active_layer_label).size(11))
.width(name_w)
.clip(true),
icons::themed_arrow_down(9.0),
@@ -710,7 +724,7 @@ pub(super) fn render_large<'a>(
.spacing(3)
.align_x(iced::Left),
)
.width(Length::Fixed(COMBO_W))
.width(Length::Fixed(combo_w))
.height(Fill)
.align_y(iced::Center)
.padding(Padding {