feat(tablestyle): editable General section (margins, flow-suppress toggles)
The Table Style editor's General fields are now editable: H/V cell margins (buffers + Apply) and title/header row-suppressed toggles, loaded from the selected style on select. Per-cell (Data/Header/Title) text/fill/border editing remains a follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
a21caf821b
commit
0dd86eb658
4 changed files with 111 additions and 5 deletions
|
|
@ -296,6 +296,9 @@ pub(super) struct OpenCADStudio {
|
||||||
|
|
||||||
// ── TableStyle Dialog ─────────────────────────────────────────────────
|
// ── TableStyle Dialog ─────────────────────────────────────────────────
|
||||||
tablestyle_selected: String,
|
tablestyle_selected: String,
|
||||||
|
/// Edit buffers for the table style's general margins.
|
||||||
|
ts_hmargin: String,
|
||||||
|
ts_vmargin: String,
|
||||||
|
|
||||||
// ── TextStyle Font Browser ────────────────────────────────────────────
|
// ── TextStyle Font Browser ────────────────────────────────────────────
|
||||||
textstyle_selected: String,
|
textstyle_selected: String,
|
||||||
|
|
@ -987,6 +990,13 @@ pub enum Message {
|
||||||
TableStyleDialogDelete,
|
TableStyleDialogDelete,
|
||||||
/// Toggle the Annotative flag on the selected table style.
|
/// Toggle the Annotative flag on the selected table style.
|
||||||
TableStyleToggleAnnotative,
|
TableStyleToggleAnnotative,
|
||||||
|
/// Toggle a boolean flag (title_suppressed / header_suppressed / flow) on
|
||||||
|
/// the selected table style.
|
||||||
|
TableStyleToggle(&'static str),
|
||||||
|
/// Update a general edit buffer (hmargin / vmargin).
|
||||||
|
TableStyleEdit { field: &'static str, value: String },
|
||||||
|
/// Write the general edit buffers back into the selected table style.
|
||||||
|
TableStyleApply,
|
||||||
// ── MLineStyle Dialog ─────────────────────────────────────────────────
|
// ── MLineStyle Dialog ─────────────────────────────────────────────────
|
||||||
MlStyleDialogOpen,
|
MlStyleDialogOpen,
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
@ -1158,6 +1168,8 @@ impl OpenCADStudio {
|
||||||
textstyle_ttf: String::new(),
|
textstyle_ttf: String::new(),
|
||||||
// TableStyle dialog
|
// TableStyle dialog
|
||||||
tablestyle_selected: "Standard".to_string(),
|
tablestyle_selected: "Standard".to_string(),
|
||||||
|
ts_hmargin: "1.5".to_string(),
|
||||||
|
ts_vmargin: "1.5".to_string(),
|
||||||
// MLineStyle dialog
|
// MLineStyle dialog
|
||||||
mlstyle_selected: "Standard".to_string(),
|
mlstyle_selected: "Standard".to_string(),
|
||||||
// DimStyle dialog
|
// DimStyle dialog
|
||||||
|
|
|
||||||
|
|
@ -5740,7 +5740,69 @@ impl OpenCADStudio {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::TableStyleDialogSelect(name) => {
|
Message::TableStyleDialogSelect(name) => {
|
||||||
|
use acadrust::objects::ObjectType;
|
||||||
self.tablestyle_selected = name;
|
self.tablestyle_selected = name;
|
||||||
|
let i = self.active_tab;
|
||||||
|
for obj in self.tabs[i].scene.document.objects.values() {
|
||||||
|
if let ObjectType::TableStyle(s) = obj {
|
||||||
|
if s.name == self.tablestyle_selected {
|
||||||
|
self.ts_hmargin = format!("{:.4}", s.horizontal_margin);
|
||||||
|
self.ts_vmargin = format!("{:.4}", s.vertical_margin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
|
||||||
|
Message::TableStyleEdit { field, value } => {
|
||||||
|
match field {
|
||||||
|
"hmargin" => self.ts_hmargin = value,
|
||||||
|
"vmargin" => self.ts_vmargin = value,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
|
||||||
|
Message::TableStyleApply => {
|
||||||
|
use acadrust::objects::ObjectType;
|
||||||
|
let i = self.active_tab;
|
||||||
|
let name = self.tablestyle_selected.clone();
|
||||||
|
let h: Option<f64> = self.ts_hmargin.trim().parse().ok();
|
||||||
|
let v: Option<f64> = self.ts_vmargin.trim().parse().ok();
|
||||||
|
self.push_undo_snapshot(i, "TABLESTYLE EDIT");
|
||||||
|
for obj in self.tabs[i].scene.document.objects.values_mut() {
|
||||||
|
if let ObjectType::TableStyle(s) = obj {
|
||||||
|
if s.name == name {
|
||||||
|
if let Some(h) = h {
|
||||||
|
s.horizontal_margin = h;
|
||||||
|
}
|
||||||
|
if let Some(v) = v {
|
||||||
|
s.vertical_margin = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.tabs[i].dirty = true;
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
|
||||||
|
Message::TableStyleToggle(field) => {
|
||||||
|
use acadrust::objects::ObjectType;
|
||||||
|
let i = self.active_tab;
|
||||||
|
let name = self.tablestyle_selected.clone();
|
||||||
|
self.push_undo_snapshot(i, "TABLESTYLE EDIT");
|
||||||
|
for obj in self.tabs[i].scene.document.objects.values_mut() {
|
||||||
|
if let ObjectType::TableStyle(s) = obj {
|
||||||
|
if s.name == name {
|
||||||
|
match field {
|
||||||
|
"title_sup" => s.title_suppressed = !s.title_suppressed,
|
||||||
|
"header_sup" => s.header_suppressed = !s.header_suppressed,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.tabs[i].dirty = true;
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,8 @@ impl OpenCADStudio {
|
||||||
styles,
|
styles,
|
||||||
&self.tablestyle_selected,
|
&self.tablestyle_selected,
|
||||||
selected_style,
|
selected_style,
|
||||||
|
&self.ts_hmargin,
|
||||||
|
&self.ts_vmargin,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if Some(window_id) == self.mlstyle_window {
|
if Some(window_id) == self.mlstyle_window {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
//! Table Style Manager window — fills the entire OS window.
|
//! Table Style Manager window — fills the entire OS window.
|
||||||
|
|
||||||
use crate::app::Message;
|
use crate::app::Message;
|
||||||
use iced::widget::{button, checkbox, column, container, row, scrollable, text, Space};
|
use iced::widget::{button, checkbox, column, container, row, scrollable, text, text_input, Space};
|
||||||
use iced::{Background, Border, Color, Element, Fill, Theme};
|
use iced::{Background, Border, Color, Element, Fill, Theme};
|
||||||
|
|
||||||
const TB: Color = Color {
|
const TB: Color = Color {
|
||||||
|
|
@ -129,6 +129,8 @@ pub fn view_window<'a>(
|
||||||
styles: Vec<String>,
|
styles: Vec<String>,
|
||||||
selected: &'a str,
|
selected: &'a str,
|
||||||
selected_style: Option<&'a acadrust::objects::TableStyle>,
|
selected_style: Option<&'a acadrust::objects::TableStyle>,
|
||||||
|
hmargin_buf: &'a str,
|
||||||
|
vmargin_buf: &'a str,
|
||||||
) -> Element<'a, Message> {
|
) -> Element<'a, Message> {
|
||||||
// ── Toolbar ───────────────────────────────────────────────────────────
|
// ── Toolbar ───────────────────────────────────────────────────────────
|
||||||
let toolbar = container(
|
let toolbar = container(
|
||||||
|
|
@ -227,10 +229,38 @@ pub fn view_window<'a>(
|
||||||
.on_toggle(|_| Message::TableStyleToggleAnnotative)
|
.on_toggle(|_| Message::TableStyleToggleAnnotative)
|
||||||
.size(14)
|
.size(14)
|
||||||
.text_size(11),
|
.text_size(11),
|
||||||
info_row("H Margin:", format!("{:.4}", s.horizontal_margin)),
|
row![
|
||||||
info_row("V Margin:", format!("{:.4}", s.vertical_margin)),
|
text("H Margin:").size(11).color(DIM).width(160),
|
||||||
info_row("Title Suppressed:", s.title_suppressed.to_string()),
|
text_input("1.5", hmargin_buf)
|
||||||
info_row("Header Suppressed:", s.header_suppressed.to_string()),
|
.on_input(|v| Message::TableStyleEdit { field: "hmargin", value: v })
|
||||||
|
.size(11)
|
||||||
|
.width(100),
|
||||||
|
]
|
||||||
|
.spacing(8)
|
||||||
|
.align_y(iced::Center),
|
||||||
|
row![
|
||||||
|
text("V Margin:").size(11).color(DIM).width(160),
|
||||||
|
text_input("1.5", vmargin_buf)
|
||||||
|
.on_input(|v| Message::TableStyleEdit { field: "vmargin", value: v })
|
||||||
|
.size(11)
|
||||||
|
.width(100),
|
||||||
|
]
|
||||||
|
.spacing(8)
|
||||||
|
.align_y(iced::Center),
|
||||||
|
checkbox(s.title_suppressed)
|
||||||
|
.label("Title row suppressed")
|
||||||
|
.on_toggle(|_| Message::TableStyleToggle("title_sup"))
|
||||||
|
.size(14)
|
||||||
|
.text_size(11),
|
||||||
|
checkbox(s.header_suppressed)
|
||||||
|
.label("Header row suppressed")
|
||||||
|
.on_toggle(|_| Message::TableStyleToggle("header_sup"))
|
||||||
|
.size(14)
|
||||||
|
.text_size(11),
|
||||||
|
button(text("Apply margins").size(11))
|
||||||
|
.on_press(Message::TableStyleApply)
|
||||||
|
.style(btn_s(true))
|
||||||
|
.padding([4, 12]),
|
||||||
row_info("Data Row:", &s.data_row_style),
|
row_info("Data Row:", &s.data_row_style),
|
||||||
row_info("Header Row:", &s.header_row_style),
|
row_info("Header Row:", &s.header_row_style),
|
||||||
row_info("Title Row:", &s.title_row_style),
|
row_info("Title Row:", &s.title_row_style),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue