Skip to main content

plot_redactor/controller/
command.rs

1//! Undoable state transitions.
2//!
3//! Commands keep old/new values so the controller can apply and reverse edits safely.
4
5use crate::model::{
6    AxisConfig, AxisKind, LayoutConfig, LegendConfig, MarkerStyle, RangePolicy, ScaleType,
7    SeriesId, SeriesModel,
8};
9
10/// EN: Mutations with old/new values for undo/redo-safe state transitions.
11/// RU: Izmeneniya sostoyaniya s old/new dlya bezopasnogo undo/redo.
12pub enum Command {
13    SetChartTitle {
14        old: String,
15        new: String,
16    },
17    SetAxisLabel {
18        axis: AxisKind,
19        old: String,
20        new: String,
21    },
22    SetAxisLabelFontSize {
23        axis: AxisKind,
24        old: u32,
25        new: u32,
26    },
27    SetAxisScale {
28        axis: AxisKind,
29        old: ScaleType,
30        new: ScaleType,
31    },
32    SetAxisRange {
33        axis: AxisKind,
34        old: RangePolicy,
35        new: RangePolicy,
36    },
37    SetAxisMajorTickStep {
38        axis: AxisKind,
39        old: Option<f64>,
40        new: Option<f64>,
41    },
42    SetAxisMinorTicks {
43        axis: AxisKind,
44        old: u16,
45        new: u16,
46    },
47    ReplaceAxisConfig {
48        axis: AxisKind,
49        old: AxisConfig,
50        new: AxisConfig,
51    },
52    AddSeries {
53        series: SeriesModel,
54        index: usize,
55    },
56    RemoveSeries {
57        series: SeriesModel,
58        index: usize,
59    },
60    RenameSeries {
61        series_id: SeriesId,
62        old: String,
63        new: String,
64    },
65    SetSeriesVisibility {
66        series_id: SeriesId,
67        old: bool,
68        new: bool,
69    },
70    SetSeriesXColumn {
71        series_id: SeriesId,
72        old: String,
73        new: String,
74    },
75    SetSeriesYColumn {
76        series_id: SeriesId,
77        old: String,
78        new: String,
79    },
80    SetSeriesLineWidth {
81        series_id: SeriesId,
82        old: f32,
83        new: f32,
84    },
85    SetSeriesLineStyle {
86        series_id: SeriesId,
87        old: crate::model::LineStyle,
88        new: crate::model::LineStyle,
89    },
90    SetSeriesColor {
91        series_id: SeriesId,
92        old: crate::model::Color,
93        new: crate::model::Color,
94    },
95    SetSeriesMarker {
96        series_id: SeriesId,
97        old: Option<MarkerStyle>,
98        new: Option<MarkerStyle>,
99    },
100    ReplaceLegend {
101        old: LegendConfig,
102        new: LegendConfig,
103    },
104    ReplaceLayout {
105        old: LayoutConfig,
106        new: LayoutConfig,
107    },
108    Batch {
109        commands: Vec<Command>,
110    },
111}
112
113