Skip to content

Commit 845c373

Browse files
committed
fixes #123, use egui to create a help page, show notes and chords and usage information
1 parent 9cb87d0 commit 845c373

File tree

35 files changed

+1367
-63
lines changed

35 files changed

+1367
-63
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Keyboard Shortcuts - GUI
2+
- *F1* toggle help dialog
3+
- *Tab* toggle control gui
4+
- *F5* reload current tab
5+
6+
# Keyboard Shortcuts - Move Around
7+
- *Home* jump to the first bar of current section
8+
- *End* jump to the last bar of current section
9+
- *Page Up* jump to the first bar of last section
10+
- *Page Down* jump to the first bar of next section
11+
- *Left* jump to last bar
12+
- *Right* jump to next bar
13+
- *Down* play one guitar note (same as clicking on guitar fretboard)
14+
15+
# Keyboard Shortcuts - Play Control
16+
- *Space* play or pause
17+
- *Return* stop
18+
- *1* set play speed to 25%
19+
- *2* set play speed to 50%
20+
- *3* set play speed to 75%
21+
- *4* set play speed to 100%
22+
- *L* toggle loop mode
23+
24+
# Keyboard Shortcuts - Repeat Selection
25+
- *A* set the beginning of repeat selection to current bar
26+
- *B* set the end of repeat selection to current bar
27+
- *C* clear repeat selection
28+
- *D* set repeat selection to current bar
29+
- *E* set repeat selection to current section
30+
31+
# Keyboard Shortcuts - Others
32+
- *Backspace* toggle layout between grid mode and line mode
33+
- *G* toggle whether showing syllable in guitar fretboard
34+
- *M* toggle whether showing syllable in melody lines
35+
- *F* toggle whether always show fret number in guitar tab
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Thanks for trying /Fun Notation/, it's a highly experimental musical notation system, at the top of this page, there are a bunch of topics to browse, you may also check the [Web Site](https://www.notation.fun) for more information.
2+
3+
We are using [Solfège](https://en.wikipedia.org/wiki/Solf%C3%A8ge) system for the note names, so instead of *C D E F G A B*, they are named *Do Re Mi Fa So La Ti*, or *1 2 3 4 5 6 7*, it's a relative notation, means the actual pitch of each notes are decided by key, check the notes page for note pitches in this songs.
4+
5+
# Notes
6+
Each note has a color associated with, which is for quick recognition. The color choice is based on [Chromesthesia](https://en.wikipedia.org/wiki/Chromesthesia), check the colors page for more details.
7+
8+
# Chords
9+
We use circles with slots in them to represent chords, it's quite controversial, so need some more explanation.
10+
11+
# Guitar
12+
Many features of /Fun Notation/ are created for my needs for guitar tabs.

apps/notation_viewer/assets/tabs/scarborough_fair.ron

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
Perfect5th,
2828
Minor7th,
2929
),
30-
base: None,
30+
bass: None,
3131
),
3232
Dotted(Half),
3333
)),// [2]
@@ -40,7 +40,7 @@
4040
Perfect5th,
4141
Minor7th,
4242
),
43-
base: Some(Perfect4th),
43+
bass: Some(Perfect4th),
4444
),
4545
Dotted(Half),
4646
)),// [4]
@@ -52,7 +52,7 @@
5252
Major3nd,
5353
Perfect5th,
5454
),
55-
base: Some(Perfect4th),
55+
bass: Some(Perfect4th),
5656
),
5757
Dotted(Half),
5858
)),// [6]
@@ -64,7 +64,7 @@
6464
Major3nd,
6565
Perfect5th,
6666
),
67-
base: None,
67+
bass: None,
6868
),
6969
Dotted(Half),
7070
)),// [8]
@@ -76,7 +76,7 @@
7676
Major2nd,
7777
Perfect5th,
7878
),
79-
base: None,
79+
bass: None,
8080
),
8181
Dotted(Half),
8282
)),// [10]
@@ -88,7 +88,7 @@
8888
Minor3nd,
8989
Perfect5th,
9090
),
91-
base: None,
91+
bass: None,
9292
),
9393
Dotted(Half),
9494
)),// [12]
@@ -100,7 +100,7 @@
100100
Major3nd,
101101
Perfect5th,
102102
),
103-
base: None,
103+
bass: None,
104104
),
105105
Dotted(Half),
106106
)),// [14]
@@ -116,7 +116,7 @@
116116
Major3nd,
117117
Perfect5th,
118118
),
119-
base: None,
119+
bass: None,
120120
),
121121
Simple(Quarter),
122122
)),// [17]
@@ -131,7 +131,7 @@
131131
Major3nd,
132132
Perfect5th,
133133
),
134-
base: None,
134+
bass: None,
135135
),
136136
Simple(Half),
137137
)),// [19]
@@ -148,7 +148,7 @@
148148
Major3nd,
149149
Perfect5th,
150150
),
151-
base: None,
151+
bass: None,
152152
),
153153
Simple(Quarter),
154154
)),// [23]
@@ -159,7 +159,7 @@
159159
Major3nd,
160160
Perfect5th,
161161
),
162-
base: Some(Major3nd),
162+
bass: Some(Major3nd),
163163
),
164164
Simple(Quarter),
165165
)),// [24]
@@ -170,7 +170,7 @@
170170
Minor3nd,
171171
Perfect5th,
172172
),
173-
base: None,
173+
bass: None,
174174
),
175175
Simple(Quarter),
176176
)),// [25]

apps/notation_viewer/assets/tabs/test.ron

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
Major3nd,
2727
Perfect5th,
2828
),
29-
base: None,
29+
bass: None,
3030
),
3131
Simple(Whole),
3232
)),// [2]
@@ -38,7 +38,7 @@
3838
Minor3nd,
3939
Perfect5th,
4040
),
41-
base: None,
41+
bass: None,
4242
),
4343
Simple(Whole),
4444
)),

crates/notation_bevy/src/app/app.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use bevy::window::WindowResized;
77

88
use bevy_asset_loader::AssetLoader;
99

10+
use crate::help::help_panel::HelpPanel;
1011
use crate::theme::theme_colors::UiColors;
1112
use crate::{prelude::*, settings::layout_settings::LayoutMode};
1213
use crate::ui::viewer::TabViewerPlugin;
@@ -58,8 +59,11 @@ impl NotationApp {
5859
app.insert_resource(ClearColor(UiColors::default().app_background));
5960
app.add_plugin(bevy_easings::EasingsPlugin);
6061

62+
app.add_plugin(UtilsPlugin);
63+
6164
app.init_resource::<NotationTheme>();
6265
app.init_resource::<NotationSettings>();
66+
app.init_resource::<HelpPanel>();
6367
app.add_plugins(NotationPlugins);
6468

6569
#[cfg(target_arch = "wasm32")]
@@ -104,7 +108,7 @@ impl NotationApp {
104108
app.init_resource::<NotationAppState>();
105109

106110
app.add_startup_system(setup_camera.system());
107-
//app.add_startup_system(setup_hot_reloading.system());
111+
app.add_startup_system(setup_hot_reloading.system());
108112

109113
app.add_system_set(
110114
SystemSet::on_enter(NotationAssetsStates::Loaded)
@@ -144,15 +148,15 @@ fn setup_camera(mut commands: Commands) {
144148
* Ideally can use hot-reloading to update tabs automatically, but that means need to patch bevy
145149
* to bypass the assumption with asset path under assets folder in reloading.
146150
* Leave the codes here in case that want to revisit this feature in the future.
151+
* Also the hot reloading works really nice for the markdown assets.
147152
*
148153
* The crash error is:
149154
*
150155
* thread 'Compute Task Pool (2)' panicked at 'called `Result::unwrap()` on an `Err` value: StripPrefixError(())', C:\Users\yjpark\scoop\persist\rustup-msvc\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_asset-0.5.1\src\io\file_asset_io.rs:135:84
151-
*
156+
*/
152157
fn setup_hot_reloading(asset_server: Res<AssetServer>) {
153-
asset_server.watch_for_changes().unwrap();
158+
//asset_server.watch_for_changes().unwrap();
154159
}
155-
*/
156160

157161
fn on_tab_asset(
158162
mut evts: EventReader<AssetEvent<TabAsset>>,
@@ -241,10 +245,12 @@ fn handle_keyboard_inputs(
241245
return;
242246
}
243247
if keyboard_input.just_released(KeyCode::Tab) {
244-
app_state.hide_control = !app_state.hide_control;
248+
app_state.show_control = !app_state.show_control;
245249
if !ControlView::HUD_MODE {
246250
window_resized_evts.send(WindowResizedEvent());
247251
}
252+
} else if keyboard_input.just_released(KeyCode::F1) {
253+
app_state.show_help = !app_state.show_help;
248254
} else if keyboard_input.just_released(KeyCode::F5) {
249255
Control::reload_tab(&mut app_state, &mut theme);
250256
} else if keyboard_input.just_released(KeyCode::Space) {
@@ -316,20 +322,22 @@ fn handle_mouse_inputs(
316322
if app_state.tab.is_none() {
317323
return;
318324
}
319-
if mouse_input.just_released(MouseButton::Left) {
325+
let cursor_position =
320326
windows
321327
.get_primary()
322-
.and_then(|x| x.cursor_position())
323-
.map(|cursor_position| {
324-
//println!("handle_inputs() -> MouseClickedEvent({:?})", cursor_position);
325-
mouse_clicked.send(MouseClickedEvent { cursor_position });
326-
});
328+
.and_then(|x| x.cursor_position());
329+
if cursor_position.is_none() {
330+
return;
331+
}
332+
let cursor_position = cursor_position.unwrap();
333+
if mouse_input.just_released(MouseButton::Left) {
334+
mouse_clicked.send(MouseClickedEvent { cursor_position });
327335
} else if mouse_input.just_pressed(MouseButton::Right) {
328336
} else if mouse_input.just_released(MouseButton::Right) {
329337
} else if mouse_input.pressed(MouseButton::Right) {
330338
for event in mouse_motion_events.iter() {
331339
//println!("handle_inputs() -> MouseDraggedEvent({:?})", event.delta);
332-
mouse_dragged.send(MouseDraggedEvent { delta: event.delta });
340+
mouse_dragged.send(MouseDraggedEvent { cursor_position, delta: event.delta });
333341
}
334342
} else {
335343
for event in mouse_wheel_input.iter() {
@@ -342,7 +350,7 @@ fn handle_mouse_inputs(
342350
if settings.layout.mode == LayoutMode::Line {
343351
delta = Vec2::new(delta.y, delta.x);
344352
}
345-
mouse_dragged.send(MouseDraggedEvent { delta: delta });
353+
mouse_dragged.send(MouseDraggedEvent { cursor_position, delta: delta });
346354
}
347355
}
348356
}

crates/notation_bevy/src/app/app_events.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct MouseClickedEvent {
1010

1111
#[derive(Clone, Debug)]
1212
pub struct MouseDraggedEvent {
13+
pub cursor_position: Vec2,
1314
pub delta: Vec2,
1415
}
1516

crates/notation_bevy/src/app/app_state.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub struct NotationAppState {
1212
pub scale_factor_override: Option<f64>,
1313
pub tab_path: String,
1414
pub tab: Option<Arc<Tab>>,
15-
pub hide_control: bool,
15+
pub show_control: bool,
16+
pub show_help: bool,
1617
pub parse_error: Option<ParseError>,
1718
pub debug_str: Option<String>,
1819
pub _despawn_delay_seconds: f32,
@@ -27,7 +28,8 @@ impl NotationAppState {
2728
scale_factor_override: None,
2829
tab_path,
2930
tab: None,
30-
hide_control: true,
31+
show_control: false,
32+
show_help: false,
3133
parse_error: None,
3234
debug_str: None,
3335
_despawn_delay_seconds: 0.0,

crates/notation_bevy/src/app/assets.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use bevy::prelude::*;
22
use bevy_asset_loader::AssetCollection;
3+
use notation_bevy_utils::asset::markdown_asset::MarkDownAsset;
34

45
#[derive(AssetCollection)]
56
pub struct NotationAssets {
@@ -11,6 +12,10 @@ pub struct NotationAssets {
1112
//pub guitar: Handle<Scene>,
1213
#[asset(path = "png/fretboard.png")]
1314
pub fretboard: Handle<Texture>,
15+
#[asset(path = "help/welcome.md")]
16+
pub help_welcome: Handle<MarkDownAsset>,
17+
#[asset(path = "help/usage.md")]
18+
pub help_usage: Handle<MarkDownAsset>,
1419
}
1520

1621
#[derive(Clone, Eq, PartialEq, Debug, Hash)]

crates/notation_bevy/src/chord/chord_diagram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl ChordDiagramData {
133133
);
134134
interval_data.spawn(commands, theme, diagram_entity);
135135
}
136-
if let Some(base) = chord.base {
136+
if let Some(base) = chord.bass {
137137
let base_data = ChordBaseData::new_data(entry_props, chord.root, base.clone(), radius);
138138
base_data.spawn(commands, theme, diagram_entity);
139139
}

crates/notation_bevy/src/guitar/guitar_view.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl GuitarView {
376376
} else {
377377
top_y
378378
};
379-
println!("GuitarView::adjust_y_by_frets {} {} [{} - {}] -> {} {} -> {}", view_size, guitar_size, min_fret, max_fret, top_y, bottom_y, y);
379+
//println!("GuitarView::adjust_y_by_frets {} {} [{} - {}] -> {} {} -> {}", view_size, guitar_size, min_fret, max_fret, top_y, bottom_y, y);
380380
Self::update_y(guitar_view_query, y);
381381
}
382382
pub fn adjust_y_by_barre(

0 commit comments

Comments
 (0)