Skip to content

Commit

Permalink
Initial work on resurrecting the shift string command.
Browse files Browse the repository at this point in the history
This doesn't do much at the moment, and is mostly getting code compiling again.

- Renamed the Shift Forward / Backward commands to Insert / Remove Space, to hopefully reduce confusion with string shifting (and potential future commands for shifting notes up / down by a semitone)
- Name this command as Shift String Up/Down

#20
  • Loading branch information
cameronwhite committed Jun 22, 2020
1 parent f6478ba commit df80803
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 239 deletions.
2 changes: 2 additions & 0 deletions source/actions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ set( srcs
removetempomarker.cpp
removetextitem.cpp
shiftpositions.cpp
shiftstring.cpp
undomanager.cpp
)

Expand Down Expand Up @@ -111,6 +112,7 @@ set( headers
removetempomarker.h
removetextitem.h
shiftpositions.h
shiftstring.h
undomanager.h
)

Expand Down
39 changes: 39 additions & 0 deletions source/actions/shiftstring.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2020 Cameron White
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "shiftstring.h"

ShiftString::ShiftString(const ScoreLocation &location, bool shift_up)
: QUndoCommand(shift_up ? QObject::tr("Shift String Up")
: QObject::tr("Shift String Down")),
myLocation(location),
myShiftUp(shift_up)
{
// TODO - copy original positions.
}

void
ShiftString::redo()
{
// TODO
}

void
ShiftString::undo()
{
// TODO
}
41 changes: 41 additions & 0 deletions source/actions/shiftstring.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2020 Cameron White
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ACTIONS_SHIFTTABNUMBER_H
#define ACTIONS_SHIFTTABNUMBER_H

#include <QUndoCommand>
#include <score/position.h>
#include <score/scorelocation.h>
#include <vector>

/// Shift tab numbers to an adjacent string.
class ShiftString : public QUndoCommand
{
public:
ShiftString(const ScoreLocation &location, bool shift_up);

void undo() final;
void redo() final;

private:
ScoreLocation myLocation;
std::vector<Position> myOriginalPositions;
const bool myShiftUp;
};

#endif
74 changes: 0 additions & 74 deletions source/actions/shifttabnumber.cpp

This file was deleted.

55 changes: 0 additions & 55 deletions source/actions/shifttabnumber.h

This file was deleted.

95 changes: 49 additions & 46 deletions source/app/powertabeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1965,17 +1965,16 @@ void PowerTabEditor::createCommands()
connect(myLastSectionCommand, &QAction::triggered, this,
&PowerTabEditor::moveCaretToLastSection);

myShiftForwardCommand = new Command(tr("Shift Forward"),
"Position.ShiftForward",
QKeySequence(Qt::Key_Insert), this);
connect(myShiftForwardCommand, &QAction::triggered, this,
myInsertSpaceCommand =
new Command(tr("Insert Space"), "Position.InsertSpace",
QKeySequence(Qt::Key_Insert), this);
connect(myInsertSpaceCommand, &QAction::triggered, this,
&PowerTabEditor::shiftForward);

myShiftBackwardCommand = new Command(tr("Shift Backward"),
"Position.ShiftBackward",
QKeySequence(Qt::SHIFT + Qt::Key_Insert),
this);
connect(myShiftBackwardCommand, &QAction::triggered, this,
myRemoveSpaceCommand =
new Command(tr("Remove Space"), "Position.RemoveSpace",
QKeySequence(Qt::SHIFT + Qt::Key_Insert), this);
connect(myRemoveSpaceCommand, &QAction::triggered, this,
&PowerTabEditor::shiftBackward);

// Position-related actions.
Expand Down Expand Up @@ -2046,18 +2045,7 @@ void PowerTabEditor::createCommands()
Qt::SHIFT + Qt::Key_Tab, this);
connect(myPrevBarCommand, &QAction::triggered, this,
&PowerTabEditor::moveCaretToPrevBar);
#if 0
// Actions for shifting tab numbers up/down a string
shiftTabNumUp = new Command(tr("Shift Tab Number Up"), "Position.ShiftTabNumberUp",
Qt::CTRL + Qt::Key_Up, this);
sigfwd::connect(shiftTabNumUp, SIGNAL(triggered()),
boost::bind(&PowerTabEditor::shiftTabNumber, this, Position::SHIFT_UP));

shiftTabNumDown = new Command(tr("Shift Tab Number Down"), "Position.ShiftTabNumberDown",
Qt::CTRL + Qt::Key_Down, this);
sigfwd::connect(shiftTabNumDown, SIGNAL(triggered()),
boost::bind(&PowerTabEditor::shiftTabNumber, this, Position::SHIFT_DOWN));
#endif

myRemoveNoteCommand = new Command(tr("Remove Note"), "Position.RemoveNote",
QKeySequence::Delete, this);
connect(myRemoveNoteCommand, &QAction::triggered, this, &PowerTabEditor::removeCurrentPosition);
Expand Down Expand Up @@ -2220,6 +2208,18 @@ void PowerTabEditor::createCommands()
connect(myLeftHandFingeringCommand, &QAction::triggered, this,
&PowerTabEditor::editLeftHandFingering);

myShiftStringUpCommand =
new Command(tr("Shift String Up"), "Notes.ShiftStringUp",
Qt::CTRL + Qt::Key_Up, this);
connect(myShiftStringUpCommand, &QAction::triggered, this,
[=]() { shiftString(true); });

myShiftStringDownCommand =
new Command(tr("Shift String Down"), "Notes.ShiftStringDown",
Qt::CTRL + Qt::Key_Down, this);
connect(myShiftStringDownCommand, &QAction::triggered, this,
[=]() { shiftString(false); });

myTieCommand = new Command(tr("Tied"), "Notes.Tied", Qt::Key_Y, this);
myTieCommand->setCheckable(true);
connect(myTieCommand, &QAction::triggered, this, &PowerTabEditor::editTiedNote);
Expand Down Expand Up @@ -2752,14 +2752,9 @@ void PowerTabEditor::createMenus()
myPositionStaffMenu->addAction(myNextBarCommand);
myPositionStaffMenu->addAction(myPrevBarCommand);

#if 0
positionMenu->addSeparator();
positionMenu->addAction(shiftTabNumUp);
positionMenu->addAction(shiftTabNumDown);
#endif
myPositionMenu->addSeparator();
myPositionMenu->addAction(myShiftForwardCommand);
myPositionMenu->addAction(myShiftBackwardCommand);
myPositionMenu->addAction(myInsertSpaceCommand);
myPositionMenu->addAction(myRemoveSpaceCommand);
myPositionMenu->addSeparator();
myPositionMenu->addAction(myRemoveNoteCommand);
myPositionMenu->addAction(myRemovePositionCommand);
Expand Down Expand Up @@ -2807,6 +2802,8 @@ void PowerTabEditor::createMenus()
myNotesMenu->addAction(myRemoveDotCommand);
myNotesMenu->addSeparator();
myNotesMenu->addAction(myLeftHandFingeringCommand);
myNotesMenu->addAction(myShiftStringUpCommand);
myNotesMenu->addAction(myShiftStringDownCommand);
myNotesMenu->addSeparator();
myNotesMenu->addAction(myTieCommand);
myNotesMenu->addAction(myMutedCommand);
Expand Down Expand Up @@ -3123,8 +3120,8 @@ void PowerTabEditor::updateCommands()
Score::MAX_LINE_SPACING);
myDecreaseLineSpacingCommand->setEnabled(score.getLineSpacing() >
Score::MIN_LINE_SPACING);
myShiftBackwardCommand->setEnabled(!pos && (position == 0 || !barline) &&
!tempoMarker && !altEnding && !dynamic);
myRemoveSpaceCommand->setEnabled(!pos && (position == 0 || !barline) &&
!tempoMarker && !altEnding && !dynamic);
myRemoveNoteCommand->setEnabled(pos || barline || hasSelection);
myRemovePositionCommand->setEnabled(pos || barline || hasSelection);

Expand Down Expand Up @@ -3624,25 +3621,13 @@ void PowerTabEditor::adjustLineSpacing(int amount)
UndoManager::AFFECTS_ALL_SYSTEMS);
}

ScoreArea *PowerTabEditor::getScoreArea()
{
return dynamic_cast<ScoreArea *>(myTabWidget->currentWidget());
}

Caret &PowerTabEditor::getCaret()
{
return myDocumentManager->getCurrentDocument().getCaret();
}

ScoreLocation &PowerTabEditor::getLocation()
void
PowerTabEditor::shiftString(bool shift_up)
{
return getCaret().getLocation();
}
// TODO - implement
// TODO - enable / disable the menu items as appropriate.

#if 0

void PowerTabEditor::shiftTabNumber(int direction)
{
const Position::ShiftType shiftType = static_cast<Position::ShiftType>(direction);
Caret* caret = getCurrentScoreArea()->getCaret();
Position* currentPos = caret->getCurrentPosition();
Expand All @@ -3659,8 +3644,26 @@ void PowerTabEditor::shiftTabNumber(int direction)
shiftType, tuning),
caret->getCurrentSystemIndex());
caret->moveCaretVertical(direction == 1 ? direction : -1);
#endif
}

ScoreArea *PowerTabEditor::getScoreArea()
{
return dynamic_cast<ScoreArea *>(myTabWidget->currentWidget());
}

Caret &PowerTabEditor::getCaret()
{
return myDocumentManager->getCurrentDocument().getCaret();
}

ScoreLocation &PowerTabEditor::getLocation()
{
return getCaret().getLocation();
}

#if 0

void PowerTabEditor::editVolumeSwell()
{
Caret* caret = getCurrentScoreArea()->getCaret();
Expand Down
Loading

0 comments on commit df80803

Please sign in to comment.