Merge branch 'master' into arpDownUp
This commit is contained in:
@@ -186,6 +186,7 @@ void SampleBuffer::update( bool _keep_settings )
|
||||
char * f = qstrdup( file.toUtf8().constData() );
|
||||
#endif
|
||||
int_sample_t * buf = NULL;
|
||||
sample_t * fbuf = NULL;
|
||||
ch_cnt_t channels = DEFAULT_CHANNELS;
|
||||
sample_rate_t samplerate = engine::mixer()->baseSampleRate();
|
||||
m_frames = 0;
|
||||
@@ -210,7 +211,7 @@ void SampleBuffer::update( bool _keep_settings )
|
||||
#endif
|
||||
if( m_frames == 0 )
|
||||
{
|
||||
m_frames = decodeSampleSF( f, buf, channels,
|
||||
m_frames = decodeSampleSF( f, fbuf, channels,
|
||||
samplerate );
|
||||
}
|
||||
#ifdef LMMS_HAVE_OGGVORBIS
|
||||
@@ -377,7 +378,7 @@ void SampleBuffer::normalizeSampleRate( const sample_rate_t _src_sr,
|
||||
|
||||
|
||||
f_cnt_t SampleBuffer::decodeSampleSF( const char * _f,
|
||||
int_sample_t * & _buf,
|
||||
sample_t * & _buf,
|
||||
ch_cnt_t & _channels,
|
||||
sample_rate_t & _samplerate )
|
||||
{
|
||||
@@ -385,29 +386,19 @@ f_cnt_t SampleBuffer::decodeSampleSF( const char * _f,
|
||||
SF_INFO sf_info;
|
||||
f_cnt_t frames = 0;
|
||||
bool sf_rr = false;
|
||||
sample_t * fbuf = 0;
|
||||
|
||||
if( ( snd_file = sf_open( _f, SFM_READ, &sf_info ) ) != NULL )
|
||||
{
|
||||
frames = sf_info.frames;
|
||||
|
||||
// check if float
|
||||
if ( (sf_info.format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT ) // if yes, use float format for buffer
|
||||
{
|
||||
fbuf = new sample_t[sf_info.channels * frames];
|
||||
sf_rr = sf_read_float( snd_file, fbuf, sf_info.channels * frames );
|
||||
}
|
||||
else // otherwise, use int
|
||||
{
|
||||
_buf = new int_sample_t[sf_info.channels * frames];
|
||||
sf_rr = sf_read_short( snd_file, _buf, sf_info.channels * frames );
|
||||
}
|
||||
_buf = new sample_t[sf_info.channels * frames];
|
||||
sf_rr = sf_read_float( snd_file, _buf, sf_info.channels * frames );
|
||||
|
||||
if( sf_rr < sf_info.channels * frames )
|
||||
{
|
||||
#ifdef DEBUG_LMMS
|
||||
printf( "SampleBuffer::decodeSampleSF(): could not read"
|
||||
" sample %s: %s\n", _f, sf_strerror( NULL ) );
|
||||
qDebug( "SampleBuffer::decodeSampleSF(): could not read"
|
||||
" sample %s: %s", _f, sf_strerror( NULL ) );
|
||||
#endif
|
||||
}
|
||||
_channels = sf_info.channels;
|
||||
@@ -418,19 +409,15 @@ f_cnt_t SampleBuffer::decodeSampleSF( const char * _f,
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_LMMS
|
||||
printf( "SampleBuffer::decodeSampleSF(): could not load "
|
||||
"sample %s: %s\n", _f, sf_strerror( NULL ) );
|
||||
qDebug( "SampleBuffer::decodeSampleSF(): could not load "
|
||||
"sample %s: %s", _f, sf_strerror( NULL ) );
|
||||
#endif
|
||||
}
|
||||
//write down either directly or convert i->f depending on file type
|
||||
|
||||
if ( frames > 0 && fbuf != NULL )
|
||||
if ( frames > 0 && _buf != NULL )
|
||||
{
|
||||
directFloatWrite ( fbuf, frames, _channels);
|
||||
}
|
||||
else if ( frames > 0 && _buf != NULL )
|
||||
{
|
||||
convertIntToFloat ( _buf, frames, _channels);
|
||||
directFloatWrite ( _buf, frames, _channels);
|
||||
}
|
||||
|
||||
return frames;
|
||||
@@ -610,23 +597,29 @@ f_cnt_t SampleBuffer::decodeSampleDS( const char * _f,
|
||||
bool SampleBuffer::play( sampleFrame * _ab, handleState * _state,
|
||||
const fpp_t _frames,
|
||||
const float _freq,
|
||||
const bool _looped )
|
||||
const LoopMode _loopmode )
|
||||
{
|
||||
QMutexLocker ml( &m_varLock );
|
||||
|
||||
engine::mixer()->clearAudioBuffer( _ab, _frames );
|
||||
f_cnt_t startFrame = m_startFrame;
|
||||
f_cnt_t endFrame = m_endFrame;
|
||||
f_cnt_t loopStartFrame = m_loopStartFrame;
|
||||
f_cnt_t loopEndFrame = m_loopEndFrame;
|
||||
|
||||
if( m_endFrame == 0 || _frames == 0 )
|
||||
if( endFrame == 0 || _frames == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// variable for determining if we should currently be playing backwards in a ping-pong loop
|
||||
bool is_backwards = _state->isBackwards();
|
||||
|
||||
const double freq_factor = (double) _freq / (double) m_frequency *
|
||||
m_sampleRate / engine::mixer()->processingSampleRate();
|
||||
|
||||
// calculate how many frames we have in requested pitch
|
||||
const f_cnt_t total_frames_for_current_pitch = static_cast<f_cnt_t>( (
|
||||
m_endFrame - m_startFrame ) /
|
||||
endFrame - startFrame ) /
|
||||
freq_factor );
|
||||
|
||||
if( total_frames_for_current_pitch == 0 )
|
||||
@@ -634,37 +627,36 @@ bool SampleBuffer::play( sampleFrame * _ab, handleState * _state,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// this holds the number of the first frame to play
|
||||
f_cnt_t play_frame = _state->m_frameIndex;
|
||||
if( play_frame < m_startFrame )
|
||||
|
||||
if( play_frame < startFrame )
|
||||
{
|
||||
play_frame = m_startFrame;
|
||||
play_frame = startFrame;
|
||||
}
|
||||
|
||||
// this holds the number of remaining frames in current loop
|
||||
f_cnt_t frames_for_loop;
|
||||
if( _looped )
|
||||
if( _loopmode == LoopOff )
|
||||
{
|
||||
play_frame = getLoopedIndex( play_frame );
|
||||
frames_for_loop = static_cast<f_cnt_t>(
|
||||
( m_loopEndFrame - play_frame ) /
|
||||
freq_factor );
|
||||
if( play_frame >= endFrame )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ( endFrame - play_frame ) / freq_factor == 0 ) return false;
|
||||
}
|
||||
|
||||
else if( _loopmode == LoopOn )
|
||||
{
|
||||
play_frame = getLoopedIndex( play_frame, loopStartFrame, loopEndFrame );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if( play_frame >= m_endFrame )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
frames_for_loop = static_cast<f_cnt_t>(
|
||||
( m_endFrame - play_frame ) /
|
||||
freq_factor );
|
||||
if( frames_for_loop == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
play_frame = getPingPongIndex( play_frame, loopStartFrame, loopEndFrame );
|
||||
}
|
||||
|
||||
|
||||
sampleFrame * tmp = NULL;
|
||||
|
||||
// check whether we have to change pitch...
|
||||
@@ -673,10 +665,10 @@ bool SampleBuffer::play( sampleFrame * _ab, handleState * _state,
|
||||
SRC_DATA src_data;
|
||||
// Generate output
|
||||
const f_cnt_t margin = 64;
|
||||
f_cnt_t fragment_size = (f_cnt_t)( _frames * freq_factor )
|
||||
+ margin;
|
||||
src_data.data_in = getSampleFragment( play_frame,
|
||||
fragment_size, _looped, &tmp )[0];
|
||||
f_cnt_t fragment_size = (f_cnt_t)( _frames * freq_factor ) + margin;
|
||||
src_data.data_in =
|
||||
getSampleFragment( play_frame, fragment_size, _loopmode, &tmp, &is_backwards,
|
||||
loopStartFrame, loopEndFrame, endFrame )[0];
|
||||
src_data.data_out = _ab[0];
|
||||
src_data.input_frames = fragment_size;
|
||||
src_data.output_frames = _frames;
|
||||
@@ -695,10 +687,32 @@ bool SampleBuffer::play( sampleFrame * _ab, handleState * _state,
|
||||
src_data.output_frames_gen, _frames );
|
||||
}
|
||||
// Advance
|
||||
play_frame += src_data.input_frames_used;
|
||||
if( _looped )
|
||||
switch( _loopmode )
|
||||
{
|
||||
play_frame = getLoopedIndex( play_frame );
|
||||
case LoopOff:
|
||||
play_frame += src_data.input_frames_used;
|
||||
break;
|
||||
case LoopOn:
|
||||
play_frame += src_data.input_frames_used;
|
||||
play_frame = getLoopedIndex( play_frame, loopStartFrame, loopEndFrame );
|
||||
break;
|
||||
case LoopPingPong:
|
||||
{
|
||||
f_cnt_t left = src_data.input_frames_used;
|
||||
if( _state->isBackwards() )
|
||||
{
|
||||
play_frame -= src_data.input_frames_used;
|
||||
if( play_frame < loopStartFrame )
|
||||
{
|
||||
left -= ( loopStartFrame - play_frame );
|
||||
play_frame = loopStartFrame;
|
||||
}
|
||||
else left = 0;
|
||||
}
|
||||
play_frame += left;
|
||||
play_frame = getPingPongIndex( play_frame, loopStartFrame, loopEndFrame );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -708,19 +722,43 @@ bool SampleBuffer::play( sampleFrame * _ab, handleState * _state,
|
||||
|
||||
// Generate output
|
||||
memcpy( _ab,
|
||||
getSampleFragment( play_frame, _frames, _looped, &tmp ),
|
||||
getSampleFragment( play_frame, _frames, _loopmode, &tmp, &is_backwards,
|
||||
loopStartFrame, loopEndFrame, endFrame ),
|
||||
_frames * BYTES_PER_FRAME );
|
||||
// Advance
|
||||
play_frame += _frames;
|
||||
if( _looped )
|
||||
switch( _loopmode )
|
||||
{
|
||||
play_frame = getLoopedIndex( play_frame );
|
||||
case LoopOff:
|
||||
play_frame += _frames;
|
||||
break;
|
||||
case LoopOn:
|
||||
play_frame += _frames;
|
||||
play_frame = getLoopedIndex( play_frame, loopStartFrame, loopEndFrame );
|
||||
break;
|
||||
case LoopPingPong:
|
||||
{
|
||||
f_cnt_t left = _frames;
|
||||
if( _state->isBackwards() )
|
||||
{
|
||||
play_frame -= _frames;
|
||||
if( play_frame < loopStartFrame )
|
||||
{
|
||||
left -= ( loopStartFrame - play_frame );
|
||||
play_frame = loopStartFrame;
|
||||
}
|
||||
else left = 0;
|
||||
}
|
||||
play_frame += left;
|
||||
play_frame = getPingPongIndex( play_frame, loopStartFrame, loopEndFrame );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete[] tmp;
|
||||
if( tmp != NULL ) delete[] tmp;
|
||||
|
||||
_state->m_frameIndex = play_frame;
|
||||
_state->setBackwards( is_backwards );
|
||||
_state->setFrameIndex( play_frame );
|
||||
|
||||
return true;
|
||||
|
||||
@@ -729,45 +767,104 @@ bool SampleBuffer::play( sampleFrame * _ab, handleState * _state,
|
||||
|
||||
|
||||
|
||||
sampleFrame * SampleBuffer::getSampleFragment( f_cnt_t _start,
|
||||
f_cnt_t _frames, bool _looped, sampleFrame * * _tmp ) const
|
||||
sampleFrame * SampleBuffer::getSampleFragment( f_cnt_t _index,
|
||||
f_cnt_t _frames, LoopMode _loopmode, sampleFrame * * _tmp, bool * _backwards,
|
||||
f_cnt_t _loopstart, f_cnt_t _loopend, f_cnt_t _end ) const
|
||||
{
|
||||
if( _looped )
|
||||
|
||||
if( _loopmode == LoopOff )
|
||||
{
|
||||
if( _start + _frames <= m_loopEndFrame )
|
||||
if( _index + _frames <= _end )
|
||||
{
|
||||
return m_data + _start;
|
||||
return m_data + _index;
|
||||
}
|
||||
}
|
||||
else if( _loopmode == LoopOn )
|
||||
{
|
||||
if( _index + _frames <= _loopend )
|
||||
{
|
||||
return m_data + _index;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( _start + _frames <= m_endFrame )
|
||||
{
|
||||
return m_data + _start;
|
||||
}
|
||||
if( ! *_backwards && _index + _frames < _loopend )
|
||||
return m_data + _index;
|
||||
}
|
||||
|
||||
*_tmp = new sampleFrame[_frames];
|
||||
|
||||
if( _looped )
|
||||
if( _loopmode == LoopOff )
|
||||
{
|
||||
f_cnt_t copied = m_loopEndFrame - _start;
|
||||
memcpy( *_tmp, m_data + _start, copied * BYTES_PER_FRAME );
|
||||
f_cnt_t loop_frames = m_loopEndFrame - m_loopStartFrame;
|
||||
while( _frames - copied > 0 )
|
||||
f_cnt_t available = _end - _index;
|
||||
memcpy( *_tmp, m_data + _index, available * BYTES_PER_FRAME );
|
||||
memset( *_tmp + available, 0, ( _frames - available ) *
|
||||
BYTES_PER_FRAME );
|
||||
}
|
||||
else if( _loopmode == LoopOn )
|
||||
{
|
||||
f_cnt_t copied = qMin( _frames, _loopend - _index );
|
||||
memcpy( *_tmp, m_data + _index, copied * BYTES_PER_FRAME );
|
||||
f_cnt_t loop_frames = _loopend - _loopstart;
|
||||
while( copied < _frames )
|
||||
{
|
||||
f_cnt_t todo = qMin( _frames - copied, loop_frames );
|
||||
memcpy( *_tmp + copied, m_data + m_loopStartFrame,
|
||||
todo * BYTES_PER_FRAME );
|
||||
memcpy( *_tmp + copied, m_data + _loopstart, todo * BYTES_PER_FRAME );
|
||||
copied += todo;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
f_cnt_t available = m_endFrame - _start;
|
||||
memcpy( *_tmp, m_data + _start, available * BYTES_PER_FRAME );
|
||||
memset( *_tmp + available, 0, ( _frames - available ) *
|
||||
BYTES_PER_FRAME );
|
||||
f_cnt_t pos = _index;
|
||||
bool backwards = pos < _loopstart
|
||||
? false
|
||||
: *_backwards;
|
||||
f_cnt_t copied = 0;
|
||||
|
||||
|
||||
if( backwards )
|
||||
{
|
||||
copied = qMin( _frames, pos - _loopstart );
|
||||
for( int i=0; i < copied; i++ )
|
||||
{
|
||||
(*_tmp)[i][0] = m_data[ pos - i ][0];
|
||||
(*_tmp)[i][1] = m_data[ pos - i ][1];
|
||||
}
|
||||
pos -= copied;
|
||||
if( pos == _loopstart ) backwards = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
copied = qMin( _frames, _loopend - pos );
|
||||
memcpy( *_tmp, m_data + pos, copied * BYTES_PER_FRAME );
|
||||
pos += copied;
|
||||
if( pos == _loopend ) backwards = true;
|
||||
}
|
||||
|
||||
while( copied < _frames )
|
||||
{
|
||||
if( backwards )
|
||||
{
|
||||
f_cnt_t todo = qMin( _frames - copied, pos - _loopstart );
|
||||
for ( int i=0; i < todo; i++ )
|
||||
{
|
||||
(*_tmp)[ copied + i ][0] = m_data[ pos - i ][0];
|
||||
(*_tmp)[ copied + i ][1] = m_data[ pos - i ][1];
|
||||
}
|
||||
pos -= todo;
|
||||
copied += todo;
|
||||
if( pos <= _loopstart ) backwards = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_cnt_t todo = qMin( _frames - copied, _loopend - pos );
|
||||
memcpy( *_tmp + copied, m_data + pos, todo * BYTES_PER_FRAME );
|
||||
pos += todo;
|
||||
copied += todo;
|
||||
if( pos >= _loopend ) backwards = true;
|
||||
}
|
||||
}
|
||||
*_backwards = backwards;
|
||||
}
|
||||
|
||||
return *_tmp;
|
||||
@@ -776,17 +873,30 @@ sampleFrame * SampleBuffer::getSampleFragment( f_cnt_t _start,
|
||||
|
||||
|
||||
|
||||
f_cnt_t SampleBuffer::getLoopedIndex( f_cnt_t _index ) const
|
||||
f_cnt_t SampleBuffer::getLoopedIndex( f_cnt_t _index, f_cnt_t _startf, f_cnt_t _endf ) const
|
||||
{
|
||||
if( _index < m_loopEndFrame )
|
||||
if( _index < _endf )
|
||||
{
|
||||
return _index;
|
||||
}
|
||||
return m_loopStartFrame + ( _index - m_loopStartFrame )
|
||||
% ( m_loopEndFrame - m_loopStartFrame );
|
||||
return _startf + ( _index - _startf )
|
||||
% ( _endf - _startf );
|
||||
}
|
||||
|
||||
|
||||
f_cnt_t SampleBuffer::getPingPongIndex( f_cnt_t _index, f_cnt_t _startf, f_cnt_t _endf ) const
|
||||
{
|
||||
if( _index < _endf )
|
||||
{
|
||||
return _index;
|
||||
}
|
||||
const f_cnt_t looplen = _endf - _startf;
|
||||
const f_cnt_t looppos = ( _index - _endf ) % ( looplen*2 );
|
||||
|
||||
return ( looppos < looplen )
|
||||
? _endf - looppos
|
||||
: _startf + ( looppos - looplen );
|
||||
}
|
||||
|
||||
|
||||
void SampleBuffer::visualize( QPainter & _p, const QRect & _dr,
|
||||
@@ -915,19 +1025,19 @@ QString SampleBuffer::openAndSetWaveformFile()
|
||||
{
|
||||
m_audioFile = configManager::inst()->factorySamplesDir() + "waveforms/10saw.flac";
|
||||
}
|
||||
|
||||
|
||||
QString fileName = this->openAudioFile();
|
||||
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
this->setAudioFile( fileName );
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
m_audioFile = "";
|
||||
}
|
||||
|
||||
return fileName;
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
@@ -1328,7 +1438,8 @@ QString SampleBuffer::tryToMakeAbsolute( const QString & _file )
|
||||
|
||||
SampleBuffer::handleState::handleState( bool _varying_pitch ) :
|
||||
m_frameIndex( 0 ),
|
||||
m_varyingPitch( _varying_pitch )
|
||||
m_varyingPitch( _varying_pitch ),
|
||||
m_isBackwards( false )
|
||||
{
|
||||
int error;
|
||||
if( ( m_resamplingData = src_new(/*
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
|
||||
QPixmap * timeLine::s_timeLinePixmap = NULL;
|
||||
QPixmap * timeLine::s_posMarkerPixmap = NULL;
|
||||
QPixmap * timeLine::s_loopPointPixmap = NULL;
|
||||
|
||||
QPixmap * timeLine::s_loopPointBeginPixmap = NULL;
|
||||
QPixmap * timeLine::s_loopPointEndPixmap = NULL;
|
||||
|
||||
timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt,
|
||||
song::playPos & _pos, const MidiTime & _begin,
|
||||
@@ -81,10 +81,15 @@ timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt,
|
||||
s_posMarkerPixmap = new QPixmap( embed::getIconPixmap(
|
||||
"playpos_marker" ) );
|
||||
}
|
||||
if( s_loopPointPixmap == NULL )
|
||||
if( s_loopPointBeginPixmap == NULL )
|
||||
{
|
||||
s_loopPointPixmap = new QPixmap( embed::getIconPixmap(
|
||||
"loop_point" ) );
|
||||
s_loopPointBeginPixmap = new QPixmap( embed::getIconPixmap(
|
||||
"loop_point_b" ) );
|
||||
}
|
||||
if( s_loopPointEndPixmap == NULL )
|
||||
{
|
||||
s_loopPointEndPixmap = new QPixmap( embed::getIconPixmap(
|
||||
"loop_point_e" ) );
|
||||
}
|
||||
|
||||
setAttribute( Qt::WA_OpaquePaintEvent, true );
|
||||
@@ -235,8 +240,8 @@ void timeLine::paintEvent( QPaintEvent * )
|
||||
p.setPen( QColor( 0, 0, 0 ) );
|
||||
|
||||
p.setOpacity( loopPointsEnabled() ? 0.9 : 0.2 );
|
||||
p.drawPixmap( markerX( loopBegin() )+2, 2, *s_loopPointPixmap );
|
||||
p.drawPixmap( markerX( loopEnd() )+2, 2, *s_loopPointPixmap );
|
||||
p.drawPixmap( markerX( loopBegin() )+2, 2, *s_loopPointBeginPixmap );
|
||||
p.drawPixmap( markerX( loopEnd() )+2, 2, *s_loopPointEndPixmap );
|
||||
p.setOpacity( 1.0 );
|
||||
|
||||
|
||||
|
||||
@@ -249,7 +249,9 @@ trackContentObjectView::trackContentObjectView( trackContentObject * _tco,
|
||||
m_action( NoAction ),
|
||||
m_autoResize( false ),
|
||||
m_initialMouseX( 0 ),
|
||||
m_hint( NULL )
|
||||
m_hint( NULL ),
|
||||
m_fgColor( NULL ),
|
||||
m_textColor( NULL )
|
||||
{
|
||||
if( s_textFloat == NULL )
|
||||
{
|
||||
@@ -275,6 +277,9 @@ trackContentObjectView::trackContentObjectView( trackContentObject * _tco,
|
||||
connect( m_tco, SIGNAL( destroyedTCO() ), this, SLOT( close() ) );
|
||||
setModel( m_tco );
|
||||
|
||||
setFgColor( QColor( 0,0,0 ) );
|
||||
setTextColor( QColor( 0,0,0 ) );
|
||||
|
||||
m_trackView->getTrackContentWidget()->addTCOView( this );
|
||||
}
|
||||
|
||||
@@ -314,6 +319,23 @@ bool trackContentObjectView::fixedTCOs()
|
||||
|
||||
|
||||
|
||||
// qproperty access functions, to be inherited & used by TCOviews
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentObjectView::fgColor() const
|
||||
{ if( m_fgColor ) return *m_fgColor; else return QColor( 0,0,0 ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentObjectView::textColor() const
|
||||
{ if( m_textColor ) return *m_textColor; else return QColor( 0,0,0 ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentObjectView::setFgColor( const QColor & _c )
|
||||
{ if( m_fgColor ) *m_fgColor = _c; else m_fgColor = new QColor( 0,0,0 ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentObjectView::setTextColor( const QColor & _c )
|
||||
{ if( m_textColor ) *m_textColor = _c; else m_textColor = new QColor( 0,0,0 ); }
|
||||
|
||||
|
||||
/*! \brief Close a trackContentObjectView
|
||||
*
|
||||
@@ -817,7 +839,14 @@ void trackContentObjectView::setAutoResizeEnabled( bool _e )
|
||||
*/
|
||||
trackContentWidget::trackContentWidget( trackView * _parent ) :
|
||||
QWidget( _parent ),
|
||||
m_trackView( _parent )
|
||||
m_trackView( _parent ),
|
||||
m_darkerColor1( NULL ),
|
||||
m_darkerColor2( NULL ),
|
||||
m_darkerColor3( NULL ),
|
||||
m_lighterColor1( NULL ),
|
||||
m_lighterColor2( NULL ),
|
||||
m_lighterColor3( NULL ),
|
||||
m_gradMidPoint( 0.0f )
|
||||
{
|
||||
setAcceptDrops( true );
|
||||
|
||||
@@ -825,6 +854,16 @@ trackContentWidget::trackContentWidget( trackView * _parent ) :
|
||||
SIGNAL( positionChanged( const MidiTime & ) ),
|
||||
this, SLOT( changePosition( const MidiTime & ) ) );
|
||||
|
||||
//initialize qproperties
|
||||
setDarkerColor1( QColor( 0, 0, 0 ) );
|
||||
setDarkerColor2( QColor( 0, 0, 0 ) );
|
||||
setDarkerColor3( QColor( 0, 0, 0 ) );
|
||||
setLighterColor1( QColor( 0, 0, 0 ) );
|
||||
setLighterColor2( QColor( 0, 0, 0 ) );
|
||||
setLighterColor3( QColor( 0, 0, 0 ) );
|
||||
|
||||
setStyle( QApplication::style() );
|
||||
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
@@ -856,15 +895,15 @@ void trackContentWidget::updateBackground()
|
||||
QPainter pmp( &m_background );
|
||||
|
||||
QLinearGradient grad( 0,0, 0, h );
|
||||
grad.setColorAt( 0.0, QColor( 50, 50, 50 ) );
|
||||
grad.setColorAt( 0.33, QColor( 20, 20, 20 ) );
|
||||
grad.setColorAt( 1.0, QColor( 15, 15, 15 ) );
|
||||
grad.setColorAt( 0.0, darkerColor1() );
|
||||
grad.setColorAt( gradMidPoint(), darkerColor2() );
|
||||
grad.setColorAt( 1.0, darkerColor3() );
|
||||
pmp.fillRect( 0, 0, w, h, grad );
|
||||
|
||||
QLinearGradient grad2( 0,0, 0, h );
|
||||
grad2.setColorAt( 0.0, QColor( 50, 50, 50 ) );
|
||||
grad2.setColorAt( 0.33, QColor( 40, 40, 40 ) );
|
||||
grad2.setColorAt( 1.0, QColor( 30, 30, 30 ) );
|
||||
grad2.setColorAt( 0.0, lighterColor1() );
|
||||
grad2.setColorAt( gradMidPoint(), lighterColor2() );
|
||||
grad2.setColorAt( 1.0, lighterColor3() );
|
||||
pmp.fillRect( w, 0, w , h, grad2 );
|
||||
|
||||
// draw lines
|
||||
@@ -1195,6 +1234,62 @@ MidiTime trackContentWidget::endPosition( const MidiTime & _pos_start )
|
||||
}
|
||||
|
||||
|
||||
// qproperty access methods
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::darkerColor1() const
|
||||
{ if( m_darkerColor1 ) return *m_darkerColor1; else return QColor( 0, 0, 0 ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::darkerColor2() const
|
||||
{ if( m_darkerColor2 ) return *m_darkerColor2; else return QColor( 0, 0, 0 ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::darkerColor3() const
|
||||
{ if( m_darkerColor3 ) return *m_darkerColor3; else return QColor( 0, 0, 0 ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::lighterColor1() const
|
||||
{ if( m_lighterColor1 ) return *m_lighterColor1; else return QColor( 0, 0, 0 ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::lighterColor2() const
|
||||
{ if( m_lighterColor2 ) return *m_lighterColor2; else return QColor( 0, 0, 0 ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::lighterColor3() const
|
||||
{ if( m_lighterColor3 ) return *m_lighterColor3; else return QColor( 0, 0, 0 ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setDarkerColor1( const QColor & _c )
|
||||
{ if( m_darkerColor1 ) *m_darkerColor1 = _c; else m_darkerColor1 = new QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setDarkerColor2( const QColor & _c )
|
||||
{ if( m_darkerColor2 ) *m_darkerColor2 = _c; else m_darkerColor2 = new QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setDarkerColor3( const QColor & _c )
|
||||
{ if( m_darkerColor3 ) *m_darkerColor3 = _c; else m_darkerColor3 = new QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setLighterColor1( const QColor & _c )
|
||||
{ if( m_lighterColor1 ) *m_lighterColor1 = _c; else m_lighterColor1 = new QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setLighterColor2( const QColor & _c )
|
||||
{ if( m_lighterColor2 ) *m_lighterColor2 = _c; else m_lighterColor2 = new QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setLighterColor3( const QColor & _c )
|
||||
{ if( m_lighterColor3 ) *m_lighterColor3 = _c; else m_lighterColor3 = new QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
float trackContentWidget::gradMidPoint() const
|
||||
{ return m_gradMidPoint; }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setGradMidPoint( float _g )
|
||||
{ m_gradMidPoint = _g; }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -273,8 +273,9 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
|
||||
|
||||
QLinearGradient lin2grad( 0, min, 0, max );
|
||||
|
||||
lin2grad.setColorAt( 1, c.lighter( 200 ) );
|
||||
lin2grad.setColorAt( 0, c );
|
||||
lin2grad.setColorAt( 1, fgColor().lighter( 150 ) );
|
||||
lin2grad.setColorAt( 0.5, fgColor() );
|
||||
lin2grad.setColorAt( 0, fgColor().darker( 150 ) );
|
||||
|
||||
for( AutomationPattern::timeMap::const_iterator it =
|
||||
m_pat->getTimeMap().begin();
|
||||
@@ -313,7 +314,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
|
||||
|
||||
QColor text_color = ( m_pat->isMuted() || m_pat->getTrack()->isMuted() )
|
||||
? QColor( 30, 30, 30 )
|
||||
: QColor( 255, 255, 255 );
|
||||
: textColor();
|
||||
|
||||
p.setPen( QColor( 0, 0, 0 ) );
|
||||
p.drawText( 4, p.fontMetrics().height()+1, m_pat->name() );
|
||||
|
||||
@@ -71,15 +71,15 @@ FxMixerView::FxMixerView() :
|
||||
|
||||
// Channel area
|
||||
m_channelAreaWidget = new QWidget;
|
||||
chLayout = new QHBoxLayout(m_channelAreaWidget);
|
||||
chLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
||||
chLayout = new QHBoxLayout( m_channelAreaWidget );
|
||||
chLayout->setSizeConstraint( QLayout::SetMinimumSize );
|
||||
chLayout->setSpacing( 0 );
|
||||
chLayout->setMargin( 0 );
|
||||
m_channelAreaWidget->setLayout(chLayout);
|
||||
|
||||
// add master channel
|
||||
m_fxChannelViews.resize(m->numChannels());
|
||||
m_fxChannelViews[0] = new FxChannelView(this, this, 0);
|
||||
m_fxChannelViews.resize( m->numChannels() );
|
||||
m_fxChannelViews[0] = new FxChannelView( this, this, 0 );
|
||||
|
||||
FxChannelView * masterView = m_fxChannelViews[0];
|
||||
ml->addWidget( masterView->m_fxLine, 0, Qt::AlignTop );
|
||||
@@ -90,7 +90,7 @@ FxMixerView::FxMixerView() :
|
||||
for( int i = 1; i < m_fxChannelViews.size(); ++i )
|
||||
{
|
||||
m_fxChannelViews[i] = new FxChannelView(m_channelAreaWidget, this, i);
|
||||
chLayout->addWidget(m_fxChannelViews[i]->m_fxLine);
|
||||
chLayout->addWidget( m_fxChannelViews[i]->m_fxLine );
|
||||
}
|
||||
|
||||
// add the scrolling section to the main layout
|
||||
@@ -98,22 +98,22 @@ FxMixerView::FxMixerView() :
|
||||
class ChannelArea : public QScrollArea
|
||||
{
|
||||
public:
|
||||
ChannelArea(QWidget * parent, FxMixerView * mv) :
|
||||
QScrollArea(parent), m_mv(mv) {}
|
||||
ChannelArea( QWidget * parent, FxMixerView * mv ) :
|
||||
QScrollArea( parent ), m_mv( mv ) {}
|
||||
~ChannelArea() {}
|
||||
virtual void keyPressEvent(QKeyEvent * e)
|
||||
virtual void keyPressEvent( QKeyEvent * e )
|
||||
{
|
||||
m_mv->keyPressEvent(e);
|
||||
m_mv->keyPressEvent( e );
|
||||
}
|
||||
private:
|
||||
FxMixerView * m_mv;
|
||||
};
|
||||
channelArea = new ChannelArea(this, this);
|
||||
channelArea->setWidget(m_channelAreaWidget);
|
||||
channelArea = new ChannelArea( this, this );
|
||||
channelArea->setWidget( m_channelAreaWidget );
|
||||
channelArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
channelArea->setFrameStyle( QFrame::NoFrame );
|
||||
channelArea->setMinimumWidth( fxLineSize.width() * 6 );
|
||||
channelArea->setFixedHeight( fxLineSize.height() +
|
||||
channelArea->setFixedHeight( fxLineSize.height() +
|
||||
style()->pixelMetric( QStyle::PM_ScrollBarExtent ) );
|
||||
ml->addWidget(channelArea);
|
||||
|
||||
@@ -124,10 +124,12 @@ FxMixerView::FxMixerView() :
|
||||
connect( newChannelBtn, SIGNAL(clicked()), this, SLOT(addNewChannel()));
|
||||
ml->addWidget( newChannelBtn, 0, Qt::AlignTop );
|
||||
|
||||
|
||||
|
||||
// Create EffectRack and set initial index to master channel
|
||||
m_rackView = new EffectRackView( &m->m_fxChannels[0]->m_fxChain, this );
|
||||
m_rackView->setFixedSize( 245, fxLineSize.height() );
|
||||
ml->addWidget( m_rackView, 0, Qt::AlignTop );
|
||||
|
||||
setCurrentFxLine( m_fxChannelViews[0]->m_fxLine );
|
||||
|
||||
setLayout( ml );
|
||||
@@ -344,7 +346,7 @@ void FxMixerView::deleteChannel(int index)
|
||||
|
||||
|
||||
|
||||
void FxMixerView::moveChannelLeft(int index)
|
||||
void FxMixerView::moveChannelLeft(int index)
|
||||
{
|
||||
// can't move master or first channel left or last channel right
|
||||
if( index <= 1 || index >= m_fxChannelViews.size() ) return;
|
||||
|
||||
@@ -225,6 +225,7 @@ bool fileBrowser::filterItems( QTreeWidgetItem * _item, const QString & _filter
|
||||
|
||||
void fileBrowser::reloadTree( void )
|
||||
{
|
||||
const QString text = m_filterEdit->text();
|
||||
m_filterEdit->clear();
|
||||
m_l->clear();
|
||||
QStringList paths = m_directories.split( '*' );
|
||||
@@ -232,6 +233,8 @@ void fileBrowser::reloadTree( void )
|
||||
{
|
||||
addItems( *it );
|
||||
}
|
||||
m_filterEdit->setText( text );
|
||||
filterItems( text );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ FxLine::FxLine( QWidget * _parent, FxMixerView * _mv, int _channelIndex) :
|
||||
setCursor( QCursor( embed::getIconPixmap( "hand" ), 0, 0 ) );
|
||||
|
||||
// mixer sends knob
|
||||
m_sendKnob = new knob(0, this, tr("Channel send amount"));
|
||||
m_sendKnob->move(0, 22);
|
||||
m_sendKnob = new knob( knobBright_26, this, tr("Channel send amount") );
|
||||
m_sendKnob->move(3, 22);
|
||||
m_sendKnob->setVisible(false);
|
||||
|
||||
// send button indicator
|
||||
@@ -59,7 +59,7 @@ FxLine::FxLine( QWidget * _parent, FxMixerView * _mv, int _channelIndex) :
|
||||
// channel number
|
||||
m_lcd = new LcdWidget( 2, this );
|
||||
m_lcd->setValue( m_channelIndex );
|
||||
m_lcd->move( 2, 58 );
|
||||
m_lcd->move( 4, 58 );
|
||||
m_lcd->setMarginWidth( 1 );
|
||||
}
|
||||
|
||||
|
||||
@@ -358,7 +358,7 @@ void SampleTCOView::paintEvent( QPaintEvent * _pe )
|
||||
}
|
||||
else
|
||||
{
|
||||
p.setPen( c.lighter( 200 ) );
|
||||
p.setPen( fgColor() );
|
||||
}
|
||||
QRect r = QRect( 1, 1,
|
||||
qMax( static_cast<int>( m_tco->sampleLength() *
|
||||
@@ -383,10 +383,10 @@ void SampleTCOView::paintEvent( QPaintEvent * _pe )
|
||||
|
||||
p.setPen( QColor( 0, 0, 0 ) );
|
||||
p.drawText( 10, p.fontMetrics().height()+1, "Rec" );
|
||||
p.setPen( QColor( 255, 60, 60 ) );
|
||||
p.setPen( textColor() );
|
||||
p.drawText( 9, p.fontMetrics().height(), "Rec" );
|
||||
|
||||
p.setBrush( QBrush( QColor( 255, 60, 60 ) ) );
|
||||
p.setBrush( QBrush( textColor() ) );
|
||||
p.drawEllipse( 4, 5, 4, 4 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ void bbTCOView::paintEvent( QPaintEvent * )
|
||||
|
||||
p.setPen( QColor( 0, 0, 0 ) );
|
||||
p.drawText( 4, p.fontMetrics().height()+1, m_bbTCO->name() );
|
||||
p.setPen( QColor( 255, 255, 255 ) );
|
||||
p.setPen( textColor() );
|
||||
p.drawText( 3, p.fontMetrics().height(), m_bbTCO->name() );
|
||||
|
||||
if( m_bbTCO->isMuted() )
|
||||
|
||||
@@ -1019,7 +1019,7 @@ void patternView::paintEvent( QPaintEvent * )
|
||||
}
|
||||
else
|
||||
{
|
||||
p.setPen( QColor( 255, 255, 255 ) ); /// \todo make this a qproperty
|
||||
p.setPen( fgColor() );
|
||||
}
|
||||
|
||||
// scan through all the notes and draw them on the pattern
|
||||
@@ -1133,7 +1133,7 @@ void patternView::paintEvent( QPaintEvent * )
|
||||
|
||||
QColor text_color = ( m_pat->isMuted() || m_pat->getTrack()->isMuted() )
|
||||
? QColor( 30, 30, 30 )
|
||||
: QColor( 255, 255, 255 );
|
||||
: textColor();
|
||||
|
||||
if( m_pat->name() != m_pat->instrumentTrack()->name() )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user