Skip to content

Commit

Permalink
fix bug: SLOT function should have been changed from patternRenamed t…
Browse files Browse the repository at this point in the history
…o updateAfterPatternChange

In a former commit, the slot function "patternRenamed " was renamed to "updateAfterPatternChange" but two places in code were not changed accordingly by mistake. This issue now fixed.
Also, removed trailing-spaces from files.
  • Loading branch information
Mister-Lemon committed Sep 4, 2018
1 parent bd27463 commit 98c43a4
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 51 deletions.
18 changes: 9 additions & 9 deletions include/StepRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ class StepRecorder : public QObject

void initialize();
void start(const MidiTime& currentPosition,const MidiTime& stepLength);
void stop();
void stop();
void notePressed(const Note & n);
void noteReleased(const Note & n);
bool keyPressEvent(QKeyEvent* ke);
bool mousePressEvent(QMouseEvent* ke);
void setCurrentPattern(Pattern* newPattern);
void setStepsLength(const MidiTime& newLength);

QVector<Note*> getCurStepNotes();

bool isRecording() const
Expand All @@ -58,16 +58,16 @@ class StepRecorder : public QObject
}

QColor curStepNoteColor() const
{
{
return QColor(245,3,139); // radiant pink
}

private slots:
private slots:
void removeNotesReleasedForTooLong();

private:
void stepForwards();
void stepBackwards();
void stepBackwards();

void applyStep();
void dismissStep();
Expand All @@ -90,9 +90,9 @@ class StepRecorder : public QObject
MidiTime m_stepsLength;
MidiTime m_curStepLength; // current step length refers to the step currently recorded. it may defer from m_stepsLength
// since the user can make current step larger
QTimer m_updateReleasedTimer;

QTimer m_updateReleasedTimer;

Pattern* m_pattern;

class StepNote
Expand Down Expand Up @@ -129,7 +129,7 @@ class StepRecorder : public QObject
Note m_note;

private:
bool m_pressed;
bool m_pressed;
QTime releasedTimer;
} ;

Expand Down
22 changes: 11 additions & 11 deletions include/StepRecorderWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
class StepRecorderWidget : public QWidget
{
Q_OBJECT

public:
StepRecorderWidget(
QWidget * parent,
const int ppt,
QWidget * parent,
const int ppt,
const int marginTop,
const int marginBottom,
const int marginLeft,
const int marginRight);

//API used by PianoRoll
//API used by PianoRoll
void setPixelsPerTact(int ppt);
void setCurrentPosition(MidiTime currentPosition);
void setBottomMargin(const int marginBottom);
Expand All @@ -51,25 +51,25 @@ class StepRecorderWidget : public QWidget
void setStepsLength(MidiTime stepsLength);
void setStartPosition(MidiTime pos);
void setEndPosition(MidiTime pos);

void showHint();

private:
virtual void paintEvent(QPaintEvent * pe);

int xCoordOfTick(int tick);

void drawVerLine(QPainter* painter, int x, const QColor& color, int top, int bottom);
void drawVerLine(QPainter* painter, const MidiTime& pos, const QColor& color, int top, int bottom);

void updateBoundaries();

MidiTime m_stepsLength;
MidiTime m_curStepStartPos;
MidiTime m_curStepEndPos;

int m_ppt; // pixels per tact
MidiTime m_currentPosition; // current position showed by on PianoRoll
int m_ppt; // pixels per tact
MidiTime m_currentPosition; // current position showed by on PianoRoll

QColor m_colorLineStart;
QColor m_colorLineEnd;
Expand All @@ -86,7 +86,7 @@ class StepRecorderWidget : public QWidget
const int m_marginRight;

signals:
void positionChanged(const MidiTime & t);
void positionChanged(const MidiTime & t);
} ;

#endif //STEP_RECOREDER_WIDGET_H
42 changes: 21 additions & 21 deletions src/core/StepRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
using std::min;
using std::max;

const int REMOVE_RELEASED_NOTE_TIME_THRESHOLD_MS = 70;
const int REMOVE_RELEASED_NOTE_TIME_THRESHOLD_MS = 70;

StepRecorder::StepRecorder(PianoRoll& pianoRoll, StepRecorderWidget& stepRecorderWidget):
m_pianoRoll(pianoRoll),
m_stepRecorderWidget(stepRecorderWidget)
{
m_stepRecorderWidget.hide();
m_stepRecorderWidget.hide();
}

void StepRecorder::initialize()
Expand All @@ -45,28 +45,28 @@ void StepRecorder::initialize()
void StepRecorder::start(const MidiTime& currentPosition, const MidiTime& stepLength)
{
m_isRecording = true;

setStepsLength(stepLength);

// quantize current position to get start recording position
const int q = m_pianoRoll.quantization();
const int curPosTicks = currentPosition.getTicks();
const int QuantizedPosTicks = (curPosTicks / q) * q;
const MidiTime& QuantizedPos = MidiTime(QuantizedPosTicks);

m_curStepStartPos = QuantizedPos;
m_curStepLength = 0;

m_stepRecorderWidget.show();

m_stepRecorderWidget.showHint();

prepareNewStep();
prepareNewStep();
}

void StepRecorder::stop()
{
m_stepRecorderWidget.hide();
m_stepRecorderWidget.hide();
m_isRecording = false;
}

Expand All @@ -75,17 +75,17 @@ void StepRecorder::notePressed(const Note & n)
//if this is the first pressed note in step, advance position
if(!m_isStepInProgress)
{
m_isStepInProgress = true;
m_isStepInProgress = true;

//move curser one step forwards
//move curser one step forwards
stepForwards();
}

StepNote* stepNote = findCurStepNote(n.key());
if(stepNote == nullptr)
{
m_curStepNotes.append(new StepNote(Note(m_stepsLength, m_curStepStartPos, n.key(), n.getVolume(), n.getPanning())));
m_pianoRoll.update();
m_pianoRoll.update();
}
else if (stepNote->isReleased())
{
Expand All @@ -101,7 +101,7 @@ void StepRecorder::noteReleased(const Note & n)
{
stepNote->setReleased();

//if m_updateReleasedTimer is not already active, activate it
//if m_updateReleasedTimer is not already active, activate it
//(when activated, the timer will re-set itself as long as there are released notes)
if(!m_updateReleasedTimer.isActive())
{
Expand All @@ -115,12 +115,12 @@ void StepRecorder::noteReleased(const Note & n)
{
applyStep();
}
else
else
{
dismissStep();
}
}
}
}
}

bool StepRecorder::keyPressEvent(QKeyEvent* ke)
Expand Down Expand Up @@ -163,7 +163,7 @@ void StepRecorder::setStepsLength(const MidiTime& newLength)
updateCurStepNotes();
}

m_stepsLength = newLength;
m_stepsLength = newLength;

updateWidget();
}
Expand Down Expand Up @@ -191,7 +191,7 @@ void StepRecorder::stepForwards()

updateCurStepNotes();
}
else
else
{
m_curStepStartPos += m_stepsLength;
}
Expand All @@ -207,15 +207,15 @@ void StepRecorder::stepBackwards()
{
m_curStepLength = max(m_curStepLength - m_stepsLength, 0);
}
else
else
{
//if length is already zero - move starting position backwards
m_curStepStartPos = max(m_curStepStartPos - m_stepsLength, 0);
}

updateCurStepNotes();
}
else
else
{
m_curStepStartPos = max(m_curStepStartPos - m_stepsLength, 0);
}
Expand Down Expand Up @@ -257,7 +257,7 @@ void StepRecorder::prepareNewStep()
delete stepNote;
}
m_curStepNotes.clear();

m_isStepInProgress = false;

m_curStepStartPos = getCurStepEndPos();
Expand All @@ -282,7 +282,7 @@ void StepRecorder::removeNotesReleasedForTooLong()
bool notesRemoved = false;

QMutableVectorIterator<StepNote*> itr(m_curStepNotes);
while (itr.hasNext())
while (itr.hasNext())
{
StepNote* stepNote = itr.next();

Expand All @@ -295,7 +295,7 @@ void StepRecorder::removeNotesReleasedForTooLong()
itr.remove();
notesRemoved = true;
}
else
else
{
nextTimout = min(nextTimout, REMOVE_RELEASED_NOTE_TIME_THRESHOLD_MS - timeSinceReleased);
}
Expand All @@ -311,7 +311,7 @@ void StepRecorder::removeNotesReleasedForTooLong()
{
m_updateReleasedTimer.start(nextTimout);
}
else
else
{
// no released note found for next timout, stop timer
m_updateReleasedTimer.stop();
Expand Down Expand Up @@ -348,7 +348,7 @@ bool StepRecorder::allCurStepNotesReleased()
}
}

return true;
return true;
}

StepRecorder::StepNote* StepRecorder::findCurStepNote(const int key)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4379,8 +4379,8 @@ void PianoRollWindow::setCurrentPattern( Pattern* pattern )
if ( pattern )
{
setWindowTitle( tr( "Piano-Roll - %1" ).arg( pattern->name() ) );
connect( pattern->instrumentTrack(), SIGNAL( nameChanged() ), this, SLOT( patternRenamed()) );
connect( pattern, SIGNAL( dataChanged() ), this, SLOT( patternRenamed() ) );
connect( pattern->instrumentTrack(), SIGNAL( nameChanged() ), this, SLOT( updateAfterPatternChange()) );
connect( pattern, SIGNAL( dataChanged() ), this, SLOT( updateAfterPatternChange() ) );
}
else
{
Expand Down
16 changes: 8 additions & 8 deletions src/gui/widgets/StepRecorderWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
#include "TextFloat.h"
#include "embed.h"

StepRecorderWidget::StepRecorderWidget(
QWidget * parent,
const int ppt,
StepRecorderWidget::StepRecorderWidget(
QWidget * parent,
const int ppt,
const int marginTop,
const int marginBottom,
const int marginLeft,
const int marginRight) :
const int marginRight) :
QWidget(parent),
m_marginTop(marginTop),
m_marginBottom(marginBottom),
Expand Down Expand Up @@ -65,18 +65,18 @@ void StepRecorderWidget::setBottomMargin(const int marginBottom)

void StepRecorderWidget::setStartPosition(MidiTime pos)
{
m_curStepStartPos = pos;
m_curStepStartPos = pos;
}

void StepRecorderWidget::setEndPosition(MidiTime pos)
{
m_curStepEndPos = pos;
m_curStepEndPos = pos;
emit positionChanged(m_curStepEndPos);
}

void StepRecorderWidget::showHint()
{
TextFloat::displayMessage(tr( "Hint" ), tr("Move recording curser using <Left/Right> arrows"),
TextFloat::displayMessage(tr( "Hint" ), tr("Move recording curser using <Left/Right> arrows"),
embed::getIconPixmap("hint"));
}

Expand Down Expand Up @@ -119,7 +119,7 @@ void StepRecorderWidget::paintEvent(QPaintEvent * pe)
//add another line to make it clearer
if(m_curStepEndPos == 0)
{
drawVerLine(&painter, xCoordOfTick(m_curStepEndPos) + 1, m_colorLineEnd, m_top, m_bottom);
drawVerLine(&painter, xCoordOfTick(m_curStepEndPos) + 1, m_colorLineEnd, m_top, m_bottom);
}
}

Expand Down

0 comments on commit 98c43a4

Please sign in to comment.