Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 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
6 changes: 6 additions & 0 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
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();
}

public slots:
void scrolled( int new_pos );

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

RubberBand *rubberBand() const;

virtual int timeLineWidgetHeight() const
{
return 0;
}

public slots:
void realignTracks();
TrackView * createTrackView( Track * _t );
Expand Down
30 changes: 19 additions & 11 deletions src/gui/TrackContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,26 @@ 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 * tv = trackViewAt(_de->pos().y() - timeLineWidgetHeight());
if (type == "samplefile" && tv && tv->getTrack()->type() == Track::SampleTrack)
{
_de->accept();
}
//This code handles the file types if we are not dropping on a sampletrack or it's not a sample file
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
1 change: 0 additions & 1 deletion src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "MeterDialog.h"
#include "Mixer.h"
#include "TextFloat.h"
#include "TimeLineWidget.h"
#include "ToolTip.h"
#include "VisualizationWidget.h"
#include "TimeDisplayWidget.h"
Expand Down
48 changes: 46 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,48 @@ 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); }
}
else
{
TrackView::dropEvent(de);
}
}




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