Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
1 change: 1 addition & 0 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private slots:
void updateScrollBar(int len);

void zoomingChanged();
void timeLineHeigthChanged();

private:
virtual void keyPressEvent( QKeyEvent * ke );
Expand Down
2 changes: 2 additions & 0 deletions include/TimeLineWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class TimeLineWidget : public QWidget, public JournallingObject

void regionSelectedFromPixels( int, int );
void selectionFinished();
void sizeChanged();


public slots:
Expand All @@ -188,6 +189,7 @@ public slots:
virtual void mousePressEvent( QMouseEvent * _me );
virtual void mouseMoveEvent( QMouseEvent * _me );
virtual void mouseReleaseEvent( QMouseEvent * _me );
virtual void resizeEvent(QResizeEvent * _re);


private:
Expand Down
2 changes: 2 additions & 0 deletions include/TrackContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <QThread>

#include "Track.h"
#include "SampleTrack.h"
#include "JournallingObject.h"
#include "InstrumentTrack.h"

Expand Down Expand Up @@ -152,6 +153,7 @@ public slots:
virtual void resizeEvent( QResizeEvent * );

MidiTime m_currentPosition;
int m_timeLineWidgetHeight;


private:
Expand Down
8 changes: 8 additions & 0 deletions src/gui/TimeLineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,11 @@ void TimeLineWidget::mouseReleaseEvent( QMouseEvent* event )
if ( m_action == SelectSongTCO ) { emit selectionFinished(); }
m_action = NoAction;
}




void TimeLineWidget::resizeEvent(QResizeEvent *_re)
{
emit sizeChanged();
}
54 changes: 43 additions & 11 deletions src/gui/TrackContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ TrackContainerView::TrackContainerView( TrackContainer * _tc ) :
JournallingObject(),
SerializingObjectHook(),
m_currentPosition( 0, 0 ),
m_timeLineWidgetHeight(0),
m_tc( _tc ),
m_trackViews(),
m_scrollArea( new scrollArea( this ) ),
Expand Down Expand Up @@ -377,18 +378,46 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
//it->toggledInstrumentTrackButton( true );
_de->accept();
}
else if( type == "samplefile" || type == "pluginpresetfile"
|| type == "soundfontfile" || type == "vstpluginfile"
|| type == "patchfile" )
else if (type == "samplefile" || type == "pluginpresetfile"
|| type == "soundfontfile" || type == "vstpluginfile"
|| type == "patchfile")
{
InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
Track::create( Track::InstrumentTrack,
m_tc ) );
PluginFactory::PluginInfoAndKey piakn =
pluginFactory->pluginSupportingExtension(FileItem::extension(value));
Instrument * i = it->loadInstrument(piakn.info.name(), &piakn.key);
i->loadFile( value );
//it->toggledInstrumentTrackButton( true );
const TrackView * trackView = trackViewAt(_de->pos().y() - m_timeLineWidgetHeight);
//if we drop on a sample track, add sample TCO to it
if (type == "samplefile" && trackView && trackView->getTrack()->type() == Track::SampleTrack)
{
for (auto tv : trackViews())
{
if (tv == trackView)
{
int trackHeadWidth = ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt()==1
? DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT
: DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_OP_WIDTH;

int xPos = _de->pos().x() < trackHeadWidth
? trackHeadWidth
: _de->pos().x();

SampleTCO * newTco = new SampleTCO(tv->getTrack());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have to use the Track::createTCO function instead.

newTco->setSampleFile(value);
newTco->movePosition(fixedTCOs() == false
? MidiTime((xPos - trackHeadWidth) / pixelsPerTact()
* MidiTime::ticksPerTact()).toNearestTact()
: MidiTime(0)
);
}
}
}
else
{
InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct me if i'm wrong, isn't it another feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code handles the file types if we are not dropping on a sampletrack or it's not a sample file:

(type == "samplefile" || type == "pluginpresetfile"
			|| type == "soundfontfile" || type == "vstpluginfile"
			|| type == "patchfile")

Track::create(Track::InstrumentTrack,
m_tc));
PluginFactory::PluginInfoAndKey piakn =
pluginFactory->pluginSupportingExtension(FileItem::extension(value));
Instrument * i = it->loadInstrument(piakn.info.name(), &piakn.key);
i->loadFile(value);
}
_de->accept();
}
else if( type == "presetfile" )
Expand Down Expand Up @@ -474,6 +503,9 @@ void TrackContainerView::resizeEvent( QResizeEvent * _re )
QWidget::resizeEvent( _re );
}




RubberBand *TrackContainerView::rubberBand() const
{
return m_rubberBand;
Expand Down
9 changes: 9 additions & 0 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ SongEditor::SongEditor( Song * song ) :
this, SLOT( selectRegionFromPixels( int, int ) ) );
connect( m_timeLine, SIGNAL( selectionFinished() ),
this, SLOT( stopRubberBand() ) );
connect(m_timeLine, SIGNAL(sizeChanged()), this, SLOT(timeLineHeigthChanged()));

m_positionLine = new positionLine( this );
static_cast<QVBoxLayout *>( layout() )->insertWidget( 1, m_timeLine );
Expand Down Expand Up @@ -625,6 +626,14 @@ void SongEditor::zoomingChanged()



void SongEditor::timeLineHeigthChanged()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could add a virtual timeLineWidget getter instead of this signal, member variable and slot. But that's ok too.

{
m_timeLineWidgetHeight = m_timeLine->height();
}




void SongEditor::selectAllTcos( bool select )
{
QVector<selectableObject *> so = select ? rubberBand()->selectableObjects() : rubberBand()->selectedObjects();
Expand Down