use super::{STAFF_HEIGHT, STAFF_SPACE};
#[derive(Debug, Clone)]
pub struct StaffConfig {
pub lines: u8,
pub space: f32,
pub height: f32,
pub line_width: f32,
}
impl Default for StaffConfig {
fn default() -> Self {
Self {
lines: 5,
space: STAFF_SPACE,
height: STAFF_HEIGHT,
line_width: 1.0,
}
}
}
#[derive(Debug, Clone)]
pub struct NoteConfig {
pub head_width: f32,
pub head_height: f32,
pub stem_width: f32,
pub stem_height: f32,
pub flag_width: f32,
pub beam_thickness: f32,
pub ledger_width: f32,
pub ledger_extension: f32,
pub accidental_spacing: f32,
pub dot_spacing: f32,
pub dot_radius: f32,
}
impl Default for NoteConfig {
fn default() -> Self {
Self {
head_width: STAFF_SPACE * 1.4,
head_height: STAFF_SPACE,
stem_width: 1.2,
stem_height: STAFF_SPACE * 3.5,
flag_width: STAFF_SPACE,
beam_thickness: STAFF_SPACE * 0.5,
ledger_width: STAFF_SPACE * 2.0,
ledger_extension: 4.0,
accidental_spacing: STAFF_SPACE * 0.8,
dot_spacing: STAFF_SPACE * 0.5,
dot_radius: STAFF_SPACE * 0.2,
}
}
}
#[derive(Debug, Clone)]
pub struct ColorScheme {
pub staff_lines: (f32, f32, f32, f32),
pub notes: (f32, f32, f32, f32),
pub rests: (f32, f32, f32, f32),
pub clefs: (f32, f32, f32, f32),
pub bar_lines: (f32, f32, f32, f32),
pub background: (f32, f32, f32, f32),
pub selected: (f32, f32, f32, f32),
pub accidentals: (f32, f32, f32, f32),
}
impl Default for ColorScheme {
fn default() -> Self {
Self {
staff_lines: (0.0, 0.0, 0.0, 1.0),
notes: (0.0, 0.0, 0.0, 1.0),
rests: (0.0, 0.0, 0.0, 1.0),
clefs: (0.0, 0.0, 0.0, 1.0),
bar_lines: (0.0, 0.0, 0.0, 1.0),
background: (1.0, 1.0, 1.0, 1.0),
selected: (0.2, 0.4, 0.8, 1.0),
accidentals: (0.0, 0.0, 0.0, 1.0),
}
}
}
#[derive(Debug, Clone)]
pub struct RenderConfig {
pub staff: StaffConfig,
pub note: NoteConfig,
pub colors: ColorScheme,
pub staff_spacing: f32,
pub system_spacing: f32,
pub margin_left: f32,
pub margin_right: f32,
pub margin_top: f32,
pub margin_bottom: f32,
pub clef_width: f32,
pub key_sig_width: f32,
pub time_sig_width: f32,
pub measure_width: f32,
pub scale: f32,
pub show_bar_numbers: bool,
pub show_ledger_lines: bool,
}
impl Default for RenderConfig {
fn default() -> Self {
Self {
staff: StaffConfig::default(),
note: NoteConfig::default(),
colors: ColorScheme::default(),
staff_spacing: STAFF_SPACE * 8.0,
system_spacing: STAFF_SPACE * 12.0,
margin_left: 40.0,
margin_right: 20.0,
margin_top: 40.0,
margin_bottom: 40.0,
clef_width: STAFF_SPACE * 4.0,
key_sig_width: STAFF_SPACE * 2.0,
time_sig_width: STAFF_SPACE * 3.0,
measure_width: STAFF_SPACE * 20.0,
scale: 1.0,
show_bar_numbers: true,
show_ledger_lines: true,
}
}
}
impl RenderConfig {
pub fn preview() -> Self {
Self {
scale: 0.5,
show_bar_numbers: false,
..Default::default()
}
}
pub fn print() -> Self {
Self {
scale: 1.5,
..Default::default()
}
}
pub fn with_scale(scale: f32) -> Self {
Self {
scale,
..Default::default()
}
}
}