Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop sample on sampletracks #5043

Merged
merged 17 commits into from Jun 28, 2019
Merged
4 changes: 3 additions & 1 deletion include/SampleTrack.h
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
6 changes: 6 additions & 0 deletions include/SongEditor.h
Expand Up @@ -31,6 +31,7 @@

#include "ActionGroup.h"
#include "Editor.h"
#include "TimeLineWidget.h"
#include "TrackContainerView.h"

class QLabel;
Expand Down Expand Up @@ -74,6 +75,11 @@ class SongEditor : public TrackContainerView

ComboBoxModel *zoomingModel() const;

int timeLineWidgetHeight() const
{
return m_timeLine->height();
}
PhysSong marked this conversation as resolved.
Show resolved Hide resolved

public slots:
void scrolled( int new_pos );

Expand Down
5 changes: 5 additions & 0 deletions include/TrackContainerView.h
Expand Up @@ -124,6 +124,11 @@ class TrackContainerView : public QWidget, public ModelView,

RubberBand *rubberBand() const;

virtual int timeLineWidgetHeight() const
{
return 0;
}
PhysSong marked this conversation as resolved.
Show resolved Hide resolved

public slots:
void realignTracks();
TrackView * createTrackView( Track * _t );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/TrackContainerView.cpp
Expand Up @@ -377,7 +377,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
//it->toggledInstrumentTrackButton( true );
_de->accept();
}
else if( type == "samplefile" || type == "pluginpresetfile"
else if( type == "samplefile" || type == "pluginpresetfile"
PhysSong marked this conversation as resolved.
Show resolved Hide resolved
|| type == "soundfontfile" || type == "vstpluginfile"
|| type == "patchfile" )
{
Expand Down
1 change: 0 additions & 1 deletion src/gui/editors/SongEditor.cpp
Expand Up @@ -44,7 +44,6 @@
#include "MeterDialog.h"
#include "Mixer.h"
#include "TextFloat.h"
#include "TimeLineWidget.h"
PhysSong marked this conversation as resolved.
Show resolved Hide resolved
#include "ToolTip.h"
#include "VisualizationWidget.h"
#include "TimeDisplayWidget.h"
Expand Down
45 changes: 43 additions & 2 deletions src/tracks/SampleTrack.cpp
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