diff --git a/include/bb_editor.h b/include/bb_editor.h index 200896718d2..a4bce625308 100644 --- a/include/bb_editor.h +++ b/include/bb_editor.h @@ -56,6 +56,8 @@ public slots: void stop(); void updatePosition(); void addAutomationTrack(); + void addSteps(); + void removeSteps(); private: virtual void keyPressEvent( QKeyEvent * _ke ); diff --git a/include/pattern.h b/include/pattern.h index 2c937eacac7..26b51849e3c 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -125,9 +125,6 @@ class EXPORT pattern : public trackContentObject bool empty(); - void addSteps( int _n ); - void removeSteps( int _n ); - virtual trackContentObjectView * createView( trackView * _tv ); @@ -140,6 +137,8 @@ class EXPORT pattern : public trackContentObject protected slots: + void addSteps(); + void removeSteps(); void clear(); void freeze(); void unfreeze(); @@ -164,6 +163,7 @@ protected slots: friend class patternView; friend class patternFreezeThread; + friend class bbEditor; } ; @@ -187,9 +187,6 @@ protected slots: void resetName(); void changeName(); - void addSteps( QAction * _item ); - void removeSteps( QAction * _item ); - protected: virtual void constructContextMenu( QMenu * ); diff --git a/src/gui/bb_editor.cpp b/src/gui/bb_editor.cpp index 8045c8af178..e66e74da117 100644 --- a/src/gui/bb_editor.cpp +++ b/src/gui/bb_editor.cpp @@ -36,6 +36,9 @@ #include "tool_button.h" #include "config_mgr.h" +#include "TrackContainer.h" +#include "pattern.h" + bbEditor::bbEditor( bbTrackContainer* tc ) : @@ -93,6 +96,16 @@ bbEditor::bbEditor( bbTrackContainer* tc ) : tr( "Add automation-track" ), this, SLOT( addAutomationTrack() ), m_toolBar ); + toolButton * remove_bar = new toolButton( + embed::getIconPixmap( "step_btn_remove" ), + tr( "Remove steps" ), + this, SLOT( removeSteps() ), m_toolBar ); + + toolButton * add_bar = new toolButton( + embed::getIconPixmap( "step_btn_add" ), + tr( "Add steps" ), + this, SLOT( addSteps() ), m_toolBar ); + m_playButton->setWhatsThis( @@ -119,6 +132,8 @@ bbEditor::bbEditor( bbTrackContainer* tc ) : tb_layout->addWidget( add_bb_track ); tb_layout->addWidget( add_automation_track ); tb_layout->addStretch(); + tb_layout->addWidget( remove_bar ); + tb_layout->addWidget( add_bar ); tb_layout->addWidget( l ); tb_layout->addSpacing( 15 ); @@ -219,6 +234,44 @@ void bbEditor::addAutomationTrack() +void bbEditor::addSteps() +{ + TrackContainer::TrackList tl = model()->tracks(); + + for( TrackContainer::TrackList::iterator it = tl.begin(); + it != tl.end(); ++it ) + { + if( ( *it )->type() == track::InstrumentTrack ) + { + pattern * p = static_cast( + ( *it )->getTCO( m_bbtc->currentBB() ) ); + p->addSteps(); + } + } +} + + + + +void bbEditor::removeSteps() +{ + TrackContainer::TrackList tl = model()->tracks(); + + for( TrackContainer::TrackList::iterator it = tl.begin(); + it != tl.end(); ++it ) + { + if( ( *it )->type() == track::InstrumentTrack ) + { + pattern * p = static_cast( + ( *it )->getTCO( m_bbtc->currentBB() ) ); + p->removeSteps(); + } + } +} + + + + void bbEditor::keyPressEvent( QKeyEvent * _ke ) { if ( _ke->key() == Qt::Key_Space ) diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 5ad261ca8ad..197c411f0de 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -485,9 +485,9 @@ void pattern::abortFreeze() -void pattern::addSteps( int _n ) +void pattern::addSteps() { - m_steps += _n; + m_steps += midiTime::stepsPerTact(); ensureBeatNotes(); emit dataChanged(); } @@ -495,8 +495,9 @@ void pattern::addSteps( int _n ) -void pattern::removeSteps( int _n ) +void pattern::removeSteps() { + int _n = midiTime::stepsPerTact(); if( _n < m_steps ) { for( int i = m_steps - _n; i < m_steps; ++i ) @@ -908,23 +909,6 @@ void patternView::changeName() - -void patternView::addSteps( QAction * _item ) -{ - m_pat->addSteps( _item->text().section( ' ', 0, 0 ).toInt() ); -} - - - - -void patternView::removeSteps( QAction * _item ) -{ - m_pat->removeSteps( _item->text().section( ' ', 0, 0 ).toInt() ); -} - - - - void patternView::constructContextMenu( QMenu * _cm ) { QAction * a = new QAction( embed::getIconPixmap( "piano" ), @@ -967,24 +951,10 @@ void patternView::constructContextMenu( QMenu * _cm ) _cm->addSeparator(); } - QMenu * add_step_menu = _cm->addMenu( - embed::getIconPixmap( "step_btn_add" ), - tr( "Add steps" ) ); - QMenu * remove_step_menu = _cm->addMenu( - embed::getIconPixmap( "step_btn_remove" ), - tr( "Remove steps" ) ); - connect( add_step_menu, SIGNAL( triggered( QAction * ) ), - this, SLOT( addSteps( QAction * ) ) ); - connect( remove_step_menu, SIGNAL( triggered( QAction * ) ), - this, SLOT( removeSteps( QAction * ) ) ); - for( int i = 1; i <= 16; i *= 2 ) - { - const QString label = ( i == 1 ) ? - tr( "1 step" ) : - tr( "%1 steps" ).arg( i ); - add_step_menu->addAction( label ); - remove_step_menu->addAction( label ); - } + _cm->addAction( embed::getIconPixmap( "step_btn_add" ), + tr( "Add steps" ), m_pat, SLOT( addSteps() ) ); + _cm->addAction( embed::getIconPixmap( "step_btn_remove" ), + tr( "Remove steps" ), m_pat, SLOT( removeSteps() ) ); }