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

+7
View File
@@ -614,6 +614,9 @@ pub(super) struct OpenCADStudio {
/// The open in-canvas modal dialog, if any (Plan B: shared overlay instead
/// of OS windows).
active_modal: Option<ModalKind>,
/// Plot modal geometry preserved while the Plot Style editor is open as
/// a child dialog. None means Plotstyle was opened directly (e.g. command).
plotstyle_parent_plot_geometry: Option<(iced::Vector, iced::Vector)>,
/// FIND dialog inputs and current result cursor.
find_replace: FindReplaceState,
/// Set once the user acknowledges the AEC-drop warning, so re-entering the
@@ -1187,6 +1190,8 @@ pub enum ColorPickTarget {
DimStyle(DsField),
MLeader(&'static str),
Table(u8, &'static str),
/// Plot-style colour override for the currently selected ACI entry.
PlotStyle,
/// Selected entities' colour (left properties panel).
Properties,
/// Selected entities' background colour (hatch / MTEXT background row).
@@ -2741,6 +2746,7 @@ pub enum Message {
/// Edit buffers changed.
PlotStylePanelColorBuf(String),
PlotStylePanelLwBuf(String),
PlotStylePanelLwSet(u8),
PlotStylePanelScreenBuf(String),
/// Apply current edit buffers to the selected ACI entry.
PlotStylePanelApply,
@@ -3153,6 +3159,7 @@ impl OpenCADStudio {
color_picker_tab: ColorPickerTab::Index,
recent_colors: Vec::new(),
active_modal: None,
plotstyle_parent_plot_geometry: None,
find_replace: FindReplaceState::default(),
aec_drop_acknowledged: false,
aec_drop_count: 0,
+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 {
+26 -2
View File
@@ -1829,6 +1829,30 @@ impl OpenCADStudio {
open_progress_layer,
];
// If the Plot Style editor was launched from PLOT, keep the Plot dialog
// rendered underneath as its blocked parent.
let modal_underlay: Element<'_, Message> =
if self.active_modal == Some(super::ModalKind::Plotstyle) {
if let Some((plot_offset, plot_resize)) =
self.plotstyle_parent_plot_geometry.as_ref()
{
let plot_content = self.plot_modal_content(*plot_resize);
crate::ui::modal::modal(
composed,
crate::tr!("modal", "plot"),
plot_content,
Message::CloseModal,
*plot_offset,
crate::ui::modal::ModalOptions::STANDARD,
)
} else {
composed.into()
}
} else {
composed.into()
};
// ── In-canvas modal dialogs (Plan B) ───────────────────────────────
// Former pop-up windows render as overlays here, so they work on both
// the native (single main window) and web builds.
@@ -1842,7 +1866,7 @@ impl OpenCADStudio {
crate::ui::modal::ModalOptions::STANDARD
};
crate::ui::modal::modal(
composed,
modal_underlay,
self.modal_title(),
content,
Message::CloseModal,
@@ -1850,7 +1874,7 @@ impl OpenCADStudio {
modal_options,
)
}
None => composed.into(),
None => modal_underlay,
};
// Shared CAD colour picker. Indexed ACI colours use OpenCADStudio's own
// dialog; True Color keeps the existing iced_aw gradient picker.
+18 -15
View File
@@ -50,7 +50,23 @@ impl OpenCADStudio {
None => String::new(),
}
}
pub(super) fn plot_modal_content<'s>(
&'s self,
extra: iced::Vector,
) -> Element<'s, Message> {
sized_flow(
extra,
760,
540,
|flow| {
crate::ui::window::plot::view_window(
&self.plot_dialog,
self.print_all_options,
flow,
)
},
)
}
/// Build the currently-open modal dialog's content (Plan B), or `None`.
/// Iced 0.15 measures the content first, so dialogs start at their natural
/// size and overflowing regions become scrollable where a cap is supplied.
@@ -280,20 +296,7 @@ impl OpenCADStudio {
})
}
}
super::super::ModalKind::Plot => {
sized_flow(
ex,
760,
540,
|flow| {
crate::ui::window::plot::view_window(
&self.plot_dialog,
self.print_all_options,
flow,
)
},
)
}
super::super::ModalKind::Plot => self.plot_modal_content(ex),
super::super::ModalKind::PrintAll => sized_flow(
ex,
520,