Skip to content

Commit

Permalink
- Basic key-signature has been added to tempo, time
Browse files Browse the repository at this point in the history
  -signature and location markers map. (EXPERIMENTAL)
  • Loading branch information
rncbc committed Dec 5, 2019
1 parent a61b6f3 commit 4e3e2fc
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ ChangeLog

GIT HEAD

- Basic key-signature has been added to tempo, time
-signature and location markers map. (EXPERIMENTAL)

- MIDI Clip editor (aka. piano-roll) horizontal and
vertical splitter sizes, widths and heights resp.
are now preserved as user preferences and also to
Expand Down
10 changes: 5 additions & 5 deletions src/qtractorMidiEditTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,17 @@ void qtractorMidiEditTime::updatePixmap ( int cx, int /*cy*/)
while (pMarker) {
x = pTimeScale->pixelFromFrame(pMarker->frame) - dx + 4;
if (x > w) break;
if (!pMarker->text.isEmpty()) {
painter.setPen(pMarker->color);
painter.drawText(x, y2, pMarker->text);
x += fm.horizontalAdvance(pMarker->text) + 4;
}
if (pMarker->accidentals || pMarker->minor) {
const QString& sKeySignature
= qtractorTimeScale::keySignatureName(
pMarker->accidentals, pMarker->minor);
painter.setPen(Qt::darkGray);
painter.drawText(x, y2, sKeySignature);
x += fm.horizontalAdvance(sKeySignature) + 4;
}
if (!pMarker->text.isEmpty()) {
painter.setPen(pMarker->color);
painter.drawText(x, y2, pMarker->text);
}
pMarker = pMarker->next();
}
Expand Down
25 changes: 15 additions & 10 deletions src/qtractorTimeScaleForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ qtractorTimeScaleForm::qtractorTimeScaleForm (
QObject::connect(m_ui.KeySignatureAccidentalsComboBox,
SIGNAL(activated(int)),
SLOT(changed()));
QObject::connect(m_ui.KeySignatureModeComboBox,
QObject::connect(m_ui.KeySignatureMinorComboBox,
SIGNAL(activated(int)),
SLOT(modeChanged(int)));
SLOT(minorChanged(int)));

QObject::connect(m_ui.MarkerTextLineEdit,
SIGNAL(textChanged(const QString&)),
Expand Down Expand Up @@ -469,9 +469,9 @@ void qtractorTimeScaleForm::setCurrentKeySignature (
updateKeySignatures(iAccidentals, bMinor);

const bool bBlockSignals
= m_ui.KeySignatureModeComboBox->blockSignals(true);
m_ui.KeySignatureModeComboBox->setCurrentIndex(bMinor ? 1 : 0);
m_ui.KeySignatureModeComboBox->blockSignals(bBlockSignals);
= m_ui.KeySignatureMinorComboBox->blockSignals(true);
m_ui.KeySignatureMinorComboBox->setCurrentIndex(bMinor ? 1 : 0);
m_ui.KeySignatureMinorComboBox->blockSignals(bBlockSignals);
}


Expand All @@ -488,6 +488,7 @@ void qtractorTimeScaleForm::updateKeySignatures (
= m_ui.KeySignatureAccidentalsComboBox->blockSignals(true);

m_ui.KeySignatureAccidentalsComboBox->clear();

int iIndex = 0;
for (int iData = -9; 9 >= iData; ++iData) {
m_ui.KeySignatureAccidentalsComboBox->addItem(
Expand Down Expand Up @@ -637,7 +638,7 @@ unsigned int qtractorTimeScaleForm::flags (void) const
= m_ui.KeySignatureAccidentalsComboBox->currentIndex();
if (iIndex >= 0)
iAccidentals = m_ui.KeySignatureAccidentalsComboBox->itemData(iIndex).toInt();
const bool bMinor = (m_ui.KeySignatureModeComboBox->currentIndex() > 0);
const bool bMinor = (m_ui.KeySignatureMinorComboBox->currentIndex() > 0);

if (pMarker && pMarker->frame == iFrame) {
if (!sMarkerText.isEmpty())
Expand Down Expand Up @@ -706,7 +707,7 @@ void qtractorTimeScaleForm::addItem (void)
const int iIndex = m_ui.KeySignatureAccidentalsComboBox->currentIndex();
if (iIndex >= 0)
iAccidentals = m_ui.KeySignatureAccidentalsComboBox->itemData(iIndex).toInt();
const bool bMinor = (m_ui.KeySignatureModeComboBox->currentIndex() > 0);
const bool bMinor = (m_ui.KeySignatureMinorComboBox->currentIndex() > 0);
if (iAccidentals || bMinor) {
pSession->execute(
new qtractorTimeScaleAddKeySignatureCommand(
Expand Down Expand Up @@ -771,7 +772,7 @@ void qtractorTimeScaleForm::updateItem (void)
const int iIndex = m_ui.KeySignatureAccidentalsComboBox->currentIndex();
if (iIndex >= 0)
iAccidentals = m_ui.KeySignatureAccidentalsComboBox->itemData(iIndex).toInt();
const bool bMinor = (m_ui.KeySignatureModeComboBox->currentIndex() > 0);
const bool bMinor = (m_ui.KeySignatureMinorComboBox->currentIndex() > 0);
pSession->execute(
new qtractorTimeScaleUpdateKeySignatureCommand(
m_pTimeScale, iFrame, iAccidentals, bMinor));
Expand Down Expand Up @@ -946,18 +947,22 @@ void qtractorTimeScaleForm::tempoChanged (void)


// Key signature has changed.
void qtractorTimeScaleForm::modeChanged ( int iMode )
void qtractorTimeScaleForm::minorChanged ( int iMinor )
{
if (m_iDirtySetup > 0)
return;

#ifdef CONFIG_DEBUG
qDebug("qtractorTimeScaleForm::minorChanged(%d)", iMinor);
#endif

int iAccidentals = 0;
const int iIndex
= m_ui.KeySignatureAccidentalsComboBox->currentIndex();
if (iIndex >= 0)
iAccidentals = m_ui.KeySignatureAccidentalsComboBox->itemData(iIndex).toInt();

updateKeySignatures(iAccidentals, iMode > 0);
updateKeySignatures(iAccidentals, (iMinor > 0));

changed();
}
Expand Down
2 changes: 1 addition & 1 deletion src/qtractorTimeScaleForm.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected slots:
void barChanged(int);
void timeChanged(unsigned long);
void tempoChanged();
void modeChanged(int);
void minorChanged(int);
void changed();

void tempoTap();
Expand Down
4 changes: 2 additions & 2 deletions src/qtractorTimeScaleForm.ui
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
</widget>
</item>
<item row="5" column="4" colspan="2">
<widget class="QComboBox" name="KeySignatureModeComboBox">
<widget class="QComboBox" name="KeySignatureMinorComboBox">
<property name="toolTip">
<string>Key signature (mode)</string>
</property>
Expand Down Expand Up @@ -502,7 +502,7 @@
<tabstop>TempoSpinBox</tabstop>
<tabstop>TempoTapPushButton</tabstop>
<tabstop>KeySignatureAccidentalsComboBox</tabstop>
<tabstop>KeySignatureModeComboBox</tabstop>
<tabstop>KeySignatureMinorComboBox</tabstop>
<tabstop>MarkerTextLineEdit</tabstop>
<tabstop>MarkerColorToolButton</tabstop>
<tabstop>TempoFactorSpinBox</tabstop>
Expand Down
10 changes: 5 additions & 5 deletions src/qtractorTrackTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ void qtractorTrackTime::updatePixmap ( int cx, int /* cy */)
while (pMarker) {
x = pTimeScale->pixelFromFrame(pMarker->frame) - cx + 4;
if (x > w) break;
if (!pMarker->text.isEmpty()) {
painter.setPen(pMarker->color);
painter.drawText(x, y2, pMarker->text);
x += fm.horizontalAdvance(pMarker->text) + 4;
}
if (pMarker->accidentals || pMarker->minor) {
const QString& sKeySignature
= qtractorTimeScale::keySignatureName(
pMarker->accidentals, pMarker->minor);
painter.setPen(Qt::darkGray);
painter.drawText(x, y2, sKeySignature);
x += fm.horizontalAdvance(sKeySignature) + 4;
}
if (!pMarker->text.isEmpty()) {
painter.setPen(pMarker->color);
painter.drawText(x, y2, pMarker->text);
}
pMarker = pMarker->next();
}
Expand Down

0 comments on commit 4e3e2fc

Please sign in to comment.