forked from 1b-agent/opencadstudio-upstream
style: apply cargo fmt across workspace (as on main)
Formats the branch the way main's 9cf9ff2 did, so merging main only
conflicts where the code itself differs.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013RyGiMXcsf9HTKfqDxaQGt
This commit is contained in:
532 files changed
+56995
-33416
No files matched your search
+167
-123
@@ -1,6 +1,7 @@
|
||||
//! Layer Manager — floating window.
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::t;
|
||||
use crate::ui::properties::{lw_options, LinetypeItem, LwItem};
|
||||
use crate::ui::style::common::muted_style;
|
||||
use crate::ui::style::row_button::{cell_button_style, header_button_style};
|
||||
@@ -15,7 +16,6 @@ use iced::widget::{
|
||||
};
|
||||
use iced::Padding;
|
||||
use iced::{Background, Border, Color, Element, Fill, Length, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
|
||||
// ── Per-viewport column descriptor ───────────────────────────────────────────
|
||||
@@ -237,8 +237,7 @@ impl LayerPanel {
|
||||
.collect();
|
||||
|
||||
// Re-resolve the selection against the rebuilt rows by name.
|
||||
self.selected = anchor_name
|
||||
.and_then(|n| self.layers.iter().position(|l| l.name == n));
|
||||
self.selected = anchor_name.and_then(|n| self.layers.iter().position(|l| l.name == n));
|
||||
self.selected_multi = multi_names
|
||||
.iter()
|
||||
.filter_map(|n| self.layers.iter().position(|l| l.name == *n))
|
||||
@@ -290,9 +289,7 @@ impl LayerPanel {
|
||||
LayerSortCol::Lock => a.locked.cmp(&b.locked),
|
||||
LayerSortCol::Plot => a.plottable.cmp(&b.plottable),
|
||||
LayerSortCol::Color => color_sort_key(a.color).cmp(&color_sort_key(b.color)),
|
||||
LayerSortCol::Linetype => {
|
||||
a.linetype.to_lowercase().cmp(&b.linetype.to_lowercase())
|
||||
}
|
||||
LayerSortCol::Linetype => a.linetype.to_lowercase().cmp(&b.linetype.to_lowercase()),
|
||||
LayerSortCol::Lineweight => a.lineweight.value().cmp(&b.lineweight.value()),
|
||||
LayerSortCol::Transparency => a.transparency.cmp(&b.transparency),
|
||||
};
|
||||
@@ -396,9 +393,7 @@ impl LayerPanel {
|
||||
.align_y(iced::Center),
|
||||
)
|
||||
.style(|theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme.palette().background.weak.color
|
||||
)),
|
||||
background: Some(Background::Color(theme.palette().background.weak.color)),
|
||||
..Default::default()
|
||||
})
|
||||
.width(Length::Fill)
|
||||
@@ -409,27 +404,69 @@ impl LayerPanel {
|
||||
let sa = self.sort_asc;
|
||||
let mut header_row = row![
|
||||
text(t!("Status")).size(10).style(muted_style).width(50),
|
||||
sortable_header(t!("Name"), LayerSortCol::Name, Length::Fixed(name_col_w), sc, sa),
|
||||
sortable_header(
|
||||
t!("Name"),
|
||||
LayerSortCol::Name,
|
||||
Length::Fixed(name_col_w),
|
||||
sc,
|
||||
sa
|
||||
),
|
||||
// Draggable divider: adjusts the Name column width (#359).
|
||||
iced::widget::mouse_area(
|
||||
container(iced::widget::Space::new().width(2).height(14)).style(
|
||||
|theme: &Theme| container::Style {
|
||||
container(iced::widget::Space::new().width(2).height(14)).style(|theme: &Theme| {
|
||||
container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme.palette().background.neutral.color
|
||||
theme.palette().background.neutral.color,
|
||||
)),
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
}
|
||||
},),
|
||||
)
|
||||
.on_press(Message::LayerNameColGrab)
|
||||
.interaction(iced::mouse::Interaction::ResizingHorizontally),
|
||||
sortable_header(t!("On"), LayerSortCol::On, Length::Fixed(COL_ICON), sc, sa),
|
||||
sortable_header(t!("Freeze"), LayerSortCol::Freeze, Length::Fixed(COL_ICON), sc, sa),
|
||||
sortable_header(t!("Lock"), LayerSortCol::Lock, Length::Fixed(COL_ICON), sc, sa),
|
||||
sortable_header(t!("Plot"), LayerSortCol::Plot, Length::Fixed(COL_ICON), sc, sa),
|
||||
sortable_header(t!("Color"), LayerSortCol::Color, Length::Fixed(COL_COLOR), sc, sa),
|
||||
sortable_header(t!("Linetype"), LayerSortCol::Linetype, Length::Fixed(COL_LT), sc, sa),
|
||||
sortable_header(t!("Lineweight"), LayerSortCol::Lineweight, Length::Fixed(COL_LW), sc, sa),
|
||||
sortable_header(
|
||||
t!("Freeze"),
|
||||
LayerSortCol::Freeze,
|
||||
Length::Fixed(COL_ICON),
|
||||
sc,
|
||||
sa
|
||||
),
|
||||
sortable_header(
|
||||
t!("Lock"),
|
||||
LayerSortCol::Lock,
|
||||
Length::Fixed(COL_ICON),
|
||||
sc,
|
||||
sa
|
||||
),
|
||||
sortable_header(
|
||||
t!("Plot"),
|
||||
LayerSortCol::Plot,
|
||||
Length::Fixed(COL_ICON),
|
||||
sc,
|
||||
sa
|
||||
),
|
||||
sortable_header(
|
||||
t!("Color"),
|
||||
LayerSortCol::Color,
|
||||
Length::Fixed(COL_COLOR),
|
||||
sc,
|
||||
sa
|
||||
),
|
||||
sortable_header(
|
||||
t!("Linetype"),
|
||||
LayerSortCol::Linetype,
|
||||
Length::Fixed(COL_LT),
|
||||
sc,
|
||||
sa
|
||||
),
|
||||
sortable_header(
|
||||
t!("Lineweight"),
|
||||
LayerSortCol::Lineweight,
|
||||
Length::Fixed(COL_LW),
|
||||
sc,
|
||||
sa
|
||||
),
|
||||
sortable_header(
|
||||
t!("Transparency"),
|
||||
LayerSortCol::Transparency,
|
||||
@@ -454,13 +491,13 @@ impl LayerPanel {
|
||||
.style(|theme: &Theme| {
|
||||
let palette = theme.palette();
|
||||
container::Style {
|
||||
background: Some(Background::Color(palette.background.weak.color)),
|
||||
border: Border {
|
||||
color: palette.background.neutral.color,
|
||||
width: 1.0,
|
||||
radius: 0.0.into(),
|
||||
},
|
||||
..Default::default()
|
||||
background: Some(Background::Color(palette.background.weak.color)),
|
||||
border: Border {
|
||||
color: palette.background.neutral.color,
|
||||
width: 1.0,
|
||||
radius: 0.0.into(),
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
})
|
||||
.padding([4, 8])
|
||||
@@ -500,7 +537,6 @@ impl LayerPanel {
|
||||
&self.vp_cols,
|
||||
name_col_w,
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
let table = scrollable(rows_col)
|
||||
@@ -515,7 +551,9 @@ impl LayerPanel {
|
||||
let grid = column![
|
||||
col_header,
|
||||
table,
|
||||
iced::widget::Space::new().width(Length::Fixed(inner_w)).height(0),
|
||||
iced::widget::Space::new()
|
||||
.width(Length::Fixed(inner_w))
|
||||
.height(0),
|
||||
]
|
||||
.height(Length::Fill);
|
||||
let grid = scrollable(grid)
|
||||
@@ -571,25 +609,24 @@ fn sortable_header<'a>(
|
||||
|
||||
// ── Toolbar buttons ───────────────────────────────────────────────────────
|
||||
|
||||
fn toolbar_btn<'a>(icon: &'static [u8], label: Cow<'static, str>, msg: Message) -> Element<'a, Message> {
|
||||
fn toolbar_btn<'a>(
|
||||
icon: &'static [u8],
|
||||
label: Cow<'static, str>,
|
||||
msg: Message,
|
||||
) -> Element<'a, Message> {
|
||||
button(
|
||||
row![
|
||||
crate::ui::icons::themed(icon, 12.0),
|
||||
text(label).size(11),
|
||||
]
|
||||
.spacing(5)
|
||||
.align_y(iced::Center),
|
||||
row![crate::ui::icons::themed(icon, 12.0), text(label).size(11),]
|
||||
.spacing(5)
|
||||
.align_y(iced::Center),
|
||||
)
|
||||
.on_press(msg)
|
||||
.style(|theme: &Theme, status| {
|
||||
let palette = theme.palette();
|
||||
let pair = match status {
|
||||
button::Status::Hovered | button::Status::Pressed => {
|
||||
palette.background.strong
|
||||
}
|
||||
_ => palette.background.weak,
|
||||
};
|
||||
button::Style {
|
||||
.style(|theme: &Theme, status| {
|
||||
let palette = theme.palette();
|
||||
let pair = match status {
|
||||
button::Status::Hovered | button::Status::Pressed => palette.background.strong,
|
||||
_ => palette.background.weak,
|
||||
};
|
||||
button::Style {
|
||||
background: Some(Background::Color(pair.color)),
|
||||
border: Border {
|
||||
radius: 3.0.into(),
|
||||
@@ -598,10 +635,10 @@ fn toolbar_btn<'a>(icon: &'static [u8], label: Cow<'static, str>, msg: Message)
|
||||
},
|
||||
text_color: pair.text,
|
||||
..Default::default()
|
||||
}
|
||||
})
|
||||
.padding([4, 10])
|
||||
.into()
|
||||
}
|
||||
})
|
||||
.padding([4, 10])
|
||||
.into()
|
||||
}
|
||||
|
||||
fn toolbar_btn_cond<'a>(
|
||||
@@ -620,11 +657,11 @@ fn toolbar_btn_cond<'a>(
|
||||
if enabled {
|
||||
text(label).size(11)
|
||||
} else {
|
||||
text(label).size(11).style(|theme: &Theme| iced::widget::text::Style {
|
||||
color: Some(
|
||||
theme.palette().background.base.text.scale_alpha(0.42)
|
||||
),
|
||||
})
|
||||
text(label)
|
||||
.size(11)
|
||||
.style(|theme: &Theme| iced::widget::text::Style {
|
||||
color: Some(theme.palette().background.base.text.scale_alpha(0.42)),
|
||||
})
|
||||
},
|
||||
]
|
||||
.spacing(5)
|
||||
@@ -637,18 +674,18 @@ fn toolbar_btn_cond<'a>(
|
||||
_ => palette.background.weak,
|
||||
};
|
||||
button::Style {
|
||||
background: Some(Background::Color(pair.color)),
|
||||
border: Border {
|
||||
radius: 3.0.into(),
|
||||
color: palette.background.neutral.color,
|
||||
width: 1.0,
|
||||
},
|
||||
text_color: if enabled {
|
||||
pair.text
|
||||
} else {
|
||||
pair.text.scale_alpha(0.42)
|
||||
},
|
||||
..Default::default()
|
||||
background: Some(Background::Color(pair.color)),
|
||||
border: Border {
|
||||
radius: 3.0.into(),
|
||||
color: palette.background.neutral.color,
|
||||
width: 1.0,
|
||||
},
|
||||
text_color: if enabled {
|
||||
pair.text
|
||||
} else {
|
||||
pair.text.scale_alpha(0.42)
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
})
|
||||
.padding([4, 10]);
|
||||
@@ -673,14 +710,14 @@ fn name_tip<'a>(name: &'a str) -> Element<'a, Message> {
|
||||
.style(|theme: &Theme| {
|
||||
let palette = theme.palette();
|
||||
container::Style {
|
||||
background: Some(Background::Color(palette.background.strong.color)),
|
||||
border: Border {
|
||||
color: palette.background.neutral.color,
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
text_color: Some(palette.background.strong.text),
|
||||
..Default::default()
|
||||
background: Some(Background::Color(palette.background.strong.color)),
|
||||
border: Border {
|
||||
color: palette.background.neutral.color,
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
text_color: Some(palette.background.strong.text),
|
||||
..Default::default()
|
||||
}
|
||||
})
|
||||
.into()
|
||||
@@ -704,16 +741,16 @@ fn layer_row<'a>(
|
||||
let lname = layer.name.clone();
|
||||
let svg_btn = |bytes: &'static [u8], on_press: Message| -> Element<'a, Message> {
|
||||
button(crate::ui::icons::semantic(bytes, ICON_SZ))
|
||||
.on_press(on_press)
|
||||
.style(cell_button_style(is_selected, index))
|
||||
.padding(Padding {
|
||||
top: COMBO_PAD_V,
|
||||
bottom: COMBO_PAD_V,
|
||||
left: 4.0,
|
||||
right: 4.0,
|
||||
})
|
||||
.height(Length::Fixed(ROW_H))
|
||||
.into()
|
||||
.on_press(on_press)
|
||||
.style(cell_button_style(is_selected, index))
|
||||
.padding(Padding {
|
||||
top: COMBO_PAD_V,
|
||||
bottom: COMBO_PAD_V,
|
||||
left: 4.0,
|
||||
right: 4.0,
|
||||
})
|
||||
.height(Length::Fixed(ROW_H))
|
||||
.into()
|
||||
};
|
||||
|
||||
let vis_svg = crate::ui::icons::layer_visible(layer.visible);
|
||||
@@ -767,24 +804,27 @@ fn layer_row<'a>(
|
||||
} else {
|
||||
// ~6 px per glyph at the 10 px row font — track the column width.
|
||||
let name_budget = ((name_col_w / 6.0) as usize).max(8);
|
||||
let name_btn = button(
|
||||
text(crate::ui::text_util::elide(&layer.name, name_budget))
|
||||
.size(FONT_SZ),
|
||||
)
|
||||
.on_press(Message::LayerRenameStart(lname.clone()))
|
||||
.style(cell_button_style(is_selected, index))
|
||||
.padding(Padding {
|
||||
top: COMBO_PAD_V,
|
||||
bottom: COMBO_PAD_V,
|
||||
left: 4.0,
|
||||
right: 4.0,
|
||||
})
|
||||
.height(Length::Fixed(ROW_H))
|
||||
.width(Length::Fixed(name_col_w));
|
||||
let name_btn =
|
||||
button(text(crate::ui::text_util::elide(&layer.name, name_budget)).size(FONT_SZ))
|
||||
.on_press(Message::LayerRenameStart(lname.clone()))
|
||||
.style(cell_button_style(is_selected, index))
|
||||
.padding(Padding {
|
||||
top: COMBO_PAD_V,
|
||||
bottom: COMBO_PAD_V,
|
||||
left: 4.0,
|
||||
right: 4.0,
|
||||
})
|
||||
.height(Length::Fixed(ROW_H))
|
||||
.width(Length::Fixed(name_col_w));
|
||||
// When the name is truncated, reveal the full text on hover so the
|
||||
// user can still read it without widening the column.
|
||||
if layer.name.chars().count() > name_budget {
|
||||
tooltip(name_btn, name_tip(&layer.name), tooltip::Position::FollowCursor).into()
|
||||
tooltip(
|
||||
name_btn,
|
||||
name_tip(&layer.name),
|
||||
tooltip::Position::FollowCursor,
|
||||
)
|
||||
.into()
|
||||
} else {
|
||||
name_btn.into()
|
||||
}
|
||||
@@ -793,24 +833,25 @@ fn layer_row<'a>(
|
||||
// Color cell — looks like a combo_box input; click opens swatch dropdown below row.
|
||||
// Shared colour selector. Layers carry a concrete colour (no ByLayer /
|
||||
// ByBlock); true colours stay RGB instead of being collapsed to ACI 7.
|
||||
let color_cell: Element<'_, Message> = container(crate::ui::color_select::color_selector_with_name(
|
||||
layer.color,
|
||||
layer.color_name.as_deref(),
|
||||
color_picker_open,
|
||||
crate::ui::color_select::ColorExtras {
|
||||
by_layer: false,
|
||||
by_block: false,
|
||||
..Default::default()
|
||||
},
|
||||
Message::LayerColorSet,
|
||||
Message::LayerColorPickerToggle(lname.clone()),
|
||||
Message::OpenColorWindow(
|
||||
crate::app::ColorPickTarget::Layer(lname.clone()),
|
||||
let color_cell: Element<'_, Message> =
|
||||
container(crate::ui::color_select::color_selector_with_name(
|
||||
layer.color,
|
||||
),
|
||||
))
|
||||
.width(Length::Fixed(COL_COLOR))
|
||||
.into();
|
||||
layer.color_name.as_deref(),
|
||||
color_picker_open,
|
||||
crate::ui::color_select::ColorExtras {
|
||||
by_layer: false,
|
||||
by_block: false,
|
||||
..Default::default()
|
||||
},
|
||||
Message::LayerColorSet,
|
||||
Message::LayerColorPickerToggle(lname.clone()),
|
||||
Message::OpenColorWindow(
|
||||
crate::app::ColorPickTarget::Layer(lname.clone()),
|
||||
layer.color,
|
||||
),
|
||||
))
|
||||
.width(Length::Fixed(COL_COLOR))
|
||||
.into();
|
||||
|
||||
// Linetype cell — uses LinetypeItem (with ASCII art) same as Properties panel
|
||||
let cur_lt_item = LinetypeItem {
|
||||
@@ -847,9 +888,12 @@ fn layer_row<'a>(
|
||||
// Lineweight cell
|
||||
let cur_lw_item = LwItem(layer.lineweight);
|
||||
let lw_cell: Element<'_, Message> = if let Some(state) = lw_combo_state {
|
||||
combo_box(state, t!("lineweight").as_ref(), Some(&cur_lw_item), |item: LwItem| {
|
||||
Message::LayerLineweightSet(item.0)
|
||||
})
|
||||
combo_box(
|
||||
state,
|
||||
t!("lineweight").as_ref(),
|
||||
Some(&cur_lw_item),
|
||||
|item: LwItem| Message::LayerLineweightSet(item.0),
|
||||
)
|
||||
.size(FONT_SZ)
|
||||
.padding(Padding {
|
||||
top: COMBO_PAD_V,
|
||||
@@ -941,9 +985,9 @@ fn layer_row<'a>(
|
||||
palette.background.weak
|
||||
};
|
||||
container::Style {
|
||||
background: Some(Background::Color(pair.color)),
|
||||
text_color: Some(pair.text),
|
||||
..Default::default()
|
||||
background: Some(Background::Color(pair.color)),
|
||||
text_color: Some(pair.text),
|
||||
..Default::default()
|
||||
}
|
||||
})
|
||||
.padding(Padding {
|
||||
|
||||
Reference in new issue
Block a user