fixed modified project indicator and scrolling
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@619 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -25,37 +25,35 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QPainter>
|
||||
#include "bb_editor.h"
|
||||
|
||||
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtGui/QMdiArea>
|
||||
#include <QtGui/QPainter>
|
||||
|
||||
|
||||
#include "bb_editor.h"
|
||||
#include "song_editor.h"
|
||||
#include "bb_track.h"
|
||||
#include "combobox.h"
|
||||
#include "embed.h"
|
||||
#include "engine.h"
|
||||
#include "tool_button.h"
|
||||
#include "track_container.h"
|
||||
#include "bb_track.h"
|
||||
#include "name_label.h"
|
||||
#include "templates.h"
|
||||
#include "debug.h"
|
||||
#include "tooltip.h"
|
||||
#include "combobox.h"
|
||||
#include "main_window.h"
|
||||
|
||||
|
||||
const int BBE_PPT = 192;
|
||||
#include "name_label.h"
|
||||
#include "song_editor.h"
|
||||
#include "templates.h"
|
||||
#include "tool_button.h"
|
||||
#include "tooltip.h"
|
||||
#include "track_container.h"
|
||||
|
||||
|
||||
|
||||
|
||||
bbEditor::bbEditor( void )
|
||||
bbEditor::bbEditor( void ) :
|
||||
m_currentBB( -1 )
|
||||
{
|
||||
// create toolbar
|
||||
m_toolBar = new QWidget( this );
|
||||
m_toolBar = new QWidget;
|
||||
m_toolBar->setFixedHeight( 32 );
|
||||
m_toolBar->move( 0, 0 );
|
||||
m_toolBar->setAutoFillBackground( TRUE );
|
||||
@@ -63,6 +61,7 @@ bbEditor::bbEditor( void )
|
||||
pal.setBrush( m_toolBar->backgroundRole(),
|
||||
embed::getIconPixmap( "toolbar_bg" ) );
|
||||
m_toolBar->setPalette( pal );
|
||||
static_cast<QVBoxLayout *>( layout() )->insertWidget( 0, m_toolBar );
|
||||
|
||||
QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar );
|
||||
tb_layout->setMargin( 0 );
|
||||
@@ -70,12 +69,9 @@ bbEditor::bbEditor( void )
|
||||
|
||||
setWindowIcon( embed::getIconPixmap( "bb_track" ) );
|
||||
setWindowTitle( tr( "Beat+Baseline Editor" ) );
|
||||
setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH +
|
||||
BBE_PPT + 2 * TCO_BORDER_WIDTH +
|
||||
DEFAULT_SCROLLBAR_SIZE );
|
||||
|
||||
containerWidget()->move( 0, 32 );
|
||||
setPixelsPerTact( BBE_PPT );
|
||||
// TODO: Use style sheet
|
||||
setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH
|
||||
+ 2 * TCO_BORDER_WIDTH + 192 );
|
||||
|
||||
|
||||
m_playButton = new toolButton( embed::getIconPixmap( "play" ),
|
||||
@@ -123,6 +119,9 @@ bbEditor::bbEditor( void )
|
||||
if( engine::getMainWindow()->workspace() != NULL )
|
||||
{
|
||||
engine::getMainWindow()->workspace()->addSubWindow( this );
|
||||
parentWidget()->setAttribute( Qt::WA_DeleteOnClose, FALSE );
|
||||
parentWidget()->layout()->setSizeConstraint(
|
||||
QLayout::SetMinimumSize );
|
||||
}
|
||||
|
||||
QWidget * w = ( parentWidget() != NULL ) ? parentWidget() : this;
|
||||
@@ -150,23 +149,17 @@ bbEditor::~bbEditor()
|
||||
|
||||
|
||||
|
||||
int bbEditor::currentBB( void ) const
|
||||
{
|
||||
return( static_cast<int>( currentPosition().getTact() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void bbEditor::setCurrentBB( int _bb )
|
||||
{
|
||||
m_currentBB = _bb;
|
||||
|
||||
if( m_bbComboBox->value() != _bb )
|
||||
{
|
||||
m_bbComboBox->setValue( _bb );
|
||||
}
|
||||
|
||||
// first make sure, all channels have a TCO at current BB
|
||||
createTCOsForBB( static_cast<int>( _bb ) );
|
||||
createTCOsForBB( _bb );
|
||||
|
||||
realignTracks();
|
||||
|
||||
@@ -177,8 +170,7 @@ void bbEditor::setCurrentBB( int _bb )
|
||||
bbTrack::findBBTrack( i )->trackLabel()->update();
|
||||
}
|
||||
|
||||
emit positionChanged( m_currentPosition = midiTime(
|
||||
static_cast<int>( _bb ), 0 ) );
|
||||
emit positionChanged( NULL );
|
||||
}
|
||||
|
||||
|
||||
@@ -188,13 +180,10 @@ tact bbEditor::lengthOfBB( int _bb )
|
||||
{
|
||||
midiTime max_length;
|
||||
|
||||
trackVector tv = tracks();
|
||||
for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it )
|
||||
QList<track *> tl = tracks();
|
||||
for( int i = 0; i < tl.size(); ++i )
|
||||
{
|
||||
trackContentObject * tco = ( *it )->getTCO( _bb );
|
||||
#ifdef LMMS_DEBUG
|
||||
assert( tco != NULL );
|
||||
#endif
|
||||
trackContentObject * tco = tl[i]->getTCO( _bb );
|
||||
max_length = tMax( max_length, tco->length() );
|
||||
}
|
||||
if( max_length.getTact64th() == 0 )
|
||||
@@ -220,11 +209,10 @@ bool FASTCALL bbEditor::play( midiTime _start, fpp_t _frames,
|
||||
|
||||
_start = ( _start.getTact() % lengthOfBB( _tco_num ) ) * 64 +
|
||||
_start.getTact64th();
|
||||
trackVector tv = tracks();
|
||||
for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it )
|
||||
QList<track *> tl = tracks();
|
||||
for( int i = 0; i < tl.size(); ++i )
|
||||
{
|
||||
if( ( *it )->play( _start, _frames, _offset,
|
||||
_tco_num ) == TRUE )
|
||||
if( tl[i]->play( _start, _frames, _offset, _tco_num ) == TRUE )
|
||||
{
|
||||
played_a_note = TRUE;
|
||||
}
|
||||
@@ -246,15 +234,15 @@ int bbEditor::numOfBBs( void ) const
|
||||
|
||||
void bbEditor::removeBB( int _bb )
|
||||
{
|
||||
trackVector tv = tracks();
|
||||
for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it )
|
||||
QList<track *> tl = tracks();
|
||||
for( int i = 0; i < tl.size(); ++i )
|
||||
{
|
||||
( *it )->removeTCO( _bb );
|
||||
( *it )->getTrackContentWidget()->removeTact( _bb * 64 );
|
||||
tl[i]->removeTCO( _bb );
|
||||
tl[i]->getTrackContentWidget()->removeTact( _bb * 64 );
|
||||
}
|
||||
if( _bb <= currentBB() )
|
||||
if( _bb <= m_currentBB )
|
||||
{
|
||||
setCurrentBB( tMax( (int)currentBB() - 1, 0 ) );
|
||||
setCurrentBB( tMax( m_currentBB - 1, 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +253,7 @@ void bbEditor::updateBBTrack( trackContentObject * _tco )
|
||||
bbTrack * t = bbTrack::findBBTrack( _tco->startPosition() / 64 );
|
||||
if( t != NULL )
|
||||
{
|
||||
t->getTrackContentWidget()->updateTCOs();
|
||||
t->getTrackContentWidget()->update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,8 +265,6 @@ void bbEditor::updateComboBox( void )
|
||||
disconnect( m_bbComboBox, SIGNAL( valueChanged( int ) ),
|
||||
this, SLOT( setCurrentBB( int ) ) );
|
||||
|
||||
int current_bb = currentBB();
|
||||
|
||||
m_bbComboBox->clear();
|
||||
|
||||
for( int i = 0; i < numOfBBs(); ++i )
|
||||
@@ -287,7 +273,7 @@ void bbEditor::updateComboBox( void )
|
||||
m_bbComboBox->addItem( bbt->trackLabel()->text(),
|
||||
bbt->trackLabel()->pixmap() );
|
||||
}
|
||||
m_bbComboBox->setValue( current_bb );
|
||||
m_bbComboBox->setValue( m_currentBB );
|
||||
|
||||
connect( m_bbComboBox, SIGNAL( valueChanged( int ) ),
|
||||
this, SLOT( setCurrentBB( int ) ) );
|
||||
@@ -296,24 +282,6 @@ void bbEditor::updateComboBox( void )
|
||||
|
||||
|
||||
|
||||
// close-handler for bb-editor-window because closing of bb-editor isn't allowed
|
||||
// instead of closing it's being hidden
|
||||
void bbEditor::closeEvent( QCloseEvent * _ce )
|
||||
{
|
||||
if( parentWidget() )
|
||||
{
|
||||
parentWidget()->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
hide();
|
||||
}
|
||||
_ce->ignore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void bbEditor::keyPressEvent( QKeyEvent * _ke )
|
||||
{
|
||||
if ( _ke->key() == Qt::Key_Space )
|
||||
@@ -329,16 +297,16 @@ void bbEditor::keyPressEvent( QKeyEvent * _ke )
|
||||
}
|
||||
else if ( _ke->key() == Qt::Key_Plus )
|
||||
{
|
||||
if( currentBB() + 1 < numOfBBs() )
|
||||
if( m_currentBB + 1 < numOfBBs() )
|
||||
{
|
||||
setCurrentBB( currentBB() + 1 );
|
||||
setCurrentBB( m_currentBB + 1 );
|
||||
}
|
||||
}
|
||||
else if ( _ke->key() == Qt::Key_Minus )
|
||||
{
|
||||
if( currentBB() > 0 )
|
||||
if( m_currentBB > 0 )
|
||||
{
|
||||
setCurrentBB( currentBB() - 1 );
|
||||
setCurrentBB( m_currentBB - 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -352,28 +320,6 @@ void bbEditor::keyPressEvent( QKeyEvent * _ke )
|
||||
|
||||
|
||||
|
||||
void bbEditor::resizeEvent( QResizeEvent * _re )
|
||||
{
|
||||
setPixelsPerTact( width() - ( TRACK_OP_WIDTH +
|
||||
DEFAULT_SETTINGS_WIDGET_WIDTH + 2 *
|
||||
TCO_BORDER_WIDTH +
|
||||
DEFAULT_SCROLLBAR_SIZE ) );
|
||||
trackContainer::resizeEvent( _re );
|
||||
m_toolBar->setFixedWidth( width() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QRect bbEditor::scrollAreaRect( void ) const
|
||||
{
|
||||
return( QRect( 0, 0, (int) pixelsPerTact(),
|
||||
height() - m_toolBar->height() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void bbEditor::play( void )
|
||||
{
|
||||
if( engine::getSongEditor()->playing() )
|
||||
@@ -455,14 +401,14 @@ void bbEditor::createTCOsForBB( int _bb )
|
||||
return;
|
||||
}
|
||||
|
||||
trackVector tv = tracks();
|
||||
for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it )
|
||||
QList<track *> tl = tracks();
|
||||
for( int i = 0; i < tl.size(); ++i )
|
||||
{
|
||||
while( ( *it )->numOfTCOs() < _bb + 1 )
|
||||
while( tl[i]->numOfTCOs() < _bb + 1 )
|
||||
{
|
||||
midiTime position = midiTime( ( *it )->numOfTCOs(), 0 );
|
||||
trackContentObject * tco = ( *it )->addTCO(
|
||||
( *it )->createTCO( position ) );
|
||||
midiTime position = midiTime( tl[i]->numOfTCOs(), 0 );
|
||||
trackContentObject * tco = tl[i]->addTCO(
|
||||
tl[i]->createTCO( position ) );
|
||||
tco->movePosition( position );
|
||||
tco->changeLength( midiTime( 1, 0 ) );
|
||||
}
|
||||
@@ -474,10 +420,10 @@ void bbEditor::createTCOsForBB( int _bb )
|
||||
|
||||
void bbEditor::swapBB( int _bb1, int _bb2 )
|
||||
{
|
||||
trackVector tv = tracks();
|
||||
for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it )
|
||||
QList<track *> tl = tracks();
|
||||
for( int i = 0; i < tl.size(); ++i )
|
||||
{
|
||||
( *it )->swapPositionOfTCOs( _bb1, _bb2 );
|
||||
tl[i]->swapPositionOfTCOs( _bb1, _bb2 );
|
||||
}
|
||||
updateComboBox();
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ void listView::activateListItem( QTreeWidgetItem * _item, int _column )
|
||||
}
|
||||
else if( f->type() == fileItem::PROJECT_FILE )
|
||||
{
|
||||
if( engine::getSongEditor()->mayChangeProject() )
|
||||
if( engine::getMainWindow()->mayChangeProject() )
|
||||
{
|
||||
engine::getSongEditor()->loadProject( f->fullName() );
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QDesktopServices>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QMdiArea>
|
||||
#include <QtGui/QMdiSubWindow>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QSplashScreen>
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QtGui/QMdiArea>
|
||||
#include <QtGui/QMdiSubWindow>
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -76,7 +76,8 @@ mainWindow::mainWindow( void ) :
|
||||
m_workspace( NULL ),
|
||||
m_templatesMenu( NULL ),
|
||||
m_recentlyOpenedProjectsMenu( NULL ),
|
||||
m_tools_menu( NULL )
|
||||
m_tools_menu( NULL ),
|
||||
m_modified( FALSE )
|
||||
{
|
||||
setAttribute( Qt::WA_DeleteOnClose );
|
||||
|
||||
@@ -511,7 +512,7 @@ void mainWindow::addSpacingToToolBar( int _size )
|
||||
|
||||
|
||||
|
||||
void mainWindow::resetWindowTitle( void )
|
||||
void mainWindow::resetWindowTitle( bool _modified )
|
||||
{
|
||||
QString title = "";
|
||||
if( engine::getSongEditor()->projectFileName() != "" )
|
||||
@@ -523,8 +524,45 @@ void mainWindow::resetWindowTitle( void )
|
||||
{
|
||||
title = tr( "Untitled" );
|
||||
}
|
||||
setWindowTitle( title + "[*] - " + tr( "LMMS %1" ).arg( VERSION ) );
|
||||
setWindowModified( FALSE );
|
||||
if( _modified )
|
||||
{
|
||||
title += '*';
|
||||
}
|
||||
setWindowTitle( title + " - " + tr( "LMMS %1" ).arg( VERSION ) );
|
||||
m_modified = _modified;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool mainWindow::mayChangeProject( void )
|
||||
{
|
||||
if( !m_modified )
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
QMessageBox mb ( tr( "Project not saved" ),
|
||||
tr( "The current project was modified since "
|
||||
"last saving. Do you want to save it "
|
||||
"now?" ),
|
||||
QMessageBox::Question,
|
||||
QMessageBox::Yes,
|
||||
QMessageBox::No,
|
||||
QMessageBox::Cancel,
|
||||
this );
|
||||
int answer = mb.exec();
|
||||
|
||||
if( answer == QMessageBox::Yes )
|
||||
{
|
||||
return( saveProject() );
|
||||
}
|
||||
else if( answer == QMessageBox::No )
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
|
||||
@@ -584,7 +622,7 @@ void mainWindow::restoreWidgetState( QWidget * _w, const QDomElement & _de )
|
||||
|
||||
void mainWindow::createNewProject( void )
|
||||
{
|
||||
if( engine::getSongEditor()->mayChangeProject() == TRUE )
|
||||
if( mayChangeProject() )
|
||||
{
|
||||
engine::getSongEditor()->createNewProject();
|
||||
}
|
||||
@@ -595,8 +633,7 @@ void mainWindow::createNewProject( void )
|
||||
|
||||
void mainWindow::createNewProjectFromTemplate( QAction * _idx )
|
||||
{
|
||||
if( m_templatesMenu != NULL &&
|
||||
engine::getSongEditor()->mayChangeProject() == TRUE )
|
||||
if( m_templatesMenu != NULL && mayChangeProject() )
|
||||
{
|
||||
QString dir_base = m_templatesMenu->actions().indexOf( _idx )
|
||||
>= m_custom_templates_count ?
|
||||
@@ -613,7 +650,7 @@ void mainWindow::createNewProjectFromTemplate( QAction * _idx )
|
||||
|
||||
void mainWindow::openProject( void )
|
||||
{
|
||||
if( engine::getSongEditor()->mayChangeProject() == TRUE )
|
||||
if( mayChangeProject() )
|
||||
{
|
||||
QFileDialog ofd( this, tr( "Open project" ), "",
|
||||
tr( "MultiMedia Project (*.mmp *.mmpz *.xml)" ) );
|
||||
@@ -823,7 +860,7 @@ void mainWindow::redo( void )
|
||||
|
||||
void mainWindow::closeEvent( QCloseEvent * _ce )
|
||||
{
|
||||
if( engine::getSongEditor()->mayChangeProject() == TRUE )
|
||||
if( mayChangeProject() )
|
||||
{
|
||||
_ce->accept();
|
||||
}
|
||||
|
||||
@@ -78,8 +78,6 @@
|
||||
#include "tooltip.h"
|
||||
#include "visualization_widget.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -102,14 +100,11 @@ songEditor::songEditor( void ) :
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
setFocus();
|
||||
|
||||
QWidget * cw = this;
|
||||
|
||||
|
||||
// create time-line
|
||||
timeLine * tl = new timeLine( TRACK_OP_WIDTH +
|
||||
DEFAULT_SETTINGS_WIDGET_WIDTH, 32,
|
||||
pixelsPerTact(), m_playPos[PLAY_SONG],
|
||||
m_currentPosition, cw );
|
||||
m_currentPosition, this );
|
||||
connect( this, SIGNAL( positionChanged( const midiTime & ) ),
|
||||
m_playPos[PLAY_SONG].m_timeLine,
|
||||
SLOT( updatePosition( const midiTime & ) ) );
|
||||
@@ -253,23 +248,21 @@ songEditor::songEditor( void ) :
|
||||
|
||||
|
||||
// create own toolbar
|
||||
m_toolBar = new QWidget( cw );
|
||||
m_toolBar = new QWidget( this );
|
||||
m_toolBar->setFixedHeight( 32 );
|
||||
m_toolBar->move( 0, 0 );
|
||||
m_toolBar->setAutoFillBackground( TRUE );
|
||||
QPalette pal;
|
||||
pal.setBrush( m_toolBar->backgroundRole(),
|
||||
embed::getIconPixmap( "toolbar_bg" ) );
|
||||
m_toolBar->setPalette( pal );
|
||||
|
||||
static_cast<QVBoxLayout *>( layout() )->insertWidget( 0, m_toolBar );
|
||||
static_cast<QVBoxLayout *>( layout() )->insertWidget( 1, tl );
|
||||
|
||||
QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar );
|
||||
tb_layout->setMargin( 0 );
|
||||
tb_layout->setSpacing( 0 );
|
||||
|
||||
containerWidget()->setParent( cw );
|
||||
containerWidget()->move( 0, m_toolBar->height() + tl->height() );
|
||||
|
||||
|
||||
|
||||
// fill own tool-bar
|
||||
m_playButton = new toolButton( embed::getIconPixmap( "play" ),
|
||||
@@ -368,11 +361,12 @@ songEditor::songEditor( void ) :
|
||||
tb_layout->addStretch();
|
||||
|
||||
|
||||
m_leftRightScroll = new QScrollBar( Qt::Horizontal, cw );
|
||||
m_leftRightScroll = new QScrollBar( Qt::Horizontal, this );
|
||||
m_leftRightScroll->setMinimum( 0 );
|
||||
m_leftRightScroll->setMaximum( 0 );
|
||||
m_leftRightScroll->setSingleStep( 1 );
|
||||
m_leftRightScroll->setPageStep( 20 );
|
||||
static_cast<QVBoxLayout *>( layout() )->addWidget( m_leftRightScroll );
|
||||
connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ),
|
||||
this, SLOT( scrolled( int ) ) );
|
||||
|
||||
@@ -380,6 +374,7 @@ songEditor::songEditor( void ) :
|
||||
if( engine::getMainWindow()->workspace() != NULL )
|
||||
{
|
||||
engine::getMainWindow()->workspace()->addSubWindow( this );
|
||||
parentWidget()->setAttribute( Qt::WA_DeleteOnClose, FALSE );
|
||||
}
|
||||
|
||||
QWidget * w = ( parentWidget() != NULL ) ? parentWidget() : this;
|
||||
@@ -410,22 +405,6 @@ songEditor::~songEditor()
|
||||
|
||||
|
||||
|
||||
void songEditor::closeEvent( QCloseEvent * _ce )
|
||||
{
|
||||
if( parentWidget() )
|
||||
{
|
||||
parentWidget()->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
hide();
|
||||
}
|
||||
_ce->ignore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void songEditor::paintEvent( QPaintEvent * _pe )
|
||||
{
|
||||
m_leftRightScroll->setMaximum( lengthInTacts() );
|
||||
@@ -435,29 +414,6 @@ void songEditor::paintEvent( QPaintEvent * _pe )
|
||||
|
||||
|
||||
|
||||
QRect songEditor::scrollAreaRect( void ) const
|
||||
{
|
||||
return( QRect( 0, 0, width(), height() - m_toolBar->height() -
|
||||
m_playPos[PLAY_SONG].m_timeLine->height() -
|
||||
DEFAULT_SCROLLBAR_SIZE ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// responsible for moving scrollbars after resizing
|
||||
void songEditor::resizeEvent( QResizeEvent * _re )
|
||||
{
|
||||
m_leftRightScroll->setGeometry( 0, height() - DEFAULT_SCROLLBAR_SIZE,
|
||||
width(), DEFAULT_SCROLLBAR_SIZE );
|
||||
m_playPos[PLAY_SONG].m_timeLine->setFixedWidth( width() );
|
||||
m_toolBar->setFixedWidth( width() );
|
||||
trackContainer::resizeEvent( _re );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void songEditor::keyPressEvent( QKeyEvent * _ke )
|
||||
{
|
||||
if( /*_ke->modifiers() & Qt::ShiftModifier*/
|
||||
@@ -548,7 +504,7 @@ void songEditor::wheelEvent( QWheelEvent * _we )
|
||||
m_playPos[PLAY_SONG].m_timeLine->setPixelsPerTact(
|
||||
pixelsPerTact() );
|
||||
// and make sure, all TCO's are resized and relocated
|
||||
realignTracks( TRUE );
|
||||
realignTracks();
|
||||
}
|
||||
else if( engine::getMainWindow()->isShiftPressed() == TRUE )
|
||||
{
|
||||
@@ -693,7 +649,7 @@ void songEditor::zoomingChanged( const QString & _zfac )
|
||||
setPixelsPerTact( _zfac.left( _zfac.length() - 1 ).toInt() *
|
||||
DEFAULT_PIXELS_PER_TACT / 100 );
|
||||
m_playPos[PLAY_SONG].m_timeLine->setPixelsPerTact( pixelsPerTact() );
|
||||
realignTracks( TRUE );
|
||||
realignTracks();
|
||||
}
|
||||
|
||||
|
||||
@@ -870,13 +826,13 @@ void songEditor::processNextBuffer( void )
|
||||
return;
|
||||
}
|
||||
|
||||
trackVector tv;
|
||||
QList<track *> trackList;
|
||||
Sint16 tco_num = -1;
|
||||
|
||||
switch( m_playMode )
|
||||
{
|
||||
case PLAY_SONG:
|
||||
tv = tracks();
|
||||
trackList = tracks();
|
||||
// at song-start we have to reset the LFOs
|
||||
if( m_playPos[PLAY_SONG] == 0 )
|
||||
{
|
||||
@@ -885,14 +841,15 @@ void songEditor::processNextBuffer( void )
|
||||
break;
|
||||
|
||||
case PLAY_TRACK:
|
||||
tv.push_back( m_trackToPlay );
|
||||
trackList.push_back( m_trackToPlay );
|
||||
break;
|
||||
|
||||
case PLAY_BB:
|
||||
if( engine::getBBEditor()->numOfBBs() > 0 )
|
||||
{
|
||||
tco_num = engine::getBBEditor()->currentBB();
|
||||
tv.push_back( bbTrack::findBBTrack( tco_num ) );
|
||||
trackList.push_back( bbTrack::findBBTrack(
|
||||
tco_num ) );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -901,7 +858,8 @@ void songEditor::processNextBuffer( void )
|
||||
{
|
||||
tco_num = m_patternToPlay->getTrack()->getTCONum(
|
||||
m_patternToPlay );
|
||||
tv.push_back( m_patternToPlay->getTrack() );
|
||||
trackList.push_back(
|
||||
m_patternToPlay->getTrack() );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -910,7 +868,7 @@ void songEditor::processNextBuffer( void )
|
||||
|
||||
}
|
||||
|
||||
if( tv.empty() == TRUE )
|
||||
if( trackList.empty() == TRUE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1033,10 +991,9 @@ void songEditor::processNextBuffer( void )
|
||||
}
|
||||
|
||||
// loop through all tracks and play them
|
||||
for( trackVector::iterator it = tv.begin();
|
||||
it != tv.end(); ++it )
|
||||
for( int i = 0; i < trackList.size(); ++i )
|
||||
{
|
||||
( *it )->play( m_playPos[m_playMode],
|
||||
trackList[i]->play( m_playPos[m_playMode],
|
||||
played_frames,
|
||||
total_frames_played, tco_num );
|
||||
}
|
||||
@@ -1136,11 +1093,10 @@ void songEditor::playPattern( pattern * _patternToPlay, bool _loop )
|
||||
tact songEditor::lengthInTacts( void ) const
|
||||
{
|
||||
tact len = 0;
|
||||
constTrackVector ctv = tracks();
|
||||
for( constTrackVector::const_iterator it = ctv.begin(); it != ctv.end();
|
||||
++it )
|
||||
const QList<track *> ctl = tracks();
|
||||
for( int i = 0; i < ctl.size(); ++i )
|
||||
{
|
||||
len = tMax( ( *it )->length(), len );
|
||||
len = tMax( ctl[i]->length(), len );
|
||||
}
|
||||
return( len );
|
||||
}
|
||||
@@ -1234,10 +1190,10 @@ void songEditor::stopExport( void )
|
||||
|
||||
void songEditor::insertBar( void )
|
||||
{
|
||||
trackVector tv = tracks();
|
||||
for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it )
|
||||
QList<track *> tl = tracks();
|
||||
for( int i = 0; i < tl.size(); ++i )
|
||||
{
|
||||
( *it )->getTrackContentWidget()->insertTact(
|
||||
tl[i]->getTrackContentWidget()->insertTact(
|
||||
m_playPos[PLAY_SONG] );
|
||||
}
|
||||
}
|
||||
@@ -1247,10 +1203,10 @@ void songEditor::insertBar( void )
|
||||
|
||||
void songEditor::removeBar( void )
|
||||
{
|
||||
trackVector tv = tracks();
|
||||
for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it )
|
||||
QList<track *> tl = tracks();
|
||||
for( int i = 0; i < tl.size(); ++i )
|
||||
{
|
||||
( *it )->getTrackContentWidget()->removeTact(
|
||||
tl[i]->getTrackContentWidget()->removeTact(
|
||||
m_playPos[PLAY_SONG] );
|
||||
}
|
||||
}
|
||||
@@ -1294,39 +1250,6 @@ automationPattern * songEditor::tempoAutomationPattern( void )
|
||||
|
||||
|
||||
|
||||
bool songEditor::mayChangeProject( void )
|
||||
{
|
||||
if( engine::getMainWindow()->isWindowModified() == FALSE )
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
QMessageBox mb ( tr( "Project not saved" ),
|
||||
tr( "The current project was modified since "
|
||||
"last saving. Do you want to save it "
|
||||
"now?" ),
|
||||
QMessageBox::Question,
|
||||
QMessageBox::Yes,
|
||||
QMessageBox::No,
|
||||
QMessageBox::Cancel,
|
||||
engine::getMainWindow() );
|
||||
int answer = mb.exec();
|
||||
|
||||
if( answer == QMessageBox::Yes )
|
||||
{
|
||||
return( engine::getMainWindow()->saveProject() );
|
||||
}
|
||||
else if( answer == QMessageBox::No )
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void songEditor::clearProject( void )
|
||||
{
|
||||
engine::getProjectJournal()->setJournalling( FALSE );
|
||||
@@ -1658,7 +1581,7 @@ void songEditor::setModified( void )
|
||||
{
|
||||
if( !m_loadingProject )
|
||||
{
|
||||
engine::getMainWindow()->setWindowModified( TRUE );
|
||||
engine::getMainWindow()->resetWindowTitle( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,35 +26,36 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <Qt/QtXml>
|
||||
#include "track.h"
|
||||
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QStyleOption>
|
||||
|
||||
|
||||
#include "track.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "track_container.h"
|
||||
#include "automation_track.h"
|
||||
#include "instrument_track.h"
|
||||
#include "bb_editor.h"
|
||||
#include "bb_track.h"
|
||||
#include "sample_track.h"
|
||||
#include "song_editor.h"
|
||||
#include "templates.h"
|
||||
#include "clipboard.h"
|
||||
#include "embed.h"
|
||||
#include "engine.h"
|
||||
#include "gui_templates.h"
|
||||
#include "pixmap_button.h"
|
||||
#include "debug.h"
|
||||
#include "tooltip.h"
|
||||
#include "string_pair_drag.h"
|
||||
#include "mmp.h"
|
||||
#include "instrument_track.h"
|
||||
#include "main_window.h"
|
||||
#include "text_float.h"
|
||||
#include "mmp.h"
|
||||
#include "pixmap_button.h"
|
||||
#include "project_journal.h"
|
||||
#include "sample_track.h"
|
||||
#include "song_editor.h"
|
||||
#include "string_pair_drag.h"
|
||||
#include "templates.h"
|
||||
#include "text_float.h"
|
||||
#include "tooltip.h"
|
||||
#include "track_container.h"
|
||||
|
||||
|
||||
const Sint16 RESIZE_GRIP_WIDTH = 4;
|
||||
@@ -140,17 +141,26 @@ void trackContentObject::movePosition( const midiTime & _pos )
|
||||
|
||||
void trackContentObject::changeLength( const midiTime & _length )
|
||||
{
|
||||
if( fixedTCOs() )
|
||||
{
|
||||
setFixedWidth( parentWidget()->width() );
|
||||
}
|
||||
else
|
||||
{
|
||||
setFixedWidth( static_cast<int>( m_length * pixelsPerTact() /
|
||||
64 ) + TCO_BORDER_WIDTH * 2 );
|
||||
}
|
||||
|
||||
if( m_length != _length )
|
||||
{
|
||||
//engine::getSongEditor()->setModified();
|
||||
addJournalEntry( journalEntry( RESIZE, m_length - _length ) );
|
||||
m_length = _length;
|
||||
|
||||
// changing length of TCO can result in change of song-length
|
||||
// etc., therefore we update the track-container
|
||||
m_track->getTrackContainer()->update();
|
||||
}
|
||||
setFixedWidth( static_cast<int>( m_length * pixelsPerTact() /
|
||||
64 ) + TCO_BORDER_WIDTH * 2 );
|
||||
// changing length of TCO can result in change of song-length etc.,
|
||||
// therefore we update the track-container
|
||||
m_track->getTrackContainer()->update();
|
||||
}
|
||||
|
||||
|
||||
@@ -455,13 +465,6 @@ void trackContentObject::contextMenuEvent( QContextMenuEvent * _cme )
|
||||
|
||||
float trackContentObject::pixelsPerTact( void )
|
||||
{
|
||||
if( fixedTCOs() )
|
||||
{
|
||||
return( ( getTrack()->getTrackContentWidget()->width() -
|
||||
2 * TCO_BORDER_WIDTH -
|
||||
DEFAULT_SCROLLBAR_SIZE ) /
|
||||
tMax<float>( length().getTact(), 1.0f ) );
|
||||
}
|
||||
return( getTrack()->getTrackContainer()->pixelsPerTact() );
|
||||
}
|
||||
|
||||
@@ -734,7 +737,7 @@ void trackContentWidget::removeTact( const midiTime & _pos )
|
||||
|
||||
|
||||
|
||||
void trackContentWidget::updateTCOs( void )
|
||||
void trackContentWidget::update( void )
|
||||
{
|
||||
for( tcoVector::iterator it = m_trackContentObjects.begin();
|
||||
it != m_trackContentObjects.end(); ++it )
|
||||
@@ -742,6 +745,7 @@ void trackContentWidget::updateTCOs( void )
|
||||
( *it )->setFixedHeight( height() - 2 );
|
||||
( *it )->update();
|
||||
}
|
||||
QWidget::update();
|
||||
}
|
||||
|
||||
|
||||
@@ -812,14 +816,19 @@ void trackContentWidget::paintEvent( QPaintEvent * _pe )
|
||||
{
|
||||
QPainter p( this );
|
||||
p.fillRect( rect(), QColor( 96, 96, 96 ) );
|
||||
|
||||
const trackContainer * tc = getTrack()->getTrackContainer();
|
||||
const int offset = (int)( ( tc->currentPosition() % 4 ) *
|
||||
tc->pixelsPerTact() );
|
||||
// draw vertical lines
|
||||
p.setPen( QColor( 128, 128, 128 ) );
|
||||
for( int x = -offset; x < width(); x += (int) tc->pixelsPerTact() )
|
||||
if( !tc->fixedTCOs() )
|
||||
{
|
||||
p.drawLine( x, 0, x, height() );
|
||||
const int offset = (int)( ( tc->currentPosition() % 4 ) *
|
||||
tc->pixelsPerTact() );
|
||||
// draw vertical lines
|
||||
p.setPen( QColor( 128, 128, 128 ) );
|
||||
for( int x = -offset; x < width();
|
||||
x += (int) tc->pixelsPerTact() )
|
||||
{
|
||||
p.drawLine( x, 0, x, height() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,7 +837,7 @@ void trackContentWidget::paintEvent( QPaintEvent * _pe )
|
||||
|
||||
void trackContentWidget::resizeEvent( QResizeEvent * _re )
|
||||
{
|
||||
updateTCOs();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -846,7 +855,6 @@ void trackContentWidget::undoStep( journalEntry & _je )
|
||||
dynamic_cast<trackContentObject *>(
|
||||
engine::getProjectJournal()->getJournallingObject(
|
||||
map["id"].toInt() ) );
|
||||
assert( tco != NULL );
|
||||
multimediaProject mmp(
|
||||
multimediaProject::JOURNAL_DATA );
|
||||
tco->saveState( mmp, mmp.content() );
|
||||
@@ -1107,7 +1115,7 @@ void trackOperationsWidget::removeTrack( void )
|
||||
void trackOperationsWidget::setMuted( bool _muted )
|
||||
{
|
||||
m_muteBtn->setChecked( _muted );
|
||||
m_trackWidget->getTrackContentWidget().updateTCOs();
|
||||
m_trackWidget->getTrackContentWidget().update();
|
||||
}
|
||||
|
||||
|
||||
@@ -1221,6 +1229,15 @@ trackWidget::trackWidget( track * _track, QWidget * _parent ) :
|
||||
QColor( 64, 64, 64 ) );
|
||||
m_trackSettingsWidget.setPalette( pal );
|
||||
|
||||
QHBoxLayout * layout = new QHBoxLayout( this );
|
||||
layout->setMargin( 0 );
|
||||
layout->setSpacing( 0 );
|
||||
layout->addWidget( &m_trackOperationsWidget );
|
||||
layout->addWidget( &m_trackSettingsWidget );
|
||||
layout->addWidget( &m_trackContentWidget, 1 );
|
||||
|
||||
resizeEvent( NULL );
|
||||
|
||||
setAcceptDrops( TRUE );
|
||||
}
|
||||
|
||||
@@ -1234,10 +1251,12 @@ trackWidget::~trackWidget()
|
||||
|
||||
|
||||
|
||||
void trackWidget::repaint( void )
|
||||
void trackWidget::resizeEvent( QResizeEvent * _re )
|
||||
{
|
||||
m_trackContentWidget.repaint();
|
||||
QWidget::repaint();
|
||||
m_trackOperationsWidget.setFixedSize( TRACK_OP_WIDTH, height() - 1 );
|
||||
m_trackSettingsWidget.setFixedSize( DEFAULT_SETTINGS_WIDGET_WIDTH,
|
||||
height() - 1 );
|
||||
m_trackContentWidget.setFixedHeight( height() - 1 );
|
||||
}
|
||||
|
||||
|
||||
@@ -1246,6 +1265,10 @@ void trackWidget::repaint( void )
|
||||
void trackWidget::update( void )
|
||||
{
|
||||
m_trackContentWidget.update();
|
||||
if( !m_track->getTrackContainer()->fixedTCOs() )
|
||||
{
|
||||
changePosition();
|
||||
}
|
||||
QWidget::update();
|
||||
}
|
||||
|
||||
@@ -1256,6 +1279,28 @@ void trackWidget::update( void )
|
||||
// change of visible viewport
|
||||
void trackWidget::changePosition( const midiTime & _new_pos )
|
||||
{
|
||||
const int tcos = m_trackContentWidget.numOfTCOs();
|
||||
|
||||
if( m_track->getTrackContainer() == engine::getBBEditor() )
|
||||
{
|
||||
const int showTco = engine::getBBEditor()->currentBB();
|
||||
for( int i = 0; i < tcos; ++i )
|
||||
{
|
||||
trackContentObject * tco = m_trackContentWidget.getTCO(
|
||||
i );
|
||||
if( i == showTco )
|
||||
{
|
||||
tco->move( 0, tco->y() );
|
||||
tco->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
tco->hide();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
midiTime pos = _new_pos;
|
||||
if( pos < 0 )
|
||||
{
|
||||
@@ -1265,7 +1310,6 @@ void trackWidget::changePosition( const midiTime & _new_pos )
|
||||
const Sint32 begin = pos;
|
||||
const Sint32 end = endPosition( pos );
|
||||
const float ppt = m_track->getTrackContainer()->pixelsPerTact();
|
||||
const int tcos = m_trackContentWidget.numOfTCOs();
|
||||
|
||||
for( int i = 0; i < tcos; ++i )
|
||||
{
|
||||
@@ -1408,7 +1452,7 @@ void trackWidget::mouseMoveEvent( QMouseEvent * _me )
|
||||
trackContainer * tc = m_track->getTrackContainer();
|
||||
// look which track-widget the mouse-cursor is over
|
||||
const trackWidget * track_at_y = tc->trackWidgetAt(
|
||||
mapTo( tc->containerWidget(), _me->pos() ).y() );
|
||||
mapTo( tc->contentWidget(), _me->pos() ).y() );
|
||||
// a track-widget not equal to ourself?
|
||||
if( track_at_y != NULL && track_at_y != this )
|
||||
{
|
||||
@@ -1451,27 +1495,10 @@ void trackWidget::mouseReleaseEvent( QMouseEvent * _me )
|
||||
|
||||
void trackWidget::paintEvent( QPaintEvent * _pe )
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.initFrom( this );
|
||||
QPainter p( this );
|
||||
p.setPen( QColor( 0, 0, 0 ) );
|
||||
p.drawLine( 0, height() - 1, width() - 1, height() - 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void trackWidget::resizeEvent( QResizeEvent * _re )
|
||||
{
|
||||
m_trackOperationsWidget.setFixedSize( TRACK_OP_WIDTH, height() - 1 );
|
||||
m_trackOperationsWidget.move( 0, 0 );
|
||||
m_trackSettingsWidget.setFixedSize( DEFAULT_SETTINGS_WIDGET_WIDTH,
|
||||
height() - 1 );
|
||||
m_trackSettingsWidget.move( TRACK_OP_WIDTH, 0 );
|
||||
m_trackContentWidget.resize( m_track->getTrackContainer()->width() -
|
||||
TRACK_OP_WIDTH -
|
||||
DEFAULT_SETTINGS_WIDGET_WIDTH,
|
||||
height() - 1 );
|
||||
m_trackContentWidget.move( m_trackOperationsWidget.width() +
|
||||
m_trackSettingsWidget.width(), 0 );
|
||||
style()->drawPrimitive( QStyle::PE_Widget, &opt, &p, this );
|
||||
}
|
||||
|
||||
|
||||
@@ -1499,9 +1526,7 @@ track::track( trackContainer * _tc, bool _create_widget ) :
|
||||
{
|
||||
if( _create_widget )
|
||||
{
|
||||
m_trackWidget = new trackWidget( this,
|
||||
m_trackContainer->containerWidget() );
|
||||
|
||||
m_trackWidget = new trackWidget( this, m_trackContainer );
|
||||
m_trackContainer->addTrack( this );
|
||||
}
|
||||
}
|
||||
@@ -1514,13 +1539,12 @@ track::~track()
|
||||
if( m_trackContainer == engine::getBBEditor()
|
||||
&& engine::getSongEditor() )
|
||||
{
|
||||
trackVector tracks = engine::getSongEditor()->tracks();
|
||||
for( trackVector::iterator it = tracks.begin();
|
||||
it != tracks.end(); ++it )
|
||||
QList<track *> tracks = engine::getSongEditor()->tracks();
|
||||
for( int i = 0; i < tracks.size(); ++i )
|
||||
{
|
||||
if( ( *it )->type() == BB_TRACK )
|
||||
if( tracks[i]->type() == BB_TRACK )
|
||||
{
|
||||
bbTrack * bb_track = (bbTrack *)*it;
|
||||
bbTrack * bb_track = (bbTrack *)tracks[i];
|
||||
if( bb_track->automationDisabled( this ) )
|
||||
{
|
||||
// Remove reference from bbTrack
|
||||
@@ -1566,9 +1590,7 @@ track * track::create( trackTypes _tt, trackContainer * _tc )
|
||||
default: break;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LMMS
|
||||
assert( t != NULL );
|
||||
#endif
|
||||
_tc->updateAfterTrackAdd();
|
||||
|
||||
return( t );
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
#include "track_container.h"
|
||||
|
||||
|
||||
#include <Qt/QtXml>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QProgressDialog>
|
||||
#include <QtGui/QWheelEvent>
|
||||
#include <QtGui/QMdiArea>
|
||||
#include <QtGui/QProgressDialog>
|
||||
#include <QtGui/QScrollBar>
|
||||
#include <QtGui/QWheelEvent>
|
||||
|
||||
|
||||
#include "bb_track.h"
|
||||
@@ -51,7 +51,6 @@
|
||||
#include "rubberband.h"
|
||||
#include "song_editor.h"
|
||||
#include "string_pair_drag.h"
|
||||
#include "templates.h"
|
||||
#include "track.h"
|
||||
|
||||
|
||||
@@ -62,6 +61,19 @@ trackContainer::trackContainer( void ) :
|
||||
m_rubberBand( new rubberBand( m_scrollArea ) ),
|
||||
m_origin()
|
||||
{
|
||||
QVBoxLayout * layout = new QVBoxLayout( this );
|
||||
layout->setMargin( 0 );
|
||||
layout->setSpacing( 0 );
|
||||
layout->addWidget( m_scrollArea );
|
||||
|
||||
QWidget * scrollContent = new QWidget;
|
||||
m_scrollLayout = new QVBoxLayout( scrollContent );
|
||||
m_scrollLayout->setMargin( 0 );
|
||||
m_scrollLayout->setSpacing( 0 );
|
||||
m_scrollLayout->setSizeConstraint( QLayout::SetMinimumSize );
|
||||
|
||||
m_scrollArea->setWidget( scrollContent );
|
||||
|
||||
m_scrollArea->show();
|
||||
m_rubberBand->hide();
|
||||
|
||||
@@ -73,14 +85,10 @@ trackContainer::trackContainer( void ) :
|
||||
|
||||
trackContainer::~trackContainer()
|
||||
{
|
||||
engine::getProjectJournal()->setJournalling( FALSE );
|
||||
|
||||
while( m_trackWidgets.size() )
|
||||
while( !m_tracks.empty() )
|
||||
{
|
||||
removeTrack( m_trackWidgets.front()->getTrack() );
|
||||
delete m_tracks.takeFirst();
|
||||
}
|
||||
|
||||
engine::getProjectJournal()->setJournalling( TRUE );
|
||||
}
|
||||
|
||||
|
||||
@@ -93,10 +101,9 @@ void trackContainer::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
mainWindow::saveWidgetState( this, _this );
|
||||
|
||||
// save settings of each track
|
||||
for( trackWidgetVector::iterator it = m_trackWidgets.begin();
|
||||
it != m_trackWidgets.end(); ++it )
|
||||
for( int i = 0; i < m_tracks.size(); ++i )
|
||||
{
|
||||
( *it )->getTrack()->saveState( _doc, _this );
|
||||
m_tracks[i]->saveState( _doc, _this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +169,8 @@ void trackContainer::addTrack( track * _track )
|
||||
map["id"] = _track->id();
|
||||
addJournalEntry( journalEntry( ADD_TRACK, map ) );
|
||||
|
||||
m_trackWidgets.push_back( _track->getTrackWidget() );
|
||||
m_tracks.push_back( _track );
|
||||
m_scrollLayout->addWidget( _track->getTrackWidget() );
|
||||
connect( this, SIGNAL( positionChanged( const midiTime & ) ),
|
||||
_track->getTrackWidget(),
|
||||
SLOT( changePosition( const midiTime & ) ) );
|
||||
@@ -174,9 +182,8 @@ void trackContainer::addTrack( track * _track )
|
||||
|
||||
void trackContainer::removeTrack( track * _track )
|
||||
{
|
||||
trackWidgetVector::iterator it = qFind( m_trackWidgets.begin(),
|
||||
m_trackWidgets.end(), _track->getTrackWidget() );
|
||||
if( it != m_trackWidgets.end() )
|
||||
int index = m_tracks.indexOf( _track );
|
||||
if( index != -1 )
|
||||
{
|
||||
QMap<QString, QVariant> map;
|
||||
multimediaProject mmp( multimediaProject::JOURNAL_DATA );
|
||||
@@ -185,8 +192,10 @@ void trackContainer::removeTrack( track * _track )
|
||||
map["state"] = mmp.toString();
|
||||
addJournalEntry( journalEntry( REMOVE_TRACK, map ) );
|
||||
|
||||
disconnect( *it );
|
||||
m_trackWidgets.erase( it );
|
||||
m_tracks.removeAt( index );
|
||||
|
||||
disconnect( _track->getTrackWidget() );
|
||||
m_scrollLayout->removeWidget( _track->getTrackWidget() );
|
||||
|
||||
delete _track;
|
||||
|
||||
@@ -203,15 +212,15 @@ void trackContainer::removeTrack( track * _track )
|
||||
|
||||
void trackContainer::moveTrackUp( track * _track )
|
||||
{
|
||||
for( trackWidgetVector::iterator it = m_trackWidgets.begin();
|
||||
it != m_trackWidgets.end(); ++it )
|
||||
for( int i = 1; i < m_tracks.size(); ++i )
|
||||
{
|
||||
if( *it == _track->getTrackWidget() &&
|
||||
it > m_trackWidgets.begin() )
|
||||
if( m_tracks[i] == _track )
|
||||
{
|
||||
bbTrack::swapBBTracks( ( *it )->getTrack(),
|
||||
( *( it - 1 ) )->getTrack() );
|
||||
qSwap( *it, *( it - 1 ) );
|
||||
bbTrack::swapBBTracks( m_tracks[i], m_tracks[i - 1] );
|
||||
QWidget * tw = m_tracks[i]->getTrackWidget();
|
||||
m_scrollLayout->removeWidget( tw );
|
||||
m_scrollLayout->insertWidget( i - 1, tw );
|
||||
m_tracks.swap( i - 1, i );
|
||||
realignTracks();
|
||||
break;
|
||||
}
|
||||
@@ -223,15 +232,15 @@ void trackContainer::moveTrackUp( track * _track )
|
||||
|
||||
void trackContainer::moveTrackDown( track * _track )
|
||||
{
|
||||
for( trackWidgetVector::iterator it = m_trackWidgets.begin();
|
||||
it != m_trackWidgets.end(); ++it )
|
||||
for( int i = 0; i < m_tracks.size() - 1; ++i )
|
||||
{
|
||||
if( *it == _track->getTrackWidget() &&
|
||||
it + 1 < m_trackWidgets.end() )
|
||||
if( m_tracks[i] == _track )
|
||||
{
|
||||
bbTrack::swapBBTracks( ( *it )->getTrack(),
|
||||
( *( it + 1 ) )->getTrack() );
|
||||
qSwap( *it, *( it + 1 ) );
|
||||
bbTrack::swapBBTracks( m_tracks[i], m_tracks[i + 1] );
|
||||
QWidget * tw = m_tracks[i]->getTrackWidget();
|
||||
m_scrollLayout->removeWidget( tw );
|
||||
m_scrollLayout->insertWidget( i + 1, tw );
|
||||
m_tracks.swap( i, i + 1 );
|
||||
realignTracks();
|
||||
break;
|
||||
}
|
||||
@@ -248,21 +257,19 @@ void trackContainer::updateAfterTrackAdd( void )
|
||||
|
||||
|
||||
|
||||
void trackContainer::realignTracks( bool _complete_update )
|
||||
void trackContainer::realignTracks( void )
|
||||
{
|
||||
int y = 0;
|
||||
for( trackWidgetVector::iterator it = m_trackWidgets.begin();
|
||||
it != m_trackWidgets.end(); ++it )
|
||||
QWidget * content = m_scrollArea->widget();
|
||||
content->setFixedWidth( width()
|
||||
- m_scrollArea->verticalScrollBar()->width() );
|
||||
content->setFixedHeight( content->minimumSizeHint().height() );
|
||||
|
||||
for( int i = 0; i < m_tracks.size(); ++i )
|
||||
{
|
||||
( *it )->show();
|
||||
( *it )->update();
|
||||
( *it )->move( 0, y );
|
||||
( *it )->resize( width() - DEFAULT_SCROLLBAR_SIZE,
|
||||
( *it )->height() );
|
||||
( *it )->changePosition( m_currentPosition );
|
||||
y += ( *it )->height();
|
||||
trackWidget * tw = m_tracks[i]->getTrackWidget();
|
||||
tw->show();
|
||||
tw->update();
|
||||
}
|
||||
updateScrollArea();
|
||||
}
|
||||
|
||||
|
||||
@@ -270,9 +277,9 @@ void trackContainer::realignTracks( bool _complete_update )
|
||||
|
||||
void trackContainer::clearAllTracks( void )
|
||||
{
|
||||
while( !m_trackWidgets.empty() )
|
||||
while( !m_tracks.empty() )
|
||||
{
|
||||
removeTrack( m_trackWidgets.front()->getTrack() );
|
||||
removeTrack( m_tracks.front() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,14 +290,13 @@ const trackWidget * trackContainer::trackWidgetAt( const int _y ) const
|
||||
{
|
||||
const int abs_y = _y + m_scrollArea->viewport()->y();
|
||||
int y_cnt = 0;
|
||||
for( trackWidgetVector::const_iterator it = m_trackWidgets.begin();
|
||||
it != m_trackWidgets.end(); ++it )
|
||||
for( int i = 0; i < m_tracks.size(); ++i )
|
||||
{
|
||||
const int y_cnt1 = y_cnt;
|
||||
y_cnt += ( *it )->height();
|
||||
y_cnt += m_tracks[i]->getTrackWidget()->height();
|
||||
if( abs_y >= y_cnt1 && abs_y < y_cnt )
|
||||
{
|
||||
return( *it );
|
||||
return( m_tracks[i]->getTrackWidget() );
|
||||
}
|
||||
}
|
||||
return( NULL );
|
||||
@@ -310,10 +316,9 @@ bool trackContainer::allowRubberband( void ) const
|
||||
Uint16 trackContainer::countTracks( track::trackTypes _tt ) const
|
||||
{
|
||||
Uint16 cnt = 0;
|
||||
for( trackWidgetVector::const_iterator it = m_trackWidgets.begin();
|
||||
it != m_trackWidgets.end(); ++it )
|
||||
for( int i = 0; i < m_tracks.size(); ++i )
|
||||
{
|
||||
if( ( *it )->getTrack()->type() == _tt ||
|
||||
if( m_tracks[i]->type() == _tt ||
|
||||
_tt == track::TOTAL_TRACK_TYPES )
|
||||
{
|
||||
++cnt;
|
||||
@@ -327,39 +332,26 @@ Uint16 trackContainer::countTracks( track::trackTypes _tt ) const
|
||||
|
||||
void trackContainer::setMutedOfAllTracks( bool _muted )
|
||||
{
|
||||
for( trackWidgetVector::iterator it = m_trackWidgets.begin();
|
||||
it != m_trackWidgets.end(); ++it )
|
||||
for( int i = 0; i < m_tracks.size(); ++i )
|
||||
{
|
||||
( *it )->getTrack()->setMuted( _muted );
|
||||
m_tracks[i]->setMuted( _muted );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
constTrackVector trackContainer::tracks( void ) const
|
||||
const QList<track *> trackContainer::tracks( void ) const
|
||||
{
|
||||
constTrackVector tracks;
|
||||
for( trackWidgetVector::const_iterator it = m_trackWidgets.begin();
|
||||
it != m_trackWidgets.end(); ++it )
|
||||
{
|
||||
tracks.push_back( ( *it )->getTrack() );
|
||||
}
|
||||
return( tracks );
|
||||
return( m_tracks );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
trackVector trackContainer::tracks( void )
|
||||
QList<track *> trackContainer::tracks( void )
|
||||
{
|
||||
trackVector tracks;
|
||||
for( trackWidgetVector::iterator it = m_trackWidgets.begin();
|
||||
it != m_trackWidgets.end(); ++it )
|
||||
{
|
||||
tracks.push_back( ( *it )->getTrack() );
|
||||
}
|
||||
return( tracks );
|
||||
return( m_tracks );
|
||||
}
|
||||
|
||||
|
||||
@@ -487,9 +479,6 @@ void trackContainer::dropEvent( QDropEvent * _de )
|
||||
{
|
||||
multimediaProject mmp( value, FALSE );
|
||||
track::create( mmp.content().firstChild().toElement(), this );
|
||||
// after adding a track, we have to make sure, actual editor
|
||||
// can setup new track (e.g. adding TCO's (bbEditor does so))
|
||||
updateAfterTrackAdd();
|
||||
_de->accept();
|
||||
}
|
||||
engine::getMixer()->unlock();
|
||||
@@ -541,18 +530,6 @@ void trackContainer::resizeEvent( QResizeEvent * )
|
||||
|
||||
|
||||
|
||||
void trackContainer::updateScrollArea( void )
|
||||
{
|
||||
m_scrollArea->resize( width(), scrollAreaRect().height() );
|
||||
/* m_scrollArea->resize( tMax( m_scrollArea->parentWidget()->width() -
|
||||
m_scrollArea->x() - 2, 0 ),
|
||||
tMax( m_scrollArea->parentWidget()->height() -
|
||||
m_scrollArea->y() - 2, 0 ) );*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
trackContainer::scrollArea::scrollArea( trackContainer * _parent ) :
|
||||
QScrollArea( _parent ),
|
||||
m_trackContainer( _parent )
|
||||
|
||||
@@ -307,8 +307,6 @@ bbTrack::bbTrack( trackContainer * _tc ) :
|
||||
|
||||
engine::getBBEditor()->setCurrentBB( bbNum );
|
||||
engine::getBBEditor()->updateComboBox();
|
||||
|
||||
_tc->updateAfterTrackAdd();
|
||||
}
|
||||
|
||||
|
||||
@@ -428,11 +426,10 @@ void bbTrack::saveTrackSpecificSettings( QDomDocument & _doc,
|
||||
}
|
||||
|
||||
int track_num = 0;
|
||||
trackVector tracks = engine::getBBEditor()->tracks();
|
||||
for( trackVector::iterator it = tracks.begin(); it != tracks.end();
|
||||
++it, ++track_num )
|
||||
QList<track *> tracks = engine::getBBEditor()->tracks();
|
||||
for( int i = 0; i < tracks.size(); ++i, ++track_num )
|
||||
{
|
||||
if( automationDisabled( *it ) )
|
||||
if( automationDisabled( tracks[i] ) )
|
||||
{
|
||||
QDomElement disabled = _doc.createElement(
|
||||
"automation-disabled" );
|
||||
@@ -468,7 +465,7 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this )
|
||||
engine::getBBEditor()->setCurrentBB( s_infoMap[this] );
|
||||
}*/
|
||||
|
||||
trackVector tracks = engine::getBBEditor()->tracks();
|
||||
QList<track *> tracks = engine::getBBEditor()->tracks();
|
||||
node = _this.firstChild();
|
||||
while( !node.isNull() )
|
||||
{
|
||||
|
||||
@@ -306,8 +306,6 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
|
||||
setWindowIcon( embed::getIconPixmap( "instrument_track" ) );
|
||||
|
||||
|
||||
_tc->updateAfterTrackAdd();
|
||||
|
||||
setFixedWidth( INSTRUMENT_WIDTH );
|
||||
resize( sizeHint() );
|
||||
|
||||
|
||||
@@ -677,10 +677,10 @@ void pattern::mouseDoubleClickEvent( QMouseEvent * _me )
|
||||
void pattern::mousePressEvent( QMouseEvent * _me )
|
||||
{
|
||||
if( _me->button() == Qt::LeftButton &&
|
||||
m_patternType == pattern::BEAT_PATTERN &&
|
||||
( pixelsPerTact() >= 192 ||
|
||||
m_steps != DEFAULT_STEPS_PER_TACT ) &&
|
||||
_me->y() > height() - s_stepBtnOff->height() )
|
||||
m_patternType == pattern::BEAT_PATTERN &&
|
||||
( fixedTCOs() || pixelsPerTact() >= 192 ||
|
||||
m_steps != DEFAULT_STEPS_PER_TACT ) &&
|
||||
_me->y() > height() - s_stepBtnOff->height() )
|
||||
{
|
||||
int step = ( _me->x() - TCO_BORDER_WIDTH ) *
|
||||
length() / BEATS_PER_TACT / width();
|
||||
@@ -725,9 +725,9 @@ void pattern::mousePressEvent( QMouseEvent * _me )
|
||||
void pattern::wheelEvent( QWheelEvent * _we )
|
||||
{
|
||||
if( m_patternType == pattern::BEAT_PATTERN &&
|
||||
( pixelsPerTact() >= 192 ||
|
||||
m_steps != DEFAULT_STEPS_PER_TACT ) &&
|
||||
_we->y() > height() - s_stepBtnOff->height() )
|
||||
( fixedTCOs() || pixelsPerTact() >= 192 ||
|
||||
m_steps != DEFAULT_STEPS_PER_TACT ) &&
|
||||
_we->y() > height() - s_stepBtnOff->height() )
|
||||
{
|
||||
int step = ( _we->x() - TCO_BORDER_WIDTH ) *
|
||||
length() / BEATS_PER_TACT / width();
|
||||
@@ -816,7 +816,10 @@ void pattern::paintEvent( QPaintEvent * )
|
||||
p.setPen( QColor( 0, 0, 0 ) );
|
||||
p.drawRect( 1, 1, width() - 2, height() - 2 );
|
||||
|
||||
const float ppt = pixelsPerTact();
|
||||
const float ppt = fixedTCOs() ?
|
||||
( parentWidget()->width() - 2 * TCO_BORDER_WIDTH )
|
||||
/ (float)length().getTact() :
|
||||
pixelsPerTact();
|
||||
|
||||
if( m_patternType == pattern::MELODY_PATTERN )
|
||||
{
|
||||
@@ -894,7 +897,8 @@ void pattern::paintEvent( QPaintEvent * )
|
||||
}
|
||||
}
|
||||
else if( m_patternType == pattern::BEAT_PATTERN &&
|
||||
( ppt >= 96 || m_steps != DEFAULT_STEPS_PER_TACT ) )
|
||||
( fixedTCOs() || ppt >= 96
|
||||
|| m_steps != DEFAULT_STEPS_PER_TACT ) )
|
||||
{
|
||||
QPixmap stepon;
|
||||
QPixmap stepoverlay;
|
||||
|
||||
@@ -356,8 +356,6 @@ sampleTrack::sampleTrack( trackContainer * _tc ) :
|
||||
tr( "With this knob you can set "
|
||||
"the volume of the opened "
|
||||
"channel." ) );
|
||||
|
||||
_tc->updateAfterTrackAdd();
|
||||
}
|
||||
|
||||
|
||||
@@ -365,6 +363,12 @@ sampleTrack::sampleTrack( trackContainer * _tc ) :
|
||||
|
||||
sampleTrack::~sampleTrack()
|
||||
{
|
||||
// disconnect sampleTCOs
|
||||
for( int i = 0; i < numOfTCOs(); ++i )
|
||||
{
|
||||
disconnect( engine::getSongEditor(), 0, getTCO( i ), 0 );
|
||||
}
|
||||
|
||||
engine::getMixer()->removePlayHandles( this );
|
||||
delete m_audioPort;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QColorDialog>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QFontDatabase>
|
||||
|
||||
Reference in New Issue
Block a user