@@ -7,10 +7,10 @@ use notation_bevy_utils::prelude::{BevyUtil, LayoutAnchor, LayoutChangedQuery, L
77use notation_midi:: prelude:: MidiState ;
88use 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 } ;
1414use crate :: ui:: layout:: NotationLayout ;
1515
1616use 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 (
0 commit comments