Skip to content

Commit 9c95d64

Browse files
committed
tweak preset settings
1 parent e2cd89b commit 9c95d64

File tree

13 files changed

+109
-52
lines changed

13 files changed

+109
-52
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/notation_kb/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ dev = [
2222

2323
[dependencies]
2424
notation_bevy = { path = "../../crates/notation_bevy" }
25+
notation_viewer = { path = "../notation_viewer" }

apps/notation_kb/src/index_panel.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,19 @@ impl IndexPanel {
119119
state: Res<NotationState>,
120120
mut theme: ResMut<NotationTheme>,
121121
mut settings: ResMut<NotationSettings>,
122-
index: Res<IndexPanel>,
122+
_index: Res<IndexPanel>,
123123
) {
124+
if !state.show_kb {
125+
return;
126+
}
124127
theme.sizes.melody.note_height = 8.0;
125128
theme.sizes.melody.semitone_height = 8.0;
126129
theme.texts.melody.text_y = -18.0;
127-
settings.add_ready_section = false;
128130
settings.hide_mini_map = true;
129131
settings.hide_bar_number = true;
130132
settings.layout.focus_bar_ease_ms = 0;
133+
settings.show_melody_pitch = true;
131134
settings.show_melody_syllable = true;
132-
settings.show_syllable_as_pitch = true;
133135
if state.window_width > 0.0 && state.window_height > 0.0 {
134136
if state.window_width > state.window_height {
135137
let width = state.window_width / 3.0 + theme.sizes.layout.page_margin;

apps/notation_kb/src/kb.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use notation_bevy::bevy::prelude::*;
44
use notation_bevy::prelude::*;
55

66
use crate::index_panel::IndexPanel;
7+
use notation_viewer::viewer::NotationViewer;
78

89
pub struct NotationKnowledgeBase();
910

@@ -21,6 +22,9 @@ impl NotationKnowledgeBase {
2122
.with_system(IndexPanel::index_ui)
2223
.with_system(IndexPanel::index_audio)
2324
.with_system(IndexPanel::handle_link_evts)
25+
.with_system(NotationViewer::handle_keyboard_inputs)
26+
.with_system(NotationViewer::handle_mouse_inputs)
27+
.with_system(NotationViewer::handle_touch_inputs)
2428
.with_system(Self::load_tab)
2529
.with_system(Self::on_window_resized)
2630
);
@@ -39,12 +43,13 @@ impl NotationKnowledgeBase {
3943
mut windows: ResMut<Windows>,
4044
mut state: ResMut<NotationState>,
4145
mut theme: ResMut<NotationTheme>,
42-
settings: Res<NotationSettings>,
46+
mut settings: ResMut<NotationSettings>,
4347
mut evts: EventWriter<AddTabEvent>,
4448
entities: Query<Entity, With<GlobalTransform>>,
4549
viewer_query: Query<(Entity, &TabViewer), With<TabViewer>>,
4650
index: Res<IndexPanel>,
4751
) {
52+
settings.add_ready_section = false;
4853
NotationApp::load_tab(&mut commands, &time, &mut windows, &mut state, &mut theme, &settings, &mut evts, &entities, &viewer_query, |tab_path| {
4954
Some(TabAsset::from(index.make_tab(tab_path)))
5055
})

apps/notation_kb/src/theory/scale.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl ScalePage {
137137
new_bar(8),
138138
new_bar(12),
139139
];
140-
let section = ProtoSection::new("notes".to_owned(), SectionKind::Ready, bars);
140+
let section = ProtoSection::new("notes".to_owned(), SectionKind::Verse, bars);
141141
ProtoTab::new(
142142
ProtoTab::new_uuid().as_str(),
143143
meta,

apps/notation_viewer/src/viewer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl NotationViewer {
4747
NotationApp::load_tab_from_assets(&asset_server, &assets, tab_path)
4848
})
4949
}
50-
fn handle_keyboard_inputs(
50+
pub fn handle_keyboard_inputs(
5151
keyboard_input: Res<Input<KeyCode>>,
5252
egui_ctx: Res<EguiContext>,
5353
mut app_state: ResMut<NotationState>,
@@ -111,7 +111,7 @@ impl NotationViewer {
111111
} else if keyboard_input.just_released(KeyCode::M) {
112112
Control::toggle_show_melody_syllable(&mut app_state, &mut settings, &mut theme);
113113
} else if keyboard_input.just_released(KeyCode::P) {
114-
Control::toggle_show_syllable_as_pitch(&mut app_state, &mut settings, &mut theme);
114+
Control::toggle_show_melody_pitch(&mut app_state, &mut settings, &mut theme);
115115
} else if keyboard_input.just_released(KeyCode::F) {
116116
Control::toggle_always_show_fret(&mut app_state, &mut settings, &mut theme);
117117
} else if keyboard_input.just_released(KeyCode::L) {
@@ -139,7 +139,7 @@ impl NotationViewer {
139139
}
140140
}
141141

142-
fn handle_mouse_inputs(
142+
pub fn handle_mouse_inputs(
143143
windows: Res<Windows>,
144144
mouse_input: Res<Input<MouseButton>>,
145145
egui_ctx: Res<EguiContext>,
@@ -193,7 +193,7 @@ impl NotationViewer {
193193
}
194194
}
195195

196-
fn handle_touch_inputs(
196+
pub fn handle_touch_inputs(
197197
windows: Res<Windows>,
198198
touch_input: Res<Touches>,
199199
egui_ctx: Res<EguiContext>,

crates/notation_bevy/src/guitar/fret_finger.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use notation_model::prelude::{
88

99
use crate::chord::chord_note::{ChordNoteData, ChordNoteExtra, ChordNoteValue};
1010
use crate::prelude::{NotationAssets, NotationSettings, NotationTheme};
11-
use crate::theme::theme_texts::MelodyTexts;
1211

1312
#[derive(Clone, Debug)]
1413
pub struct FretFingerExtra {
@@ -179,7 +178,7 @@ impl FretFingerData {
179178
}
180179
if settings.show_guitar_syllable && self.value.extra.fret.is_some() {
181180
let syllable = self.value.calc_syllable();
182-
theme.guitar.syllable_text.spawn_scaled_syllable_text(
181+
theme.guitar.syllable_text.spawn_scaled_note_text(
183182
commands,
184183
entity,
185184
assets,

crates/notation_bevy/src/notation/control.rs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ pub struct Control();
1010

1111
impl Control {
1212
pub const PRESET_GUITAR_STRINGS: &'static str = "guitar_strings";
13+
pub const PRESET_MELODY: &'static str = "melody";
14+
pub const ALL_PRESETS: [&'static str ; 2 ] = [
15+
Self::PRESET_GUITAR_STRINGS,
16+
Self::PRESET_MELODY,
17+
];
1318

1419
pub fn reload_tab(state: &mut NotationState, theme: &mut NotationTheme) {
1520
state.reload_tab();
@@ -67,12 +72,12 @@ impl Control {
6772
settings.show_melody_syllable = !settings.show_melody_syllable;
6873
Self::reload_tab(state, theme);
6974
}
70-
pub fn toggle_show_syllable_as_pitch(
75+
pub fn toggle_show_melody_pitch(
7176
state: &mut NotationState,
7277
settings: &mut NotationSettings,
7378
theme: &mut NotationTheme,
7479
) {
75-
settings.show_syllable_as_pitch = !settings.show_syllable_as_pitch;
80+
settings.show_melody_pitch = !settings.show_melody_pitch;
7681
Self::reload_tab(state, theme);
7782
}
7883
pub fn toggle_always_show_fret(
@@ -105,26 +110,37 @@ impl Control {
105110
_window_resized_evts: &mut EventWriter<WindowResizedEvent>,
106111
preset: &'static str,
107112
) {
113+
state.show_kb = false;
114+
state.preset = Some(preset.to_owned());
115+
#[cfg(not(target_arch = "wasm32"))]
116+
Self::set_primary_window_size(windows, 1080, 1920);
108117
match preset {
109118
Self::PRESET_GUITAR_STRINGS => {
110-
state.preset = Some(preset.to_owned());
111-
settings.add_ready_section = false;
112-
settings.hide_indicators = true;
113-
settings.hide_guitar_view = true;
114-
settings.hide_chords_view = true;
115-
settings.hide_shapes_lane = true;
119+
settings.hack_for_screenshot();
120+
settings.hide_strings_lane = false;
116121
settings.always_show_fret = true;
117-
settings.override_beat_size = Some(128.0);
122+
theme.sizes.layout.page_margin = 24.0;
118123
theme.sizes.strings.string_space = 20.0;
119124
theme.sizes.strings.note_height = 9.0;
120125
theme.texts.strings.fret_font_size = 20.0;
121126
theme.texts.strings.text_y = 8.0;
127+
},
128+
Self::PRESET_MELODY => {
129+
settings.hack_for_screenshot();
130+
settings.hide_melody_lane = false;
131+
settings.show_melody_pitch = true;
132+
settings.show_melody_syllable = true;
133+
settings.show_syllable_as_num = true;
122134
theme.sizes.layout.page_margin = 24.0;
123-
#[cfg(not(target_arch = "wasm32"))]
124-
Self::set_primary_window_size(windows, 1080, 1920);
125-
Self::reload_tab(state, theme);
135+
theme.sizes.melody.note_height = 9.0;
136+
theme.sizes.melody.semitone_height = 9.0;
137+
theme.texts.melody.text_y = -18.0;
138+
theme.texts.melody.syllable_font_size = 20.0;
139+
},
140+
_ => {
141+
println!("Control::set_preset() Invalid Preset: {}", preset);
126142
},
127-
_ => {},
128143
}
144+
Self::reload_tab(state, theme);
129145
}
130146
}

crates/notation_bevy/src/notation/control_panel.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,19 @@ impl ControlPanel {
191191
if show_guitar_syllable != settings.show_guitar_syllable {
192192
Control::reload_tab(state, theme);
193193
}
194+
let show_melody_pitch = settings.show_melody_pitch;
195+
ui.checkbox(
196+
&mut settings.show_melody_pitch,
197+
"Show Melody Pitch",
198+
);
199+
if show_melody_pitch != settings.show_melody_pitch {
200+
Control::reload_tab(state, theme);
201+
}
194202
let show_melody_syllable = settings.show_melody_syllable;
195203
ui.checkbox(&mut settings.show_melody_syllable, "Show Melody Syllable");
196204
if show_melody_syllable != settings.show_melody_syllable {
197205
Control::reload_tab(state, theme);
198206
}
199-
let show_syllable_as_pitch = settings.show_syllable_as_pitch;
200-
ui.checkbox(
201-
&mut settings.show_syllable_as_pitch,
202-
"Show Syllable as Pitches",
203-
);
204-
if show_syllable_as_pitch != settings.show_syllable_as_pitch {
205-
Control::reload_tab(state, theme);
206-
}
207207
let show_syllable_as_num = settings.show_syllable_as_num;
208208
ui.checkbox(
209209
&mut settings.show_syllable_as_num,
@@ -631,11 +631,11 @@ impl ControlPanel {
631631
))
632632
.default_open(true)
633633
.show(ui, |ui| {
634-
ui.horizontal(|ui| {
635-
if ui.button(Control::PRESET_GUITAR_STRINGS).clicked() {
636-
Control::set_preset(state, settings, theme, windows, window_resized_evts, Control::PRESET_GUITAR_STRINGS);
634+
for preset in Control::ALL_PRESETS.iter() {
635+
if ui.button(*preset).clicked() {
636+
Control::set_preset(state, settings, theme, windows, window_resized_evts, *preset);
637637
}
638-
});
638+
}
639639
});
640640
}
641641
pub fn control_ui(
@@ -697,8 +697,6 @@ impl ControlPanel {
697697
);
698698
Self::display_ui(ui, &mut state, &mut settings, &mut theme);
699699
ui.separator();
700-
Self::presets_ui(ui, &mut state, &mut settings, &mut theme, &mut windows, &mut window_resized_evts);
701-
ui.separator();
702700
Self::layout_ui(ui, &mut state, &mut settings, &mut theme);
703701
Self::overrides_ui(
704702
ui,
@@ -737,6 +735,8 @@ impl ControlPanel {
737735
*theme = NotationTheme::default();
738736
Control::reload_tab(&mut state, &mut theme);
739737
}
738+
ui.separator();
739+
Self::presets_ui(ui, &mut state, &mut settings, &mut theme, &mut windows, &mut window_resized_evts);
740740
});
741741
});
742742
});

crates/notation_bevy/src/notation/ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//use bevy::app::StartupStage;
22
use bevy::prelude::*;
3-
use bevy_egui::{EguiContext, EguiSettings};
3+
use bevy_egui::{EguiSettings};
44

55
use crate::prelude::{NotationState};
66

0 commit comments

Comments
 (0)