Drop sample on sampletracks (#5043)
* implements drag and drop samples to sampletracks * clean up / take care of timeLineWidget heigth in songeditor * unused memeber removed * clean up * Update include/TrackContainerView.h Co-Authored-By: Spekular <Spekular@users.noreply.github.com> * Update src/gui/TrackContainerView.cpp Co-Authored-By: Spekular <Spekular@users.noreply.github.com> * Update src/gui/TrackContainerView.cpp Co-Authored-By: Spekular <Spekular@users.noreply.github.com> * Update src/gui/editors/SongEditor.cpp Co-Authored-By: Spekular <Spekular@users.noreply.github.com> * load AFP if we don't drop on a sample track * take care of timeLineWidget size changes * clean up * consolidate some code * requested changes by code review * move logic to SampleTrackView * clean up * clean up * clean up
This commit is contained in:
committed by
GitHub
parent
68cb91726a
commit
d766b87688
@@ -139,7 +139,7 @@ public:
|
||||
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,
|
||||
@@ -218,6 +218,8 @@ protected:
|
||||
return "SampleTrackView";
|
||||
}
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent *dee);
|
||||
void dropEvent(QDropEvent *de);
|
||||
|
||||
private slots:
|
||||
void assignFxLine( int channelIndex );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user