egui_charts/ui/drawing_toolbar/actions.rs
1//! Actions that can be returned from drawing toolbar interactions.
2
3use super::categories::cursors::CursorType;
4use super::state::MagnetType;
5use crate::drawings::DrawingToolType;
6
7/// Actions returned from toolbar interactions
8///
9/// # Examples
10///
11/// ```
12/// use egui_charts::ui::drawing_toolbar::DrawingToolbarAction;
13/// use egui_charts::drawings::DrawingToolType;
14///
15/// let action = DrawingToolbarAction::SelectTool(DrawingToolType::TrendLine);
16/// match action {
17/// DrawingToolbarAction::SelectTool(tool) => {
18/// println!("Selected tool: {:?}", tool);
19/// }
20/// _ => {}
21/// }
22/// ```
23#[derive(Debug, Clone, PartialEq)]
24#[non_exhaustive]
25pub enum DrawingToolbarAction {
26 /// No action taken
27 None,
28 /// A drawing tool was selected
29 SelectTool(DrawingToolType),
30 /// Set cursor type (Cross, Dot, Arrow, Magic)
31 SetCursorType(CursorType),
32 /// Magnet mode toggled, from a click on the magnet or its Off row
33 ToggleMagnet,
34 /// Stay-in-drawing mode toggled
35 ToggleStayInDrawingMode,
36 /// Clear all drawings requested
37 ClearAllDrawings,
38 /// Drawing color changed (RGBA)
39 ColorChanged([u8; 4]),
40 /// Eraser mode toggled
41 ToggleEraserMode,
42 /// Hide all drawings
43 HideAllDrawings,
44 /// Hide all indicators
45 HideAllIndicators,
46 /// Hide all positions
47 HideAllPoss,
48 /// Hide all orders
49 HideAllOrders,
50 /// Remove all drawings
51 RemoveAllDrawings,
52 /// Remove all indicators
53 RemoveAllIndicators,
54 /// Remove all studies (indicators + overlays)
55 RemoveAllStudies,
56 /// Hide drawings, indicators, positions and orders at once. A host applies it as it
57 /// applies `HideAllDrawings`, `HideAllIndicators`, `HideAllPoss` and `HideAllOrders` with
58 /// everything hidden, in one undo step.
59 HideAll,
60 /// Remove all drawings and all indicators at once. A host applies it as it applies
61 /// `RemoveAllDrawings` and `RemoveAllIndicators`, in one undo step.
62 RemoveDrawingsAndIndicators,
63 /// Change magnet type (Weak/Strong)
64 SetMagnetType(MagnetType),
65 /// Include or exclude visible study plots from drawing magnet targets.
66 /// Hosts set `DrawingManagerOptions::snap_to_indicators` to this value.
67 SetSnapToIndicators(bool),
68 /// Zoom in (save current state to history)
69 ZoomIn,
70 /// Zoom out (restore previous state from history)
71 ZoomOut,
72 /// Toggle values tooltip on long press
73 ToggleValuesTooltip,
74 /// Lock all drawings
75 LockAllDrawings,
76 /// Save current drawing properties as a template
77 SaveTemplate {
78 /// Template name provided by the user
79 name: String,
80 },
81 /// Load a previously saved drawing template
82 LoadTemplate {
83 /// Template ID to load
84 template_id: String,
85 },
86 /// Open the template name input.
87 OpenTemplateMenu,
88 /// Open the host's drawing template catalog for loading and deletion.
89 ManageTemplates,
90 /// Place a bundled icon, emoji or sticker at its independent pixel size.
91 InsertGlyph {
92 /// Bundled glyph id or Unicode emoji.
93 icon_name: &'static str,
94 /// Size in logical pixels, saved as `Drawing::font_size`.
95 size: f32,
96 },
97 /// Legacy host intent for an emoji at the configured default size.
98 InsertEmoji {
99 /// The icon or emoji to place
100 icon_name: &'static str,
101 },
102}