Skip to content

Commit

Permalink
Fix failure to reactivate the Save Alignment button when the alignmen…
Browse files Browse the repository at this point in the history
…t was edited by user. This also makes dynamic recalculation of the tempo curve while editing work.
  • Loading branch information
cannam committed Dec 13, 2023
1 parent 7f7f3e7 commit dbf3b1d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
11 changes: 11 additions & 0 deletions main/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ MainWindow::MainWindow(AudioMode audioMode, MIDIMode midiMode, bool withOSCSuppo

connect(&m_session, SIGNAL(alignmentReadyForReview()),
this, SLOT(alignmentReadyForReview()));
connect(&m_session, SIGNAL(alignmentModified()),
this, SLOT(alignmentModified()));
connect(&m_session, SIGNAL(alignmentAccepted()),
this, SLOT(alignmentAccepted()));
connect(&m_session, SIGNAL(alignmentRejected()),
Expand Down Expand Up @@ -2746,6 +2748,15 @@ MainWindow::alignmentReadyForReview()
updateMenuStates();
}

void
MainWindow::alignmentModified()
{
SVDEBUG << "MainWindow::alignmentModified" << endl;

m_scoreAlignmentModified = true;
updateMenuStates();
}

void
MainWindow::alignmentAccepted()
{
Expand Down
1 change: 1 addition & 0 deletions main/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ protected slots:
void actOnScorePosition(int, ScoreWidget::InteractionMode, bool activated);
void scoreInteractionEnded(ScoreWidget::InteractionMode);
void alignmentReadyForReview();
void alignmentModified();
void alignmentAccepted();
void alignmentRejected();
void alignmentFrameIlluminated(sv_frame_t);
Expand Down
23 changes: 23 additions & 0 deletions main/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ Session::modelReady(ModelId id)
}
}

void
Session::modelChanged(ModelId id)
{
SVDEBUG << "Session::modelChanged: model is " << id << endl;

if (m_displayedOnsetsLayer && id == m_displayedOnsetsLayer->getModel()) {
recalculateTempoLayer();
emit alignmentModified();
}
}

void
Session::alignmentComplete()
{
Expand Down Expand Up @@ -376,6 +387,9 @@ Session::acceptAlignment()
recalculateTempoLayer();

emit alignmentAccepted();

connect(ModelById::get(m_displayedOnsetsLayer->getModel()).get(),
SIGNAL(modelChanged(ModelId)), this, SLOT(modelChanged(ModelId)));
}

void
Expand Down Expand Up @@ -503,11 +517,14 @@ Session::importAlignmentFrom(QString path)
return false;
}

bool existingModelIsNew = false;

if (!m_displayedOnsetsLayer) {
m_displayedOnsetsLayer = dynamic_cast<TimeValueLayer *>
(m_document->createEmptyLayer(LayerFactory::TimeValues));
m_document->addLayerToView(m_topPane, m_displayedOnsetsLayer);
setOnsetsLayerProperties(m_displayedOnsetsLayer);
existingModelIsNew = true;
}

auto existingModel = ModelById::getAs<SparseTimeValueModel>
Expand All @@ -518,6 +535,9 @@ Session::importAlignmentFrom(QString path)
return false;
}

disconnect(existingModel.get(), SIGNAL(modelChanged(ModelId)),
this, nullptr);

EventVector oldEvents = existingModel->getAllEvents();
EventVector newEvents = stvm->getAllEvents();

Expand All @@ -533,6 +553,9 @@ Session::importAlignmentFrom(QString path)
recalculateTempoLayer();
emit alignmentAccepted();

connect(existingModel.get(), SIGNAL(modelChanged(ModelId)),
this, SLOT(modelChanged(ModelId)));

return true;
}

Expand Down
2 changes: 2 additions & 0 deletions main/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ public slots:
void alignmentReadyForReview();
void alignmentAccepted();
void alignmentRejected();
void alignmentModified();
void alignmentFrameIlluminated(sv_frame_t);

protected slots:
void modelChanged(ModelId);
void modelReady(ModelId);

private:
Expand Down
2 changes: 1 addition & 1 deletion repoint-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"pin": "7df85ecf98d9477c1ac5a36f51807062e00d8695"
},
"svcore": {
"pin": "1706fe073070cbfcd2459a0cfd2b738997dcf85a"
"pin": "719a0fbfc193a67c630ffd5ea3949faac079ade6"
},
"svgui": {
"pin": "ef0e579917c0c9aed151df7cae3506130ea55a05"
Expand Down

0 comments on commit dbf3b1d

Please sign in to comment.