Skip to content

Commit dff074a

Browse files
committed
adjust some sizes, improve lyrics display
1 parent 58a2edd commit dff074a

File tree

20 files changed

+195
-173
lines changed

20 files changed

+195
-173
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use bevy::prelude::*;
2+
use notation_bevy_utils::prelude::ColorBackground;
3+
use notation_model::prelude::Chord;
4+
5+
use crate::prelude::NotationTheme;
6+
7+
#[derive(Clone, Debug)]
8+
pub struct ChordColorBackground;
9+
10+
impl ChordColorBackground {
11+
pub fn spawn(commands: &mut Commands, entity: Entity, z: f32, color: Color) -> Entity {
12+
let result = ColorBackground::spawn(
13+
commands,
14+
entity,
15+
z,
16+
color,
17+
);
18+
commands.entity(result).insert(ChordColorBackground);
19+
result
20+
}
21+
pub fn update_color(
22+
commands: &mut Commands,
23+
theme: &NotationTheme,
24+
query: &mut Query<(Entity, &mut ColorBackground), With<ChordColorBackground>>,
25+
chord: Option<Chord>,
26+
) {
27+
let color = theme.colors.of_option_chord(chord);
28+
for (entity, mut background) in query.iter_mut() {
29+
background.update_color(commands, entity, color);
30+
}
31+
}
32+
}

crates/notation_bevy/src/chord/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ pub mod chord_note;
66
pub mod chord_playing;
77
pub mod chord_view;
88
pub mod interval_dot;
9+
pub mod chord_color_background;

crates/notation_bevy/src/guitar/guitar_view.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33
use float_eq::float_ne;
44

55
use bevy::prelude::*;
6-
use notation_bevy_utils::prelude::{BevyUtil, ColorBackground, LayoutAnchor, LayoutChangedQuery, LayoutSize, ShapeOp, View, ViewBundle};
6+
use notation_bevy_utils::prelude::{BevyUtil, LayoutAnchor, LayoutChangedQuery, LayoutSize, ShapeOp, View, ViewBundle};
77
use notation_midi::prelude::MidiState;
88
use notation_model::prelude::{
99
Duration, Entry, HandShape6, Interval, LaneEntry, LaneKind, ModelEntryProps, Pick, Syllable,
@@ -54,12 +54,6 @@ impl GuitarView {
5454
entity,
5555
ViewBundle::from(GuitarView::new(tab.clone(), Syllable::default())),
5656
);
57-
ColorBackground::spawn(
58-
commands,
59-
guitar_entity,
60-
theme.core.mini_map_z,
61-
theme.core.background_color,
62-
);
6357
let sprite_bundle = SpriteBundle {
6458
sprite: Sprite::new(Vec2::new(
6559
theme.guitar.image_size.0,

crates/notation_bevy/src/play/bar_indicator.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ impl ShapeOp<NotationTheme, StrokeRectangle> for BarIndicatorData {
3030
let offset = if self.bar_layout.size.width <= 0.0 {
3131
BevyUtil::offscreen_offset()
3232
} else {
33-
let x = self.bar_layout.offset.x;
33+
let x = self.bar_layout.offset.x - theme.sizes.bar.bar_separator_size;
3434
let y = self.bar_layout.offset.y + theme.sizes.bar.bar_separator_extra;
3535
Vec3::new(x, y, theme.core.bar_indicator_z)
3636
};
3737
let color = theme
3838
.colors
3939
.of_option_chord(self.chord);
4040
StrokeRectangle {
41-
width: self.bar_layout.size.width,
41+
width: self.bar_layout.size.width + theme.sizes.bar.bar_separator_size * 2.0,
4242
height: self.bar_layout.size.height + theme.sizes.bar.bar_separator_extra * 2.0,
4343
origin: shapes::RectangleOrigin::TopLeft,
4444
color, //: theme.colors.bar.bar_indicator,
@@ -74,10 +74,13 @@ impl BarIndicatorData {
7474
bar_indicator_query: &mut Query<(Entity, &mut BarIndicatorData), With<BarIndicatorData>>,
7575
bar_props: TabBarProps,
7676
in_bar_pos: Units,
77-
) {
77+
) -> Option<BarIndicatorData> {
7878
if let Ok((entity, mut data)) = bar_indicator_query.single_mut() {
7979
data.update_chord(bar_props, Some(in_bar_pos));
8080
data.update(commands, theme, entity);
81+
Some(data.clone())
82+
} else {
83+
None
8184
}
8285
}
8386
}

crates/notation_bevy/src/play/play_plugin.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use 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};
44
use notation_midi::prelude::PlayControlEvent;
55
use notation_model::prelude::{
66
LaneEntry, PlayState, PlayingState, Position, Tab, TickResult,
@@ -10,6 +10,7 @@ use bevy::prelude::*;
1010

1111
use crate::bar::bar_beat::BarBeatData;
1212
use crate::bar::bar_view::BarView;
13+
use crate::chord::chord_color_background::ChordColorBackground;
1314
use crate::chord::chord_playing::ChordPlaying;
1415
use 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,

crates/notation_bevy/src/tab/tab_bars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl TabBars {
136136
for lane in bar.lanes.iter() {
137137
let lane_id = lane.id();
138138
if !lane_layouts.contains_key(&lane_id) {
139-
let height = theme.sizes.layout.calc_lane_height(lane.kind);
139+
let height = theme.sizes.calc_lane_height(lane.kind);
140140
let margin = theme.sizes.layout.lane_margin;
141141
lane_layouts.insert(lane_id, LaneLayoutData::new(&lane, height, margin));
142142
}

crates/notation_bevy/src/tab/tab_control.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ use std::sync::Arc;
33

44
use bevy::prelude::*;
55
use notation_bevy_utils::prelude::{BevyUtil, DockPanel, DockSide, DockView, LayoutConstraint, LayoutQuery, LayoutSize, View, ViewBundle, ViewQuery};
6-
use notation_model::prelude::Tab;
6+
use notation_model::prelude::{Tab};
77

8+
use crate::chord::chord_color_background::ChordColorBackground;
89
use crate::play::play_panel::PlayPanel;
910
use crate::prelude::{NotationAppState, NotationAssets, NotationSettings, NotationTheme, GuitarView};
1011
use crate::ui::layout::NotationLayout;
@@ -53,6 +54,12 @@ impl TabControl {
5354
let control = TabControl::new(tab.clone());
5455
let control_entity =
5556
BevyUtil::spawn_child_bundle(commands, entity, ViewBundle::from(control));
57+
ChordColorBackground::spawn(
58+
commands,
59+
control_entity,
60+
theme.core.mini_map_z,
61+
theme.colors.of_syllable(tab.meta.scale.calc_root_syllable()),
62+
);
5663
GuitarView::spawn(commands, materials, assets, theme, control_entity, tab);
5764
PlayPanel::spawn(
5865
commands,

crates/notation_bevy/src/theme/lyrics_theme.rs

Lines changed: 0 additions & 64 deletions
This file was deleted.

crates/notation_bevy/src/theme/melody_theme.rs

Lines changed: 0 additions & 44 deletions
This file was deleted.

crates/notation_bevy/src/theme/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
pub mod core_theme;
22
pub mod guitar_theme;
3-
pub mod lyrics_theme;
4-
pub mod melody_theme;
53
pub mod notation_theme;
64
pub mod shapes_theme;
75
pub mod strings_theme;

0 commit comments

Comments
 (0)