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)
|
||||
|
||||
+36
-9
@@ -1,7 +1,9 @@
|
||||
//! Multileader Style Manager window — fills the entire OS window.
|
||||
|
||||
use crate::app::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 {
|
||||
@@ -169,16 +171,17 @@ fn num_row<'a>(
|
||||
|
||||
fn enum_row<'a>(
|
||||
label: &'static str,
|
||||
val: String,
|
||||
options: Vec<String>,
|
||||
selected: String,
|
||||
field: &'static str,
|
||||
) -> Element<'a, Message> {
|
||||
row![
|
||||
text(label).size(11).color(DIM).width(150),
|
||||
text(val).size(11).width(150),
|
||||
button(text("Cycle").size(10))
|
||||
.on_press(Message::MLeaderStyleCycle(field))
|
||||
.style(btn_s(false))
|
||||
.padding([2, 8]),
|
||||
pick_list(options, Some(selected), move |value| {
|
||||
Message::MLeaderStyleSetEnum { field, value }
|
||||
})
|
||||
.text_size(11)
|
||||
.width(190),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center)
|
||||
@@ -276,7 +279,15 @@ pub fn view_window<'a>(v: MLeaderStyleView<'a>) -> Element<'a, Message> {
|
||||
.spacing(8),
|
||||
// Leader Format
|
||||
section("Leader Format"),
|
||||
enum_row("Path type:", format!("{:?}", s.path_type), "path_type"),
|
||||
enum_row(
|
||||
"Path type:",
|
||||
["Invisible", "StraightLineSegments", "Spline"]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect(),
|
||||
format!("{:?}", s.path_type),
|
||||
"path_type"
|
||||
),
|
||||
num_row("Line color (ACI):", "256", v.line_color, "line_color"),
|
||||
num_row("Arrowhead size:", "0.18", v.arrowhead_size, "arrowhead_size"),
|
||||
num_row("Break gap size:", "0.125", v.break_gap, "break_gap"),
|
||||
@@ -293,17 +304,33 @@ pub fn view_window<'a>(v: MLeaderStyleView<'a>) -> Element<'a, Message> {
|
||||
chk("Annotative", s.is_annotative, "annotative"),
|
||||
// Content
|
||||
section("Content"),
|
||||
enum_row("Content type:", format!("{:?}", s.content_type), "content_type"),
|
||||
enum_row(
|
||||
"Content type:",
|
||||
["None", "Block", "MText", "Tolerance"]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect(),
|
||||
format!("{:?}", s.content_type),
|
||||
"content_type"
|
||||
),
|
||||
num_row("Default text:", "", v.default_text, "default_text"),
|
||||
num_row("Text height:", "0.18", v.text_height, "text_height"),
|
||||
num_row("Text color (ACI):", "256", v.text_color, "text_color"),
|
||||
enum_row(
|
||||
"Text angle:",
|
||||
["ParallelToLastLeaderLine", "Horizontal", "Optimized"]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect(),
|
||||
format!("{:?}", s.text_angle_type),
|
||||
"text_angle_type"
|
||||
),
|
||||
enum_row(
|
||||
"Text alignment:",
|
||||
["Left", "Center", "Right"]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect(),
|
||||
format!("{:?}", s.text_alignment),
|
||||
"text_alignment"
|
||||
),
|
||||
|
||||
+23
-6
@@ -1,7 +1,9 @@
|
||||
//! Table Style Manager window — fills the entire OS window.
|
||||
|
||||
use crate::app::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 {
|
||||
@@ -241,11 +243,26 @@ pub fn view_window<'a>(
|
||||
cell_in(" Fill color (ACI):", "256", &cell_fillcolor[r], "fillcolor"),
|
||||
row![
|
||||
text(" Alignment:").size(11).color(DIM).width(150),
|
||||
text(format!("{:?}", rs.alignment)).size(11).width(120),
|
||||
button(text("Cycle").size(10))
|
||||
.on_press(Message::TableStyleCellCycleAlign(row))
|
||||
.style(btn_s(false))
|
||||
.padding([2, 8]),
|
||||
pick_list(
|
||||
[
|
||||
"TopLeft",
|
||||
"TopCenter",
|
||||
"TopRight",
|
||||
"MiddleLeft",
|
||||
"MiddleCenter",
|
||||
"MiddleRight",
|
||||
"BottomLeft",
|
||||
"BottomCenter",
|
||||
"BottomRight",
|
||||
]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
Some(format!("{:?}", rs.alignment)),
|
||||
move |value| Message::TableStyleCellSetAlign { row, value },
|
||||
)
|
||||
.text_size(11)
|
||||
.width(140),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
|
||||
Reference in new issue
Block a user