Skip to main content

oa/viewer/
config.rs

1//! Viewer configuration types. Donor: `ViewerConfig`, `ViewerMode`, etc.
2
3use crate::input::{Key, MotionSpeed};
4use crate::ui::types::UiStyle;
5pub use crate::viewer::types::ViewerConfig;
6
7/// Media source mode for the Viewer.
8#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
9pub enum ViewerMode {
10	/// Probe path as image → video → audio.
11	#[default]
12	Auto,
13	Image,
14	Video,
15	Audio,
16	/// Attach a `ViewerLiveSource` and render its output each frame.
17	Live,
18	/// Dock-style host for UI elements (`Workspace`); content is composed
19	/// through `split_pane` + `tab_bar`, not a second compositor.
20	Workspace,
21}
22
23/// Audio visualization mode.
24#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
25pub enum ViewerAudioView {
26	#[default]
27	Waveform,
28	Spectrum,
29	Mel,
30}
31
32/// Canvas background style.
33#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
34pub enum ViewerCanvasBackground {
35	#[default]
36	Dark,
37	Gradient,
38}
39
40impl Default for ViewerConfig {
41	fn default() -> Self {
42		Self {
43			mode: ViewerMode::Auto,
44			path: String::new(),
45			title: String::from("Viewer"),
46			width: 1280,
47			height: 720,
48			style: UiStyle::viewer_dark(),
49			motion_speed: MotionSpeed::Fast,
50			show_help: true,
51			show_stats: false,
52			show_timeline: true,
53			vsync: true,
54			loop_media: true,
55			start_playing: true,
56			auto_hide_controls: true,
57			controls_hide_delay_ms: 2_000,
58			canvas_background: ViewerCanvasBackground::Gradient,
59			show_canvas_grid: true,
60			audio_view: ViewerAudioView::Waveform,
61			audio_waveform_bins: 2048,
62			audio_analysis_frames: 2048,
63			audio_fft_size: 1024,
64			audio_hop_size: 256,
65			audio_mel_bins: 80,
66			audio_ring_ms: 500,
67			key_quit: Key::Escape,
68			key_quit_q: Key::Q,
69			key_red: Key::Num1,
70			key_green: Key::Num2,
71			key_blue: Key::Num3,
72			key_alpha: Key::Num4,
73			key_rgb: Key::Num5,
74			key_zoom_in: Key::Equals,
75			key_zoom_out: Key::Minus,
76			key_zoom_fit: Key::Num0,
77			key_zoom_100: Key::Num9,
78			key_canvas_background: Key::B,
79			key_canvas_grid: Key::G,
80		}
81	}
82}