Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/AutomationClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class LMMS_EXPORT AutomationClip : public Clip
const bool ignoreSurroundingPoints = true
);

bool isEmpty() override
{
return m_timeMap.empty();
}

void removeNode(const TimePos & time);
void removeNodes(const int tick0, const int tick1);

Expand Down
7 changes: 7 additions & 0 deletions include/Clip.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TrackView;
class LMMS_EXPORT Clip : public Model, public JournallingObject
{
Q_OBJECT
mapPropertyFromModel(bool,isHidden,setHidden,m_hiddenModel);
mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel);
mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel);
public:
Expand Down Expand Up @@ -98,6 +99,11 @@ class LMMS_EXPORT Clip : public Model, public JournallingObject

bool isInPattern() const;

virtual bool isEmpty()
{
return false;
}

bool manuallyResizable() const;

/*! \brief Set whether a clip has been resized yet by the user or the knife tool.
Expand Down Expand Up @@ -171,6 +177,7 @@ public slots:
TimePos m_length;
TimePos m_startTimeOffset;

BoolModel m_hiddenModel;
BoolModel m_mutedModel;
BoolModel m_soloModel;
bool m_autoResize = true;
Expand Down
5 changes: 5 additions & 0 deletions include/MidiClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ class LMMS_EXPORT MidiClip : public Clip
return m_clipType;
}

bool isEmpty() override
{
return !m_notes.size();
}


// next/previous track based on position in the containing track
MidiClip * previousMidiClip() const;
Expand Down
2 changes: 2 additions & 0 deletions include/PatternEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public slots:
protected slots:
void dropEvent(QDropEvent * de ) override;
void resizeEvent(QResizeEvent* de) override;
void showAllTracks();
void hideEmptyTracks();
void updatePosition();
void updatePixelsPerBar();

Expand Down
5 changes: 5 additions & 0 deletions include/SampleClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class SampleClip : public Clip
void setIsPlaying(bool isPlaying);
void setSampleBuffer(std::shared_ptr<const SampleBuffer> sb);

bool isEmpty() override
{
return !m_sample.sampleSize();
}

SampleClip* clone() override
{
return new SampleClip(*this);
Expand Down
4 changes: 4 additions & 0 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class LMMS_EXPORT Track : public Model, public JournallingObject

void createClipsForPattern(int pattern);

bool hiddenForPattern(size_t pattern);
void setVisibilityForPattern(bool hidden, size_t pattern);
void hideForPatternIfEmpty(size_t pattern);

void insertBar( const TimePos & pos );
void removeBar( const TimePos & pos );
Expand Down Expand Up @@ -238,6 +241,7 @@ public slots:
void nameChanged();
void clipAdded( lmms::Clip * );
void colorChanged();
void visibilityChanged();
} ;


Expand Down
1 change: 1 addition & 0 deletions include/TrackOperationsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private slots:
void recordingOn();
void recordingOff();
void clearTrack();
void hideTrack();

private:
TrackView * m_trackView;
Expand Down
4 changes: 4 additions & 0 deletions include/TrackView.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ class TrackView : public QWidget, public ModelView, public JournallingObject
// Currently instrument track and sample track supports it
virtual QMenu * createMixerMenu(QString title, QString newMixerLabel);

void setVisibleForThisPattern(bool hidden);
void hideIfEmpty();


public slots:
virtual bool close();
void visibilityChanged();


protected:
Expand Down
2 changes: 2 additions & 0 deletions src/core/AutomationClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ void AutomationClip::saveSettings( QDomDocument & _doc, QDomElement & _this )
_this.setAttribute( "name", name() );
_this.setAttribute( "prog", QString::number( static_cast<int>(progressionType()) ) );
_this.setAttribute( "tens", QString::number( getTension() ) );
_this.setAttribute( "hidden", QString::number( isHidden() ) );
_this.setAttribute( "mute", QString::number( isMuted() ) );
_this.setAttribute("off", startTimeOffset());
_this.setAttribute("autoresize", QString::number(getAutoResize()));
Expand Down Expand Up @@ -837,6 +838,7 @@ void AutomationClip::loadSettings( const QDomElement & _this )
setProgressionType( static_cast<ProgressionType>( _this.attribute(
"prog" ).toInt() ) );
setTension( _this.attribute( "tens" ) );
setHidden(_this.attribute( "hidden", QString::number( false ) ).toInt() );
setMuted(_this.attribute( "mute", QString::number( false ) ).toInt() );
setAutoResize(_this.attribute("autoresize", "1").toInt());
setStartTimeOffset(_this.attribute("off").toInt());
Expand Down
4 changes: 4 additions & 0 deletions src/core/Clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Clip::Clip( Track * track ) :
if( getTrack() )
{
getTrack()->addClip( this );
connect(&m_hiddenModel, SIGNAL(dataChanged()),
getTrack(), SIGNAL(visibilityChanged()));
}
setJournalling( false );
movePosition( 0 );
Expand Down Expand Up @@ -84,6 +86,8 @@ Clip::Clip(const Clip& other):
if (getTrack())
{
getTrack()->addClip(this);
connect(&m_hiddenModel, SIGNAL(dataChanged()),
getTrack(), SIGNAL(visibilityChanged()));
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/SampleClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ void SampleClip::saveSettings( QDomDocument & _doc, QDomElement & _this )
_this.setAttribute( "pos", startPosition() );
}
_this.setAttribute( "len", length() );
_this.setAttribute( "hidden", isHidden() );
_this.setAttribute( "muted", isMuted() );
_this.setAttribute( "src", sampleFile() );
_this.setAttribute( "off", startTimeOffset() );
Expand Down Expand Up @@ -324,6 +325,7 @@ void SampleClip::loadSettings( const QDomElement & _this )
m_sample = Sample(std::move(buffer));
}
changeLength( _this.attribute( "len" ).toInt() );
setHidden( _this.attribute( "hidden" ).toInt() );
setMuted( _this.attribute( "muted" ).toInt() );
setStartTimeOffset( _this.attribute( "off" ).toInt() );
setAutoResize(_this.attribute("autoresize", "1").toInt());
Expand Down
27 changes: 27 additions & 0 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,33 @@ void Track::createClipsForPattern(int pattern)
}


bool Track::hiddenForPattern(size_t pattern)
{
if (pattern >= m_clips.size())
return false;
return m_clips[pattern]->isHidden();
}

void Track::setVisibilityForPattern(bool hidden, size_t pattern)
{
if (pattern < m_clips.size())
{
m_clips[pattern]->setHidden(hidden);
}
}

void Track::hideForPatternIfEmpty(size_t pattern)
{
if (pattern < m_clips.size())
{
if (m_clips[pattern]->isEmpty())
{
m_clips[pattern]->setHidden(true);
}
}
}




/*! \brief Move all the clips after a certain time later by one bar.
Expand Down
21 changes: 21 additions & 0 deletions src/gui/editors/PatternEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,23 @@ void PatternEditor::resizeEvent(QResizeEvent* re)
}


void PatternEditor::showAllTracks()
{
for (const auto& trackView : trackViews())
{
trackView->setVisibleForThisPattern(false);
}
}

void PatternEditor::hideEmptyTracks()
{
for (const auto& trackView : trackViews())
{
trackView->hideIfEmpty();
}
}


void PatternEditor::updatePosition()
{
//realignTracks();
Expand Down Expand Up @@ -322,6 +339,10 @@ PatternEditorWindow::PatternEditorWindow(PatternStore* ps) :
m_editor, SLOT(addSampleTrack()));
trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_automation"), tr("Add automation-track"),
m_editor, SLOT(addAutomationTrack()));
trackAndStepActionsToolBar->addAction(embed::getIconPixmap(""), tr("Show all"),
m_editor, SLOT(showAllTracks()));
trackAndStepActionsToolBar->addAction(embed::getIconPixmap(""), tr("Hide empty"),
m_editor, SLOT(hideEmptyTracks()));

auto stretch = new QWidget(m_toolBar);
stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Expand Down
11 changes: 11 additions & 0 deletions src/gui/tracks/TrackOperationsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "InstrumentTrackView.h"
#include "lmms_math.h"
#include "KeyboardShortcuts.h"
#include "PatternStore.h"
#include "Song.h"
#include "StringPairDrag.h"
#include "Track.h"
Expand Down Expand Up @@ -236,6 +237,12 @@ void TrackOperationsWidget::clearTrack()
}


void TrackOperationsWidget::hideTrack()
{
m_trackView->setVisibleForThisPattern(true);
}


/*! \brief Remove this track from the track list
*
*/
Expand Down Expand Up @@ -313,6 +320,10 @@ void TrackOperationsWidget::updateMenu()
{
toMenu->addAction( tr( "Clear this track" ), this, SLOT(clearTrack()));
}
if (m_trackView->getTrack()->trackContainer() == Engine::patternStore())
{
toMenu->addAction(tr( "Hide this track for current pattern" ), this, SLOT(hideTrack()));
}
if (QMenu *mixerMenu = m_trackView->createMixerMenu(tr("Channel %1: %2"), tr("Assign to new Mixer Channel")))
{
toMenu->addMenu(mixerMenu);
Expand Down
27 changes: 26 additions & 1 deletion src/gui/tracks/TrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "DeprecationHelper.h"
#include "Engine.h"
#include "FadeButton.h"
#include "PatternStore.h"
#include "StringPairDrag.h"
#include "Track.h"
#include "TrackGrip.h"
Expand Down Expand Up @@ -95,6 +96,8 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) :
this, SLOT(createClipView(lmms::Clip*)),
Qt::QueuedConnection );

connect(m_track, SIGNAL(visibilityChanged()), this, SLOT(visibilityChanged()));

connect( &m_track->m_mutedModel, SIGNAL(dataChanged()),
&m_trackContentWidget, SLOT(update()));

Expand All @@ -115,6 +118,7 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) :
}

m_trackContainerView->addTrackView( this );
visibilityChanged();
}


Expand Down Expand Up @@ -157,7 +161,7 @@ void TrackView::update()
{
m_trackContentWidget.changePosition();
}
QWidget::update();
visibilityChanged();
}


Expand Down Expand Up @@ -435,6 +439,16 @@ void TrackView::createClipView( Clip * clip )



void TrackView::setVisibleForThisPattern(bool hidden)
{
m_track->setVisibilityForPattern(hidden, Engine::patternStore()->currentPattern());
}
void TrackView::hideIfEmpty()
{
m_track->hideForPatternIfEmpty(Engine::patternStore()->currentPattern());
}



void TrackView::muteChanged()
{
Expand All @@ -443,6 +457,17 @@ void TrackView::muteChanged()
}


void TrackView::visibilityChanged()
{
PatternStore* ps = Engine::patternStore();
if (m_track->trackContainer() == ps)
{
setVisible(!m_track->hiddenForPattern(ps->currentPattern()));
}
QWidget::update();
}


void TrackView::onTrackGripGrabbed()
{
m_action = Action::Move;
Expand Down
3 changes: 3 additions & 0 deletions src/tracks/MidiClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ void MidiClip::exportToXML(QDomDocument& doc, QDomElement& midiClipElement, bool
{
midiClipElement.setAttribute("pos", startPosition());
}
midiClipElement.setAttribute("hidden", isHidden());
midiClipElement.setAttribute("muted", isMuted());
midiClipElement.setAttribute("steps", m_steps);
midiClipElement.setAttribute("len", length());
Expand Down Expand Up @@ -489,6 +490,8 @@ void MidiClip::loadSettings( const QDomElement & _this )
{
movePosition( _this.attribute( "pos" ).toInt() );
}
setHidden(static_cast<bool>(_this.attribute("hidden").toInt()));

if (static_cast<bool>(_this.attribute("muted").toInt()) != isMuted())
{
toggleMute();
Expand Down
Loading