Add dialog box to change current BPM

This commit is contained in:
Stepland 2023-07-09 23:38:55 +02:00
parent 03eb055464
commit 6a3f941d95
3 changed files with 27 additions and 0 deletions

View File

@ -1278,6 +1278,24 @@ void EditorState::display_sync_menu() {
ImGui::End(); ImGui::End();
} }
void EditorState::display_bpm_change_menu() {
if (ImGui::Begin("Insert BPM Change", &show_bpm_change_menu)) {
auto bpm = std::visit(
[&](const auto& pos){return applicable_timing->bpm_at(pos);},
playback_position
);
ImGui::PushItemWidth(-70.0f);
if (feis::InputDecimal("BPM", &bpm, ImGuiInputTextFlags_EnterReturnsTrue)) {
if (bpm > 0) {
auto new_timing = *applicable_timing;
new_timing.insert(better::BPMAtBeat{bpm, current_snaped_beats()});
replace_applicable_timing_with(new_timing);
}
}
}
ImGui::End();
}
bool EditorState::needs_to_save() const { bool EditorState::needs_to_save() const {
return not history.current_state_is_saved(); return not history.current_state_is_saved();
}; };

View File

@ -179,6 +179,9 @@ public:
bool show_sync_menu = false; bool show_sync_menu = false;
void display_sync_menu(); void display_sync_menu();
bool show_bpm_change_menu = false;
void display_bpm_change_menu();
enum class SaveOutcome { enum class SaveOutcome {
UserSaved, UserSaved,
UserDeclindedSaving, UserDeclindedSaving,

View File

@ -519,6 +519,9 @@ int main() {
if (editor_state->show_sync_menu) { if (editor_state->show_sync_menu) {
editor_state->display_sync_menu(); editor_state->display_sync_menu();
} }
if (editor_state->show_bpm_change_menu) {
editor_state->display_bpm_change_menu();
}
} else { } else {
bg.render(window); bg.render(window);
} }
@ -644,6 +647,9 @@ int main() {
if (ImGui::MenuItem("Adjust Sync")) { if (ImGui::MenuItem("Adjust Sync")) {
editor_state->show_sync_menu = true; editor_state->show_sync_menu = true;
} }
if (ImGui::MenuItem("Insert BPM Change")) {
editor_state->show_bpm_change_menu = true;
}
ImGui::EndMenu(); ImGui::EndMenu();
} }
if (ImGui::BeginMenu("Notes", editor_state.has_value())) { if (ImGui::BeginMenu("Notes", editor_state.has_value())) {