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