From 19dc1aa913136c19080831b5868975f692dcf7ae Mon Sep 17 00:00:00 2001 From: Hannu Haahti Date: Fri, 17 Jan 2014 15:20:01 +0200 Subject: [PATCH 1/3] b&b editor: always add and remove so many steps as there are in one bar --- include/pattern.h | 8 ++------ src/tracks/pattern.cpp | 46 ++++++++---------------------------------- 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/include/pattern.h b/include/pattern.h index 2c937eaca..2d3f208f2 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -125,9 +125,6 @@ public: bool empty(); - void addSteps( int _n ); - void removeSteps( int _n ); - virtual trackContentObjectView * createView( trackView * _tv ); @@ -140,6 +137,8 @@ protected: protected slots: + void addSteps(); + void removeSteps(); void clear(); void freeze(); void unfreeze(); @@ -187,9 +186,6 @@ protected slots: void resetName(); void changeName(); - void addSteps( QAction * _item ); - void removeSteps( QAction * _item ); - protected: virtual void constructContextMenu( QMenu * ); diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 5ad261ca8..197c411f0 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() ) ); } From 7e6642db4e0c4967c9241b7782b559e2ff81d179 Mon Sep 17 00:00:00 2001 From: Hannu Haahti Date: Sat, 18 Jan 2014 09:59:44 +0200 Subject: [PATCH 2/3] add new steps to all tracks at once --- include/bb_editor.h | 2 ++ include/pattern.h | 1 + src/gui/bb_editor.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/bb_editor.h b/include/bb_editor.h index 200896718..a4bce6253 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 2d3f208f2..26b51849e 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -163,6 +163,7 @@ private: friend class patternView; friend class patternFreezeThread; + friend class bbEditor; } ; diff --git a/src/gui/bb_editor.cpp b/src/gui/bb_editor.cpp index 8045c8af1..211981788 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,38 @@ void bbEditor::addAutomationTrack() +void bbEditor::addSteps() +{ + TrackContainer::TrackList tl = model()->tracks(); + + for( TrackContainer::TrackList::iterator it = tl.begin(); + it != tl.end(); ++it ) + { + 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 ) + { + pattern * p = static_cast( + ( *it )->getTCO( m_bbtc->currentBB() ) ); + p->removeSteps(); + } +} + + + + void bbEditor::keyPressEvent( QKeyEvent * _ke ) { if ( _ke->key() == Qt::Key_Space ) From ae3273faf9ade4fd76f350205017c97e803127e8 Mon Sep 17 00:00:00 2001 From: Hannu Haahti Date: Sat, 18 Jan 2014 10:04:30 +0200 Subject: [PATCH 3/3] check track type first before adding or removing steps --- src/gui/bb_editor.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gui/bb_editor.cpp b/src/gui/bb_editor.cpp index 211981788..e66e74da1 100644 --- a/src/gui/bb_editor.cpp +++ b/src/gui/bb_editor.cpp @@ -241,9 +241,12 @@ void bbEditor::addSteps() for( TrackContainer::TrackList::iterator it = tl.begin(); it != tl.end(); ++it ) { - pattern * p = static_cast( - ( *it )->getTCO( m_bbtc->currentBB() ) ); - p->addSteps(); + if( ( *it )->type() == track::InstrumentTrack ) + { + pattern * p = static_cast( + ( *it )->getTCO( m_bbtc->currentBB() ) ); + p->addSteps(); + } } } @@ -257,9 +260,12 @@ void bbEditor::removeSteps() for( TrackContainer::TrackList::iterator it = tl.begin(); it != tl.end(); ++it ) { - pattern * p = static_cast( - ( *it )->getTCO( m_bbtc->currentBB() ) ); - p->removeSteps(); + if( ( *it )->type() == track::InstrumentTrack ) + { + pattern * p = static_cast( + ( *it )->getTCO( m_bbtc->currentBB() ) ); + p->removeSteps(); + } } }