Skip to content

Commit

Permalink
Implement the new editing style for alterations of pace.
Browse files Browse the repository at this point in the history
This is similar to the changes in 56e5ba8 for tempo markers.

Bug: #23, #192, #220
  • Loading branch information
cameronwhite committed Jan 17, 2021
1 parent 78013d9 commit 1dd0cfa
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 17 deletions.
44 changes: 31 additions & 13 deletions source/app/powertabeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,10 @@ void PowerTabEditor::removeSelectedItem()
editTempoMarker(/* remove */ true);
break;

case ScoreItem::AlterationOfPace:
editAlterationOfPace(/* remove */ true);
break;

case ScoreItem::RehearsalSign:
editRehearsalSign(/* remove */ true);
break;
Expand Down Expand Up @@ -1335,33 +1339,43 @@ void PowerTabEditor::editTempoMarker(bool remove)
myTempoMarkerCommand->setChecked(false);
}

void PowerTabEditor::editAlterationOfPace()
void PowerTabEditor::editAlterationOfPace(bool remove)
{
const ScoreLocation &location = getLocation();
const TempoMarker *marker = ScoreUtils::findByPosition(
location.getSystem().getTempoMarkers(), location.getPositionIndex());

if (marker)
if (remove)
{
Q_ASSERT(marker);
Q_ASSERT(marker->getMarkerType() == TempoMarker::AlterationOfPace);
myUndoManager->push(new RemoveTempoMarker(location),
location.getSystemIndex());
return;
}
else

AlterationOfPaceDialog dialog(this, marker);
if (dialog.exec() == QDialog::Accepted)
{
AlterationOfPaceDialog dialog(this);
if (dialog.exec() == QDialog::Accepted)
{
TempoMarker marker(location.getPositionIndex());
marker.setMarkerType(TempoMarker::AlterationOfPace);
marker.setAlterationOfPace(dialog.getAlterationOfPaceType());
TempoMarker new_marker(location.getPositionIndex());
new_marker.setMarkerType(TempoMarker::AlterationOfPace);
new_marker.setAlterationOfPace(dialog.getAlterationOfPaceType());

myUndoManager->push(new AddTempoMarker(location, marker),
if (marker)
{
myUndoManager->beginMacro(tr("Edit Alteration of Pace"));
myUndoManager->push(new RemoveTempoMarker(location),
location.getSystemIndex());
}
else
myAlterationOfPaceCommand->setChecked(false);

myUndoManager->push(new AddTempoMarker(location, new_marker),
location.getSystemIndex());

if (marker)
myUndoManager->endMacro();
}
else
myAlterationOfPaceCommand->setChecked(false);
}

void PowerTabEditor::insertStandardBarline()
Expand Down Expand Up @@ -2508,7 +2522,7 @@ void PowerTabEditor::createCommands()
"MusicSymbols.AlterationOfPace", QKeySequence(), this);
myAlterationOfPaceCommand->setCheckable(true);
connect(myAlterationOfPaceCommand, &QAction::triggered, this,
&PowerTabEditor::editAlterationOfPace);
[=]() { editAlterationOfPace(); });

myKeySignatureCommand = new Command(tr("Edit Key Signature..."),
"MusicSymbols.EditKeySignature",
Expand Down Expand Up @@ -3375,6 +3389,9 @@ void PowerTabEditor::setupNewTab()
case ScoreItem::TempoMarker:
editTempoMarker();
break;
case ScoreItem::AlterationOfPace:
editAlterationOfPace();
break;
case ScoreItem::RehearsalSign:
editRehearsalSign();
break;
Expand Down Expand Up @@ -3476,6 +3493,7 @@ canDeleteItem(ScoreItem item)
{
switch (item)
{
case ScoreItem::AlterationOfPace:
case ScoreItem::AlternateEnding:
case ScoreItem::PlayerChange:
case ScoreItem::RehearsalSign:
Expand Down
2 changes: 1 addition & 1 deletion source/app/powertabeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private slots:
/// Adds or removes a tempo marker at the current position.
void editTempoMarker(bool remove = false);
/// Adds or removes an accel/rit symbol at the current position.
void editAlterationOfPace();
void editAlterationOfPace(bool remove = false);
/// Edits the key signature at the caret's current location.
void editKeySignature();
/// Edits the time signature at the caret's current location.
Expand Down
10 changes: 9 additions & 1 deletion source/dialogs/alterationofpacedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include "alterationofpacedialog.h"
#include "ui_alterationofpacedialog.h"

AlterationOfPaceDialog::AlterationOfPaceDialog(QWidget *parent)
AlterationOfPaceDialog::AlterationOfPaceDialog(
QWidget *parent, const TempoMarker *current_marker)
: QDialog(parent), ui(new Ui::AlterationOfPaceDialog)
{
ui->setupUi(this);
Expand All @@ -30,6 +31,13 @@ AlterationOfPaceDialog::AlterationOfPaceDialog(QWidget *parent)
TempoMarker::Accelerando);
ui->typeComboBox->addItem(QStringLiteral("Ritardando (rit.)"),
TempoMarker::Ritardando);

if (current_marker)
{
ui->typeComboBox->setCurrentIndex(
current_marker->getAlterationOfPace() == TempoMarker::Ritardando
? 1 : 0);
}
}

AlterationOfPaceDialog::~AlterationOfPaceDialog()
Expand Down
3 changes: 2 additions & 1 deletion source/dialogs/alterationofpacedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class AlterationOfPaceDialog : public QDialog
Q_OBJECT

public:
explicit AlterationOfPaceDialog(QWidget *parent);
explicit AlterationOfPaceDialog(QWidget *parent,
const TempoMarker *current_marker);
~AlterationOfPaceDialog();

TempoMarker::AlterationOfPaceType getAlterationOfPaceType() const;
Expand Down
1 change: 1 addition & 0 deletions source/painters/scoreclickevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ConstScoreLocation;
/// Item types that can be clicked.
enum class ScoreItem
{
AlterationOfPace,
AlternateEnding,
Barline,
Clef,
Expand Down
4 changes: 3 additions & 1 deletion source/painters/systemrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,9 @@ SystemRenderer::drawTempoMarkers(const ConstScoreLocation &location,
auto group = new ClickableGroup(
QObject::tr("Double-click to edit tempo marker."),
myScoreArea->getClickEvent(), marker_location,
ScoreItem::TempoMarker);
tempo.getMarkerType() == TempoMarker::AlterationOfPace
? ScoreItem::AlterationOfPace
: ScoreItem::TempoMarker);

QFont font = myPlainTextFont;
if (tempo.getMarkerType() == TempoMarker::AlterationOfPace)
Expand Down

0 comments on commit 1dd0cfa

Please sign in to comment.