11use std:: sync:: Arc ;
22
3- use notation_bevy_utils:: prelude:: { DoLayoutEvent , GridData , LayoutData , ShapeOp } ;
3+ use notation_bevy_utils:: prelude:: { DoLayoutEvent , GridData , LayoutData , ShapeOp , ColorBackground } ;
44use notation_midi:: prelude:: PlayControlEvent ;
55use notation_model:: prelude:: {
66 LaneEntry , PlayState , PlayingState , Position , Tab , TickResult ,
@@ -10,6 +10,7 @@ use bevy::prelude::*;
1010
1111use crate :: bar:: bar_beat:: BarBeatData ;
1212use crate :: bar:: bar_view:: BarView ;
13+ use crate :: chord:: chord_color_background:: ChordColorBackground ;
1314use crate :: chord:: chord_playing:: ChordPlaying ;
1415use crate :: prelude:: {
1516 BarPlaying , EntryPlaying , NotationAssetsStates , NotationSettings , NotationTheme ,
@@ -64,6 +65,7 @@ fn update_indicators(
6465 commands : & mut Commands ,
6566 theme : & NotationTheme ,
6667 settings : & mut NotationSettings ,
68+ chord_color_background_query : & mut Query < ( Entity , & mut ColorBackground ) , With < ChordColorBackground > > ,
6769 bar_indicator_query : & mut Query < ( Entity , & mut BarIndicatorData ) , With < BarIndicatorData > > ,
6870 pos_indicator_query : & mut Query < ( Entity , & mut PosIndicatorData ) , With < PosIndicatorData > > ,
6971 tab_bars_query : & mut Query < (
@@ -91,6 +93,7 @@ fn update_indicators(
9193 data. bar_props = bar_props;
9294 data. bar_layout = bar_layout;
9395 data. update_data ( commands, theme, entity, bar_props, bar_layout, in_bar_pos) ;
96+ ChordColorBackground :: update_color ( commands, theme, chord_color_background_query, data. chord ) ;
9497 }
9598}
9699
@@ -100,6 +103,7 @@ fn on_tab_resized(
100103 theme : Res < NotationTheme > ,
101104 mut settings : ResMut < NotationSettings > ,
102105 mut query : Query < ( Entity , & BarPlaying , & Arc < BarView > , & LayoutData ) > ,
106+ mut chord_color_background_query : Query < ( Entity , & mut ColorBackground ) , With < ChordColorBackground > > ,
103107 mut bar_indicator_query : Query < ( Entity , & mut BarIndicatorData ) , With < BarIndicatorData > > ,
104108 mut pos_indicator_query : Query < ( Entity , & mut PosIndicatorData ) , With < PosIndicatorData > > ,
105109 mut tab_bars_query : Query < (
@@ -136,6 +140,7 @@ fn on_tab_resized(
136140 & mut commands,
137141 & theme,
138142 & mut settings,
143+ & mut chord_color_background_query,
139144 & mut bar_indicator_query,
140145 & mut pos_indicator_query,
141146 & mut tab_bars_query,
@@ -151,6 +156,7 @@ fn on_bar_playing_changed(
151156 theme : Res < NotationTheme > ,
152157 mut settings : ResMut < NotationSettings > ,
153158 mut query : Query < ( Entity , & BarPlaying , & Arc < BarView > , & LayoutData ) , Changed < BarPlaying > > ,
159+ mut chord_color_background_query : Query < ( Entity , & mut ColorBackground ) , With < ChordColorBackground > > ,
154160 mut bar_indicator_query : Query < ( Entity , & mut BarIndicatorData ) , With < BarIndicatorData > > ,
155161 mut pos_indicator_query : Query < ( Entity , & mut PosIndicatorData ) , With < PosIndicatorData > > ,
156162 mut tab_bars_query : Query < (
@@ -167,6 +173,7 @@ fn on_bar_playing_changed(
167173 & mut commands,
168174 & theme,
169175 & mut settings,
176+ & mut chord_color_background_query,
170177 & mut bar_indicator_query,
171178 & mut pos_indicator_query,
172179 & mut tab_bars_query,
@@ -221,6 +228,7 @@ fn on_tick(
221228 commands : & mut Commands ,
222229 theme : & NotationTheme ,
223230 settings : & mut NotationSettings ,
231+ chord_color_background_query : & mut Query < ( Entity , & mut ColorBackground ) , With < ChordColorBackground > > ,
224232 bar_indicator_query : & mut Query < ( Entity , & mut BarIndicatorData ) , With < BarIndicatorData > > ,
225233 pos_indicator_query : & mut Query < ( Entity , & mut PosIndicatorData ) , With < PosIndicatorData > > ,
226234 bar_playing_query : & mut Query < ( Entity , & mut BarPlaying ) , With < BarPlaying > > ,
@@ -270,7 +278,9 @@ fn on_tick(
270278 . focus_bar ( commands, theme, tab_bars_query, & pos_data) ;
271279 }
272280 if chord_changed > 0 {
273- BarIndicatorData :: update_pos ( commands, theme, bar_indicator_query, pos_data. bar_props , pos_data. bar_position . in_bar_pos ) ;
281+ if let Some ( bar_data) = BarIndicatorData :: update_pos ( commands, theme, bar_indicator_query, pos_data. bar_props , pos_data. bar_position . in_bar_pos ) {
282+ ChordColorBackground :: update_color ( commands, theme, chord_color_background_query, bar_data. chord ) ;
283+ }
274284 }
275285 }
276286 }
@@ -282,6 +292,7 @@ fn on_play_control_evt(
282292 mut settings : ResMut < NotationSettings > ,
283293 mut evts : EventReader < PlayControlEvent > ,
284294 mut tab_state_query : Query < ( Entity , & mut TabState ) > ,
295+ mut chord_color_background_query : Query < ( Entity , & mut ColorBackground ) , With < ChordColorBackground > > ,
285296 mut bar_indicator_query : Query < ( Entity , & mut BarIndicatorData ) , With < BarIndicatorData > > ,
286297 mut pos_indicator_query : Query < ( Entity , & mut PosIndicatorData ) , With < PosIndicatorData > > ,
287298 mut bar_playing_query : Query < ( Entity , & mut BarPlaying ) , With < BarPlaying > > ,
@@ -312,6 +323,7 @@ fn on_play_control_evt(
312323 & mut commands,
313324 & theme,
314325 & mut settings,
326+ & mut chord_color_background_query,
315327 & mut bar_indicator_query,
316328 & mut pos_indicator_query,
317329 & mut bar_playing_query,
0 commit comments