forked from 1b-agent/opencadstudio-upstream
refactor(styles): replace cycle buttons with dropdowns
The enum/handle pickers in the MLeader, Table and Dimension style editors used "Cycle" buttons, which were awkward. Replace them with pick_list dropdowns: - MLeader: path type, content type, text angle, text alignment. - Table per-cell: alignment (9 anchors). - Dimension: arrowhead blocks (DIMBLK/1/2/LDRBLK) and ext-line linetypes (DIMLTYPE/LTEX1/LTEX2), options resolved from block_records/line_types. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
1b7edf6cae
commit
bd120ca307
6 files changed
+161
-102
No files matched your search
+26
-17
@@ -1,7 +1,9 @@
|
||||
//! Dimension Style Manager window — fills the entire OS window.
|
||||
|
||||
use crate::app::{DsField, Message};
|
||||
use iced::widget::{button, checkbox, column, container, row, scrollable, text, text_input, Space};
|
||||
use iced::widget::{
|
||||
button, checkbox, column, container, pick_list, row, scrollable, text, text_input, Space,
|
||||
};
|
||||
use iced::{Background, Border, Color, Element, Fill, Theme};
|
||||
|
||||
const TB: Color = Color {
|
||||
@@ -130,7 +132,7 @@ pub struct DimStyleValues<'a> {
|
||||
pub dimalttz: &'a str,
|
||||
pub dimtolj: &'a str,
|
||||
pub dimtzin: &'a str,
|
||||
// Resolved display names for the block/linetype Handle fields.
|
||||
// Resolved selected names for the block/linetype Handle fields.
|
||||
pub dimblk_name: String,
|
||||
pub dimblk1_name: String,
|
||||
pub dimblk2_name: String,
|
||||
@@ -138,6 +140,9 @@ pub struct DimStyleValues<'a> {
|
||||
pub dimltex_name: String,
|
||||
pub dimltex1_name: String,
|
||||
pub dimltex2_name: String,
|
||||
// Dropdown option lists shared by the arrowhead / linetype fields.
|
||||
pub block_opts: Vec<String>,
|
||||
pub lt_opts: Vec<String>,
|
||||
}
|
||||
|
||||
fn btn_s(accent: bool) -> impl Fn(&Theme, button::Status) -> button::Style {
|
||||
@@ -384,16 +389,20 @@ pub fn view_window<'a>(
|
||||
.into()
|
||||
};
|
||||
|
||||
// Block / linetype Handle cycler: shows the resolved name and a button that
|
||||
// advances to the next available block-record (arrowheads) or linetype.
|
||||
let hrow = move |label: &'static str, name: String, field: &'static str| -> Element<'a, Message> {
|
||||
// Block / linetype Handle dropdown: pick a block-record (arrowheads) or a
|
||||
// linetype by name from the available records.
|
||||
let hrow = move |label: &'static str,
|
||||
options: Vec<String>,
|
||||
selected: String,
|
||||
field: &'static str|
|
||||
-> Element<'a, Message> {
|
||||
row![
|
||||
lbl(label),
|
||||
text(name).size(11).width(110),
|
||||
button(text("Cycle").size(10))
|
||||
.on_press(Message::DsCycleHandle(field))
|
||||
.style(btn_s(false))
|
||||
.padding([2, 8]),
|
||||
pick_list(options, Some(selected), move |value| {
|
||||
Message::DsSetHandle { field, value }
|
||||
})
|
||||
.text_size(11)
|
||||
.width(150),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center)
|
||||
@@ -444,18 +453,18 @@ pub fn view_window<'a>(
|
||||
row![lbl("Ext line weight (DIMLWE)"), mk_field(DsField::Dimlwe, vals.dimlwe)].spacing(8).align_y(iced::Center),
|
||||
chk("Fixed-length ext lines (DIMFXLON)", vals.dimfxlon, DsField::Dimfxlon),
|
||||
row![lbl("Fixed length (DIMFXL)"), mk_field(DsField::Dimfxl, vals.dimfxl)].spacing(8).align_y(iced::Center),
|
||||
hrow("Dim line linetype (DIMLTYPE)", vals.dimltex_name.clone(), "dimltex_handle"),
|
||||
hrow("Ext line 1 linetype (DIMLTEX1)", vals.dimltex1_name.clone(), "dimltex1_handle"),
|
||||
hrow("Ext line 2 linetype (DIMLTEX2)", vals.dimltex2_name.clone(), "dimltex2_handle"),
|
||||
hrow("Dim line linetype (DIMLTYPE)", vals.lt_opts.clone(), vals.dimltex_name.clone(), "dimltex_handle"),
|
||||
hrow("Ext line 1 linetype (DIMLTEX1)", vals.lt_opts.clone(), vals.dimltex1_name.clone(), "dimltex1_handle"),
|
||||
hrow("Ext line 2 linetype (DIMLTEX2)", vals.lt_opts.clone(), vals.dimltex2_name.clone(), "dimltex2_handle"),
|
||||
]
|
||||
.spacing(7)
|
||||
.into(),
|
||||
1 => column![
|
||||
text("Arrows").size(11).color(ACCENT),
|
||||
hrow("Arrowhead (DIMBLK)", vals.dimblk_name.clone(), "dimblk"),
|
||||
hrow("1st arrowhead (DIMBLK1)", vals.dimblk1_name.clone(), "dimblk1"),
|
||||
hrow("2nd arrowhead (DIMBLK2)", vals.dimblk2_name.clone(), "dimblk2"),
|
||||
hrow("Leader arrowhead (DIMLDRBLK)", vals.dimldrblk_name.clone(), "dimldrblk"),
|
||||
hrow("Arrowhead (DIMBLK)", vals.block_opts.clone(), vals.dimblk_name.clone(), "dimblk"),
|
||||
hrow("1st arrowhead (DIMBLK1)", vals.block_opts.clone(), vals.dimblk1_name.clone(), "dimblk1"),
|
||||
hrow("2nd arrowhead (DIMBLK2)", vals.block_opts.clone(), vals.dimblk2_name.clone(), "dimblk2"),
|
||||
hrow("Leader arrowhead (DIMLDRBLK)", vals.block_opts.clone(), vals.dimldrblk_name.clone(), "dimldrblk"),
|
||||
row![
|
||||
lbl("Arrow size (DIMASZ)"),
|
||||
mk_field(DsField::Dimasz, vals.dimasz)
|
||||
|
||||
Reference in new issue
Block a user