Skip to content

Commit af135d1

Browse files
committed
refs #99, tweak some bugs related to added first empty bar
1 parent e1bbc40 commit af135d1

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

crates/notation_bevy/src/play/play_button.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl PlayButtonShape {
110110
PlayButtonAction::SetBegin |
111111
PlayButtonAction::SetEnd |
112112
PlayButtonAction::Clear =>
113-
theme.colors.ui.of_button(self.begin_bar_ordinal != 0 || self.end_bar_ordinal != self.bars),
113+
theme.colors.ui.of_button(self.begin_bar_ordinal != 0 || self.end_bar_ordinal + 1 != self.bars),
114114
}
115115
}
116116
}
@@ -164,7 +164,7 @@ impl PlayButton {
164164
should_loop: settings.should_loop,
165165
bars: tab.bars.len(),
166166
begin_bar_ordinal: 0,
167-
end_bar_ordinal: tab.bars.len(),
167+
end_bar_ordinal: if tab.bars.len() > 0 { tab.bars.len() - 1 } else { 0 },
168168
};
169169
button_shape.create(commands, theme, button_entity);
170170
button_entity

crates/notation_bevy/src/tab/tab_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl TabState {
6060
self.play_control.is_bar_in_range(bar_ordinal)
6161
}
6262
pub fn is_bar_selected(&self, bar_ordinal: usize) -> bool {
63-
if self.play_control.begin_bar_ordinal != 0 || self.play_control.end_bar_ordinal != self.tab.bars.len() {
63+
if self.play_control.begin_bar_ordinal != 0 || self.play_control.end_bar_ordinal + 1 != self.tab.bars.len() {
6464
self.play_control.is_bar_in_range(bar_ordinal)
6565
} else {
6666
false

crates/notation_bevy/src/viewer/control.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ impl ControlView {
179179
midi_state: &mut MidiState,
180180
play_control_evts: &mut EventWriter<PlayControlEvent>,
181181
) {
182-
midi_state.play_control.begin_bar_ordinal = 1;
183-
midi_state.play_control.end_bar_ordinal = midi_state.play_control.bars;
182+
midi_state.play_control.begin_bar_ordinal = 0;
183+
midi_state.play_control.end_bar_ordinal = midi_state.play_control.get_last_car_ordinal();
184184
Self::send_begin_end_evt(midi_state, play_control_evts);
185185
}
186186
pub fn set_begin_bar_ordinal(

crates/notation_model/src/play/play_control.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ impl PlayControl {
9090
play_speed: PlaySpeed::new(tab_meta),
9191
}
9292
}
93+
pub fn get_last_car_ordinal(&self) -> usize {
94+
if self.bars > 0 { self.bars - 1 } else { 0 }
95+
}
9396
pub fn new(tab: &Tab) -> Self {
9497
Self::_new(&tab.meta, tab.bars.len())
9598
}

0 commit comments

Comments
 (0)