Skip to content
Merged
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
4 changes: 3 additions & 1 deletion include/SampleTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class SampleTrack : public Track
virtual bool play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _frame_base, int _tco_num = -1 );
virtual TrackView * createView( TrackContainerView* tcv );
virtual TrackContentObject * createTCO( const MidiTime & _pos );
virtual TrackContentObject * createTCO(const MidiTime & pos);


virtual void saveTrackSpecificSettings( QDomDocument & _doc,
Expand Down Expand Up @@ -218,6 +218,8 @@ public slots:
return "SampleTrackView";
}

void dragEnterEvent(QDragEnterEvent *dee);
void dropEvent(QDropEvent *de);

private slots:
void assignFxLine( int channelIndex );
Expand Down
45 changes: 43 additions & 2 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,11 @@ TrackView * SampleTrack::createView( TrackContainerView* tcv )



TrackContentObject * SampleTrack::createTCO( const MidiTime & )
TrackContentObject * SampleTrack::createTCO(const MidiTime & pos)
{
return new SampleTCO( this );
SampleTCO * sTco = new SampleTCO(this);
sTco->movePosition(pos);
return sTco;
}


Expand Down Expand Up @@ -901,6 +903,45 @@ void SampleTrackView::modelChanged()




void SampleTrackView::dragEnterEvent(QDragEnterEvent *dee)
{
StringPairDrag::processDragEnterEvent(dee, QString("samplefile"));
}




void SampleTrackView::dropEvent(QDropEvent *de)
{
QString type = StringPairDrag::decodeKey(de);
QString value = StringPairDrag::decodeValue(de);

if (type == "samplefile")
{
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();

MidiTime tcoPos = trackContainerView()->fixedTCOs()
? MidiTime(0)
: MidiTime(((xPos - trackHeadWidth) / trackContainerView()->pixelsPerTact()
* MidiTime::ticksPerTact()) + trackContainerView()->currentPosition()
).toNearestTact();

SampleTCO * sTco = static_cast<SampleTCO*>(getTrack()->createTCO(tcoPos));
if (sTco) { sTco->setSampleFile(value); }
}

}




SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) :
QWidget(),
ModelView(NULL, this),
Expand Down