Skip to content

Commit 7fc33bc

Browse files
committed
refs #89, display selected bars in different way
1 parent ed518bc commit 7fc33bc

File tree

19 files changed

+270
-69
lines changed

19 files changed

+270
-69
lines changed

apps/notation_tool/src/tab/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ pub fn get_tab_list<'a>() -> Vec<TabInfo<'a>> {
3737
"songs:misc:scarborough_fair",
3838
songs::misc::scarborough_fair::new_tab,
3939
),
40+
TabInfo::new(
41+
"songs:misc:scarborough_fair",
42+
songs::misc::scarborough_fair_hard::new_tab,
43+
),
4044
]
4145
}
4246

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub mod stand_by_me;
2-
pub mod scarborough_fair;
2+
pub mod scarborough_fair;
3+
pub mod scarborough_fair_hard;

apps/notation_tool/src/tab/songs/misc/scarborough_fair.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ pub fn new_tab() -> Tab {
8181
"v4:2" Word [ "reap", "it"+ "in", "a", ] |
8282
"v4:3" Word [ "si-", "ckle"+ "of" ] |
8383
"v4:4" Word [ "lea-"* "ther" ] |
84+
"v4:12" Word [ _* "and", "to-" ] |
85+
"v4:13" Word [ "ga-" "ther" "it" ] |
86+
"v4:14" Word [ "all"* "in", "a", ] |
87+
"v4:15" Word [ "bunch"* "of" ] |
88+
"v4:16" Word [ "hea-", "ther", @ ""* ] |
8489
]}
8590
{vocal Vocal [
8691
$key = E
@@ -112,8 +117,8 @@ pub fn new_tab() -> Tab {
112117
"v4:4" Tone [ .6* .6 ] |
113118
"v4:12" Tone [ _* 6, 6, ] |
114119
"v4:14" Tone [ 5* 2, 2, ] |
115-
"v4:15" Tone [ 1 ,7 ,6 ] |
116-
"v4:16" Tone [ 2, .5, @ .5* ] |
120+
"v4:15" Tone [ 1 .7 .6 ] |
121+
"v4:16" Tone [ .7, .5, @ .5* ] |
117122
]}
118123
]
119124
Sections: [

apps/notation_tool/src/tab/songs/misc/scarborough_fair_hard.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ pub fn new_tab() -> Tab {
106106
"v4:2" Word [ "reap", "it"+ "in", "a", ] |
107107
"v4:3" Word [ "si-", "ckle"+ "of" ] |
108108
"v4:4" Word [ "lea-"* "ther" ] |
109+
"v4:12" Word [ _* "and", "to-" ] |
110+
"v4:13" Word [ "ga-" "ther" "it" ] |
111+
"v4:14" Word [ "all"* "in", "a", ] |
112+
"v4:15" Word [ "bunch"* "of" ] |
113+
"v4:16" Word [ "hea-", "ther", @ ""* ] |
109114
]}
110115
{vocal Vocal [
111116
$key = E
@@ -137,8 +142,8 @@ pub fn new_tab() -> Tab {
137142
"v4:4" Tone [ .6* .6 ] |
138143
"v4:12" Tone [ _* 6, 6, ] |
139144
"v4:14" Tone [ 5* 2, 2, ] |
140-
"v4:15" Tone [ 1 ,7 ,6 ] |
141-
"v4:16" Tone [ 2, .5, @ .5* ] |
145+
"v4:15" Tone [ 1 .7 .6 ] |
146+
"v4:16" Tone [ .7, .5, @ .5* ] |
142147
]}
143148
]
144149
Sections: [

apps/notation_tool/write-all-tabs.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ cargo run write-tab --tab songs:pu_shu:bai_hua_lin -o ../notation_viewer/assets/
44
cargo run write-tab --tab songs:jay:long_juan_feng -o ../notation_viewer/assets/songs/jay/long_juan_feng.ron
55
cargo run write-tab --tab songs:misc:stand_by_me -o ../notation_viewer/assets/songs/misc/stand_by_me.ron
66
cargo run write-tab --tab songs:misc:scarborough_fair -o ../notation_viewer/assets/songs/misc/scarborough_fair.ron
7+
cargo run write-tab --tab songs:misc:scarborough_fair_hard -o ../notation_viewer/assets/songs/misc/scarborough_fair_hard.ron
78

apps/notation_viewer/assets/songs/misc/scarborough_fair.ron

Lines changed: 96 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,6 +1869,96 @@
18691869
),
18701870
Simple(Quarter),
18711871
)),// [178]
1872+
Mark("|"),// [179]
1873+
Mark("v4:12"),// [180]
1874+
Core(Rest(Simple(Half))),// [181]
1875+
Lyric(Word(
1876+
(
1877+
text: "and",
1878+
),
1879+
Simple(Eighth),
1880+
)),// [182]
1881+
Lyric(Word(
1882+
(
1883+
text: "to-",
1884+
),
1885+
Simple(Quarter),
1886+
)),// [183]
1887+
Mark("|"),// [184]
1888+
Mark("v4:13"),// [185]
1889+
Lyric(Word(
1890+
(
1891+
text: "ga-",
1892+
),
1893+
Simple(Quarter),
1894+
)),// [186]
1895+
Lyric(Word(
1896+
(
1897+
text: "ther",
1898+
),
1899+
Simple(Quarter),
1900+
)),// [187]
1901+
Lyric(Word(
1902+
(
1903+
text: "it",
1904+
),
1905+
Simple(Quarter),
1906+
)),// [188]
1907+
Mark("|"),// [189]
1908+
Mark("v4:14"),// [190]
1909+
Lyric(Word(
1910+
(
1911+
text: "all",
1912+
),
1913+
Simple(Half),
1914+
)),// [191]
1915+
Lyric(Word(
1916+
(
1917+
text: "in",
1918+
),
1919+
Simple(Eighth),
1920+
)),// [192]
1921+
Lyric(Word(
1922+
(
1923+
text: "a",
1924+
),
1925+
Simple(Eighth),
1926+
)),// [193]
1927+
Mark("|"),// [194]
1928+
Mark("v4:15"),// [195]
1929+
Lyric(Word(
1930+
(
1931+
text: "bunch",
1932+
),
1933+
Simple(Half),
1934+
)),// [196]
1935+
Lyric(Word(
1936+
(
1937+
text: "of",
1938+
),
1939+
Simple(Quarter),
1940+
)),// [197]
1941+
Mark("|"),// [198]
1942+
Mark("v4:16"),// [199]
1943+
Lyric(Word(
1944+
(
1945+
text: "hea-",
1946+
),
1947+
Simple(Eighth),
1948+
)),// [200]
1949+
Lyric(Word(
1950+
(
1951+
text: "ther",
1952+
),
1953+
Simple(Eighth),
1954+
)),// [201]
1955+
Core(Tie),// [202]
1956+
Lyric(Word(
1957+
(
1958+
text: "",
1959+
),
1960+
Simple(Half),
1961+
)),// [203]
18721962
Mark("|"),
18731963
],
18741964
),// [2]
@@ -2573,21 +2663,21 @@
25732663
sign: Natural,
25742664
),
25752665
)),
2576-
Simple(Eighth),
2666+
Simple(Quarter),
25772667
)),// [122]
25782668
Core(Tone(
25792669
Single((
2580-
octave: P5,
2670+
octave: P4,
25812671
pitch: (
25822672
name: F,
25832673
sign: Sharp,
25842674
),
25852675
)),
2586-
Simple(Eighth),
2676+
Simple(Quarter),
25872677
)),// [123]
25882678
Core(Tone(
25892679
Single((
2590-
octave: P5,
2680+
octave: P4,
25912681
pitch: (
25922682
name: E,
25932683
sign: Natural,
@@ -2601,8 +2691,8 @@
26012691
Single((
26022692
octave: P4,
26032693
pitch: (
2604-
name: A,
2605-
sign: Natural,
2694+
name: F,
2695+
sign: Sharp,
26062696
),
26072697
)),
26082698
Simple(Eighth),

crates/notation_bevy/src/bar/bar_beat.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bevy::prelude::*;
44
use bevy_prototype_lyon::prelude::*;
55
use bevy_utils::prelude::{FillRectangle, LayoutSize, ShapeOp};
66

7-
use crate::prelude::{BarData, NotationTheme};
7+
use crate::prelude::{BarData, NotationTheme, TabState};
88
use notation_model::prelude::{Signature, TabBar};
99

1010
#[derive(Clone, Debug)]
@@ -13,6 +13,7 @@ pub struct BarBeatValue {
1313
pub bar_beats: u8,
1414
pub beat: u8,
1515
pub bar_size: LayoutSize,
16+
pub selected: bool,
1617
}
1718
impl Display for BarBeatValue {
1819
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -27,19 +28,9 @@ impl BarBeatValue {
2728
bar_beats,
2829
beat,
2930
bar_size: LayoutSize::ZERO,
31+
selected: false,
3032
}
3133
}
32-
pub fn may_new(
33-
theme: &NotationTheme,
34-
tab_bar: &TabBar,
35-
signature: &Signature,
36-
beat: u8,
37-
) -> Option<Self> {
38-
theme
39-
.colors.bar
40-
.get_beat_color(signature, beat)
41-
.map(|_color| Self::new(tab_bar, signature, beat))
42-
}
4334
}
4435

4536
pub type BarBeatData = BarData<BarBeatValue>;
@@ -49,8 +40,7 @@ impl ShapeOp<NotationTheme, FillRectangle> for BarBeatData {
4940
let signature = self.value.signature;
5041
let color = theme
5142
.colors.bar
52-
.get_beat_color(&signature, self.value.beat)
53-
.unwrap_or(theme.core.background_color);
43+
.get_beat_color(&signature, self.value.beat, self.value.selected);
5444
let x = self.value.bar_size.width / self.value.bar_beats as f32
5545
* self.value.beat as f32;
5646
FillRectangle {
@@ -63,4 +53,18 @@ impl ShapeOp<NotationTheme, FillRectangle> for BarBeatData {
6353
),
6454
}
6555
}
56+
}
57+
58+
impl BarBeatData {
59+
pub fn update_all(
60+
commands: &mut Commands,
61+
theme: &NotationTheme,
62+
tab_state: &TabState,
63+
beat_query: &mut Query<(Entity, &mut BarBeatData)>,
64+
) {
65+
for (entity, mut data) in beat_query.iter_mut() {
66+
data.value.selected = tab_state.is_bar_selected(data.bar_props.bar_ordinal);
67+
data.update(commands, theme, entity);
68+
}
69+
}
6670
}

crates/notation_bevy/src/bar/bar_view.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ impl BarView {
110110
);
111111
let signature = bar.signature();
112112
for beat in 0..signature.bar_beats {
113-
BarBeatValue::may_new(theme, bar, &signature, beat)
114-
.map(|value| BarBeatData::new(bar, value))
115-
.map(|data| data.create(commands, theme, bar_entity));
113+
let data = BarBeatData::new(bar, BarBeatValue::new(bar, &signature, beat));
114+
data.create(commands, theme, bar_entity);
116115
}
117116
bar_entity
118117
}

crates/notation_bevy/src/play/play_plugin.rs

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

99
use bevy::prelude::*;
1010

11+
use crate::bar::bar_beat::BarBeatData;
1112
use crate::bar::bar_view::BarView;
1213
use crate::chord::chord_playing::ChordPlaying;
1314
use crate::prelude::{
@@ -287,6 +288,7 @@ fn on_play_control_evt(
287288
&LayoutData,
288289
&Arc<GridData>,
289290
)>,
291+
mut beat_query: Query<(Entity, &mut BarBeatData)>,
290292
) {
291293
for evt in evts.iter() {
292294
for (state_entity, mut tab_state) in tab_state_query.iter_mut() {
@@ -315,7 +317,11 @@ fn on_play_control_evt(
315317
tab_state.set_play_state(&mut commands, state_entity, *play_state);
316318
}
317319
PlayControlEvent::OnSpeedFactor(play_speed) => {
318-
tab_state.set_speed_factor(*play_speed)
320+
tab_state.set_speed_factor(*play_speed);
321+
}
322+
PlayControlEvent::OnBeginEnd(begin_bar_ordinal, end_bar_ordinal) => {
323+
tab_state.set_begin_end(*begin_bar_ordinal, *end_bar_ordinal);
324+
BarBeatData::update_all(&mut commands, &theme, &tab_state, &mut beat_query);
319325
}
320326
}
321327
}

crates/notation_bevy/src/tab/tab_plugin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ fn on_mouse_clicked(
101101
crate::play::play_button::PlayButtonAction::Settings =>
102102
app_state.hide_control = false,
103103
crate::play::play_button::PlayButtonAction::SetBegin =>
104-
midi_state.play_control.begin_bar_ordinal = midi_state.play_control.position.bar.bar_ordinal,
104+
crate::viewer::control::ControlView::set_begin_bar_ordinal(&mut midi_state, &mut play_control_evts),
105105
crate::play::play_button::PlayButtonAction::SetEnd =>
106-
midi_state.play_control.end_bar_ordinal = midi_state.play_control.position.bar.bar_ordinal,
106+
crate::viewer::control::ControlView::set_end_bar_ordinal(&mut midi_state, &mut play_control_evts),
107107
crate::play::play_button::PlayButtonAction::LoopMode =>
108108
midi_state.play_control.should_loop = !midi_state.play_control.should_loop,
109109
}

0 commit comments

Comments
 (0)