Skip to content

Commit ee01050

Browse files
committed
refs #102, add partial control ui for theme adjustment, also add syllable display for melody lane
1 parent 40594b3 commit ee01050

38 files changed

+373
-181
lines changed

crates/notation_bevy/src/app/app.rs

Lines changed: 2 additions & 1 deletion
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::theme::theme_colors::UiColors;
1011
use crate::{prelude::*, settings::layout_settings::LayoutMode};
1112
use crate::ui::viewer::TabViewerPlugin;
1213
use crate::viewer::control::ControlView;
@@ -51,7 +52,7 @@ impl NotationApp {
5152

5253
app.insert_resource(Msaa { samples: 1 });
5354
app.add_plugins(DefaultPlugins);
54-
app.insert_resource(ClearColor(CoreTheme::default().background_color));
55+
app.insert_resource(ClearColor(UiColors::default().app_background));
5556
app.add_plugin(bevy_easings::EasingsPlugin);
5657

5758
app.init_resource::<NotationTheme>();

crates/notation_bevy/src/bar/bar_beat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl ShapeOp<NotationTheme, FillRectangle> for BarBeatData {
4949
origin: shapes::RectangleOrigin::TopLeft,
5050
color,
5151
offset: Vec3::new(
52-
x, theme.sizes.bar.bar_beat_extra, theme.core.beat_z,
52+
x, theme.sizes.bar.bar_beat_extra, theme.z.beat,
5353
),
5454
}
5555
}

crates/notation_bevy/src/bar/bar_separator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl ShapeOp<NotationTheme, StrokeLine> for BarSeparatorData {
2929
} else {
3030
self.value.bar_size.width
3131
};
32-
Vec3::new(x, 0.0, theme.core.bar_separator_z)
32+
Vec3::new(x, 0.0, theme.z.bar_separator)
3333
};
3434
StrokeLine {
3535
from: Vec2::new(0.0, theme.sizes.bar.bar_separator_extra),

crates/notation_bevy/src/chord/chord_diagram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl ShapeOp<NotationTheme, OutlineCircle> for ChordDiagramData {
4848
color,
4949
outline_width,
5050
outline_color,
51-
offset: Vec3::new(0.0, 0.0, theme.core.mini_bar_z),
51+
offset: Vec3::new(0.0, 0.0, theme.z.mini_bar),
5252
}
5353
}
5454
}

crates/notation_bevy/src/guitar/fret_finger.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl FretFingerData {
5454
ChordNoteValue::<FretFingerExtra>::new(root, interval, extra),
5555
))
5656
}
57-
fn reset(&mut self) {
57+
pub fn reset(&mut self) {
5858
self.value.extra.visible = false;
5959
self.value.extra.capo = 0;
6060
self.value.root = Syllable::Fi;
@@ -180,7 +180,7 @@ impl ChordNoteExtra for FretFingerExtra {
180180
}
181181
}
182182
fn get_z(&self, theme: &NotationTheme) -> f32 {
183-
theme.core.mini_bar_z + 3.0
183+
theme.z.chord_note
184184
}
185185
fn show_dots(&self) -> bool {
186186
self.in_chord

crates/notation_bevy/src/guitar/guitar_capo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl ShapeOp<NotationTheme, FillRectangle> for GuitarCapoData {
3636
.calc_fret_y(self.capo, self.guitar_size.height)
3737
+ height * 0.5
3838
- finger_radius;
39-
Vec3::new(0.0, y, theme.core.mini_bar_z + 2.0)
39+
Vec3::new(0.0, y, theme.z.guitar_capo)
4040
};
4141
FillRectangle {
4242
width,

crates/notation_bevy/src/guitar/guitar_string.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ pub struct GuitarStringData {
2626
}
2727

2828
impl GuitarStringData {
29-
pub fn new(string: u8, upper: bool) -> Self {
29+
pub fn new(string: u8, upper: bool, fretboard: Option<Fretboard6>) -> Self {
30+
let capo = fretboard.map(|x| x.capo).unwrap_or(0);
3031
Self {
3132
string,
3233
upper,
33-
fret: None,
34+
fret: Some(0),
3435
pick_fret: None,
35-
capo: 0,
36+
capo,
3637
note: None,
3738
state: PlayingState::Idle,
3839
hit: false,
@@ -42,6 +43,12 @@ impl GuitarStringData {
4243
guitar_size: LayoutSize::ZERO,
4344
}
4445
}
46+
pub fn reset(&mut self) {
47+
self.fret = Some(0);
48+
self.note = None;
49+
self.state = PlayingState::Idle;
50+
self.hit = false;
51+
}
4552
fn is_muted(&self) -> bool {
4653
self.pick_fret.is_none() && self.fret.is_none()
4754
}
@@ -179,7 +186,7 @@ impl ShapeOp<NotationTheme, OutlineRectangle> for GuitarStringData {
179186
self.fret() + self.capo,
180187
self.guitar_size.height,
181188
);
182-
let offset = Vec3::new(x - width / 2.0, fret_y, theme.core.mini_bar_z + 1.0);
189+
let offset = Vec3::new(x - width / 2.0, fret_y, theme.z.guitar_string);
183190
OutlineRectangle {
184191
width,
185192
height,

crates/notation_bevy/src/guitar/guitar_view.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use notation_bevy_utils::prelude::{BevyUtil, LayoutAnchor, LayoutChangedQuery, L
77
use notation_midi::prelude::MidiState;
88
use notation_model::prelude::{
99
Duration, Entry, HandShape6, Interval, LaneEntry, LaneKind, ModelEntryProps, Pick, Syllable,
10-
Tab, Units,
10+
Tab, Units, TrackKind,
1111
};
1212

13-
use crate::prelude::{EntryPlaying, NotationAssets, NotationTheme, NotationSettings};
13+
use crate::prelude::{EntryPlaying, NotationAssets, NotationTheme, NotationSettings, TabState};
1414
use crate::ui::layout::NotationLayout;
1515

1616
use super::fret_finger::{FretFingerData};
@@ -63,10 +63,14 @@ impl GuitarView {
6363
material: materials.add(assets.fretboard.clone().into()),
6464
..Default::default()
6565
};
66+
let fretboard = tab
67+
.get_track_of_kind(TrackKind::Guitar)
68+
.and_then(|x| x.get_fretboard6());
69+
6670
BevyUtil::spawn_child_bundle(commands, guitar_entity, sprite_bundle);
6771
for string in 1..=6 {
6872
for upper in [true, false] {
69-
let string_data = GuitarStringData::new(string as u8, upper);
73+
let string_data = GuitarStringData::new(string as u8, upper, fretboard);
7074
string_data.create(
7175
commands,
7276
theme,
@@ -80,7 +84,7 @@ impl GuitarView {
8084
let mut string = 1;
8185
let mut fret = 0;
8286
for _index in 0..=22 {
83-
let finger_data = FretFingerData::new_data(
87+
let mut finger_data = FretFingerData::new_data(
8488
ModelEntryProps {
8589
index: 0,
8690
tied_units: Units(0.0),
@@ -92,6 +96,7 @@ impl GuitarView {
9296
Some(fret as u8),
9397
None,
9498
);
99+
finger_data.value.extra.visible = true;
95100
finger_data.spawn(commands, theme, guitar_entity);
96101
string = string + 1;
97102
if string > 6 {
@@ -135,7 +140,7 @@ impl GuitarView {
135140
for (parent, mut transform) in sprite_query.iter_mut() {
136141
if parent.0 == entity {
137142
let scale = layout.size.width / theme.guitar.image_size.0;
138-
transform.translation = Vec3::new(0.0, 0.0, theme.core.mini_bar_z);
143+
transform.translation = Vec3::new(0.0, 0.0, theme.z.guitar_view);
139144
transform.scale = Vec3::new(scale, scale, 1.0);
140145
}
141146
}
@@ -170,6 +175,9 @@ impl GuitarView {
170175
mut finger_query: Query<(Entity, &mut FretFingerData), With<FretFingerData>>,
171176
dot_query: Query<&Children>,
172177
) {
178+
if Self::CHECKING_FRETS {
179+
return;
180+
}
173181
let mut current_entry_pick = None;
174182
let mut string_states = [None; 6];
175183
let mut hit_strings = [(false, Duration::Zero); 6];
@@ -196,7 +204,7 @@ impl GuitarView {
196204
hit,
197205
hit_duration,
198206
&time,
199-
theme.strings.hit_string_seconds_range,
207+
theme.guitar.hit_string_seconds_range,
200208
midi_state.play_control.play_speed,
201209
);
202210
if let Some(state) = string_states[(string_data.string - 1) as usize] {
@@ -234,6 +242,7 @@ impl GuitarView {
234242
mut string_query: Query<(Entity, &mut GuitarStringData), With<GuitarStringData>>,
235243
mut capo_query: Query<(Entity, &mut GuitarCapoData), With<GuitarCapoData>>,
236244
dot_query: Query<&Children>,
245+
tab_state_query: Query<(Entity, &TabState), With<TabState>>,
237246
) {
238247
if Self::CHECKING_FRETS {
239248
return;
@@ -284,6 +293,19 @@ impl GuitarView {
284293
}
285294
}
286295
}
296+
} else {
297+
let position =
298+
TabState::get_position(&tab_state_query, None);
299+
if position.is_some() && position.unwrap().bar.bar_ordinal == 0 {
300+
for (finger_entity, mut finger_data) in finger_query.iter_mut() {
301+
finger_data.reset();
302+
finger_data.update(&mut commands, &theme, finger_entity);
303+
}
304+
for (string_entity, mut string_data) in string_query.iter_mut() {
305+
string_data.reset();
306+
string_data.update(&mut commands, &theme, string_entity);
307+
}
308+
}
287309
}
288310
}
289311
pub fn update_y(

crates/notation_bevy/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,12 @@ pub mod prelude {
115115
#[doc(hidden)]
116116
pub use crate::tab::tab_state::TabState;
117117
#[doc(hidden)]
118-
pub use crate::theme::core_theme::CoreTheme;
118+
pub use crate::theme::theme_z::ThemeZ;
119119
#[doc(hidden)]
120120
pub use crate::theme::guitar_theme::GuitarTheme;
121121
#[doc(hidden)]
122122
pub use crate::theme::notation_theme::NotationTheme;
123123
#[doc(hidden)]
124-
pub use crate::theme::strings_theme::StringsTheme;
125-
#[doc(hidden)]
126124
pub use crate::theme::theme_colors::ThemeColors;
127125
#[doc(hidden)]
128126
pub use crate::tone::tone_bundle::ToneBundle;

crates/notation_bevy/src/mini/mini_bar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl ShapeOp<NotationTheme, OutlineRectangle> for MiniBarData {
6464
} else {
6565
theme.colors.of_section(self.bar_props.section_ordinal)
6666
};
67-
let mut z = theme.core.mini_bar_z;
67+
let mut z = theme.z.mini_bar;
6868
if self.value.playing_state.is_current() {
6969
z += 1.0;
7070
}

0 commit comments

Comments
 (0)