feat(plotstyle): improve CTB editor workflow

This commit is contained in:
gianlucafiore committed 2026-08-10 19:09:40 -03:00
1 parent 22a294c705
commit e2e4bfdcd4
9 files changed
+271 -48

No files matched your search

+1 -2
View File
@@ -4125,8 +4125,7 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
if let Ok(sc) = self.ps_screening_buf.trim().parse::<u8>() {
entry.screening = sc.min(100);
}
self.command_line
.push_output(crate::tf!("Plot style ACI {aci} updated.").as_ref());
}
} else {
// No table loaded: create an identity table and apply.
+38 -3
View File
@@ -125,6 +125,22 @@ impl OpenCADStudio {
/// changes, and the ribbon tool that launched the dialog is de-highlighted.
fn close_active_modal(&mut self) {
use super::ModalKind::*;
// Plot Style opened from PLOT behaves as a child modal.
// Closing it restores the parent Plot dialog instead of returning
// to the drawing.
if self.active_modal == Some(Plotstyle) {
if let Some((plot_offset, plot_resize)) =
self.plotstyle_parent_plot_geometry.take()
{
self.active_modal = Some(Plot);
self.reset_modal_geometry();
self.modal_offset = plot_offset;
self.modal_resize = plot_resize;
return;
}
}
if self.active_modal == Some(Plot) && self.print_all_options {
if let Some(previous) = self.print_all_options_prev.take() {
self.plot_dialog = previous;
@@ -6529,6 +6545,19 @@ impl OpenCADStudio {
self.ps_screening_buf = entry
.map(|e| e.screening.to_string())
.unwrap_or("100".into());
// When launched from PLOT, preserve the parent dialog so the Plot Style
// editor can appear above it instead of replacing it.
if self.active_modal == Some(super::ModalKind::Plot) {
self.plotstyle_parent_plot_geometry =
Some((self.modal_offset, self.modal_resize));
// The child editor starts with its own centred geometry.
self.reset_modal_geometry();
} else {
// Direct command launch: Plotstyle is a normal standalone modal.
self.plotstyle_parent_plot_geometry = None;
}
self.active_modal = Some(super::ModalKind::Plotstyle);
Task::none()
}
@@ -6558,15 +6587,21 @@ impl OpenCADStudio {
}
Message::PlotStylePanelColorBuf(s) => {
self.ps_color_buf = s;
Task::none()
self.on_plot_style_panel_apply()
}
Message::PlotStylePanelLwBuf(s) => {
self.ps_lineweight_buf = s;
Task::none()
self.on_plot_style_panel_apply()
}
Message::PlotStylePanelLwSet(index) => {
self.ps_lineweight_buf = index.to_string();
self.on_plot_style_panel_apply()
}
Message::PlotStylePanelScreenBuf(s) => {
self.ps_screening_buf = s;
Task::none()
self.on_plot_style_panel_apply()
}
Message::PlotStylePanelApply => self.on_plot_style_panel_apply(),
+21
View File
@@ -1115,6 +1115,26 @@ pub(super) fn on_text_style_dialog_open(&mut self) -> Task<Message> {
}
pub(super) fn on_color_window_pick(&mut self, color: acadrust::types::Color) -> Task<Message> {
if matches!(
self.color_pick_target.as_ref().map(|(target, _)| target),
Some(crate::app::ColorPickTarget::PlotStyle)
) {
self.color_pick_target = None;
let rgb = match color {
acadrust::types::Color::Rgb { r, g, b } => Some((r, g, b)),
acadrust::types::Color::Index(index) => {
acadrust::types::aci_table::aci_to_rgb(index)
}
_ => None,
};
if let Some((r, g, b)) = rgb {
self.ps_color_buf = format!("#{r:02X}{g:02X}{b:02X}");
}
return self.on_plot_style_panel_apply();
}
let s = crate::ui::color_select::color_to_aci_string(color);
let edit = match self.color_pick_target.take().map(|(target, _)| target) {
Some(crate::app::ColorPickTarget::DimStyle(f)) => Some(Message::DsEdit(f, s)),
@@ -1147,6 +1167,7 @@ pub(super) fn on_text_style_dialog_open(&mut self) -> Task<Message> {
Some(crate::app::ColorPickTarget::LayerState(idx)) => {
Some(Message::LayerStateEditorLayerColor(idx, color))
}
Some(crate::app::ColorPickTarget::PlotStyle) => None,
None => None,
};
if let Some(m) = edit {