Skip to main content

plot_redactor/controller/
action.rs

1//! View-to-controller intents.
2//!
3//! Every user interaction is represented as an `Action` and dispatched to the controller.
4
5use crate::model::{
6    AxisKind, Color, ImageFormat, ImageSize, LegendPosition, LineStyle, MarkerShape, RangePolicy,
7    ScaleType, SeriesId,
8};
9
10/// EN: UI intents emitted by View and consumed by Controller.
11/// RU: Namereniya UI, kotorye otpravlyaet View i obrabatyvaet Controller.
12pub enum Action {
13    ImportFromCsv { path: String },
14    ImportFromTxt { path: String },
15    SetChartTitle(String),
16    SetAxisLabel {
17        axis: AxisKind,
18        label: String,
19    },
20    SetAxisLabelFontSize {
21        axis: AxisKind,
22        font_size: u32,
23    },
24    SetAxisScale {
25        axis: AxisKind,
26        scale: ScaleType,
27    },
28    SetAxisRange {
29        axis: AxisKind,
30        range: RangePolicy,
31    },
32    SetAxisMajorTickStep {
33        axis: AxisKind,
34        step: Option<f64>,
35    },
36    SetAxisMinorTicks {
37        axis: AxisKind,
38        per_major: u16,
39    },
40    AddSeries {
41        name: String,
42        x_column: String,
43        y_column: String,
44    },
45    RemoveSeries {
46        series_id: SeriesId,
47    },
48    RenameSeries {
49        series_id: SeriesId,
50        name: String,
51    },
52    SetSeriesVisibility {
53        series_id: SeriesId,
54        visible: bool,
55    },
56    SetSeriesXColumn {
57        series_id: SeriesId,
58        x_column: String,
59    },
60    SetSeriesYColumn {
61        series_id: SeriesId,
62        y_column: String,
63    },
64    SetSeriesColor {
65        series_id: SeriesId,
66        color: Color,
67    },
68    SetSeriesLineWidth {
69        series_id: SeriesId,
70        width: f32,
71    },
72    SetSeriesLineStyle {
73        series_id: SeriesId,
74        line_style: LineStyle,
75    },
76    SetSeriesMarker {
77        series_id: SeriesId,
78        marker: Option<MarkerShape>,
79        size: f32,
80    },
81    SetLegendVisible(bool),
82    SetLegendTitle(Option<String>),
83    SetLegendPosition(LegendPosition),
84    SetLegendFontSize(u32),
85    SetLegendFontColor(Color),
86    SetLayoutMargin(u32),
87    SetXLabelAreaSize(u32),
88    SetYLabelAreaSize(u32),
89    SetLabelFontSize(u32),
90    SetLabelFontColor(Color),
91    RequestSaveAs {
92        path: String,
93        format: ImageFormat,
94        size: ImageSize,
95    },
96    Undo,
97    Redo,
98    ResetPlot,
99}
100
101