Merge branch 'stable-1.2'
# Conflicts: # data/locale/pl.ts # include/SongEditor.h # plugins/vst_base/CMakeLists.txt # src/core/Song.cpp # src/gui/editors/SongEditor.cpp
This commit is contained in:
@@ -1247,7 +1247,7 @@ void Mixer::fifoWriter::run()
|
||||
disable_denormals();
|
||||
|
||||
#if 0
|
||||
#ifdef LMMS_BUILD_LINUX
|
||||
#if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_FREEBSD)
|
||||
#ifdef LMMS_HAVE_SCHED_H
|
||||
cpu_set_t mask;
|
||||
CPU_ZERO( &mask );
|
||||
|
||||
@@ -168,7 +168,7 @@ void ProjectRenderer::run()
|
||||
{
|
||||
MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard);
|
||||
#if 0
|
||||
#ifdef LMMS_BUILD_LINUX
|
||||
#if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_FREEBSD)
|
||||
#ifdef LMMS_HAVE_SCHED_H
|
||||
cpu_set_t mask;
|
||||
CPU_ZERO( &mask );
|
||||
|
||||
@@ -370,11 +370,14 @@ void SampleBuffer::directFloatWrite ( sample_t * & _fbuf, f_cnt_t _frames, int _
|
||||
void SampleBuffer::normalizeSampleRate( const sample_rate_t _src_sr,
|
||||
bool _keep_settings )
|
||||
{
|
||||
const sample_rate_t old_rate = m_sampleRate;
|
||||
// do samplerate-conversion to our default-samplerate
|
||||
if( _src_sr != mixerSampleRate() )
|
||||
{
|
||||
SampleBuffer * resampled = resample( _src_sr,
|
||||
mixerSampleRate() );
|
||||
|
||||
m_sampleRate = mixerSampleRate();
|
||||
MM_FREE( m_data );
|
||||
m_frames = resampled->frames();
|
||||
m_data = MM_ALLOC( sampleFrame, m_frames );
|
||||
@@ -389,6 +392,16 @@ void SampleBuffer::normalizeSampleRate( const sample_rate_t _src_sr,
|
||||
m_loopStartFrame = m_startFrame = 0;
|
||||
m_loopEndFrame = m_endFrame = m_frames;
|
||||
}
|
||||
else if( old_rate != mixerSampleRate() )
|
||||
{
|
||||
auto old_rate_to_new_rate_ratio = static_cast<float>(mixerSampleRate()) / old_rate;
|
||||
|
||||
m_startFrame = qBound(0, f_cnt_t(m_startFrame*old_rate_to_new_rate_ratio), m_frames);
|
||||
m_endFrame = qBound(m_startFrame, f_cnt_t(m_endFrame*old_rate_to_new_rate_ratio), m_frames);
|
||||
m_loopStartFrame = qBound(0, f_cnt_t(m_loopStartFrame*old_rate_to_new_rate_ratio), m_frames);
|
||||
m_loopEndFrame = qBound(m_loopStartFrame, f_cnt_t(m_loopEndFrame*old_rate_to_new_rate_ratio), m_frames);
|
||||
m_sampleRate = mixerSampleRate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -721,7 +721,7 @@ int main( int argc, char * * argv )
|
||||
|
||||
|
||||
// try to set realtime priority
|
||||
#ifdef LMMS_BUILD_LINUX
|
||||
#if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_FREEBSD)
|
||||
#ifdef LMMS_HAVE_SCHED_H
|
||||
#ifndef __OpenBSD__
|
||||
struct sched_param sparam;
|
||||
|
||||
@@ -1518,7 +1518,12 @@ void MainWindow::exportProject(bool multiExport)
|
||||
// Get first extension from selected dropdown.
|
||||
// i.e. ".wav" from "WAV-File (*.wav), Dummy-File (*.dum)"
|
||||
suffix = efd.selectedNameFilter().mid( stx + 2, etx - stx - 2 ).split( " " )[0].trimmed();
|
||||
exportFileName.remove( "." + suffix, Qt::CaseInsensitive );
|
||||
|
||||
Qt::CaseSensitivity cs = Qt::CaseSensitive;
|
||||
#if defined(LMMS_BUILD_APPLE) || defined(LMMS_BUILD_WIN32)
|
||||
cs = Qt::CaseInsensitive;
|
||||
#endif
|
||||
exportFileName.remove( "." + suffix, cs );
|
||||
if ( efd.selectedFiles()[0].endsWith( suffix ) )
|
||||
{
|
||||
if( VersionedSaveDialog::fileExistsQuery( exportFileName + suffix,
|
||||
|
||||
@@ -187,7 +187,7 @@ int PianoView::getKeyFromKeyEvent( QKeyEvent * _ke )
|
||||
case 27: return 31; // ]
|
||||
}
|
||||
#endif
|
||||
#if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_OPENBSD)
|
||||
#if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_OPENBSD) || defined(LMMS_BUILD_FREEBSD)
|
||||
switch( k )
|
||||
{
|
||||
case 52: return 0; // Z = C
|
||||
|
||||
@@ -55,8 +55,7 @@ TrackContainerView::TrackContainerView( TrackContainer * _tc ) :
|
||||
m_trackViews(),
|
||||
m_scrollArea( new scrollArea( this ) ),
|
||||
m_ppt( DEFAULT_PIXELS_PER_TACT ),
|
||||
m_rubberBand( new RubberBand( m_scrollArea ) ),
|
||||
m_origin()
|
||||
m_rubberBand( new RubberBand( m_scrollArea ) )
|
||||
{
|
||||
m_tc->setHook( this );
|
||||
//keeps the direction of the widget, undepended on the locale
|
||||
@@ -345,12 +344,8 @@ void TrackContainerView::dragEnterEvent( QDragEnterEvent * _dee )
|
||||
arg( Track::SampleTrack ) );
|
||||
}
|
||||
|
||||
void TrackContainerView::selectRegionFromPixels(int xStart, int xEnd)
|
||||
{
|
||||
m_rubberBand->setEnabled( true );
|
||||
m_rubberBand->show();
|
||||
m_rubberBand->setGeometry( min( xStart, xEnd ), 0, max( xStart, xEnd ) - min( xStart, xEnd ), std::numeric_limits<int>::max() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrackContainerView::stopRubberBand()
|
||||
{
|
||||
@@ -427,55 +422,18 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
|
||||
|
||||
|
||||
|
||||
void TrackContainerView::mousePressEvent( QMouseEvent * _me )
|
||||
{
|
||||
if( allowRubberband() == true )
|
||||
{
|
||||
m_origin = m_scrollArea->mapFromParent( _me->pos() );
|
||||
m_rubberBand->setEnabled( true );
|
||||
m_rubberBand->setGeometry( QRect( m_origin, QSize() ) );
|
||||
m_rubberBand->show();
|
||||
}
|
||||
QWidget::mousePressEvent( _me );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void TrackContainerView::mouseMoveEvent( QMouseEvent * _me )
|
||||
{
|
||||
if( rubberBandActive() == true )
|
||||
{
|
||||
m_rubberBand->setGeometry( QRect( m_origin,
|
||||
m_scrollArea->mapFromParent( _me->pos() ) ).
|
||||
normalized() );
|
||||
}
|
||||
QWidget::mouseMoveEvent( _me );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void TrackContainerView::mouseReleaseEvent( QMouseEvent * _me )
|
||||
{
|
||||
m_rubberBand->hide();
|
||||
m_rubberBand->setEnabled( false );
|
||||
QWidget::mouseReleaseEvent( _me );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void TrackContainerView::resizeEvent( QResizeEvent * _re )
|
||||
{
|
||||
realignTracks();
|
||||
QWidget::resizeEvent( _re );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RubberBand *TrackContainerView::rubberBand() const
|
||||
{
|
||||
return m_rubberBand;
|
||||
return m_rubberBand;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "TimeDisplayWidget.h"
|
||||
#include "AudioDevice.h"
|
||||
#include "PianoRoll.h"
|
||||
|
||||
#include "Track.h"
|
||||
|
||||
positionLine::positionLine( QWidget * parent ) :
|
||||
QWidget( parent )
|
||||
@@ -80,16 +80,21 @@ SongEditor::SongEditor( Song * song ) :
|
||||
m_proportionalSnap( false ),
|
||||
m_scrollBack( false ),
|
||||
m_smoothScroll( ConfigManager::inst()->value( "ui", "smoothscroll" ).toInt() ),
|
||||
m_mode(DrawMode)
|
||||
m_mode(DrawMode),
|
||||
m_origin(),
|
||||
m_scrollPos(),
|
||||
m_mousePos(),
|
||||
m_rubberBandStartTrackview(0),
|
||||
m_rubberbandStartMidipos(0),
|
||||
m_currentZoomingValue(m_zoomingModel->value()),
|
||||
m_trackHeadWidth(ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt()==1
|
||||
? DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT
|
||||
: DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_OP_WIDTH),
|
||||
m_selectRegion(false)
|
||||
{
|
||||
m_zoomingModel->setParent(this);
|
||||
m_snappingModel->setParent(this);
|
||||
// create time-line
|
||||
m_widgetWidthTotal = ConfigManager::inst()->value( "ui",
|
||||
"compacttrackbuttons" ).toInt()==1 ?
|
||||
DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT :
|
||||
DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_OP_WIDTH;
|
||||
m_timeLine = new TimeLineWidget( m_widgetWidthTotal, 32,
|
||||
m_timeLine = new TimeLineWidget( m_trackHeadWidth, 32,
|
||||
pixelsPerTact(),
|
||||
m_song->m_playPos[Song::Mode_PlaySong],
|
||||
m_currentPosition,
|
||||
@@ -232,6 +237,10 @@ SongEditor::SongEditor( Song * song ) :
|
||||
this, SLOT( scrolled( int ) ) );
|
||||
connect( m_song, SIGNAL( lengthChanged( int ) ),
|
||||
this, SLOT( updateScrollBar( int ) ) );
|
||||
connect(m_leftRightScroll, SIGNAL(valueChanged(int)),this, SLOT(updateRubberband()));
|
||||
connect(contentWidget()->verticalScrollBar(), SIGNAL(valueChanged(int)),this, SLOT(updateRubberband()));
|
||||
connect(m_timeLine, SIGNAL(selectionFinished()), this, SLOT(stopSelectRegion()));
|
||||
|
||||
|
||||
//Set up zooming model
|
||||
for( float const & zoomLevel : m_zoomLevels )
|
||||
@@ -346,6 +355,99 @@ void SongEditor::scrolled( int new_pos )
|
||||
|
||||
|
||||
|
||||
void SongEditor::selectRegionFromPixels(int xStart, int xEnd)
|
||||
{
|
||||
if (!m_selectRegion)
|
||||
{
|
||||
m_selectRegion = true;
|
||||
|
||||
//deselect all tcos
|
||||
for (auto &it : findChildren<selectableObject *>()) { it->setSelected(false); }
|
||||
|
||||
rubberBand()->setEnabled(true);
|
||||
rubberBand()->show();
|
||||
|
||||
//we save the position of scrollbars, mouse position and zooming level
|
||||
m_origin = QPoint(xStart, 0);
|
||||
m_scrollPos = QPoint(m_leftRightScroll->value(), contentWidget()->verticalScrollBar()->value());
|
||||
m_currentZoomingValue = zoomingModel()->value();
|
||||
|
||||
//calculate the song position where the mouse was clicked
|
||||
m_rubberbandStartMidipos = MidiTime((xStart - m_trackHeadWidth)
|
||||
/ pixelsPerTact() * MidiTime::ticksPerTact())
|
||||
+ m_currentPosition;
|
||||
m_rubberBandStartTrackview = 0;
|
||||
}
|
||||
//the current mouse position within the borders of song editor
|
||||
m_mousePos = QPoint(qMax(m_trackHeadWidth, qMin(xEnd, width()))
|
||||
, std::numeric_limits<int>::max());
|
||||
updateRubberband();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SongEditor::stopSelectRegion()
|
||||
{
|
||||
m_selectRegion = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SongEditor::updateRubberband()
|
||||
{
|
||||
if (rubberBandActive())
|
||||
{
|
||||
int originX = m_origin.x();
|
||||
|
||||
//take care of the zooming
|
||||
if (m_currentZoomingValue != m_zoomingModel->value())
|
||||
{
|
||||
originX = m_trackHeadWidth + (originX - m_trackHeadWidth)
|
||||
* m_zoomLevels[m_zoomingModel->value()] / m_zoomLevels[m_currentZoomingValue];
|
||||
}
|
||||
|
||||
//take care of the scrollbar position
|
||||
int hs = (m_leftRightScroll->value() - m_scrollPos.x()) * pixelsPerTact();
|
||||
int vs = contentWidget()->verticalScrollBar()->value() - m_scrollPos.y();
|
||||
|
||||
//the adjusted origin point
|
||||
QPoint origin = QPoint(qMax(originX - hs, m_trackHeadWidth), m_origin.y() - vs);
|
||||
|
||||
//paint the rubber band rect
|
||||
rubberBand()->setGeometry(QRect(origin,
|
||||
contentWidget()->mapFromParent(QPoint(m_mousePos.x(), m_mousePos.y()))
|
||||
).normalized());
|
||||
|
||||
//the index of the TrackView the mouse is hover
|
||||
int rubberBandTrackview = trackIndexFromSelectionPoint(m_mousePos.y());
|
||||
|
||||
//the miditime the mouse is hover
|
||||
MidiTime rubberbandMidipos = MidiTime((qMin(m_mousePos.x(), width()) - m_trackHeadWidth)
|
||||
/ pixelsPerTact() * MidiTime::ticksPerTact())
|
||||
+ m_currentPosition;
|
||||
|
||||
//are tcos in the rect of selection?
|
||||
for (auto &it : findChildren<selectableObject *>())
|
||||
{
|
||||
TrackContentObjectView * tco = dynamic_cast<TrackContentObjectView*>(it);
|
||||
if (tco)
|
||||
{
|
||||
auto indexOfTrackView = trackViews().indexOf(tco->getTrackView());
|
||||
bool isBeetweenRubberbandViews = indexOfTrackView >= qMin(m_rubberBandStartTrackview, rubberBandTrackview)
|
||||
&& indexOfTrackView <= qMax(m_rubberBandStartTrackview, rubberBandTrackview);
|
||||
bool isBeetweenRubberbandMidiPos = tco->getTrackContentObject()->endPosition() >= qMin(m_rubberbandStartMidipos, rubberbandMidipos)
|
||||
&& tco->getTrackContentObject()->startPosition() <= qMax(m_rubberbandStartMidipos, rubberbandMidipos);
|
||||
it->setSelected(isBeetweenRubberbandViews && isBeetweenRubberbandMidiPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SongEditor::setEditMode( EditMode mode )
|
||||
{
|
||||
m_mode = mode;
|
||||
@@ -447,7 +549,7 @@ void SongEditor::wheelEvent( QWheelEvent * we )
|
||||
z = qBound( 0, z, m_zoomingModel->size() - 1 );
|
||||
|
||||
|
||||
int x = (we->x() - m_widgetWidthTotal);
|
||||
int x = (we->x() - m_trackHeadWidth);
|
||||
// tact based on the mouse x-position where the scroll wheel was used
|
||||
int tact= x / pixelsPerTact();
|
||||
// what would be the tact in the new zoom level on the very same mouse x
|
||||
@@ -480,7 +582,7 @@ void SongEditor::wheelEvent( QWheelEvent * we )
|
||||
|
||||
|
||||
void SongEditor::closeEvent( QCloseEvent * ce )
|
||||
{
|
||||
{
|
||||
if( parentWidget() )
|
||||
{
|
||||
parentWidget()->hide();
|
||||
@@ -490,7 +592,53 @@ void SongEditor::closeEvent( QCloseEvent * ce )
|
||||
hide();
|
||||
}
|
||||
ce->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SongEditor::mousePressEvent(QMouseEvent *me)
|
||||
{
|
||||
if (allowRubberband())
|
||||
{
|
||||
//we save the position of scrollbars, mouse position and zooming level
|
||||
m_scrollPos = QPoint(m_leftRightScroll->value(), contentWidget()->verticalScrollBar()->value());
|
||||
m_origin = contentWidget()->mapFromParent(QPoint(me->pos().x(), me->pos().y()));
|
||||
m_currentZoomingValue = zoomingModel()->value();
|
||||
|
||||
//paint the rubberband
|
||||
rubberBand()->setEnabled(true);
|
||||
rubberBand()->setGeometry(QRect(m_origin, QSize()));
|
||||
rubberBand()->show();
|
||||
|
||||
//the trackView(index) and the miditime where the mouse was clicked
|
||||
m_rubberBandStartTrackview = trackIndexFromSelectionPoint(me->y());
|
||||
m_rubberbandStartMidipos = MidiTime((me->x() - m_trackHeadWidth)
|
||||
/ pixelsPerTact() * MidiTime::ticksPerTact())
|
||||
+ m_currentPosition;
|
||||
}
|
||||
QWidget::mousePressEvent(me);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SongEditor::mouseMoveEvent(QMouseEvent *me)
|
||||
{
|
||||
m_mousePos = me->pos();
|
||||
updateRubberband();
|
||||
QWidget::mouseMoveEvent(me);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SongEditor::mouseReleaseEvent(QMouseEvent *me)
|
||||
{
|
||||
rubberBand()->hide();
|
||||
rubberBand()->setEnabled(false);
|
||||
QWidget::mouseReleaseEvent(me);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -688,6 +836,7 @@ void SongEditor::zoomingChanged()
|
||||
m_song->m_playPos[Song::Mode_PlaySong].m_timeLine->
|
||||
setPixelsPerTact( pixelsPerTact() );
|
||||
realignTracks();
|
||||
updateRubberband();
|
||||
}
|
||||
|
||||
|
||||
@@ -713,6 +862,26 @@ bool SongEditor::allowRubberband() const
|
||||
|
||||
|
||||
|
||||
int SongEditor::trackIndexFromSelectionPoint(int yPos)
|
||||
{
|
||||
const TrackView * tv = trackViewAt(yPos - m_timeLine->height());
|
||||
return tv ? indexOfTrackView(tv)
|
||||
: yPos < m_timeLine->height() ? 0
|
||||
: trackViews().count();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int SongEditor::indexOfTrackView(const TrackView *tv)
|
||||
{
|
||||
return static_cast<int>(std::distance(trackViews().begin(),
|
||||
std::find(trackViews().begin(), trackViews().end(), tv)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ComboBoxModel *SongEditor::zoomingModel() const
|
||||
{
|
||||
return m_zoomingModel;
|
||||
|
||||
@@ -66,18 +66,6 @@ QVector<selectableObject *> RubberBand::selectedObjects() const
|
||||
void RubberBand::resizeEvent( QResizeEvent * _re )
|
||||
{
|
||||
QRubberBand::resizeEvent( _re );
|
||||
if( isEnabled() )
|
||||
{
|
||||
QVector<selectableObject *> so = selectableObjects();
|
||||
for( QVector<selectableObject *>::iterator it = so.begin();
|
||||
it != so.end(); ++it )
|
||||
{
|
||||
( *it )->setSelected( QRect( pos(), size() ).intersects(
|
||||
QRect( ( *it )->mapTo( parentWidget(),
|
||||
QPoint() ),
|
||||
( *it )->size() ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#cmakedefine LMMS_BUILD_WIN64
|
||||
#cmakedefine LMMS_BUILD_APPLE
|
||||
#cmakedefine LMMS_BUILD_OPENBSD
|
||||
#cmakedefine LMMS_BUILD_FREEBSD
|
||||
#cmakedefine LMMS_BUILD_HAIKU
|
||||
|
||||
#cmakedefine LMMS_HOST_X86
|
||||
|
||||
Reference in New Issue
Block a user