Skip to content
Permalink
Browse files

- MIDI Clip editor (aka. piano-roll) horizontal and

  vertical splitter sizes, widths and heights resp.
  are now preserved as user preferences and also to
  session state. (EXPERIMENTAL)
  • Loading branch information
rncbc committed Nov 18, 2019
1 parent f446bb4 commit a3c8f0ac073255f48224ab6499ff3836d9138970
@@ -8,7 +8,8 @@ GIT HEAD

- MIDI Clip editor (aka. piano-roll) horizontal and
vertical splitter sizes, widths and heights resp.
are now preserved as user preferences. (EXPERIMENTAL)
are now preserved as user preferences and also to
session state. (EXPERIMENTAL)

- Second attempt to fix the yet non-official though
CMake build configuration. (EXPERIMENTAL)
@@ -182,10 +182,14 @@ qtractorMidiClip::qtractorMidiClip ( qtractorTrack *pTrack )

m_pMidiEditorForm = nullptr;

m_iEditorHorizontalZoom = 100;
m_iEditorVerticalZoom = 100;

m_iBeatsPerBar2 = 0;
m_iBeatDivisor2 = 0;
}


// Copy constructor.
qtractorMidiClip::qtractorMidiClip ( const qtractorMidiClip& clip )
: qtractorClip(clip.track())
@@ -205,6 +209,12 @@ qtractorMidiClip::qtractorMidiClip ( const qtractorMidiClip& clip )

m_pMidiEditorForm = nullptr;

m_iEditorHorizontalZoom = clip.editorHorizontalZoom();
m_iEditorVerticalZoom = clip.editorVerticalZoom();

m_editorHorizontalSizes = clip.editorHorizontalSizes();
m_editorVerticalSizes = clip.editorVerticalSizes();

m_iBeatsPerBar2 = clip.beatsPerBar2();
m_iBeatDivisor2 = clip.beatDivisor2();
}
@@ -1305,6 +1315,24 @@ bool qtractorMidiClip::loadClipElement (
m_sizeEditor.setWidth(swh.at(0).toInt());
m_sizeEditor.setHeight(swh.at(1).toInt());
}
else if (eChild.tagName() == "editor-horizontal-zoom") {
m_iEditorHorizontalZoom = eChild.text().toUShort();
}
else if (eChild.tagName() == "editor-vertical-zoom") {
m_iEditorVerticalZoom = eChild.text().toUShort();
}
else if (eChild.tagName() == "editor-horizontal-sizes") {
const QStringList& hsizes = eChild.text().split(',');
m_editorHorizontalSizes.clear();
m_editorHorizontalSizes.append(hsizes.at(0).toInt());
m_editorHorizontalSizes.append(hsizes.at(1).toInt());
}
else if (eChild.tagName() == "editor-vertical-sizes") {
const QStringList& vsizes = eChild.text().split(',');
m_editorVerticalSizes.clear();
m_editorVerticalSizes.append(vsizes.at(0).toInt());
m_editorVerticalSizes.append(vsizes.at(1).toInt());
}
else if (eChild.tagName() == "ghost-track-name") {
m_sGhostTrackName = eChild.text();
}
@@ -1340,6 +1368,24 @@ bool qtractorMidiClip::saveClipElement (
QString::number(m_sizeEditor.width()) + ',' +
QString::number(m_sizeEditor.height()), &eMidiClip);
}
if (m_iEditorHorizontalZoom != 100) {
pDocument->saveTextElement("editor-horizontal-zoom",
QString::number(m_iEditorHorizontalZoom), &eMidiClip);
}
if (m_iEditorVerticalZoom != 100) {
pDocument->saveTextElement("editor-vertical-zoom",
QString::number(m_iEditorVerticalZoom), &eMidiClip);
}
if (m_editorHorizontalSizes.count() >= 2) {
pDocument->saveTextElement("editor-horizontal-sizes",
QString::number(m_editorHorizontalSizes.at(0)) + ',' +
QString::number(m_editorHorizontalSizes.at(1)), &eMidiClip);
}
if (m_editorVerticalSizes.count() >= 2) {
pDocument->saveTextElement("editor-vertical-sizes",
QString::number(m_editorVerticalSizes.at(0)) + ',' +
QString::number(m_editorVerticalSizes.at(1)), &eMidiClip);
}
if (!m_sGhostTrackName.isEmpty()) {
pDocument->saveTextElement("ghost-track-name",
m_sGhostTrackName, &eMidiClip);
@@ -255,6 +255,28 @@ class qtractorMidiClip : public qtractorClip
const QSize& editorSize() const
{ return m_sizeEditor; }

// MIDI clip editor zoom ratio accessors.
void setEditorHorizontalZoom(unsigned short iHorizontalZoom)
{ m_iEditorHorizontalZoom = iHorizontalZoom; }
unsigned short editorHorizontalZoom() const
{ return m_iEditorHorizontalZoom; }

void setEditorVerticalZoom(unsigned short iVerticalZoom)
{ m_iEditorVerticalZoom = iVerticalZoom; }
unsigned short editorVerticalZoom() const
{ return m_iEditorVerticalZoom; }

// MIDI clip editor splitter sizes accessors.
void setEditorHorizontalSizes(const QList<int>& sizes)
{ m_editorHorizontalSizes = sizes; }
QList<int> editorHorizontalSizes() const
{ return m_editorHorizontalSizes; }

void setEditorVerticalSizes(const QList<int>& sizes)
{ m_editorVerticalSizes = sizes; }
QList<int> editorVerticalSizes() const
{ return m_editorVerticalSizes; }

// Ghost track setting.
void setGhostTrackName(const QString& sGhostTrackName)
{ m_sGhostTrackName = sGhostTrackName; }
@@ -319,6 +341,14 @@ class qtractorMidiClip : public qtractorClip
QPoint m_posEditor;
QSize m_sizeEditor;

// MIDI clip editor zoom ratio accessors.
unsigned short m_iEditorHorizontalZoom;
unsigned short m_iEditorVerticalZoom;

// MIDI clip editor splitter sizes accessors.
QList<int> m_editorHorizontalSizes;
QList<int> m_editorVerticalSizes;

// Ghost track setting.
QString m_sGhostTrackName;

@@ -877,6 +877,14 @@ qtractorMidiEditor::qtractorMidiEditor ( QWidget *pParent )
sizes.append(180);
pOptions->loadSplitterSizes(m_pVSplitter, sizes);
}

// Track splitter moves...
QObject::connect(m_pHSplitter,
SIGNAL(splitterMoved(int, int)),
SLOT(horizontalSplitterSlot()));
QObject::connect(m_pVSplitter,
SIGNAL(splitterMoved(int, int)),
SLOT(verticalSplitterSlot()));
}


@@ -943,6 +951,24 @@ void qtractorMidiEditor::setMidiClip ( qtractorMidiClip *pMidiClip )
}
}
}
// Set zoom ratios...
const unsigned short iHorizontalZoom
= pMidiClip->editorHorizontalZoom();
if (iHorizontalZoom != 100)
setHorizontalZoom(iHorizontalZoom);
const unsigned short iVerticalZoom
= pMidiClip->editorVerticalZoom();
if (iVerticalZoom != 100)
setVerticalZoom(iVerticalZoom);
// Set splitter sizes...
const QList<int>& hsizes
= pMidiClip->editorHorizontalSizes();
if (!hsizes.isEmpty())
setHorizontalSizes(hsizes);
const QList<int>& vsizes
= pMidiClip->editorVerticalSizes();
if (!vsizes.isEmpty())
setVerticalSizes(vsizes);
// Got clip!
} else {
// Reset those little things too..
@@ -1026,6 +1052,9 @@ void qtractorMidiEditor::setHorizontalZoom ( unsigned short iHorizontalZoom )
{
m_pTimeScale->setHorizontalZoom(iHorizontalZoom);
m_pTimeScale->updateScale();

if (m_pMidiClip)
m_pMidiClip->setEditorHorizontalZoom(iHorizontalZoom);
}

unsigned short qtractorMidiEditor::horizontalZoom (void) const
@@ -1049,6 +1078,9 @@ void qtractorMidiEditor::setVerticalZoom ( unsigned short iVerticalZoom )
m_pEditList->setItemHeight(iItemHeight);

m_pTimeScale->setVerticalZoom(iVerticalZoom);

if (m_pMidiClip)
m_pMidiClip->setEditorVerticalZoom(iVerticalZoom);
}

unsigned short qtractorMidiEditor::verticalZoom (void) const
@@ -1057,6 +1089,33 @@ unsigned short qtractorMidiEditor::verticalZoom (void) const
}


// Splitter sizes accessors.
void qtractorMidiEditor::setHorizontalSizes ( const QList<int>& sizes )
{
const bool bBlockSignals = m_pHSplitter->blockSignals(true);
m_pHSplitter->setSizes(sizes);
m_pHSplitter->blockSignals(bBlockSignals);
}

QList<int> qtractorMidiEditor::horizontalSizes (void) const
{
return m_pHSplitter->sizes();
}


void qtractorMidiEditor::setVerticalSizes ( const QList<int>& sizes )
{
const bool bBlockSignals = m_pVSplitter->blockSignals(true);
m_pVSplitter->setSizes(sizes);
m_pVSplitter->blockSignals(bBlockSignals);
}

QList<int> qtractorMidiEditor::verticalSizes (void) const
{
return m_pVSplitter->sizes();
}


// Drum mode (UI).
void qtractorMidiEditor::setDrumMode ( bool bDrumMode )
{
@@ -1620,6 +1679,22 @@ void qtractorMidiEditor::verticalZoomResetSlot (void)
}




// Splitters moved slots.
void qtractorMidiEditor::horizontalSplitterSlot (void)
{
if (m_pMidiClip)
m_pMidiClip->setEditorHorizontalSizes(m_pHSplitter->sizes());
}

void qtractorMidiEditor::verticalSplitterSlot (void)
{
if (m_pMidiClip)
m_pMidiClip->setEditorVerticalSizes(m_pVSplitter->sizes());
}


// Tell whether we can undo last command...
bool qtractorMidiEditor::canUndo (void) const
{
@@ -129,6 +129,13 @@ class qtractorMidiEditor : public QSplitter
void setVerticalZoom(unsigned short iVerticalZoom);
unsigned short verticalZoom() const;

// Splitter sizes accessors.
void setHorizontalSizes(const QList<int>& sizes);
QList<int> horizontalSizes() const;

void setVerticalSizes(const QList<int>& sizes);
QList<int> verticalSizes() const;

// Local time scale accessors.
qtractorTimeScale *timeScale() const;
unsigned long timeOffset() const;
@@ -523,6 +530,10 @@ protected slots:
void verticalZoomOutSlot();
void verticalZoomResetSlot();

// Splitters moved slots.
void horizontalSplitterSlot();
void verticalSplitterSlot();

// Command execution notification slot.
void updateNotifySlot(unsigned int flags);

0 comments on commit a3c8f0a

Please sign in to comment.
You can’t perform that action at this time.