Skip to main content

kithe_plot/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    SetAxisTitleFontSize {
28        axis: AxisKind,
29        old: u32,
30        new: u32,
31    },
32    SetAxisScale {
33        axis: AxisKind,
34        old: ScaleType,
35        new: ScaleType,
36    },
37    SetAxisRange {
38        axis: AxisKind,
39        old: RangePolicy,
40        new: RangePolicy,
41    },
42    SetAxisMajorTickStep {
43        axis: AxisKind,
44        old: Option<f64>,
45        new: Option<f64>,
46    },
47    SetAxisMinorTicks {
48        axis: AxisKind,
49        old: u16,
50        new: u16,
51    },
52    ReplaceAxisConfig {
53        axis: AxisKind,
54        old: AxisConfig,
55        new: AxisConfig,
56    },
57    AddSeries {
58        series: SeriesModel,
59        index: usize,
60    },
61    RemoveSeries {
62        series: SeriesModel,
63        index: usize,
64    },
65    RenameSeries {
66        series_id: SeriesId,
67        old: String,
68        new: String,
69    },
70    SetSeriesVisibility {
71        series_id: SeriesId,
72        old: bool,
73        new: bool,
74    },
75    SetSeriesXColumn {
76        series_id: SeriesId,
77        old: String,
78        new: String,
79    },
80    SetSeriesYColumn {
81        series_id: SeriesId,
82        old: String,
83        new: String,
84    },
85    SetSeriesLineWidth {
86        series_id: SeriesId,
87        old: f32,
88        new: f32,
89    },
90    SetSeriesLineStyle {
91        series_id: SeriesId,
92        old: crate::model::LineStyle,
93        new: crate::model::LineStyle,
94    },
95    SetSeriesColor {
96        series_id: SeriesId,
97        old: crate::model::Color,
98        new: crate::model::Color,
99    },
100    SetSeriesMarker {
101        series_id: SeriesId,
102        old: Option<MarkerStyle>,
103        new: Option<MarkerStyle>,
104    },
105    ReplaceLegend {
106        old: LegendConfig,
107        new: LegendConfig,
108    },
109    ReplaceLayout {
110        old: LayoutConfig,
111        new: LayoutConfig,
112    },
113    Batch {
114        commands: Vec<Command>,
115    },
116}
117
118