| 1 | /* |
|---|
| 2 | * Hydrogen |
|---|
| 3 | * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] |
|---|
| 4 | * |
|---|
| 5 | * http://www.hydrogen-music.org |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | * (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY, without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | * |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | #include <hydrogen/Preferences.h> |
|---|
| 24 | #include <hydrogen/hydrogen.h> |
|---|
| 25 | #include <hydrogen/instrument.h> |
|---|
| 26 | #include <hydrogen/Pattern.h> |
|---|
| 27 | #include <hydrogen/audio_engine.h> |
|---|
| 28 | #include <hydrogen/event_queue.h> |
|---|
| 29 | using namespace H2Core; |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | #include "HydrogenApp.h" |
|---|
| 33 | #include "PatternEditorPanel.h" |
|---|
| 34 | #include "PatternEditorInstrumentList.h" |
|---|
| 35 | #include "PatternEditorRuler.h" |
|---|
| 36 | #include "NotePropertiesRuler.h" |
|---|
| 37 | #include "DrumPatternEditor.h" |
|---|
| 38 | #include "PianoRollEditor.h" |
|---|
| 39 | |
|---|
| 40 | #include "../MainForm.h" |
|---|
| 41 | #include "../widgets/Button.h" |
|---|
| 42 | #include "../widgets/Fader.h" |
|---|
| 43 | #include "../widgets/PixmapWidget.h" |
|---|
| 44 | #include "../widgets/LCDCombo.h" |
|---|
| 45 | |
|---|
| 46 | #include "../Skin.h" |
|---|
| 47 | #include "../SongEditor/SongEditorPanel.h" |
|---|
| 48 | |
|---|
| 49 | #include <cmath> |
|---|
| 50 | |
|---|
| 51 | #include <QtGui> |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | void PatternEditorPanel::updateSLnameLabel( ) |
|---|
| 55 | { |
|---|
| 56 | QFont font; |
|---|
| 57 | font.setBold( true ); |
|---|
| 58 | pSLlabel->setFont( font ); |
|---|
| 59 | pSLlabel->setText( Hydrogen::get_instance()->m_currentDrumkit ); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | PatternEditorPanel::PatternEditorPanel( QWidget *pParent ) |
|---|
| 65 | : QWidget( pParent ) |
|---|
| 66 | , Object( "PatternEditorPanel" ) |
|---|
| 67 | , m_pPattern( NULL ) |
|---|
| 68 | , m_bEnablePatternResize( true ) |
|---|
| 69 | { |
|---|
| 70 | setAcceptDrops(true); |
|---|
| 71 | |
|---|
| 72 | Preferences *pPref = Preferences::getInstance(); |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | // Editor TOP |
|---|
| 76 | PixmapWidget *editor_top = new PixmapWidget(0); |
|---|
| 77 | editor_top->setPixmap("/patternEditor/editor_top.png", true); |
|---|
| 78 | editor_top->setFixedHeight(24); |
|---|
| 79 | |
|---|
| 80 | PixmapWidget *editor_top_2 = new PixmapWidget(0); |
|---|
| 81 | editor_top_2->setPixmap("/patternEditor/editor_top.png", true); |
|---|
| 82 | editor_top_2->setFixedHeight(24); |
|---|
| 83 | |
|---|
| 84 | QHBoxLayout *editor_top_hbox = new QHBoxLayout(editor_top); |
|---|
| 85 | editor_top_hbox->setSpacing(0); |
|---|
| 86 | editor_top_hbox->setMargin(0); |
|---|
| 87 | editor_top_hbox->setAlignment(Qt::AlignLeft); |
|---|
| 88 | |
|---|
| 89 | QHBoxLayout *editor_top_hbox_2 = new QHBoxLayout(editor_top_2); |
|---|
| 90 | editor_top_hbox_2->setSpacing(0); |
|---|
| 91 | editor_top_hbox_2->setMargin(0); |
|---|
| 92 | editor_top_hbox_2->setAlignment(Qt::AlignLeft); |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | //soundlibrary name |
|---|
| 96 | pSLlabel = new QLabel( NULL ); |
|---|
| 97 | pSLlabel->setText( Hydrogen::get_instance()->m_currentDrumkit ); |
|---|
| 98 | pSLlabel->setFixedSize( 170, 20 ); |
|---|
| 99 | pSLlabel->move( 10, 3 ); |
|---|
| 100 | pSLlabel->setToolTip( trUtf8("Loaded Soundlibrary") ); |
|---|
| 101 | editor_top_hbox->addWidget( pSLlabel ); |
|---|
| 102 | |
|---|
| 103 | //wolke some background images back_size_res |
|---|
| 104 | PixmapWidget *pSizeResol = new PixmapWidget( NULL ); |
|---|
| 105 | pSizeResol->setFixedSize( 200, 20 ); |
|---|
| 106 | pSizeResol->setPixmap( "/patternEditor/background_res-new.png" ); |
|---|
| 107 | pSizeResol->move( 0, 3 ); |
|---|
| 108 | editor_top_hbox_2->addWidget( pSizeResol ); |
|---|
| 109 | |
|---|
| 110 | // PATTERN size |
|---|
| 111 | __pattern_size_combo = new LCDCombo(pSizeResol, 4); |
|---|
| 112 | __pattern_size_combo->move( 34, 2 ); |
|---|
| 113 | __pattern_size_combo->setToolTip( trUtf8("Select pattern size") ); |
|---|
| 114 | for ( int i = 1; i <= 32; i++) { |
|---|
| 115 | __pattern_size_combo->addItem( QString( "%1" ).arg( i ) ); |
|---|
| 116 | } |
|---|
| 117 | __pattern_size_combo->update(); |
|---|
| 118 | connect(__pattern_size_combo, SIGNAL( valueChanged( QString ) ), this, SLOT( patternSizeChanged(QString) ) ); |
|---|
| 119 | //editor_top_hbox->addWidget(__pattern_size_combo); |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | // GRID resolution |
|---|
| 123 | __resolution_combo = new LCDCombo( pSizeResol , 7); |
|---|
| 124 | __resolution_combo->setToolTip(trUtf8("Select grid resolution")); |
|---|
| 125 | __resolution_combo->addItem( "4" ); |
|---|
| 126 | __resolution_combo->addItem( "8" ); |
|---|
| 127 | __resolution_combo->addItem( "16" ); |
|---|
| 128 | __resolution_combo->addItem( "32" ); |
|---|
| 129 | __resolution_combo->addItem( "64" ); |
|---|
| 130 | __resolution_combo->addSeparator(); |
|---|
| 131 | __resolution_combo->addItem( "4T" ); |
|---|
| 132 | __resolution_combo->addItem( "8T" ); |
|---|
| 133 | __resolution_combo->addItem( "16T" ); |
|---|
| 134 | __resolution_combo->addItem( "32T" ); |
|---|
| 135 | __resolution_combo->addSeparator(); |
|---|
| 136 | __resolution_combo->addItem( "off" ); |
|---|
| 137 | __resolution_combo->update(); |
|---|
| 138 | __resolution_combo->move( 121, 2 ); |
|---|
| 139 | connect(__resolution_combo, SIGNAL(valueChanged(QString)), this, SLOT(gridResolutionChanged(QString))); |
|---|
| 140 | //editor_top_hbox->addWidget(__resolution_combo); |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | //wolke some background images hear note rec quant |
|---|
| 144 | |
|---|
| 145 | PixmapWidget *pRec = new PixmapWidget( NULL ); |
|---|
| 146 | pRec->setFixedSize( 150, 20 ); |
|---|
| 147 | pRec->setPixmap( "/patternEditor/background_rec-new.png" ); |
|---|
| 148 | pRec->move( 0, 3 ); |
|---|
| 149 | editor_top_hbox_2->addWidget( pRec ); |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | // Hear notes btn |
|---|
| 153 | ToggleButton *hearNotesBtn = new ToggleButton( |
|---|
| 154 | pRec, |
|---|
| 155 | "/patternEditor/btn_hear_on.png", |
|---|
| 156 | "/patternEditor/btn_hear_off.png", |
|---|
| 157 | "/patternEditor/btn_hear_off.png", |
|---|
| 158 | QSize(15, 13) |
|---|
| 159 | ); |
|---|
| 160 | hearNotesBtn->move( 34, 3 ); |
|---|
| 161 | hearNotesBtn->setToolTip( trUtf8( "Hear new notes" ) ); |
|---|
| 162 | connect( hearNotesBtn, SIGNAL(clicked(Button*)), this, SLOT( hearNotesBtnClick(Button*))); |
|---|
| 163 | //editor_top_hbox->addWidget(hearNotesBtn); |
|---|
| 164 | // restore hear new notes button state |
|---|
| 165 | hearNotesBtn->setPressed( pPref->getHearNewNotes() ); |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | // Record events btn |
|---|
| 169 | ToggleButton* recordEventsBtn = new ToggleButton( |
|---|
| 170 | pRec, |
|---|
| 171 | "/patternEditor/btn_record_on.png", |
|---|
| 172 | "/patternEditor/btn_record_off.png", |
|---|
| 173 | "/patternEditor/btn_record_off.png", |
|---|
| 174 | QSize(15, 13) |
|---|
| 175 | ); |
|---|
| 176 | recordEventsBtn->move( 74, 3 ); |
|---|
| 177 | recordEventsBtn->setPressed( pPref->getRecordEvents()); |
|---|
| 178 | recordEventsBtn->setToolTip( trUtf8( "Record keyboard/midi events" ) ); |
|---|
| 179 | connect( recordEventsBtn, SIGNAL(clicked(Button*)), this, SLOT( recordEventsBtnClick(Button*))); |
|---|
| 180 | //editor_top_hbox->addWidget(recordEventsBtn); |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | // quantize |
|---|
| 184 | ToggleButton* quantizeEventsBtn = new ToggleButton( |
|---|
| 185 | pRec, |
|---|
| 186 | "/patternEditor/btn_quant_on.png", |
|---|
| 187 | "/patternEditor/btn_quant_off.png", |
|---|
| 188 | "/patternEditor/btn_quant_off.png", |
|---|
| 189 | QSize(15, 13) |
|---|
| 190 | ); |
|---|
| 191 | quantizeEventsBtn->move( 130, 3 ); |
|---|
| 192 | quantizeEventsBtn->setPressed( pPref->getQuantizeEvents()); |
|---|
| 193 | quantizeEventsBtn->setToolTip( trUtf8( "Quantize keyboard/midi events to grid" ) ); |
|---|
| 194 | connect( quantizeEventsBtn, SIGNAL(clicked(Button*)), this, SLOT( quantizeEventsBtnClick(Button*))); |
|---|
| 195 | //editor_top_hbox->addWidget(quantizeEventsBtn); |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | // PixmapWidget *pZoom = new PixmapWidget( NULL ); |
|---|
| 199 | // pZoom->setFixedSize( 73, 20 ); |
|---|
| 200 | // pZoom->setPixmap( "/patternEditor/background_zoom-new.png" ); |
|---|
| 201 | // pZoom->move( 0, 3 ); |
|---|
| 202 | // editor_top_hbox_2->addWidget( pZoom ); |
|---|
| 203 | |
|---|
| 204 | QComboBox *selInstrument = new QComboBox( NULL ); |
|---|
| 205 | selInstrument->setFixedSize( 170, 20 ); |
|---|
| 206 | selInstrument->move( 2, 1 ); |
|---|
| 207 | selInstrument->addItem ( QString( "keyb: play drumset" )); |
|---|
| 208 | selInstrument->addItem ( QString( "keyb: play instrument" )); |
|---|
| 209 | editor_top_hbox_2->addWidget( selInstrument ); |
|---|
| 210 | connect( selInstrument, SIGNAL( currentIndexChanged( QString ) ), this, SLOT( playselectedinstrument(QString) ) ); |
|---|
| 211 | |
|---|
| 212 | // zoom-in btn |
|---|
| 213 | Button *zoom_in_btn = new Button( |
|---|
| 214 | NULL, |
|---|
| 215 | "/songEditor/btn_new_on.png", |
|---|
| 216 | "/songEditor/btn_new_off.png", |
|---|
| 217 | "/songEditor/btn_new_over.png", |
|---|
| 218 | QSize(19, 13) |
|---|
| 219 | ); |
|---|
| 220 | // zoom_in_btn->move( 51, 3 ); |
|---|
| 221 | // zoom_in_btn->setText("+"); |
|---|
| 222 | zoom_in_btn->setToolTip( trUtf8( "Zoom in" ) ); |
|---|
| 223 | connect(zoom_in_btn, SIGNAL(clicked(Button*)), this, SLOT( zoomInBtnClicked(Button*) ) ); |
|---|
| 224 | //editor_top_hbox_2->addWidget(zoom_in_btn); |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | // zoom-out btn |
|---|
| 228 | Button *zoom_out_btn = new Button( |
|---|
| 229 | NULL, |
|---|
| 230 | "/songEditor/btn_minus_on.png", |
|---|
| 231 | "/songEditor/btn_minus_off.png", |
|---|
| 232 | "/songEditor/btn_minus_over.png", |
|---|
| 233 | QSize(19, 13) |
|---|
| 234 | ); |
|---|
| 235 | // zoom_out_btn->move( 2, 3 ); |
|---|
| 236 | //zoom_out_btn->setText("-"); |
|---|
| 237 | zoom_out_btn->setToolTip( trUtf8( "Zoom out" ) ); |
|---|
| 238 | connect( zoom_out_btn, SIGNAL(clicked(Button*)), this, SLOT( zoomOutBtnClicked(Button*) ) ); |
|---|
| 239 | //editor_top_hbox_2->addWidget(zoom_out_btn); |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | // End Editor TOP |
|---|
| 243 | |
|---|
| 244 | |
|---|
| 245 | // RULER____________________________________ |
|---|
| 246 | |
|---|
| 247 | // Ruler ScrollView |
|---|
| 248 | m_pRulerScrollView = new QScrollArea( NULL ); |
|---|
| 249 | m_pRulerScrollView->setFrameShape( QFrame::NoFrame ); |
|---|
| 250 | m_pRulerScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 251 | m_pRulerScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 252 | m_pRulerScrollView->setFixedHeight( 25 ); |
|---|
| 253 | // Ruler |
|---|
| 254 | m_pPatternEditorRuler = new PatternEditorRuler( m_pRulerScrollView->viewport() ); |
|---|
| 255 | |
|---|
| 256 | m_pRulerScrollView->setWidget( m_pPatternEditorRuler ); |
|---|
| 257 | |
|---|
| 258 | //~ RULER |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | // EDITOR _____________________________________ |
|---|
| 262 | // Editor scrollview |
|---|
| 263 | m_pEditorScrollView = new QScrollArea( NULL ); |
|---|
| 264 | m_pEditorScrollView->setFrameShape( QFrame::NoFrame ); |
|---|
| 265 | m_pEditorScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 266 | m_pEditorScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 267 | |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | // Editor |
|---|
| 271 | m_pDrumPatternEditor = new DrumPatternEditor( m_pEditorScrollView->viewport(), this ); |
|---|
| 272 | |
|---|
| 273 | m_pEditorScrollView->setWidget( m_pDrumPatternEditor ); |
|---|
| 274 | |
|---|
| 275 | connect( m_pEditorScrollView->verticalScrollBar(), SIGNAL( valueChanged(int) ), this, SLOT( on_patternEditorScroll(int) ) ); |
|---|
| 276 | |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | /* |
|---|
| 280 | m_pPianoRollScrollView = new QScrollArea( NULL ); |
|---|
| 281 | m_pPianoRollScrollView->setFrameShape( QFrame::NoFrame ); |
|---|
| 282 | m_pPianoRollScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 283 | m_pPianoRollScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 284 | |
|---|
| 285 | m_pPianoRollEditor = new PianoRollEditor( m_pPianoRollScrollView->viewport() ); |
|---|
| 286 | m_pPianoRollScrollView->setWidget( m_pPianoRollEditor ); |
|---|
| 287 | |
|---|
| 288 | connect( m_pPianoRollScrollView->verticalScrollBar(), SIGNAL( valueChanged(int) ), this, SLOT( on_patternEditorScroll(int) ) ); |
|---|
| 289 | |
|---|
| 290 | |
|---|
| 291 | m_pPianoRollScrollView->hide(); |
|---|
| 292 | */ |
|---|
| 293 | //~ EDITOR |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | // INSTRUMENT LIST |
|---|
| 301 | // Instrument list scrollview |
|---|
| 302 | m_pInstrListScrollView = new QScrollArea( NULL ); |
|---|
| 303 | m_pInstrListScrollView->setFrameShape( QFrame::NoFrame ); |
|---|
| 304 | m_pInstrListScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 305 | m_pInstrListScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 306 | |
|---|
| 307 | // Instrument list |
|---|
| 308 | m_pInstrumentList = new PatternEditorInstrumentList( m_pInstrListScrollView->viewport(), this ); |
|---|
| 309 | m_pInstrListScrollView->setWidget( m_pInstrumentList ); |
|---|
| 310 | m_pInstrListScrollView->setFixedWidth( m_pInstrumentList->width() ); |
|---|
| 311 | |
|---|
| 312 | connect( m_pInstrListScrollView->verticalScrollBar(), SIGNAL( valueChanged(int) ), this, SLOT( on_patternEditorScroll(int) ) ); |
|---|
| 313 | //~ INSTRUMENT LIST |
|---|
| 314 | |
|---|
| 315 | |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | // NOTE_VELOCITY EDITOR |
|---|
| 319 | m_pNoteVelocityScrollView = new QScrollArea( NULL ); |
|---|
| 320 | m_pNoteVelocityScrollView->setFrameShape( QFrame::NoFrame ); |
|---|
| 321 | m_pNoteVelocityScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 322 | m_pNoteVelocityScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 323 | m_pNoteVelocityEditor = new NotePropertiesRuler( m_pNoteVelocityScrollView->viewport(), this, NotePropertiesRuler::VELOCITY ); |
|---|
| 324 | m_pNoteVelocityScrollView->setWidget( m_pNoteVelocityEditor ); |
|---|
| 325 | m_pNoteVelocityScrollView->setFixedHeight( 100 ); |
|---|
| 326 | //~ NOTE_VELOCITY EDITOR |
|---|
| 327 | |
|---|
| 328 | |
|---|
| 329 | // NOTE_PAN EDITOR |
|---|
| 330 | m_pNotePanScrollView = new QScrollArea( NULL ); |
|---|
| 331 | m_pNotePanScrollView->setFrameShape( QFrame::NoFrame ); |
|---|
| 332 | m_pNotePanScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 333 | m_pNotePanScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 334 | m_pNotePanEditor = new NotePropertiesRuler( m_pNotePanScrollView->viewport(), this, NotePropertiesRuler::PAN ); |
|---|
| 335 | m_pNotePanScrollView->setWidget( m_pNotePanEditor ); |
|---|
| 336 | m_pNotePanScrollView->setFixedHeight( 100 ); |
|---|
| 337 | //~ NOTE_PAN EDITOR |
|---|
| 338 | |
|---|
| 339 | |
|---|
| 340 | // NOTE_LEADLAG EDITOR |
|---|
| 341 | m_pNoteLeadLagScrollView = new QScrollArea( NULL ); |
|---|
| 342 | m_pNoteLeadLagScrollView->setFrameShape( QFrame::NoFrame ); |
|---|
| 343 | m_pNoteLeadLagScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 344 | m_pNoteLeadLagScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 345 | m_pNoteLeadLagEditor = new NotePropertiesRuler( m_pNoteLeadLagScrollView->viewport(), this, NotePropertiesRuler::LEADLAG ); |
|---|
| 346 | m_pNoteLeadLagScrollView->setWidget( m_pNoteLeadLagEditor ); |
|---|
| 347 | m_pNoteLeadLagScrollView->setFixedHeight( 100 ); |
|---|
| 348 | //~ NOTE_LEADLAG EDITOR |
|---|
| 349 | |
|---|
| 350 | |
|---|
| 351 | // NOTE_NOTEKEY EDITOR |
|---|
| 352 | |
|---|
| 353 | |
|---|
| 354 | m_pNoteNoteKeyScrollView = new QScrollArea( NULL ); |
|---|
| 355 | m_pNoteNoteKeyScrollView->setFrameShape( QFrame::NoFrame ); |
|---|
| 356 | m_pNoteNoteKeyScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 357 | m_pNoteNoteKeyScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|---|
| 358 | m_pNoteNoteKeyEditor = new NotePropertiesRuler( m_pNoteNoteKeyScrollView->viewport(), this, NotePropertiesRuler::NOTEKEY ); |
|---|
| 359 | m_pNoteNoteKeyScrollView->setWidget( m_pNoteNoteKeyEditor ); |
|---|
| 360 | m_pNoteNoteKeyScrollView->setFixedHeight( 210 ); |
|---|
| 361 | |
|---|
| 362 | |
|---|
| 363 | //~ NOTE_NOTEKEY EDITOR |
|---|
| 364 | |
|---|
| 365 | |
|---|
| 366 | // external horizontal scrollbar |
|---|
| 367 | m_pPatternEditorHScrollBar = new QScrollBar( Qt::Horizontal , NULL ); |
|---|
| 368 | connect( m_pPatternEditorHScrollBar, SIGNAL(valueChanged(int)), this, SLOT( syncToExternalHorizontalScrollbar(int) ) ); |
|---|
| 369 | |
|---|
| 370 | // external vertical scrollbar |
|---|
| 371 | m_pPatternEditorVScrollBar = new QScrollBar( Qt::Vertical, NULL ); |
|---|
| 372 | connect( m_pPatternEditorVScrollBar, SIGNAL(valueChanged(int)), this, SLOT( syncToExternalHorizontalScrollbar(int) ) ); |
|---|
| 373 | |
|---|
| 374 | QHBoxLayout *pPatternEditorHScrollBarLayout = new QHBoxLayout(); |
|---|
| 375 | pPatternEditorHScrollBarLayout->setSpacing( 0 ); |
|---|
| 376 | pPatternEditorHScrollBarLayout->setMargin( 0 ); |
|---|
| 377 | pPatternEditorHScrollBarLayout->addWidget( m_pPatternEditorHScrollBar ); |
|---|
| 378 | pPatternEditorHScrollBarLayout->addWidget( zoom_in_btn ); |
|---|
| 379 | pPatternEditorHScrollBarLayout->addWidget( zoom_out_btn ); |
|---|
| 380 | |
|---|
| 381 | QWidget *pPatternEditorHScrollBarContainer = new QWidget(); |
|---|
| 382 | pPatternEditorHScrollBarContainer->setLayout( pPatternEditorHScrollBarLayout ); |
|---|
| 383 | |
|---|
| 384 | |
|---|
| 385 | QPalette label_palette; |
|---|
| 386 | label_palette.setColor( QPalette::Foreground, QColor( 230, 230, 230 ) ); |
|---|
| 387 | |
|---|
| 388 | QFont boldFont; |
|---|
| 389 | boldFont.setBold( true ); |
|---|
| 390 | m_pPatternNameLbl = new QLabel( NULL ); |
|---|
| 391 | m_pPatternNameLbl->setFont( boldFont ); |
|---|
| 392 | m_pPatternNameLbl->setText( "pattern name label" ); |
|---|
| 393 | //m_pPatternNameLbl->setFixedWidth(200); |
|---|
| 394 | m_pPatternNameLbl->setPalette(label_palette); |
|---|
| 395 | |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | |
|---|
| 400 | |
|---|
| 401 | // NOTE_PROPERTIES BUTTONS |
|---|
| 402 | PixmapWidget *pPropertiesPanel = new PixmapWidget( NULL ); |
|---|
| 403 | pPropertiesPanel->setColor( QColor( 58, 62, 72 ) ); |
|---|
| 404 | |
|---|
| 405 | pPropertiesPanel->setFixedSize( 181, 100 ); |
|---|
| 406 | |
|---|
| 407 | QVBoxLayout *pPropertiesVBox = new QVBoxLayout( pPropertiesPanel ); |
|---|
| 408 | pPropertiesVBox->setSpacing( 0 ); |
|---|
| 409 | pPropertiesVBox->setMargin( 0 ); |
|---|
| 410 | |
|---|
| 411 | |
|---|
| 412 | LCDCombo* pPropertiesCombo = new LCDCombo( NULL, 20); |
|---|
| 413 | pPropertiesCombo->setToolTip(trUtf8("Select note properties")); |
|---|
| 414 | pPropertiesCombo->addItem( trUtf8("Velocity") ); |
|---|
| 415 | pPropertiesCombo->addItem( trUtf8("Pan") ); |
|---|
| 416 | pPropertiesCombo->addItem( trUtf8("Lead and Lag") ); |
|---|
| 417 | pPropertiesCombo->addItem( trUtf8("NoteKey") ); |
|---|
| 418 | pPropertiesCombo->update(); |
|---|
| 419 | connect( pPropertiesCombo, SIGNAL(valueChanged(QString)), this, SLOT(propertiesComboChanged(QString))); |
|---|
| 420 | |
|---|
| 421 | pPropertiesVBox->addWidget( pPropertiesCombo ); |
|---|
| 422 | |
|---|
| 423 | |
|---|
| 424 | //~ NOTE_PROPERTIES BUTTONS |
|---|
| 425 | |
|---|
| 426 | |
|---|
| 427 | // LAYOUT |
|---|
| 428 | QWidget *pMainPanel = new QWidget(); |
|---|
| 429 | |
|---|
| 430 | QGridLayout *pGrid = new QGridLayout(); |
|---|
| 431 | pGrid->setSpacing( 0 ); |
|---|
| 432 | pGrid->setMargin( 0 ); |
|---|
| 433 | |
|---|
| 434 | pGrid->addWidget( editor_top, 0, 0); |
|---|
| 435 | pGrid->addWidget( editor_top_2, 0, 1, 1, 3); |
|---|
| 436 | pGrid->addWidget( m_pPatternNameLbl, 1, 0 ); |
|---|
| 437 | pGrid->addWidget( m_pRulerScrollView, 1, 1 ); |
|---|
| 438 | |
|---|
| 439 | pGrid->addWidget( m_pInstrListScrollView, 2, 0 ); |
|---|
| 440 | |
|---|
| 441 | pGrid->addWidget( m_pEditorScrollView, 2, 1 ); |
|---|
| 442 | // pGrid->addWidget( m_pPianoRollScrollView, 2, 1 ); |
|---|
| 443 | |
|---|
| 444 | pGrid->addWidget( m_pPatternEditorVScrollBar, 2, 2 ); |
|---|
| 445 | pGrid->addWidget( pPatternEditorHScrollBarContainer, 10, 1 ); |
|---|
| 446 | pGrid->addWidget( m_pNoteVelocityScrollView, 4, 1 ); |
|---|
| 447 | pGrid->addWidget( m_pNotePanScrollView, 4, 1 ); |
|---|
| 448 | pGrid->addWidget( m_pNoteLeadLagScrollView, 4, 1 ); |
|---|
| 449 | pGrid->addWidget( m_pNoteNoteKeyScrollView, 4, 1 ); |
|---|
| 450 | |
|---|
| 451 | pGrid->addWidget( pPropertiesPanel, 4, 0 ); |
|---|
| 452 | pGrid->setRowStretch( 2, 100 ); |
|---|
| 453 | pMainPanel->setLayout( pGrid ); |
|---|
| 454 | |
|---|
| 455 | |
|---|
| 456 | |
|---|
| 457 | |
|---|
| 458 | |
|---|
| 459 | // restore grid resolution |
|---|
| 460 | int nIndex; |
|---|
| 461 | if ( pPref->isPatternEditorUsingTriplets() == false ) { |
|---|
| 462 | switch ( pPref->getPatternEditorGridResolution() ) { |
|---|
| 463 | case 4: |
|---|
| 464 | __resolution_combo->set_text( "4" ); |
|---|
| 465 | nIndex = 0; |
|---|
| 466 | break; |
|---|
| 467 | |
|---|
| 468 | case 8: |
|---|
| 469 | __resolution_combo->set_text( "8" ); |
|---|
| 470 | nIndex = 1; |
|---|
| 471 | break; |
|---|
| 472 | |
|---|
| 473 | case 16: |
|---|
| 474 | __resolution_combo->set_text( "16" ); |
|---|
| 475 | nIndex = 2; |
|---|
| 476 | break; |
|---|
| 477 | |
|---|
| 478 | case 32: |
|---|
| 479 | __resolution_combo->set_text( "32" ); |
|---|
| 480 | nIndex = 3; |
|---|
| 481 | break; |
|---|
| 482 | |
|---|
| 483 | case 64: |
|---|
| 484 | __resolution_combo->set_text( "64" ); |
|---|
| 485 | nIndex = 4; |
|---|
| 486 | break; |
|---|
| 487 | |
|---|
| 488 | default: |
|---|
| 489 | ERRORLOG( "Wrong grid resolution: " + to_string( pPref->getPatternEditorGridResolution() ) ); |
|---|
| 490 | __resolution_combo->set_text( "4" ); |
|---|
| 491 | nIndex = 0; |
|---|
| 492 | } |
|---|
| 493 | } |
|---|
| 494 | else { |
|---|
| 495 | switch ( pPref->getPatternEditorGridResolution() ) { |
|---|
| 496 | case 8: |
|---|
| 497 | __resolution_combo->set_text( "4T" ); |
|---|
| 498 | nIndex = 5; |
|---|
| 499 | break; |
|---|
| 500 | |
|---|
| 501 | case 16: |
|---|
| 502 | __resolution_combo->set_text( "8T" ); |
|---|
| 503 | nIndex = 6; |
|---|
| 504 | break; |
|---|
| 505 | |
|---|
| 506 | case 32: |
|---|
| 507 | __resolution_combo->set_text( "16T" ); |
|---|
| 508 | nIndex = 7; |
|---|
| 509 | break; |
|---|
| 510 | |
|---|
| 511 | case 64: |
|---|
| 512 | __resolution_combo->set_text( "32T" ); |
|---|
| 513 | nIndex = 8; |
|---|
| 514 | break; |
|---|
| 515 | |
|---|
| 516 | default: |
|---|
| 517 | ERRORLOG( "Wrong grid resolution: " + to_string( pPref->getPatternEditorGridResolution() ) ); |
|---|
| 518 | __resolution_combo->set_text( "4T" ); |
|---|
| 519 | nIndex = 5; |
|---|
| 520 | } |
|---|
| 521 | } |
|---|
| 522 | gridResolutionChanged(__resolution_combo->getText()); |
|---|
| 523 | |
|---|
| 524 | |
|---|
| 525 | |
|---|
| 526 | |
|---|
| 527 | |
|---|
| 528 | |
|---|
| 529 | // LAYOUT |
|---|
| 530 | QVBoxLayout *pVBox = new QVBoxLayout(); |
|---|
| 531 | pVBox->setSpacing( 0 ); |
|---|
| 532 | pVBox->setMargin( 0 ); |
|---|
| 533 | this->setLayout( pVBox ); |
|---|
| 534 | |
|---|
| 535 | pVBox->addWidget( pMainPanel ); |
|---|
| 536 | |
|---|
| 537 | HydrogenApp::getInstance()->addEventListener( this ); |
|---|
| 538 | |
|---|
| 539 | selectedPatternChangedEvent(); // force an update |
|---|
| 540 | |
|---|
| 541 | pPropertiesCombo->set_text( trUtf8("Velocity")); |
|---|
| 542 | } |
|---|
| 543 | |
|---|
| 544 | |
|---|
| 545 | |
|---|
| 546 | |
|---|
| 547 | PatternEditorPanel::~PatternEditorPanel() |
|---|
| 548 | { |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | |
|---|
| 552 | |
|---|
| 553 | void PatternEditorPanel::syncToExternalHorizontalScrollbar(int) |
|---|
| 554 | { |
|---|
| 555 | // INFOLOG( "[syncToExternalHorizontalScrollbar]" ); |
|---|
| 556 | |
|---|
| 557 | // drum Editor |
|---|
| 558 | m_pEditorScrollView->horizontalScrollBar()->setValue( m_pPatternEditorHScrollBar->value() ); |
|---|
| 559 | m_pEditorScrollView->verticalScrollBar()->setValue( m_pPatternEditorVScrollBar->value() ); |
|---|
| 560 | |
|---|
| 561 | // piano roll Editor |
|---|
| 562 | // m_pPianoRollScrollView->horizontalScrollBar()->setValue( m_pPatternEditorHScrollBar->value() ); |
|---|
| 563 | // m_pPianoRollScrollView->verticalScrollBar()->setValue( m_pPatternEditorVScrollBar->value() ); |
|---|
| 564 | |
|---|
| 565 | |
|---|
| 566 | // Ruler |
|---|
| 567 | m_pRulerScrollView->horizontalScrollBar()->setValue( m_pPatternEditorHScrollBar->value() ); |
|---|
| 568 | |
|---|
| 569 | // Instrument list |
|---|
| 570 | m_pInstrListScrollView->verticalScrollBar()->setValue( m_pPatternEditorVScrollBar->value() ); |
|---|
| 571 | |
|---|
| 572 | // Velocity ruler |
|---|
| 573 | m_pNoteVelocityScrollView->horizontalScrollBar()->setValue( m_pPatternEditorHScrollBar->value() ); |
|---|
| 574 | |
|---|
| 575 | // pan ruler |
|---|
| 576 | m_pNotePanScrollView->horizontalScrollBar()->setValue( m_pPatternEditorHScrollBar->value() ); |
|---|
| 577 | |
|---|
| 578 | // leadlag ruler |
|---|
| 579 | m_pNoteLeadLagScrollView->horizontalScrollBar()->setValue( m_pPatternEditorHScrollBar->value() ); |
|---|
| 580 | } |
|---|
| 581 | |
|---|
| 582 | |
|---|
| 583 | void PatternEditorPanel::on_patternEditorScroll(int nValue) |
|---|
| 584 | { |
|---|
| 585 | // INFOLOG( "[on_patternEditorScroll]" ); |
|---|
| 586 | m_pPatternEditorVScrollBar->setValue( nValue ); |
|---|
| 587 | } |
|---|
| 588 | |
|---|
| 589 | |
|---|
| 590 | |
|---|
| 591 | |
|---|
| 592 | void PatternEditorPanel::gridResolutionChanged( QString str ) |
|---|
| 593 | { |
|---|
| 594 | int nResolution; |
|---|
| 595 | bool bUseTriplets = false; |
|---|
| 596 | |
|---|
| 597 | if ( str.contains( "off" ) ) { |
|---|
| 598 | nResolution=MAX_NOTES; |
|---|
| 599 | } |
|---|
| 600 | else if ( str.contains( "T" ) ) { |
|---|
| 601 | bUseTriplets = true; |
|---|
| 602 | QString temp = str; |
|---|
| 603 | temp.chop( 1 ); |
|---|
| 604 | nResolution = temp.toInt() * 2; |
|---|
| 605 | } |
|---|
| 606 | else { |
|---|
| 607 | nResolution = str.toInt(); |
|---|
| 608 | } |
|---|
| 609 | |
|---|
| 610 | //INFOLOG( to_string( nResolution ) ); |
|---|
| 611 | m_pDrumPatternEditor->setResolution( nResolution, bUseTriplets ); |
|---|
| 612 | |
|---|
| 613 | Preferences::getInstance()->setPatternEditorGridResolution( nResolution ); |
|---|
| 614 | Preferences::getInstance()->setPatternEditorUsingTriplets( bUseTriplets ); |
|---|
| 615 | } |
|---|
| 616 | |
|---|
| 617 | |
|---|
| 618 | |
|---|
| 619 | void PatternEditorPanel::selectedPatternChangedEvent() |
|---|
| 620 | { |
|---|
| 621 | PatternList *pPatternList = Hydrogen::get_instance()->getSong()->get_pattern_list(); |
|---|
| 622 | int nSelectedPatternNumber = Hydrogen::get_instance()->getSelectedPatternNumber(); |
|---|
| 623 | |
|---|
| 624 | if ( (nSelectedPatternNumber != -1) && ( (uint)nSelectedPatternNumber < pPatternList->get_size() ) ) { |
|---|
| 625 | // update pattern name text |
|---|
| 626 | m_pPattern = pPatternList->get( nSelectedPatternNumber ); |
|---|
| 627 | QString sCurrentPatternName = m_pPattern->get_name(); |
|---|
| 628 | this->setWindowTitle( ( trUtf8( "Pattern editor - %1").arg( sCurrentPatternName ) ) ); |
|---|
| 629 | //m_pNameLCD->setText( sCurrentPatternName ); |
|---|
| 630 | m_pPatternNameLbl->setText( sCurrentPatternName ); |
|---|
| 631 | |
|---|
| 632 | // update pattern size combobox |
|---|
| 633 | int nPatternSize = m_pPattern->get_lenght(); |
|---|
| 634 | int nEighth = MAX_NOTES / 8; |
|---|
| 635 | for ( int i = 1; i <= 32; i++ ) { |
|---|
| 636 | if ( nPatternSize == nEighth * i ) { |
|---|
| 637 | __pattern_size_combo->set_text( QString( "%1" ).arg( i ) ); |
|---|
| 638 | break; |
|---|
| 639 | } |
|---|
| 640 | } |
|---|
| 641 | } |
|---|
| 642 | else { |
|---|
| 643 | m_pPattern = NULL; |
|---|
| 644 | |
|---|
| 645 | this->setWindowTitle( ( trUtf8( "Pattern editor - %1").arg(QString("No pattern selected.")) ) ); |
|---|
| 646 | //m_pNameLCD->setText( trUtf8( "No pattern selected" ) ); |
|---|
| 647 | m_pPatternNameLbl->setText( trUtf8( "No pattern selected" ) ); |
|---|
| 648 | } |
|---|
| 649 | |
|---|
| 650 | resizeEvent( NULL ); // force an update of the scrollbars |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | |
|---|
| 654 | |
|---|
| 655 | void PatternEditorPanel::hearNotesBtnClick(Button *ref) |
|---|
| 656 | { |
|---|
| 657 | Preferences *pref = ( Preferences::getInstance() ); |
|---|
| 658 | pref->setHearNewNotes( ref->isPressed() ); |
|---|
| 659 | |
|---|
| 660 | if (ref->isPressed() ) { |
|---|
| 661 | ( HydrogenApp::getInstance() )->setStatusBarMessage( trUtf8( "Hear new notes = On" ), 2000 ); |
|---|
| 662 | } |
|---|
| 663 | else { |
|---|
| 664 | ( HydrogenApp::getInstance() )->setStatusBarMessage( trUtf8( "Hear new notes = Off" ), 2000 ); |
|---|
| 665 | } |
|---|
| 666 | |
|---|
| 667 | } |
|---|
| 668 | |
|---|
| 669 | |
|---|
| 670 | |
|---|
| 671 | void PatternEditorPanel::recordEventsBtnClick(Button *ref) |
|---|
| 672 | { |
|---|
| 673 | Preferences *pref = ( Preferences::getInstance() ); |
|---|
| 674 | pref->setRecordEvents( ref->isPressed() ); |
|---|
| 675 | |
|---|
| 676 | if (ref->isPressed() ) { |
|---|
| 677 | ( HydrogenApp::getInstance() )->setStatusBarMessage( trUtf8( "Record keyboard/midi events = On" ), 2000 ); |
|---|
| 678 | } |
|---|
| 679 | else { |
|---|
| 680 | ( HydrogenApp::getInstance() )->setStatusBarMessage( trUtf8( "Record keyboard/midi events = Off" ), 2000 ); |
|---|
| 681 | } |
|---|
| 682 | |
|---|
| 683 | |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | |
|---|
| 687 | void PatternEditorPanel::quantizeEventsBtnClick(Button *ref) |
|---|
| 688 | { |
|---|
| 689 | Preferences *pref = ( Preferences::getInstance() ); |
|---|
| 690 | pref->setQuantizeEvents( ref->isPressed() ); |
|---|
| 691 | |
|---|
| 692 | if (ref->isPressed() ) { |
|---|
| 693 | ( HydrogenApp::getInstance() )->setStatusBarMessage( trUtf8( "Quantize incoming keyboard/midi events = On" ), 2000 ); |
|---|
| 694 | } |
|---|
| 695 | else { |
|---|
| 696 | ( HydrogenApp::getInstance() )->setStatusBarMessage( trUtf8( "Quantize incoming keyboard/midi events = Off" ), 2000 ); |
|---|
| 697 | } |
|---|
| 698 | } |
|---|
| 699 | |
|---|
| 700 | |
|---|
| 701 | |
|---|
| 702 | |
|---|
| 703 | void PatternEditorPanel::stateChangedEvent(int state) |
|---|
| 704 | { |
|---|
| 705 | if ( state == STATE_READY) { |
|---|
| 706 | m_bEnablePatternResize = true; |
|---|
| 707 | } |
|---|
| 708 | else { |
|---|
| 709 | m_bEnablePatternResize = false; |
|---|
| 710 | } |
|---|
| 711 | } |
|---|
| 712 | |
|---|
| 713 | |
|---|
| 714 | |
|---|
| 715 | void PatternEditorPanel::resizeEvent( QResizeEvent *ev ) |
|---|
| 716 | { |
|---|
| 717 | UNUSED( ev ); |
|---|
| 718 | QScrollArea *pScrollArea = m_pEditorScrollView; |
|---|
| 719 | |
|---|
| 720 | /* |
|---|
| 721 | if ( m_pPianoRollScrollView->isVisible() ) { |
|---|
| 722 | pScrollArea = m_pPianoRollScrollView; |
|---|
| 723 | } |
|---|
| 724 | else { |
|---|
| 725 | pScrollArea = m_pEditorScrollView; |
|---|
| 726 | } |
|---|
| 727 | */ |
|---|
| 728 | |
|---|
| 729 | m_pPatternEditorHScrollBar->setMinimum( pScrollArea->horizontalScrollBar()->minimum() ); |
|---|
| 730 | m_pPatternEditorHScrollBar->setMaximum( pScrollArea->horizontalScrollBar()->maximum() ); |
|---|
| 731 | m_pPatternEditorHScrollBar->setSingleStep( pScrollArea->horizontalScrollBar()->singleStep() ); |
|---|
| 732 | m_pPatternEditorHScrollBar->setPageStep( pScrollArea->horizontalScrollBar()->pageStep() ); |
|---|
| 733 | |
|---|
| 734 | m_pPatternEditorVScrollBar->setMinimum( pScrollArea->verticalScrollBar()->minimum() ); |
|---|
| 735 | m_pPatternEditorVScrollBar->setMaximum( pScrollArea->verticalScrollBar()->maximum() ); |
|---|
| 736 | m_pPatternEditorVScrollBar->setSingleStep( pScrollArea->verticalScrollBar()->singleStep() ); |
|---|
| 737 | m_pPatternEditorVScrollBar->setPageStep( pScrollArea->verticalScrollBar()->pageStep() ); |
|---|
| 738 | } |
|---|
| 739 | |
|---|
| 740 | |
|---|
| 741 | |
|---|
| 742 | |
|---|
| 743 | void PatternEditorPanel::showEvent ( QShowEvent *ev ) |
|---|
| 744 | { |
|---|
| 745 | UNUSED( ev ); |
|---|
| 746 | // m_pPatternEditorVScrollBar->setValue( m_pPatternEditorVScrollBar->maximum() ); |
|---|
| 747 | } |
|---|
| 748 | |
|---|
| 749 | |
|---|
| 750 | /// richiamato dall'uso dello scroll del mouse |
|---|
| 751 | void PatternEditorPanel::contentsMoving(int dummy) |
|---|
| 752 | { |
|---|
| 753 | UNUSED( dummy ); |
|---|
| 754 | //INFOLOG( "contentsMoving" ); |
|---|
| 755 | syncToExternalHorizontalScrollbar(0); |
|---|
| 756 | } |
|---|
| 757 | |
|---|
| 758 | |
|---|
| 759 | |
|---|
| 760 | void PatternEditorPanel::selectedInstrumentChangedEvent() |
|---|
| 761 | { |
|---|
| 762 | //m_pNoteVelocityEditor->updateEditor(); |
|---|
| 763 | //m_pNotePanEditor->updateEditor(); |
|---|
| 764 | //m_pNoteLeadLagEditor->updateEditor(); |
|---|
| 765 | |
|---|
| 766 | resizeEvent(NULL); // force a scrollbar update |
|---|
| 767 | } |
|---|
| 768 | |
|---|
| 769 | |
|---|
| 770 | |
|---|
| 771 | void PatternEditorPanel::showDrumEditorBtnClick(Button *ref) |
|---|
| 772 | { |
|---|
| 773 | UNUSED( ref ); |
|---|
| 774 | __show_drum_btn->setPressed( true ); |
|---|
| 775 | __show_piano_btn->setPressed( false ); |
|---|
| 776 | |
|---|
| 777 | |
|---|
| 778 | // m_pPianoRollScrollView->hide(); |
|---|
| 779 | m_pEditorScrollView->show(); |
|---|
| 780 | m_pInstrListScrollView->show(); |
|---|
| 781 | |
|---|
| 782 | m_pDrumPatternEditor->selectedInstrumentChangedEvent(); // force an update |
|---|
| 783 | |
|---|
| 784 | // force a re-sync of extern scrollbars |
|---|
| 785 | resizeEvent( NULL ); |
|---|
| 786 | } |
|---|
| 787 | |
|---|
| 788 | |
|---|
| 789 | |
|---|
| 790 | void PatternEditorPanel::showPianoEditorBtnClick(Button *ref) |
|---|
| 791 | { |
|---|
| 792 | UNUSED( ref ); |
|---|
| 793 | __show_piano_btn->setPressed( true ); |
|---|
| 794 | __show_drum_btn->setPressed( false ); |
|---|
| 795 | |
|---|
| 796 | |
|---|
| 797 | // m_pPianoRollScrollView->show(); |
|---|
| 798 | m_pEditorScrollView->hide(); |
|---|
| 799 | m_pInstrListScrollView->hide(); |
|---|
| 800 | |
|---|
| 801 | // m_pPianoRollEditor->selectedInstrumentChangedEvent(); // force an update |
|---|
| 802 | |
|---|
| 803 | // force a re-sync of extern scrollbars |
|---|
| 804 | resizeEvent( NULL ); |
|---|
| 805 | } |
|---|
| 806 | |
|---|
| 807 | |
|---|
| 808 | |
|---|
| 809 | |
|---|
| 810 | void PatternEditorPanel::zoomInBtnClicked(Button *ref) |
|---|
| 811 | { |
|---|
| 812 | UNUSED( ref ); |
|---|
| 813 | m_pPatternEditorRuler->zoomIn(); |
|---|
| 814 | m_pDrumPatternEditor->zoom_in(); |
|---|
| 815 | m_pNoteVelocityEditor->zoomIn(); |
|---|
| 816 | m_pNoteLeadLagEditor->zoomIn(); |
|---|
| 817 | m_pNoteNoteKeyEditor->zoomIn(); |
|---|
| 818 | m_pNotePanEditor->zoomIn(); |
|---|
| 819 | |
|---|
| 820 | resizeEvent( NULL ); |
|---|
| 821 | } |
|---|
| 822 | |
|---|
| 823 | |
|---|
| 824 | |
|---|
| 825 | void PatternEditorPanel::zoomOutBtnClicked(Button *ref) |
|---|
| 826 | { |
|---|
| 827 | UNUSED( ref ); |
|---|
| 828 | m_pPatternEditorRuler->zoomOut(); |
|---|
| 829 | m_pDrumPatternEditor->zoom_out(); |
|---|
| 830 | m_pNoteVelocityEditor->zoomOut(); |
|---|
| 831 | m_pNoteLeadLagEditor->zoomOut(); |
|---|
| 832 | m_pNoteNoteKeyEditor->zoomOut(); |
|---|
| 833 | m_pNotePanEditor->zoomOut(); |
|---|
| 834 | |
|---|
| 835 | resizeEvent( NULL ); |
|---|
| 836 | } |
|---|
| 837 | |
|---|
| 838 | |
|---|
| 839 | |
|---|
| 840 | void PatternEditorPanel::patternSizeChanged( QString str ) |
|---|
| 841 | { |
|---|
| 842 | INFOLOG( "pattern size changed" ); |
|---|
| 843 | |
|---|
| 844 | uint nEighth = MAX_NOTES / 8; |
|---|
| 845 | int nSelected = str.toInt(); |
|---|
| 846 | |
|---|
| 847 | if ( m_pPattern->get_lenght() == nEighth * nSelected ) { |
|---|
| 848 | // non e' necessario aggiornare |
|---|
| 849 | return; |
|---|
| 850 | } |
|---|
| 851 | |
|---|
| 852 | |
|---|
| 853 | if ( !m_pPattern ) { |
|---|
| 854 | return; |
|---|
| 855 | } |
|---|
| 856 | |
|---|
| 857 | if ( !m_bEnablePatternResize ) { |
|---|
| 858 | __pattern_size_combo->set_text(QString::number(m_pPattern->get_lenght() / nEighth ),false); |
|---|
| 859 | QMessageBox::information( this, "Hydrogen", trUtf8( "Is not possible to change the pattern size when playing." ) ); |
|---|
| 860 | return; |
|---|
| 861 | } |
|---|
| 862 | |
|---|
| 863 | |
|---|
| 864 | if ( nSelected > 0 && nSelected <= 32 ) { |
|---|
| 865 | m_pPattern->set_lenght( nEighth * nSelected ); |
|---|
| 866 | //m_pPatternSizeLCD->setText( QString( "%1" ).arg( nSelected ) ); |
|---|
| 867 | } |
|---|
| 868 | else { |
|---|
| 869 | ERRORLOG( "[patternSizeChanged] Unhandled case " + to_string( nSelected ) ); |
|---|
| 870 | } |
|---|
| 871 | |
|---|
| 872 | m_pPatternEditorRuler->updateEditor( true ); // redraw all |
|---|
| 873 | m_pNoteVelocityEditor->updateEditor(); |
|---|
| 874 | m_pNotePanEditor->updateEditor(); |
|---|
| 875 | m_pNoteLeadLagEditor->updateEditor(); |
|---|
| 876 | m_pNoteNoteKeyEditor->updateEditor(); |
|---|
| 877 | |
|---|
| 878 | resizeEvent( NULL ); |
|---|
| 879 | |
|---|
| 880 | EventQueue::get_instance()->push_event( EVENT_SELECTED_PATTERN_CHANGED, -1 ); |
|---|
| 881 | } |
|---|
| 882 | |
|---|
| 883 | |
|---|
| 884 | |
|---|
| 885 | void PatternEditorPanel::moveUpBtnClicked(Button *) |
|---|
| 886 | { |
|---|
| 887 | Hydrogen *engine = Hydrogen::get_instance(); |
|---|
| 888 | int nSelectedInstrument = engine->getSelectedInstrumentNumber(); |
|---|
| 889 | |
|---|
| 890 | AudioEngine::get_instance()->lock( "PatternEditorPanel::moveUpBtnClicked" ); |
|---|
| 891 | |
|---|
| 892 | Song *pSong = engine->getSong(); |
|---|
| 893 | InstrumentList *pInstrumentList = pSong->get_instrument_list(); |
|---|
| 894 | |
|---|
| 895 | if ( ( nSelectedInstrument - 1 ) >= 0 ) { |
|---|
| 896 | Instrument *pTemp = pInstrumentList->get( nSelectedInstrument - 1 ); |
|---|
| 897 | pInstrumentList->replace( pInstrumentList->get( nSelectedInstrument ), nSelectedInstrument - 1 ); |
|---|
| 898 | pInstrumentList->replace( pTemp, nSelectedInstrument ); |
|---|
| 899 | |
|---|
| 900 | /* |
|---|
| 901 | // devo spostare tutte le note... |
|---|
| 902 | PatternList *pPatternList = pSong->getPatternList(); |
|---|
| 903 | for ( int nPattern = 0; nPattern < pPatternList->getSize(); nPattern++ ) { |
|---|
| 904 | Pattern *pPattern = pPatternList->get( nPattern ); |
|---|
| 905 | Sequence *pSeq1 = pPattern->m_pSequenceList->get( nSelectedInstrument ); |
|---|
| 906 | Sequence *pSeq2 = pPattern->m_pSequenceList->get( nSelectedInstrument - 1 ); |
|---|
| 907 | |
|---|
| 908 | // swap notelist.. |
|---|
| 909 | map <int, Note*> noteList = pSeq1->m_noteList; |
|---|
| 910 | pSeq1->m_noteList = pSeq2->m_noteList; |
|---|
| 911 | pSeq2->m_noteList = noteList; |
|---|
| 912 | } |
|---|
| 913 | */ |
|---|
| 914 | AudioEngine::get_instance()->unlock(); |
|---|
| 915 | engine->setSelectedInstrumentNumber( nSelectedInstrument - 1 ); |
|---|
| 916 | |
|---|
| 917 | pSong->__is_modified = true; |
|---|
| 918 | } |
|---|
| 919 | else { |
|---|
| 920 | AudioEngine::get_instance()->unlock(); |
|---|
| 921 | } |
|---|
| 922 | } |
|---|
| 923 | |
|---|
| 924 | |
|---|
| 925 | |
|---|
| 926 | void PatternEditorPanel::moveDownBtnClicked(Button *) |
|---|
| 927 | { |
|---|
| 928 | Hydrogen *engine = Hydrogen::get_instance(); |
|---|
| 929 | int nSelectedInstrument = engine->getSelectedInstrumentNumber(); |
|---|
| 930 | |
|---|
| 931 | AudioEngine::get_instance()->lock( "PatternEditorPanel::moveDownBtnClicked" ); |
|---|
| 932 | |
|---|
| 933 | Song *pSong = engine->getSong(); |
|---|
| 934 | InstrumentList *pInstrumentList = pSong->get_instrument_list(); |
|---|
| 935 | |
|---|
| 936 | if ( ( nSelectedInstrument + 1 ) < (int)pInstrumentList->get_size() ) { |
|---|
| 937 | Instrument *pTemp = pInstrumentList->get( nSelectedInstrument + 1 ); |
|---|
| 938 | pInstrumentList->replace( pInstrumentList->get( nSelectedInstrument ), nSelectedInstrument + 1 ); |
|---|
| 939 | pInstrumentList->replace( pTemp, nSelectedInstrument ); |
|---|
| 940 | |
|---|
| 941 | /* |
|---|
| 942 | // devo spostare tutte le note... |
|---|
| 943 | PatternList *pPatternList = pSong->getPatternList(); |
|---|
| 944 | for ( int nPattern = 0; nPattern < pPatternList->getSize(); nPattern++ ) { |
|---|
| 945 | Pattern *pPattern = pPatternList->get( nPattern ); |
|---|
| 946 | Sequence *pSeq1 = pPattern->m_pSequenceList->get( nSelectedInstrument ); |
|---|
| 947 | Sequence *pSeq2 = pPattern->m_pSequenceList->get( nSelectedInstrument + 1 ); |
|---|
| 948 | |
|---|
| 949 | // swap notelist.. |
|---|
| 950 | map <int, Note*> noteList = pSeq1->m_noteList; |
|---|
| 951 | pSeq1->m_noteList = pSeq2->m_noteList; |
|---|
| 952 | pSeq2->m_noteList = noteList; |
|---|
| 953 | } |
|---|
| 954 | */ |
|---|
| 955 | AudioEngine::get_instance()->unlock(); |
|---|
| 956 | engine->setSelectedInstrumentNumber( nSelectedInstrument + 1 ); |
|---|
| 957 | |
|---|
| 958 | pSong->__is_modified = true; |
|---|
| 959 | } |
|---|
| 960 | else { |
|---|
| 961 | AudioEngine::get_instance()->unlock(); |
|---|
| 962 | } |
|---|
| 963 | |
|---|
| 964 | } |
|---|
| 965 | |
|---|
| 966 | |
|---|
| 967 | |
|---|
| 968 | |
|---|
| 969 | void PatternEditorPanel::dragEnterEvent(QDragEnterEvent *event) |
|---|
| 970 | { |
|---|
| 971 | m_pInstrumentList->dragEnterEvent( event ); |
|---|
| 972 | } |
|---|
| 973 | |
|---|
| 974 | |
|---|
| 975 | |
|---|
| 976 | void PatternEditorPanel::dropEvent(QDropEvent *event) |
|---|
| 977 | { |
|---|
| 978 | m_pInstrumentList->dropEvent( event ); |
|---|
| 979 | } |
|---|
| 980 | |
|---|
| 981 | |
|---|
| 982 | |
|---|
| 983 | void PatternEditorPanel::propertiesComboChanged( QString text ) |
|---|
| 984 | { |
|---|
| 985 | if ( text == trUtf8( "Velocity" ) ) { |
|---|
| 986 | m_pNotePanScrollView->hide(); |
|---|
| 987 | m_pNoteLeadLagScrollView->hide(); |
|---|
| 988 | m_pNoteNoteKeyScrollView->hide(); |
|---|
| 989 | m_pNoteVelocityScrollView->show(); |
|---|
| 990 | |
|---|
| 991 | m_pNoteVelocityEditor->updateEditor(); |
|---|
| 992 | } |
|---|
| 993 | else if ( text == trUtf8( "Pan" ) ) { |
|---|
| 994 | m_pNoteVelocityScrollView->hide(); |
|---|
| 995 | m_pNoteLeadLagScrollView->hide(); |
|---|
| 996 | m_pNoteNoteKeyScrollView->hide(); |
|---|
| 997 | m_pNotePanScrollView->show(); |
|---|
| 998 | |
|---|
| 999 | m_pNotePanEditor->updateEditor(); |
|---|
| 1000 | } |
|---|
| 1001 | else if ( text == trUtf8( "Lead and Lag" ) ) { |
|---|
| 1002 | m_pNoteVelocityScrollView->hide(); |
|---|
| 1003 | m_pNotePanScrollView->hide(); |
|---|
| 1004 | m_pNoteNoteKeyScrollView->hide(); |
|---|
| 1005 | m_pNoteLeadLagScrollView->show(); |
|---|
| 1006 | |
|---|
| 1007 | m_pNoteLeadLagEditor->updateEditor(); |
|---|
| 1008 | } |
|---|
| 1009 | else if ( text == trUtf8( "NoteKey" ) ) { |
|---|
| 1010 | m_pNoteVelocityScrollView->hide(); |
|---|
| 1011 | m_pNotePanScrollView->hide(); |
|---|
| 1012 | m_pNoteLeadLagScrollView->hide(); |
|---|
| 1013 | m_pNoteNoteKeyScrollView->show(); |
|---|
| 1014 | |
|---|
| 1015 | m_pNoteNoteKeyEditor->updateEditor(); |
|---|
| 1016 | } |
|---|
| 1017 | else if ( text == trUtf8( "Cutoff" ) ) { |
|---|
| 1018 | } |
|---|
| 1019 | else if ( text == trUtf8( "Resonance" ) ) { |
|---|
| 1020 | } |
|---|
| 1021 | else { |
|---|
| 1022 | ERRORLOG( "Unknown text: " + text ); |
|---|
| 1023 | } |
|---|
| 1024 | } |
|---|
| 1025 | |
|---|
| 1026 | |
|---|
| 1027 | void PatternEditorPanel::playselectedinstrument( QString text ) |
|---|
| 1028 | { |
|---|
| 1029 | if ( text == "keyb: play drumset" ){ |
|---|
| 1030 | Preferences::getInstance()->__playselectedinstrument = false; |
|---|
| 1031 | }else |
|---|
| 1032 | { |
|---|
| 1033 | Preferences::getInstance()->__playselectedinstrument = true; |
|---|
| 1034 | } |
|---|
| 1035 | } |
|---|