diff --git a/assets/icons/layers/layiso.svg b/assets/icons/layers/layiso.svg new file mode 100644 index 000000000..9337d6912 --- /dev/null +++ b/assets/icons/layers/layiso.svg @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/assets/icons/layers/layuniso.svg b/assets/icons/layers/layuniso.svg new file mode 100644 index 000000000..4f1604eb3 --- /dev/null +++ b/assets/icons/layers/layuniso.svg @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/src/modules/draw/layers/layiso.rs b/src/modules/draw/layers/layiso.rs new file mode 100644 index 000000000..35b2b29ea --- /dev/null +++ b/src/modules/draw/layers/layiso.rs @@ -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()), + } +} diff --git a/src/modules/draw/layers/layuniso.rs b/src/modules/draw/layers/layuniso.rs new file mode 100644 index 000000000..0521b3f5a --- /dev/null +++ b/src/modules/draw/layers/layuniso.rs @@ -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()), + } +} diff --git a/src/modules/draw/layers/mod.rs b/src/modules/draw/layers/mod.rs index e1038df68..9dda05ed2 100644 --- a/src/modules/draw/layers/mod.rs +++ b/src/modules/draw/layers/mod.rs @@ -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; diff --git a/src/modules/draw/mod.rs b/src/modules/draw/mod.rs index 4d658ff6d..9bbbd8217 100644 --- a/src/modules/draw/mod.rs +++ b/src/modules/draw/mod.rs @@ -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(), ], }, ], diff --git a/src/ui/ribbon/widgets.rs b/src/ui/ribbon/widgets.rs index fbd2db8f1..ff637651f 100644 --- a/src/ui/ribbon/widgets.rs +++ b/src/ui/ribbon/widgets.rs @@ -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 {