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
3 changes: 3 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_timeLineWidgetHeigth;
BaraMGB marked this conversation as resolved.
Show resolved Hide resolved


private:
Expand All @@ -176,6 +178,7 @@ public slots:
} ;
friend class TrackContainerView::scrollArea;

void addSampleTCO(Track * track, QString sampleFile, int xPos);
TrackContainer* m_tc;
typedef QList<TrackView *> trackViewList;
trackViewList m_trackViews;
Expand Down
50 changes: 47 additions & 3 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_timeLineWidgetHeigth(0),
BaraMGB marked this conversation as resolved.
Show resolved Hide resolved
m_tc( _tc ),
m_trackViews(),
m_scrollArea( new scrollArea( this ) ),
Expand Down Expand Up @@ -377,9 +378,10 @@ 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 == "pluginpresetfile"
|| type == "soundfontfile"
|| type == "vstpluginfile"
|| type == "patchfile")
{
InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
Track::create( Track::InstrumentTrack,
Expand All @@ -391,6 +393,28 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
//it->toggledInstrumentTrackButton( true );
_de->accept();
}
else if(type == "samplefile")
{
const TrackView * trackView = trackViewAt(_de->pos().y() - m_timeLineWidgetHeigth);
BaraMGB marked this conversation as resolved.
Show resolved Hide resolved
if (trackView && trackView->getTrack()->type() == Track::SampleTrack)
{
for (auto tv : trackViews())
{
if (tv == trackView)
{
addSampleTCO(tv->getTrack(), value, _de->pos().x());
}
}
}
PhysSong marked this conversation as resolved.
Show resolved Hide resolved
else
{
Track * track = Track::create(Track::SampleTrack, m_tc);
if (track)
{
addSampleTCO(track, value, _de->pos().x());
}
}
}
else if( type == "presetfile" )
{
DataFile dataFile( value );
Expand Down Expand Up @@ -474,6 +498,26 @@ void TrackContainerView::resizeEvent( QResizeEvent * _re )
QWidget::resizeEvent( _re );
}




void TrackContainerView::addSampleTCO(Track *track, QString sampleFile, int xPos)
{
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;
SampleTCO * newTco = new SampleTCO(track);
newTco->setSampleFile(sampleFile);
newTco->movePosition(fixedTCOs() == false
? MidiTime((xPos - trackHeadWidth) / pixelsPerTact()
* MidiTime::ticksPerTact()).toNearestTact()
: MidiTime(0)
);
}




RubberBand *TrackContainerView::rubberBand() const
{
return m_rubberBand;
Expand Down
1 change: 1 addition & 0 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ static inline void animateScroll( QScrollBar *scrollBar, int newVal, bool smooth

void SongEditor::updatePosition( const MidiTime & t )
{
m_timeLineWidgetHeigth = m_timeLine->height();
BaraMGB marked this conversation as resolved.
Show resolved Hide resolved
int widgetWidth, trackOpWidth;
if( ConfigManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() )
{
Expand Down