refactor(ui): centralize hdivider/vsep in style::form

Deduplicate the byte-identical 1px divider helpers previously copy-pasted across 6 modules. form::{hdivider, vseparator} is now canonical, with a form::vsep alias for legacy call sites. style_manager re-exports both so scale_manager and anno_object_scale imports keep working unchanged. Delete locals in style_manager, plotstyle, dimstyle, layout_manager, attribute_editor. Replace thin wrappers in window/plot with direct imports. no visual change.
This commit is contained in:
Karim Jerbi committed 2026-09-18 13:43:29 +01:00
1 parent 9545e36975
commit b8a7f5edfb
7 files changed
+12 -112

No files matched your search

+1 -13
View File
@@ -6,6 +6,7 @@ use iced::widget::{
};
use iced::{mouse, Background, Border, Element, Length, Point, Rectangle, Theme};
use crate::ui::style::common::muted_style;
use crate::ui::style::form::hdivider;
use crate::t;
use std::borrow::Cow;
use std::fmt;
@@ -263,19 +264,6 @@ impl canvas::Program<Message> for DimensionPreview {
}
}
fn hdivider<'a>(width: iced::Length) -> Element<'a, Message> {
container(Space::new().width(width).height(1))
.width(width)
.height(1)
.style(|theme: &Theme| container::Style {
background: Some(Background::Color(
theme.palette().background.neutral.color
)),
..Default::default()
})
.into()
}
pub fn view_window<'a>(
styles: Vec<String>,
selected: &'a str,
+6
View File
@@ -83,6 +83,12 @@ pub fn vseparator<'a>(height: Length) -> Element<'a, Message> {
.into()
}
/// Alias kept for call sites that historically used `vsep`.
/// Same implementation as [`vseparator`].
pub fn vsep<'a>(height: Length) -> Element<'a, Message> {
vseparator(height)
}
/// Muted section heading.
pub fn section_label<'a>(label: Cow<'static, str>) -> Element<'a, Message> {
text(label).size(11).style(muted_style).into()
+1 -26
View File
@@ -4,6 +4,7 @@ use crate::app::Message;
use iced::widget::{button, column, container, row, scrollable, text, text_input, Space};
use iced::{Background, Border, Element, Theme};
use crate::ui::style::common::muted_style;
use crate::ui::style::form::{hdivider, vsep};
use crate::t;
use std::borrow::Cow;
use std::fmt;
@@ -83,32 +84,6 @@ fn field_style(theme: &Theme, status: text_input::Status) -> text_input::Style {
}
}
fn hdivider<'a>(width: iced::Length) -> Element<'a, Message> {
container(Space::new().width(width).height(1))
.width(width)
.height(1)
.style(|theme: &Theme| container::Style {
background: Some(Background::Color(
theme.palette().background.neutral.color
)),
..Default::default()
})
.into()
}
fn vsep<'a>(height: iced::Length) -> Element<'a, Message> {
container(Space::new().width(1).height(height))
.width(1)
.height(height)
.style(|theme: &Theme| container::Style {
background: Some(Background::Color(
theme.palette().background.neutral.color
)),
..Default::default()
})
.into()
}
pub fn view_window<'a>(
document: &'a acadrust::CadDocument,
table: Option<&'a crate::io::plot_style::PlotStyleTable>,
+1 -25
View File
@@ -327,28 +327,4 @@ pub(crate) fn muted_text_style(theme: &Theme) -> iced::widget::text::Style {
crate::ui::style::common::muted_style(theme)
}
pub(crate) fn hdivider<'a>(width: iced::Length) -> Element<'a, Message> {
container(Space::new().width(width).height(1))
.width(width)
.height(1)
.style(|theme: &Theme| container::Style {
background: Some(Background::Color(
theme.palette().background.neutral.color
)),
..Default::default()
})
.into()
}
pub(crate) fn vsep<'a>(height: iced::Length) -> Element<'a, Message> {
container(Space::new().width(1).height(height))
.width(1)
.height(height)
.style(|theme: &Theme| container::Style {
background: Some(Background::Color(
theme.palette().background.neutral.color
)),
..Default::default()
})
.into()
}
pub(crate) use crate::ui::style::form::{hdivider, vsep};