dais_core/commands.rs
1use crate::state::DrawTool;
2
3/// Every user action in Dais is represented as a discrete typed command.
4///
5/// Commands are dispatched through the [`CommandBus`](crate::bus::CommandBus) and processed
6/// by the presentation engine. The UI never mutates state directly — all mutations flow
7/// through commands.
8///
9/// This design enables future external control surfaces (REST API, WebSocket, mobile remote)
10/// to be added as new command sources without modifying the engine.
11#[derive(Debug, Clone, PartialEq)]
12pub enum Command {
13 // -- Navigation --
14 /// Advance to the next build step, or to the next logical slide if the current slide is complete.
15 NextSlide,
16 /// Go back to the previous build step, or to the previous logical slide if already at the start.
17 PreviousSlide,
18 /// Advance one PDF page (next overlay/build step within a group).
19 NextOverlay,
20 /// Go back one PDF page (previous overlay/build step).
21 PreviousOverlay,
22 /// Jump to the first slide.
23 FirstSlide,
24 /// Jump to the last slide.
25 LastSlide,
26 /// Jump to a specific logical slide by index (0-based).
27 GoToSlide(usize),
28
29 // -- Display modes --
30 /// Freeze/unfreeze the audience display.
31 ToggleFreeze,
32 /// Black out/restore the audience display.
33 ToggleBlackout,
34 /// Toggle the whiteboard (blank white drawing canvas on audience).
35 ToggleWhiteboard,
36 /// Toggle screen-share mode (audience window as normal window).
37 ToggleScreenShareMode,
38 /// Toggle presentation mode (single-monitor: console ↔ fullscreen HUD).
39 TogglePresentationMode,
40 /// Swap presenter and audience monitors for this session.
41 SwapDisplays,
42
43 // -- Presentation aids --
44 /// Toggle the laser pointer on/off.
45 ToggleLaser,
46 /// Cycle the laser pointer visual style.
47 CycleLaserStyle,
48 /// Update the pointer position (normalized 0..1 coordinates relative to slide).
49 SetPointerPosition(f32, f32),
50 /// Toggle freehand ink drawing mode.
51 ToggleInk,
52 /// Add a point to the current ink stroke (normalized coordinates).
53 AddInkPoint(f32, f32),
54 /// Finish the current ink stroke (pen lifted).
55 FinishInkStroke,
56 /// Clear all ink on the current page.
57 ClearInk,
58 /// Erase ink strokes near a position (normalized 0..1 coordinates).
59 /// Strokes are clipped at the circle boundary — only the portion within
60 /// `radius` is removed; the portions outside are kept as separate strokes.
61 EraseInkNear { x: f32, y: f32, radius: f32 },
62 /// Switch the active drawing tool (pen, highlighter, or eraser).
63 SetDrawTool(DrawTool),
64 /// Set the active pen color (RGBA). Affects only future strokes.
65 SetInkColor([u8; 4]),
66 /// Set the active pen width in logical pixels. Affects only future strokes.
67 SetInkWidth(f32),
68 /// Cycle the active pen color through the built-in preset list.
69 CycleInkColor,
70 /// Cycle the active pen width through the built-in preset list.
71 CycleInkWidth,
72 /// Toggle the spotlight overlay.
73 ToggleSpotlight,
74 /// Update the spotlight center position (normalized coordinates).
75 SetSpotlightPosition(f32, f32),
76 /// Toggle zoom mode on the audience display.
77 ToggleZoom,
78 /// Set the zoom region center and magnification factor.
79 SetZoomRegion { center: (f32, f32), factor: f32 },
80
81 // -- Timer --
82 /// Start the timer (or resume if paused).
83 StartTimer,
84 /// Pause the timer.
85 PauseTimer,
86 /// Toggle the timer between running and paused.
87 ToggleTimer,
88 /// Reset the timer to its initial state.
89 ResetTimer,
90
91 // -- UI panels --
92 /// Toggle the slide overview grid.
93 ToggleSlideOverview,
94 /// Toggle the notes panel visibility.
95 ToggleNotesPanel,
96 /// Toggle inline markdown editing for the current slide's notes.
97 ToggleNotesEdit,
98 /// Replace the current slide's notes markdown.
99 SetCurrentSlideNotes(String),
100 /// Increase notes font size by one step.
101 IncrementNotesFontSize,
102 /// Decrease notes font size by one step.
103 DecrementNotesFontSize,
104
105 // -- Text boxes --
106 /// Toggle text box placement mode.
107 ToggleTextBoxMode,
108 /// Place a new text box on the current slide (normalized coordinates).
109 PlaceTextBox { x: f32, y: f32, w: f32, h: f32 },
110 /// Update the content of a text box.
111 EditTextBoxContent { id: u64, content: String },
112 /// Move a text box to a new position (normalized coordinates).
113 MoveTextBox { id: u64, x: f32, y: f32 },
114 /// Resize a text box (normalized size).
115 ResizeTextBox { id: u64, w: f32, h: f32 },
116 /// Delete a text box by ID.
117 DeleteTextBox { id: u64 },
118 /// Select a text box by ID.
119 SelectTextBox(u64),
120 /// Deselect the currently selected text box.
121 DeselectTextBox,
122 /// Enter inline edit mode for the selected text box.
123 BeginTextBoxEdit { id: u64 },
124 /// Set the font size of a text box.
125 SetTextBoxFontSize { id: u64, size: f32 },
126 /// Set the text color of a text box (RGBA).
127 SetTextBoxColor { id: u64, color: [u8; 4] },
128 /// Set the background fill of a text box (RGBA, or None to clear).
129 SetTextBoxBackground { id: u64, color: Option<[u8; 4]> },
130
131 // -- System --
132 /// Quit the application.
133 Quit,
134 /// Save the current sidecar data to disk.
135 SaveSidecar,
136}