| 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/note.h> |
|---|
| 28 | using namespace H2Core; |
|---|
| 29 | |
|---|
| 30 | #include <cassert> |
|---|
| 31 | |
|---|
| 32 | #include "../HydrogenApp.h" |
|---|
| 33 | |
|---|
| 34 | #include "NotePropertiesRuler.h" |
|---|
| 35 | #include "PatternEditorPanel.h" |
|---|
| 36 | #include "DrumPatternEditor.h" |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | NotePropertiesRuler::NotePropertiesRuler( QWidget *parent, PatternEditorPanel *pPatternEditorPanel, NotePropertiesMode mode ) |
|---|
| 40 | : QWidget( parent ) |
|---|
| 41 | , Object( "NotePropertiesRuler" ) |
|---|
| 42 | , m_mode( mode ) |
|---|
| 43 | , m_pPatternEditorPanel( pPatternEditorPanel ) |
|---|
| 44 | , m_pPattern( NULL ) |
|---|
| 45 | { |
|---|
| 46 | //infoLog("INIT"); |
|---|
| 47 | //setAttribute(Qt::WA_NoBackground); |
|---|
| 48 | |
|---|
| 49 | m_nGridWidth = (Preferences::getInstance())->getPatternEditorGridWidth(); |
|---|
| 50 | m_nEditorWidth = 20 + m_nGridWidth * ( MAX_NOTES * 4 ); |
|---|
| 51 | |
|---|
| 52 | if (m_mode == VELOCITY ) { |
|---|
| 53 | m_nEditorHeight = 100; |
|---|
| 54 | } |
|---|
| 55 | else if ( m_mode == PAN ) { |
|---|
| 56 | m_nEditorHeight = 100; |
|---|
| 57 | } |
|---|
| 58 | else if ( m_mode == LEADLAG ) { |
|---|
| 59 | m_nEditorHeight = 100; |
|---|
| 60 | } |
|---|
| 61 | else if ( m_mode == NOTEKEY ) { |
|---|
| 62 | m_nEditorHeight = 210; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | resize( m_nEditorWidth, m_nEditorHeight ); |
|---|
| 66 | setMinimumSize( m_nEditorWidth, m_nEditorHeight ); |
|---|
| 67 | |
|---|
| 68 | m_pBackground = new QPixmap( m_nEditorWidth, m_nEditorHeight ); |
|---|
| 69 | |
|---|
| 70 | //m_pBackground->load("/patternEditor/Klaviaturklein.png"); |
|---|
| 71 | updateEditor(); |
|---|
| 72 | show(); |
|---|
| 73 | |
|---|
| 74 | HydrogenApp::getInstance()->addEventListener( this ); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | NotePropertiesRuler::~NotePropertiesRuler() |
|---|
| 80 | { |
|---|
| 81 | //infoLog("DESTROY"); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | void NotePropertiesRuler::mousePressEvent(QMouseEvent *ev) |
|---|
| 87 | { |
|---|
| 88 | // infoLog( "mousePressEvent()" ); |
|---|
| 89 | if (m_pPattern == NULL) return; |
|---|
| 90 | |
|---|
| 91 | DrumPatternEditor *pPatternEditor = m_pPatternEditorPanel->getDrumPatternEditor(); |
|---|
| 92 | int nBase; |
|---|
| 93 | if (pPatternEditor->isUsingTriplets()) { |
|---|
| 94 | nBase = 3; |
|---|
| 95 | } |
|---|
| 96 | else { |
|---|
| 97 | nBase = 4; |
|---|
| 98 | } |
|---|
| 99 | int width = (m_nGridWidth * 4 * MAX_NOTES) / ( nBase * pPatternEditor->getResolution()); |
|---|
| 100 | int x_pos = ev->x(); |
|---|
| 101 | int column; |
|---|
| 102 | column = (x_pos - 20) + (width / 2); |
|---|
| 103 | column = column / width; |
|---|
| 104 | column = (column * 4 * MAX_NOTES) / ( nBase * pPatternEditor->getResolution() ); |
|---|
| 105 | float val = height() - ev->y(); |
|---|
| 106 | if (val > height()) { |
|---|
| 107 | val = height(); |
|---|
| 108 | } |
|---|
| 109 | else if (val < 0.0) { |
|---|
| 110 | val = 0.0; |
|---|
| 111 | } |
|---|
| 112 | int keyval = val; |
|---|
| 113 | val = val / height(); |
|---|
| 114 | |
|---|
| 115 | int nSelectedInstrument = Hydrogen::get_instance()->getSelectedInstrumentNumber(); |
|---|
| 116 | Song *pSong = (Hydrogen::get_instance())->getSong(); |
|---|
| 117 | |
|---|
| 118 | std::multimap <int, Note*>::iterator pos; |
|---|
| 119 | for ( pos = m_pPattern->note_map.lower_bound( column ); pos != m_pPattern->note_map.upper_bound( column ); ++pos ) { |
|---|
| 120 | Note *pNote = pos->second; |
|---|
| 121 | assert( pNote ); |
|---|
| 122 | assert( (int)pNote->get_position() == column ); |
|---|
| 123 | if ( pNote->get_instrument() != pSong->get_instrument_list()->get( nSelectedInstrument ) ) { |
|---|
| 124 | continue; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | if ( m_mode == VELOCITY && !pNote->get_noteoff() ) { |
|---|
| 128 | pNote->set_velocity( val ); |
|---|
| 129 | |
|---|
| 130 | char valueChar[100]; |
|---|
| 131 | sprintf( valueChar, "%#.2f", val); |
|---|
| 132 | HydrogenApp::getInstance()->setStatusBarMessage( QString("Set note velocity [%1]").arg( valueChar ), 2000 ); |
|---|
| 133 | } |
|---|
| 134 | else if ( m_mode == PAN ){ |
|---|
| 135 | float pan_L, pan_R; |
|---|
| 136 | if ( (ev->button() == Qt::MidButton) || (ev->modifiers() == Qt::ControlModifier && ev->button() == Qt::LeftButton) ) { |
|---|
| 137 | val = 0.5; |
|---|
| 138 | } |
|---|
| 139 | if ( val > 0.5 ) { |
|---|
| 140 | pan_L = 1.0 - val; |
|---|
| 141 | pan_R = 0.5; |
|---|
| 142 | } |
|---|
| 143 | else { |
|---|
| 144 | pan_L = 0.5; |
|---|
| 145 | pan_R = val; |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | pNote->set_pan_l( pan_L ); |
|---|
| 149 | pNote->set_pan_r( pan_R ); |
|---|
| 150 | } |
|---|
| 151 | else if ( m_mode == LEADLAG ){ |
|---|
| 152 | if ( (ev->button() == Qt::MidButton) || (ev->modifiers() == Qt::ControlModifier && ev->button() == Qt::LeftButton) ) { |
|---|
| 153 | pNote->set_leadlag(0.0); |
|---|
| 154 | } else { |
|---|
| 155 | pNote->set_leadlag((val * -2.0) + 1.0); |
|---|
| 156 | char valueChar[100]; |
|---|
| 157 | if (pNote->get_leadlag() < 0.0) { |
|---|
| 158 | sprintf( valueChar, "%.2f", ( pNote->get_leadlag() * -5)); // FIXME: '5' taken from fLeadLagFactor calculation in hydrogen.cpp |
|---|
| 159 | HydrogenApp::getInstance()->setStatusBarMessage( QString("Leading beat by: %1 ticks").arg( valueChar ), 2000 ); |
|---|
| 160 | } else if (pNote->get_leadlag() > 0.0) { |
|---|
| 161 | sprintf( valueChar, "%.2f", ( pNote->get_leadlag() * 5)); // FIXME: '5' taken from fLeadLagFactor calculation in hydrogen.cpp |
|---|
| 162 | HydrogenApp::getInstance()->setStatusBarMessage( QString("Lagging beat by: %1 ticks").arg( valueChar ), 2000 ); |
|---|
| 163 | } else { |
|---|
| 164 | HydrogenApp::getInstance()->setStatusBarMessage( QString("Note on beat"), 2000 ); |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | } |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | else if ( m_mode == NOTEKEY ){ |
|---|
| 171 | if ( (ev->button() == Qt::MidButton) || (ev->modifiers() == Qt::ControlModifier && ev->button() == Qt::LeftButton) ) { |
|---|
| 172 | ; |
|---|
| 173 | } else { |
|---|
| 174 | //set the note hight |
|---|
| 175 | //QMessageBox::information ( this, "Hydrogen", trUtf8( "val: %1" ).arg(keyval) ); |
|---|
| 176 | if (keyval >= 6 && keyval <= 15 ){//note c |
|---|
| 177 | pNote->m_noteKey.m_key = H2Core::NoteKey::C; |
|---|
| 178 | } |
|---|
| 179 | if (keyval >= 16 && keyval <= 25 ){//note cis / cs |
|---|
| 180 | pNote->m_noteKey.m_key = H2Core::NoteKey::Cs; |
|---|
| 181 | } |
|---|
| 182 | if (keyval >= 26 && keyval <= 35 ){//note d |
|---|
| 183 | pNote->m_noteKey.m_key = H2Core::NoteKey::D; |
|---|
| 184 | } |
|---|
| 185 | if (keyval >= 36 && keyval <= 45 ){//note dis / ef |
|---|
| 186 | pNote->m_noteKey.m_key = H2Core::NoteKey::Ef; |
|---|
| 187 | } |
|---|
| 188 | if (keyval >= 46 && keyval <= 55 ){//note E |
|---|
| 189 | pNote->m_noteKey.m_key = H2Core::NoteKey::E; |
|---|
| 190 | } |
|---|
| 191 | if (keyval >= 56 && keyval <= 65 ){//note f |
|---|
| 192 | pNote->m_noteKey.m_key = H2Core::NoteKey::F; |
|---|
| 193 | } |
|---|
| 194 | if (keyval >= 66 && keyval <= 75 ){//note fis |
|---|
| 195 | pNote->m_noteKey.m_key = H2Core::NoteKey::Fs; |
|---|
| 196 | } |
|---|
| 197 | if (keyval >= 76 && keyval <= 85 ){//note g |
|---|
| 198 | pNote->m_noteKey.m_key = H2Core::NoteKey::G; |
|---|
| 199 | } |
|---|
| 200 | if (keyval >= 86 && keyval <= 95 ){//note gis / af |
|---|
| 201 | pNote->m_noteKey.m_key = H2Core::NoteKey::Af; |
|---|
| 202 | } |
|---|
| 203 | if (keyval >= 96 && keyval <= 105 ){//note a |
|---|
| 204 | pNote->m_noteKey.m_key = H2Core::NoteKey::A; |
|---|
| 205 | } |
|---|
| 206 | if (keyval >= 106 && keyval <= 115 ){//note his / bf |
|---|
| 207 | pNote->m_noteKey.m_key = H2Core::NoteKey::Bf; |
|---|
| 208 | } |
|---|
| 209 | if (keyval >= 116 && keyval <= 125 ){//note h / b |
|---|
| 210 | pNote->m_noteKey.m_key = H2Core::NoteKey::B; |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | //set the note oktave |
|---|
| 214 | if (keyval >= 135 && keyval <= 145 ){ |
|---|
| 215 | pNote->m_noteKey.m_nOctave = -3; |
|---|
| 216 | } |
|---|
| 217 | else if( keyval >= 146 && keyval <= 155 ){ |
|---|
| 218 | pNote->m_noteKey.m_nOctave = -2; |
|---|
| 219 | } |
|---|
| 220 | else if( keyval >= 156 && keyval <= 165 ){ |
|---|
| 221 | pNote->m_noteKey.m_nOctave = -1; |
|---|
| 222 | } |
|---|
| 223 | else if( keyval >= 166 && keyval <= 175 ){ |
|---|
| 224 | pNote->m_noteKey.m_nOctave = 0; |
|---|
| 225 | } |
|---|
| 226 | else if( keyval >= 176 && keyval <= 185 ){ |
|---|
| 227 | pNote->m_noteKey.m_nOctave = 1; |
|---|
| 228 | } |
|---|
| 229 | else if( keyval >= 186 && keyval <= 195 ){ |
|---|
| 230 | pNote->m_noteKey.m_nOctave = 2; |
|---|
| 231 | } |
|---|
| 232 | else if( keyval >= 196 && keyval <= 205 ){ |
|---|
| 233 | pNote->m_noteKey.m_nOctave = 3; |
|---|
| 234 | } |
|---|
| 235 | } |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | pSong->__is_modified = true; |
|---|
| 241 | updateEditor(); |
|---|
| 242 | break; |
|---|
| 243 | } |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | void NotePropertiesRuler::wheelEvent(QWheelEvent *ev) |
|---|
| 247 | { |
|---|
| 248 | // infoLog( "mousePressEvent()" ); |
|---|
| 249 | if (m_pPattern == NULL) return; |
|---|
| 250 | |
|---|
| 251 | float delta; |
|---|
| 252 | if (ev->modifiers() == Qt::ControlModifier) { |
|---|
| 253 | delta = 0.01; // fine control |
|---|
| 254 | } else { |
|---|
| 255 | delta = 0.05; // course control |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | if ( ev->delta() < 0 ) { |
|---|
| 259 | delta = (delta * -1.0); |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | DrumPatternEditor *pPatternEditor = m_pPatternEditorPanel->getDrumPatternEditor(); |
|---|
| 263 | int nBase; |
|---|
| 264 | if (pPatternEditor->isUsingTriplets()) { |
|---|
| 265 | nBase = 3; |
|---|
| 266 | } |
|---|
| 267 | else { |
|---|
| 268 | nBase = 4; |
|---|
| 269 | } |
|---|
| 270 | int width = (m_nGridWidth * 4 * MAX_NOTES) / ( nBase * pPatternEditor->getResolution()); |
|---|
| 271 | int x_pos = ev->x(); |
|---|
| 272 | int column; |
|---|
| 273 | column = (x_pos - 20) + (width / 2); |
|---|
| 274 | column = column / width; |
|---|
| 275 | column = (column * 4 * MAX_NOTES) / ( nBase * pPatternEditor->getResolution() ); |
|---|
| 276 | |
|---|
| 277 | int nSelectedInstrument = Hydrogen::get_instance()->getSelectedInstrumentNumber(); |
|---|
| 278 | Song *pSong = (Hydrogen::get_instance())->getSong(); |
|---|
| 279 | |
|---|
| 280 | std::multimap <int, Note*>::iterator pos; |
|---|
| 281 | for ( pos = m_pPattern->note_map.lower_bound( column ); pos != m_pPattern->note_map.upper_bound( column ); ++pos ) { |
|---|
| 282 | Note *pNote = pos->second; |
|---|
| 283 | assert( pNote ); |
|---|
| 284 | assert( (int)pNote->get_position() == column ); |
|---|
| 285 | if ( pNote->get_instrument() != pSong->get_instrument_list()->get( nSelectedInstrument ) ) { |
|---|
| 286 | continue; |
|---|
| 287 | } |
|---|
| 288 | if ( m_mode == VELOCITY && !pNote->get_noteoff() ) { |
|---|
| 289 | float val = pNote->get_velocity() + delta; |
|---|
| 290 | if (val > 1.0) { |
|---|
| 291 | val = 1.0; |
|---|
| 292 | } |
|---|
| 293 | else if (val < 0.0) { |
|---|
| 294 | val = 0.0; |
|---|
| 295 | } |
|---|
| 296 | |
|---|
| 297 | pNote->set_velocity(val); |
|---|
| 298 | |
|---|
| 299 | char valueChar[100]; |
|---|
| 300 | sprintf( valueChar, "%#.2f", val); |
|---|
| 301 | ( HydrogenApp::getInstance() )->setStatusBarMessage( QString("Set note velocity [%1]").arg( valueChar ), 2000 ); |
|---|
| 302 | } |
|---|
| 303 | else if ( m_mode == PAN ){ |
|---|
| 304 | float pan_L, pan_R; |
|---|
| 305 | |
|---|
| 306 | float val = (pNote->get_pan_r() - pNote->get_pan_l() + 0.5) + delta; |
|---|
| 307 | if (val > 1.0) { |
|---|
| 308 | val = 1.0; |
|---|
| 309 | } |
|---|
| 310 | else if (val < 0.0) { |
|---|
| 311 | val = 0.0; |
|---|
| 312 | } |
|---|
| 313 | if ( val > 0.5 ) { |
|---|
| 314 | pan_L = 1.0 - val; |
|---|
| 315 | pan_R = 0.5; |
|---|
| 316 | } |
|---|
| 317 | else { |
|---|
| 318 | pan_L = 0.5; |
|---|
| 319 | pan_R = val; |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | pNote->set_pan_l(pan_L); |
|---|
| 323 | pNote->set_pan_r(pan_R); |
|---|
| 324 | } |
|---|
| 325 | else if ( m_mode == LEADLAG ){ |
|---|
| 326 | float val = (pNote->get_leadlag() - 1.0)/-2.0 + delta; |
|---|
| 327 | if (val > 1.0) { |
|---|
| 328 | val = 1.0; |
|---|
| 329 | } |
|---|
| 330 | else if (val < 0.0) { |
|---|
| 331 | val = 0.0; |
|---|
| 332 | } |
|---|
| 333 | pNote->set_leadlag((val * -2.0) + 1.0); |
|---|
| 334 | char valueChar[100]; |
|---|
| 335 | if (pNote->get_leadlag() < 0.0) { |
|---|
| 336 | sprintf( valueChar, "%.2f", ( pNote->get_leadlag() * -5)); // FIXME: '5' taken from fLeadLagFactor calculation in hydrogen.cpp |
|---|
| 337 | HydrogenApp::getInstance()->setStatusBarMessage( QString("Leading beat by: %1 ticks").arg( valueChar ), 2000 ); |
|---|
| 338 | } else if (pNote->get_leadlag() > 0.0) { |
|---|
| 339 | sprintf( valueChar, "%.2f", ( pNote->get_leadlag() * 5)); // FIXME: '5' taken from fLeadLagFactor calculation in hydrogen.cpp |
|---|
| 340 | HydrogenApp::getInstance()->setStatusBarMessage( QString("Lagging beat by: %1 ticks").arg( valueChar ), 2000 ); |
|---|
| 341 | } else { |
|---|
| 342 | HydrogenApp::getInstance()->setStatusBarMessage( QString("Note on beat"), 2000 ); |
|---|
| 343 | } |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | pSong->__is_modified = true; |
|---|
| 347 | updateEditor(); |
|---|
| 348 | break; |
|---|
| 349 | } |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | |
|---|
| 353 | void NotePropertiesRuler::mouseMoveEvent( QMouseEvent *ev ) |
|---|
| 354 | { |
|---|
| 355 | // infoLog( "mouse move" ); |
|---|
| 356 | mousePressEvent( ev ); |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | |
|---|
| 360 | |
|---|
| 361 | void NotePropertiesRuler::paintEvent( QPaintEvent *ev) |
|---|
| 362 | { |
|---|
| 363 | QPainter painter(this); |
|---|
| 364 | painter.drawPixmap( ev->rect(), *m_pBackground, ev->rect() ); |
|---|
| 365 | } |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | |
|---|
| 369 | void NotePropertiesRuler::createVelocityBackground(QPixmap *pixmap) |
|---|
| 370 | { |
|---|
| 371 | if ( !isVisible() ) { |
|---|
| 372 | return; |
|---|
| 373 | } |
|---|
| 374 | |
|---|
| 375 | UIStyle *pStyle = Preferences::getInstance()->getDefaultUIStyle(); |
|---|
| 376 | |
|---|
| 377 | H2RGBColor valueColor( |
|---|
| 378 | (int)( pStyle->m_patternEditor_backgroundColor.getRed() * ( 1 - 0.3 ) ), |
|---|
| 379 | (int)( pStyle->m_patternEditor_backgroundColor.getGreen() * ( 1 - 0.3 ) ), |
|---|
| 380 | (int)( pStyle->m_patternEditor_backgroundColor.getBlue() * ( 1 - 0.3 ) ) |
|---|
| 381 | ); |
|---|
| 382 | |
|---|
| 383 | QColor res_1( pStyle->m_patternEditor_line1Color.getRed(), pStyle->m_patternEditor_line1Color.getGreen(), pStyle->m_patternEditor_line1Color.getBlue() ); |
|---|
| 384 | QColor res_2( pStyle->m_patternEditor_line2Color.getRed(), pStyle->m_patternEditor_line2Color.getGreen(), pStyle->m_patternEditor_line2Color.getBlue() ); |
|---|
| 385 | QColor res_3( pStyle->m_patternEditor_line3Color.getRed(), pStyle->m_patternEditor_line3Color.getGreen(), pStyle->m_patternEditor_line3Color.getBlue() ); |
|---|
| 386 | QColor res_4( pStyle->m_patternEditor_line4Color.getRed(), pStyle->m_patternEditor_line4Color.getGreen(), pStyle->m_patternEditor_line4Color.getBlue() ); |
|---|
| 387 | QColor res_5( pStyle->m_patternEditor_line5Color.getRed(), pStyle->m_patternEditor_line5Color.getGreen(), pStyle->m_patternEditor_line5Color.getBlue() ); |
|---|
| 388 | |
|---|
| 389 | QColor backgroundColor( pStyle->m_patternEditor_backgroundColor.getRed(), pStyle->m_patternEditor_backgroundColor.getGreen(), pStyle->m_patternEditor_backgroundColor.getBlue() ); |
|---|
| 390 | QColor horizLinesColor( |
|---|
| 391 | pStyle->m_patternEditor_backgroundColor.getRed() - 20, |
|---|
| 392 | pStyle->m_patternEditor_backgroundColor.getGreen() - 20, |
|---|
| 393 | pStyle->m_patternEditor_backgroundColor.getBlue() - 20 |
|---|
| 394 | ); |
|---|
| 395 | |
|---|
| 396 | unsigned nNotes = MAX_NOTES; |
|---|
| 397 | if (m_pPattern) { |
|---|
| 398 | nNotes = m_pPattern->get_lenght(); |
|---|
| 399 | } |
|---|
| 400 | |
|---|
| 401 | |
|---|
| 402 | QPainter p( pixmap ); |
|---|
| 403 | |
|---|
| 404 | p.fillRect( 0, 0, width(), height(), QColor(0,0,0) ); |
|---|
| 405 | p.fillRect( 0, 0, 20 + nNotes * m_nGridWidth, height(), backgroundColor ); |
|---|
| 406 | |
|---|
| 407 | |
|---|
| 408 | // vertical lines |
|---|
| 409 | |
|---|
| 410 | DrumPatternEditor *pPatternEditor = m_pPatternEditorPanel->getDrumPatternEditor(); |
|---|
| 411 | int nBase; |
|---|
| 412 | if (pPatternEditor->isUsingTriplets()) { |
|---|
| 413 | nBase = 3; |
|---|
| 414 | } |
|---|
| 415 | else { |
|---|
| 416 | nBase = 4; |
|---|
| 417 | } |
|---|
| 418 | |
|---|
| 419 | int n4th = 4 * MAX_NOTES / (nBase * 4); |
|---|
| 420 | int n8th = 4 * MAX_NOTES / (nBase * 8); |
|---|
| 421 | int n16th = 4 * MAX_NOTES / (nBase * 16); |
|---|
| 422 | int n32th = 4 * MAX_NOTES / (nBase * 32); |
|---|
| 423 | int n64th = 4 * MAX_NOTES / (nBase * 64); |
|---|
| 424 | int nResolution = pPatternEditor->getResolution(); |
|---|
| 425 | |
|---|
| 426 | |
|---|
| 427 | if ( !pPatternEditor->isUsingTriplets() ) { |
|---|
| 428 | |
|---|
| 429 | for (uint i = 0; i < nNotes + 1; i++) { |
|---|
| 430 | uint x = 20 + i * m_nGridWidth; |
|---|
| 431 | |
|---|
| 432 | if ( (i % n4th) == 0 ) { |
|---|
| 433 | if (nResolution >= 4) { |
|---|
| 434 | p.setPen( QPen( res_1, 0, Qt::DotLine ) ); |
|---|
| 435 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 436 | } |
|---|
| 437 | } |
|---|
| 438 | else if ( (i % n8th) == 0 ) { |
|---|
| 439 | if (nResolution >= 8) { |
|---|
| 440 | p.setPen( QPen( res_2, 0, Qt::DotLine ) ); |
|---|
| 441 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 442 | } |
|---|
| 443 | } |
|---|
| 444 | else if ( (i % n16th) == 0 ) { |
|---|
| 445 | if (nResolution >= 16) { |
|---|
| 446 | p.setPen( QPen( res_3, 0, Qt::DotLine ) ); |
|---|
| 447 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 448 | } |
|---|
| 449 | } |
|---|
| 450 | else if ( (i % n32th) == 0 ) { |
|---|
| 451 | if (nResolution >= 32) { |
|---|
| 452 | p.setPen( QPen( res_4, 0, Qt::DotLine ) ); |
|---|
| 453 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 454 | } |
|---|
| 455 | } |
|---|
| 456 | else if ( (i % n64th) == 0 ) { |
|---|
| 457 | if (nResolution >= 64) { |
|---|
| 458 | p.setPen( QPen( res_5, 0, Qt::DotLine ) ); |
|---|
| 459 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 460 | } |
|---|
| 461 | } |
|---|
| 462 | } |
|---|
| 463 | } |
|---|
| 464 | else { // Triplets |
|---|
| 465 | uint nCounter = 0; |
|---|
| 466 | int nSize = 4 * MAX_NOTES / (nBase * nResolution); |
|---|
| 467 | |
|---|
| 468 | for (uint i = 0; i < nNotes + 1; i++) { |
|---|
| 469 | uint x = 20 + i * m_nGridWidth; |
|---|
| 470 | |
|---|
| 471 | if ( (i % nSize) == 0) { |
|---|
| 472 | if ((nCounter % 3) == 0) { |
|---|
| 473 | p.setPen( QPen( res_1, 0, Qt::DotLine ) ); |
|---|
| 474 | } |
|---|
| 475 | else { |
|---|
| 476 | p.setPen( QPen( res_3, 0, Qt::DotLine ) ); |
|---|
| 477 | } |
|---|
| 478 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 479 | nCounter++; |
|---|
| 480 | } |
|---|
| 481 | } |
|---|
| 482 | } |
|---|
| 483 | |
|---|
| 484 | p.setPen( horizLinesColor ); |
|---|
| 485 | for (unsigned y = 0; y < m_nEditorHeight; y = y + (m_nEditorHeight / 10)) { |
|---|
| 486 | p.drawLine(20, y, 20 + nNotes * m_nGridWidth, y); |
|---|
| 487 | } |
|---|
| 488 | |
|---|
| 489 | // draw velocity lines |
|---|
| 490 | if (m_pPattern != NULL) { |
|---|
| 491 | int nSelectedInstrument = Hydrogen::get_instance()->getSelectedInstrumentNumber(); |
|---|
| 492 | Song *pSong = Hydrogen::get_instance()->getSong(); |
|---|
| 493 | std::multimap <int, Note*>::iterator pos; |
|---|
| 494 | for ( pos = m_pPattern->note_map.begin(); pos != m_pPattern->note_map.end(); ++pos ) { |
|---|
| 495 | Note *pNote = pos->second; |
|---|
| 496 | assert( pNote ); |
|---|
| 497 | if ( pNote->get_instrument() != pSong->get_instrument_list()->get( nSelectedInstrument ) ) { |
|---|
| 498 | continue; |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | uint pos = pNote->get_position(); |
|---|
| 502 | uint x_pos = 20 + pos * m_nGridWidth; |
|---|
| 503 | |
|---|
| 504 | uint line_end = height(); |
|---|
| 505 | |
|---|
| 506 | uint velocity = (uint)(pNote->get_velocity() * height()); |
|---|
| 507 | uint line_start = line_end - velocity; |
|---|
| 508 | |
|---|
| 509 | QColor sideColor( |
|---|
| 510 | (int)( valueColor.getRed() * ( 1 - pNote->get_velocity() ) ), |
|---|
| 511 | (int)( valueColor.getGreen() * ( 1 - pNote->get_velocity() ) ), |
|---|
| 512 | (int)( valueColor.getBlue() * ( 1 - pNote->get_velocity() ) ) |
|---|
| 513 | ); |
|---|
| 514 | p.fillRect( (int)( x_pos - m_nGridWidth / 2.0 ) + 1, line_start, m_nGridWidth, line_end - line_start, sideColor ); |
|---|
| 515 | |
|---|
| 516 | QColor centerColor( |
|---|
| 517 | (int)( valueColor.getRed() * ( 1 - pNote->get_velocity() ) ), |
|---|
| 518 | (int)( valueColor.getGreen() * ( 1 - pNote->get_velocity() ) ), |
|---|
| 519 | (int)( valueColor.getBlue() * ( 1 - pNote->get_velocity() ) ) |
|---|
| 520 | ); |
|---|
| 521 | int nLineWidth = (int)( m_nGridWidth / 2.0 ); |
|---|
| 522 | int nSpace = (int)( ( m_nGridWidth -nLineWidth ) / 2.0 ); |
|---|
| 523 | p.fillRect( (int)( x_pos - nSpace ) + 1, line_start, nLineWidth, line_end - line_start, centerColor ); |
|---|
| 524 | } |
|---|
| 525 | } |
|---|
| 526 | p.setPen(res_1); |
|---|
| 527 | p.drawLine(0, 0, m_nEditorWidth, 0); |
|---|
| 528 | p.drawLine(0, m_nEditorHeight - 1, m_nEditorWidth, m_nEditorHeight - 1); |
|---|
| 529 | } |
|---|
| 530 | |
|---|
| 531 | |
|---|
| 532 | |
|---|
| 533 | void NotePropertiesRuler::createPanBackground(QPixmap *pixmap) |
|---|
| 534 | { |
|---|
| 535 | if ( !isVisible() ) { |
|---|
| 536 | return; |
|---|
| 537 | } |
|---|
| 538 | |
|---|
| 539 | |
|---|
| 540 | UIStyle *pStyle = Preferences::getInstance()->getDefaultUIStyle(); |
|---|
| 541 | |
|---|
| 542 | QColor backgroundColor( pStyle->m_patternEditor_backgroundColor.getRed(), pStyle->m_patternEditor_backgroundColor.getGreen(), pStyle->m_patternEditor_backgroundColor.getBlue() ); |
|---|
| 543 | |
|---|
| 544 | //QColor backgroundColor( 255, 255, 255 ); |
|---|
| 545 | QColor blackKeysColor( 240, 240, 240 ); |
|---|
| 546 | QColor horizLinesColor( |
|---|
| 547 | pStyle->m_patternEditor_backgroundColor.getRed() - 20, |
|---|
| 548 | pStyle->m_patternEditor_backgroundColor.getGreen() - 20, |
|---|
| 549 | pStyle->m_patternEditor_backgroundColor.getBlue() - 20 |
|---|
| 550 | ); |
|---|
| 551 | H2RGBColor valueColor( |
|---|
| 552 | (int)( pStyle->m_patternEditor_backgroundColor.getRed() * ( 1 - 0.3 ) ), |
|---|
| 553 | (int)( pStyle->m_patternEditor_backgroundColor.getGreen() * ( 1 - 0.3 ) ), |
|---|
| 554 | (int)( pStyle->m_patternEditor_backgroundColor.getBlue() * ( 1 - 0.3 ) ) |
|---|
| 555 | ); |
|---|
| 556 | |
|---|
| 557 | QColor res_1( pStyle->m_patternEditor_line1Color.getRed(), pStyle->m_patternEditor_line1Color.getGreen(), pStyle->m_patternEditor_line1Color.getBlue() ); |
|---|
| 558 | QColor res_2( pStyle->m_patternEditor_line2Color.getRed(), pStyle->m_patternEditor_line2Color.getGreen(), pStyle->m_patternEditor_line2Color.getBlue() ); |
|---|
| 559 | QColor res_3( pStyle->m_patternEditor_line3Color.getRed(), pStyle->m_patternEditor_line3Color.getGreen(), pStyle->m_patternEditor_line3Color.getBlue() ); |
|---|
| 560 | QColor res_4( pStyle->m_patternEditor_line4Color.getRed(), pStyle->m_patternEditor_line4Color.getGreen(), pStyle->m_patternEditor_line4Color.getBlue() ); |
|---|
| 561 | QColor res_5( pStyle->m_patternEditor_line5Color.getRed(), pStyle->m_patternEditor_line5Color.getGreen(), pStyle->m_patternEditor_line5Color.getBlue() ); |
|---|
| 562 | |
|---|
| 563 | QPainter p( pixmap ); |
|---|
| 564 | |
|---|
| 565 | p.fillRect( 0, 0, width(), height(), QColor(0, 0, 0) ); |
|---|
| 566 | |
|---|
| 567 | unsigned nNotes = MAX_NOTES; |
|---|
| 568 | if (m_pPattern) { |
|---|
| 569 | nNotes = m_pPattern->get_lenght(); |
|---|
| 570 | } |
|---|
| 571 | p.fillRect( 0, 0, 20 + nNotes * m_nGridWidth, height(), backgroundColor ); |
|---|
| 572 | |
|---|
| 573 | |
|---|
| 574 | // central line |
|---|
| 575 | p.setPen( horizLinesColor ); |
|---|
| 576 | p.drawLine(0, height() / 2.0, m_nEditorWidth, height() / 2.0); |
|---|
| 577 | |
|---|
| 578 | |
|---|
| 579 | |
|---|
| 580 | // vertical lines |
|---|
| 581 | DrumPatternEditor *pPatternEditor = m_pPatternEditorPanel->getDrumPatternEditor(); |
|---|
| 582 | int nBase; |
|---|
| 583 | if (pPatternEditor->isUsingTriplets()) { |
|---|
| 584 | nBase = 3; |
|---|
| 585 | } |
|---|
| 586 | else { |
|---|
| 587 | nBase = 4; |
|---|
| 588 | } |
|---|
| 589 | |
|---|
| 590 | int n4th = 4 * MAX_NOTES / (nBase * 4); |
|---|
| 591 | int n8th = 4 * MAX_NOTES / (nBase * 8); |
|---|
| 592 | int n16th = 4 * MAX_NOTES / (nBase * 16); |
|---|
| 593 | int n32th = 4 * MAX_NOTES / (nBase * 32); |
|---|
| 594 | int n64th = 4 * MAX_NOTES / (nBase * 64); |
|---|
| 595 | |
|---|
| 596 | int nResolution = pPatternEditor->getResolution(); |
|---|
| 597 | |
|---|
| 598 | if ( !pPatternEditor->isUsingTriplets() ) { |
|---|
| 599 | |
|---|
| 600 | for (uint i = 0; i < nNotes +1 ; i++) { |
|---|
| 601 | uint x = 20 + i * m_nGridWidth; |
|---|
| 602 | |
|---|
| 603 | if ( (i % n4th) == 0 ) { |
|---|
| 604 | if (nResolution >= 4) { |
|---|
| 605 | p.setPen( QPen( res_1, 0, Qt::DotLine ) ); |
|---|
| 606 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 607 | } |
|---|
| 608 | } |
|---|
| 609 | else if ( (i % n8th) == 0 ) { |
|---|
| 610 | if (nResolution >= 8) { |
|---|
| 611 | p.setPen( QPen( res_2, 0, Qt::DotLine ) ); |
|---|
| 612 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 613 | } |
|---|
| 614 | } |
|---|
| 615 | else if ( (i % n16th) == 0 ) { |
|---|
| 616 | if (nResolution >= 16) { |
|---|
| 617 | p.setPen( QPen( res_3, 0, Qt::DotLine ) ); |
|---|
| 618 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 619 | } |
|---|
| 620 | } |
|---|
| 621 | else if ( (i % n32th) == 0 ) { |
|---|
| 622 | if (nResolution >= 32) { |
|---|
| 623 | p.setPen( QPen( res_4, 0, Qt::DotLine ) ); |
|---|
| 624 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 625 | } |
|---|
| 626 | } |
|---|
| 627 | else if ( (i % n64th) == 0 ) { |
|---|
| 628 | if (nResolution >= 64) { |
|---|
| 629 | p.setPen( QPen( res_5, 0, Qt::DotLine ) ); |
|---|
| 630 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 631 | } |
|---|
| 632 | } |
|---|
| 633 | } |
|---|
| 634 | } |
|---|
| 635 | else { // Triplets |
|---|
| 636 | uint nCounter = 0; |
|---|
| 637 | int nSize = 4 * MAX_NOTES / (nBase * nResolution); |
|---|
| 638 | |
|---|
| 639 | for (uint i = 0; i < nNotes +1; i++) { |
|---|
| 640 | uint x = 20 + i * m_nGridWidth; |
|---|
| 641 | |
|---|
| 642 | if ( (i % nSize) == 0) { |
|---|
| 643 | if ((nCounter % 3) == 0) { |
|---|
| 644 | p.setPen( QPen( res_1, 0, Qt::DotLine ) ); |
|---|
| 645 | } |
|---|
| 646 | else { |
|---|
| 647 | p.setPen( QPen( res_3, 0, Qt::DotLine ) ); |
|---|
| 648 | } |
|---|
| 649 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 650 | nCounter++; |
|---|
| 651 | } |
|---|
| 652 | } |
|---|
| 653 | } |
|---|
| 654 | |
|---|
| 655 | if ( m_pPattern ) { |
|---|
| 656 | int nSelectedInstrument = Hydrogen::get_instance()->getSelectedInstrumentNumber(); |
|---|
| 657 | Song *pSong = Hydrogen::get_instance()->getSong(); |
|---|
| 658 | |
|---|
| 659 | std::multimap <int, Note*>::iterator pos; |
|---|
| 660 | for ( pos = m_pPattern->note_map.begin(); pos != m_pPattern->note_map.end(); ++pos ) { |
|---|
| 661 | Note *pNote = pos->second; |
|---|
| 662 | assert( pNote ); |
|---|
| 663 | if ( pNote->get_instrument() != pSong->get_instrument_list()->get( nSelectedInstrument ) ) { |
|---|
| 664 | continue; |
|---|
| 665 | } |
|---|
| 666 | uint x_pos = 20 + pNote->get_position() * m_nGridWidth; |
|---|
| 667 | |
|---|
| 668 | if (pNote->get_pan_r() == pNote->get_pan_l()) { |
|---|
| 669 | // pan value is centered - draw circle |
|---|
| 670 | int y_pos = (int)( height() * 0.5 ); |
|---|
| 671 | p.setBrush(QColor( 0, 0, 0 )); |
|---|
| 672 | p.drawEllipse( x_pos-4, y_pos-4, 8, 8); |
|---|
| 673 | } else { |
|---|
| 674 | int y_start = (int)( pNote->get_pan_l() * height() ); |
|---|
| 675 | int y_end = (int)( height() - pNote->get_pan_r() * height() ); |
|---|
| 676 | |
|---|
| 677 | int nLineWidth = 3; |
|---|
| 678 | p.fillRect( x_pos - 1, y_start, nLineWidth, y_end - y_start, QColor( 0, 0 ,0 ) ); |
|---|
| 679 | |
|---|
| 680 | p.fillRect( x_pos - 1, ( height() / 2.0 ) - 2 , nLineWidth, 5, QColor( 0, 0 ,0 ) ); |
|---|
| 681 | } |
|---|
| 682 | } |
|---|
| 683 | } |
|---|
| 684 | |
|---|
| 685 | p.setPen(res_1); |
|---|
| 686 | p.drawLine(0, 0, m_nEditorWidth, 0); |
|---|
| 687 | p.drawLine(0, m_nEditorHeight - 1, m_nEditorWidth, m_nEditorHeight - 1); |
|---|
| 688 | } |
|---|
| 689 | |
|---|
| 690 | void NotePropertiesRuler::createLeadLagBackground(QPixmap *pixmap) |
|---|
| 691 | { |
|---|
| 692 | if ( !isVisible() ) { |
|---|
| 693 | return; |
|---|
| 694 | } |
|---|
| 695 | |
|---|
| 696 | |
|---|
| 697 | UIStyle *pStyle = Preferences::getInstance()->getDefaultUIStyle(); |
|---|
| 698 | |
|---|
| 699 | QColor backgroundColor( pStyle->m_patternEditor_backgroundColor.getRed(), pStyle->m_patternEditor_backgroundColor.getGreen(), pStyle->m_patternEditor_backgroundColor.getBlue() ); |
|---|
| 700 | QColor blackKeysColor( 240, 240, 240 ); |
|---|
| 701 | QColor horizLinesColor( |
|---|
| 702 | pStyle->m_patternEditor_backgroundColor.getRed() - 20, |
|---|
| 703 | pStyle->m_patternEditor_backgroundColor.getGreen() - 20, |
|---|
| 704 | pStyle->m_patternEditor_backgroundColor.getBlue() - 20 |
|---|
| 705 | ); |
|---|
| 706 | H2RGBColor valueColor( |
|---|
| 707 | (int)( pStyle->m_patternEditor_backgroundColor.getRed() * ( 1 - 0.3 ) ), |
|---|
| 708 | (int)( pStyle->m_patternEditor_backgroundColor.getGreen() * ( 1 - 0.3 ) ), |
|---|
| 709 | (int)( pStyle->m_patternEditor_backgroundColor.getBlue() * ( 1 - 0.3 ) ) |
|---|
| 710 | ); |
|---|
| 711 | |
|---|
| 712 | QColor res_1( pStyle->m_patternEditor_line1Color.getRed(), pStyle->m_patternEditor_line1Color.getGreen(), pStyle->m_patternEditor_line1Color.getBlue() ); |
|---|
| 713 | QColor res_2( pStyle->m_patternEditor_line2Color.getRed(), pStyle->m_patternEditor_line2Color.getGreen(), pStyle->m_patternEditor_line2Color.getBlue() ); |
|---|
| 714 | QColor res_3( pStyle->m_patternEditor_line3Color.getRed(), pStyle->m_patternEditor_line3Color.getGreen(), pStyle->m_patternEditor_line3Color.getBlue() ); |
|---|
| 715 | QColor res_4( pStyle->m_patternEditor_line4Color.getRed(), pStyle->m_patternEditor_line4Color.getGreen(), pStyle->m_patternEditor_line4Color.getBlue() ); |
|---|
| 716 | QColor res_5( pStyle->m_patternEditor_line5Color.getRed(), pStyle->m_patternEditor_line5Color.getGreen(), pStyle->m_patternEditor_line5Color.getBlue() ); |
|---|
| 717 | |
|---|
| 718 | QPainter p( pixmap ); |
|---|
| 719 | |
|---|
| 720 | p.fillRect( 0, 0, width(), height(), QColor(0, 0, 0) ); |
|---|
| 721 | |
|---|
| 722 | unsigned nNotes = MAX_NOTES; |
|---|
| 723 | if (m_pPattern) { |
|---|
| 724 | nNotes = m_pPattern->get_lenght(); |
|---|
| 725 | } |
|---|
| 726 | p.fillRect( 0, 0, 20 + nNotes * m_nGridWidth, height(), backgroundColor ); |
|---|
| 727 | |
|---|
| 728 | |
|---|
| 729 | // central line |
|---|
| 730 | p.setPen( horizLinesColor ); |
|---|
| 731 | p.drawLine(0, height() / 2.0, m_nEditorWidth, height() / 2.0); |
|---|
| 732 | |
|---|
| 733 | |
|---|
| 734 | |
|---|
| 735 | // vertical lines |
|---|
| 736 | DrumPatternEditor *pPatternEditor = m_pPatternEditorPanel->getDrumPatternEditor(); |
|---|
| 737 | int nBase; |
|---|
| 738 | if (pPatternEditor->isUsingTriplets()) { |
|---|
| 739 | nBase = 3; |
|---|
| 740 | } |
|---|
| 741 | else { |
|---|
| 742 | nBase = 4; |
|---|
| 743 | } |
|---|
| 744 | |
|---|
| 745 | int n4th = 4 * MAX_NOTES / (nBase * 4); |
|---|
| 746 | int n8th = 4 * MAX_NOTES / (nBase * 8); |
|---|
| 747 | int n16th = 4 * MAX_NOTES / (nBase * 16); |
|---|
| 748 | int n32th = 4 * MAX_NOTES / (nBase * 32); |
|---|
| 749 | int n64th = 4 * MAX_NOTES / (nBase * 64); |
|---|
| 750 | |
|---|
| 751 | int nResolution = pPatternEditor->getResolution(); |
|---|
| 752 | |
|---|
| 753 | if ( !pPatternEditor->isUsingTriplets() ) { |
|---|
| 754 | |
|---|
| 755 | for (uint i = 0; i < nNotes + 1; i++) { |
|---|
| 756 | uint x = 20 + i * m_nGridWidth; |
|---|
| 757 | |
|---|
| 758 | if ( (i % n4th) == 0 ) { |
|---|
| 759 | if (nResolution >= 4) { |
|---|
| 760 | p.setPen( QPen( res_1, 0, Qt::DotLine ) ); |
|---|
| 761 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 762 | } |
|---|
| 763 | } |
|---|
| 764 | else if ( (i % n8th) == 0 ) { |
|---|
| 765 | if (nResolution >= 8) { |
|---|
| 766 | p.setPen( QPen( res_2, 0, Qt::DotLine ) ); |
|---|
| 767 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 768 | } |
|---|
| 769 | } |
|---|
| 770 | else if ( (i % n16th) == 0 ) { |
|---|
| 771 | if (nResolution >= 16) { |
|---|
| 772 | p.setPen( QPen( res_3, 0, Qt::DotLine ) ); |
|---|
| 773 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 774 | } |
|---|
| 775 | } |
|---|
| 776 | else if ( (i % n32th) == 0 ) { |
|---|
| 777 | if (nResolution >= 32) { |
|---|
| 778 | p.setPen( QPen( res_4, 0, Qt::DotLine ) ); |
|---|
| 779 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 780 | } |
|---|
| 781 | } |
|---|
| 782 | else if ( (i % n64th) == 0 ) { |
|---|
| 783 | if (nResolution >= 64) { |
|---|
| 784 | p.setPen( QPen( res_5, 0, Qt::DotLine ) ); |
|---|
| 785 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 786 | } |
|---|
| 787 | } |
|---|
| 788 | } |
|---|
| 789 | } |
|---|
| 790 | else { // Triplets |
|---|
| 791 | uint nCounter = 0; |
|---|
| 792 | int nSize = 4 * MAX_NOTES / (nBase * nResolution); |
|---|
| 793 | |
|---|
| 794 | for (uint i = 0; i < nNotes + 1; i++) { |
|---|
| 795 | uint x = 20 + i * m_nGridWidth; |
|---|
| 796 | |
|---|
| 797 | if ( (i % nSize) == 0) { |
|---|
| 798 | if ((nCounter % 3) == 0) { |
|---|
| 799 | p.setPen( QPen( res_1, 0, Qt::DotLine ) ); |
|---|
| 800 | } |
|---|
| 801 | else { |
|---|
| 802 | p.setPen( QPen( res_3, 0, Qt::DotLine ) ); |
|---|
| 803 | } |
|---|
| 804 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 805 | nCounter++; |
|---|
| 806 | } |
|---|
| 807 | } |
|---|
| 808 | } |
|---|
| 809 | |
|---|
| 810 | if ( m_pPattern ) { |
|---|
| 811 | int nSelectedInstrument = Hydrogen::get_instance()->getSelectedInstrumentNumber(); |
|---|
| 812 | Song *pSong = Hydrogen::get_instance()->getSong(); |
|---|
| 813 | |
|---|
| 814 | std::multimap <int, Note*>::iterator pos; |
|---|
| 815 | for ( pos = m_pPattern->note_map.begin(); pos != m_pPattern->note_map.end(); ++pos ) { |
|---|
| 816 | Note *pNote = pos->second; |
|---|
| 817 | assert( pNote ); |
|---|
| 818 | if ( pNote->get_instrument() != pSong->get_instrument_list()->get( nSelectedInstrument ) ) { |
|---|
| 819 | continue; |
|---|
| 820 | } |
|---|
| 821 | uint x_pos = 20 + pNote->get_position() * m_nGridWidth; |
|---|
| 822 | |
|---|
| 823 | if (pNote->get_leadlag() == 0) { |
|---|
| 824 | // leadlag value is centered - draw circle |
|---|
| 825 | int y_pos = (int)( height() * 0.5 ); |
|---|
| 826 | p.setBrush(QColor( 0, 0, 0 )); |
|---|
| 827 | p.drawEllipse( x_pos-4, y_pos-4, 8, 8); |
|---|
| 828 | } else { |
|---|
| 829 | int y_start = (int)( height() * 0.5 ); |
|---|
| 830 | int y_end = y_start + ((pNote->get_leadlag()/2) * height()); |
|---|
| 831 | |
|---|
| 832 | int nLineWidth = 3; |
|---|
| 833 | int red; |
|---|
| 834 | int green; |
|---|
| 835 | int blue = (int) (pNote->get_leadlag() * 255); |
|---|
| 836 | if (blue < 0) { |
|---|
| 837 | red = blue *-1; |
|---|
| 838 | blue = (int) red * .33; |
|---|
| 839 | green = (int) red * .33; |
|---|
| 840 | } else { |
|---|
| 841 | red = (int) blue * .33; |
|---|
| 842 | green = (int) blue * .33; |
|---|
| 843 | } |
|---|
| 844 | p.fillRect( x_pos - 1, y_start, nLineWidth, y_end - y_start, QColor( red, green ,blue ) ); |
|---|
| 845 | |
|---|
| 846 | p.fillRect( x_pos - 1, ( height() / 2.0 ) - 2 , nLineWidth, 5, QColor( red, green ,blue ) ); |
|---|
| 847 | } |
|---|
| 848 | |
|---|
| 849 | } |
|---|
| 850 | } |
|---|
| 851 | |
|---|
| 852 | p.setPen(res_1); |
|---|
| 853 | p.drawLine(0, 0, m_nEditorWidth, 0); |
|---|
| 854 | p.drawLine(0, m_nEditorHeight - 1, m_nEditorWidth, m_nEditorHeight - 1); |
|---|
| 855 | } |
|---|
| 856 | |
|---|
| 857 | |
|---|
| 858 | |
|---|
| 859 | void NotePropertiesRuler::createNoteKeyBackground(QPixmap *pixmap) |
|---|
| 860 | { |
|---|
| 861 | if ( !isVisible() ) { |
|---|
| 862 | return; |
|---|
| 863 | } |
|---|
| 864 | |
|---|
| 865 | UIStyle *pStyle = Preferences::getInstance()->getDefaultUIStyle(); |
|---|
| 866 | |
|---|
| 867 | H2RGBColor valueColor( |
|---|
| 868 | (int)( pStyle->m_patternEditor_backgroundColor.getRed() * ( 1 - 0.3 ) ), |
|---|
| 869 | (int)( pStyle->m_patternEditor_backgroundColor.getGreen() * ( 1 - 0.3 ) ), |
|---|
| 870 | (int)( pStyle->m_patternEditor_backgroundColor.getBlue() * ( 1 - 0.3 ) ) |
|---|
| 871 | ); |
|---|
| 872 | |
|---|
| 873 | QColor res_1( pStyle->m_patternEditor_line1Color.getRed(), pStyle->m_patternEditor_line1Color.getGreen(), pStyle->m_patternEditor_line1Color.getBlue() ); |
|---|
| 874 | QColor res_2( pStyle->m_patternEditor_line2Color.getRed(), pStyle->m_patternEditor_line2Color.getGreen(), pStyle->m_patternEditor_line2Color.getBlue() ); |
|---|
| 875 | QColor res_3( pStyle->m_patternEditor_line3Color.getRed(), pStyle->m_patternEditor_line3Color.getGreen(), pStyle->m_patternEditor_line3Color.getBlue() ); |
|---|
| 876 | QColor res_4( pStyle->m_patternEditor_line4Color.getRed(), pStyle->m_patternEditor_line4Color.getGreen(), pStyle->m_patternEditor_line4Color.getBlue() ); |
|---|
| 877 | QColor res_5( pStyle->m_patternEditor_line5Color.getRed(), pStyle->m_patternEditor_line5Color.getGreen(), pStyle->m_patternEditor_line5Color.getBlue() ); |
|---|
| 878 | |
|---|
| 879 | QColor backgroundColor( pStyle->m_patternEditor_backgroundColor.getRed(), pStyle->m_patternEditor_backgroundColor.getGreen(), pStyle->m_patternEditor_backgroundColor.getBlue() ); |
|---|
| 880 | QColor horizLinesColor( |
|---|
| 881 | pStyle->m_patternEditor_backgroundColor.getRed() - 100, |
|---|
| 882 | pStyle->m_patternEditor_backgroundColor.getGreen() - 100, |
|---|
| 883 | pStyle->m_patternEditor_backgroundColor.getBlue() - 100 |
|---|
| 884 | ); |
|---|
| 885 | |
|---|
| 886 | unsigned nNotes = MAX_NOTES; |
|---|
| 887 | if (m_pPattern) { |
|---|
| 888 | nNotes = m_pPattern->get_lenght(); |
|---|
| 889 | } |
|---|
| 890 | QPainter p( pixmap ); |
|---|
| 891 | |
|---|
| 892 | |
|---|
| 893 | p.fillRect( 0, 0, width(), height(), QColor(0,0,0) ); |
|---|
| 894 | p.fillRect( 0, 0, 20 + nNotes * m_nGridWidth, height(), backgroundColor ); |
|---|
| 895 | |
|---|
| 896 | |
|---|
| 897 | p.setPen( horizLinesColor ); |
|---|
| 898 | for (unsigned y = 10; y < 80; y = y + 10 ) { |
|---|
| 899 | p.setPen( QPen( res_1, 1, Qt::DashLine ) ); |
|---|
| 900 | if (y == 40) p.setPen( QPen( QColor(0,0,0), 1, Qt::SolidLine ) ); |
|---|
| 901 | p.drawLine(20, y, 20 + nNotes * m_nGridWidth, y); |
|---|
| 902 | /* if (y == 20 )p.drawText ( 5, y +2 , QString("O")); |
|---|
| 903 | if (y == 30 )p.drawText ( 6, y +2 , QString("c")); |
|---|
| 904 | if (y == 40 )p.drawText ( 7, y +2 , QString("t")); |
|---|
| 905 | if (y == 50 )p.drawText ( 5, y +2 , QString("a")); |
|---|
| 906 | if (y == 60 )p.drawText ( 6, y +2 , QString("v")); |
|---|
| 907 | if (y == 70 )p.drawText ( 6, y +2 , QString("e")); |
|---|
| 908 | */ |
|---|
| 909 | } |
|---|
| 910 | |
|---|
| 911 | for (unsigned y = 90; y < 210; y = y + 10 ) { |
|---|
| 912 | p.setPen( QPen( QColor( 255, 255, 255 ), 9, Qt::SolidLine, Qt::FlatCap) ); |
|---|
| 913 | if ( y == 100 ||y == 120 ||y == 140 ||y == 170 ||y == 190) |
|---|
| 914 | p.setPen( QPen( QColor( 0, 0, 0 ), 7, Qt::SolidLine, Qt::FlatCap ) ); |
|---|
| 915 | p.drawLine(20, y, 20 + nNotes * m_nGridWidth, y); |
|---|
| 916 | /* if (y == 100 )p.drawText ( 5, y +2 , QString("H")); |
|---|
| 917 | if (y == 110 )p.drawText ( 6, y +2 , QString("a")); |
|---|
| 918 | if (y == 120 )p.drawText ( 7, y +2 , QString("l")); |
|---|
| 919 | if (y == 130 )p.drawText ( 5, y +2 , QString("f")); |
|---|
| 920 | if (y == 150 )p.drawText ( 5, y +2 , QString("s")); |
|---|
| 921 | if (y == 160 )p.drawText ( 6, y +2 , QString("t")); |
|---|
| 922 | if (y == 170 )p.drawText ( 7, y +2 , QString("e")); |
|---|
| 923 | if (y == 180 )p.drawText ( 5, y +2 , QString("p")); |
|---|
| 924 | if (y == 190 )p.drawText ( 5, y +2 , QString("s")); |
|---|
| 925 | */ |
|---|
| 926 | } |
|---|
| 927 | |
|---|
| 928 | // vertical lines |
|---|
| 929 | DrumPatternEditor *pPatternEditor = m_pPatternEditorPanel->getDrumPatternEditor(); |
|---|
| 930 | int nBase; |
|---|
| 931 | if (pPatternEditor->isUsingTriplets()) { |
|---|
| 932 | nBase = 3; |
|---|
| 933 | } |
|---|
| 934 | else { |
|---|
| 935 | nBase = 4; |
|---|
| 936 | } |
|---|
| 937 | |
|---|
| 938 | int n4th = 4 * MAX_NOTES / (nBase * 4); |
|---|
| 939 | int n8th = 4 * MAX_NOTES / (nBase * 8); |
|---|
| 940 | int n16th = 4 * MAX_NOTES / (nBase * 16); |
|---|
| 941 | int n32th = 4 * MAX_NOTES / (nBase * 32); |
|---|
| 942 | int n64th = 4 * MAX_NOTES / (nBase * 64); |
|---|
| 943 | int nResolution = pPatternEditor->getResolution(); |
|---|
| 944 | |
|---|
| 945 | |
|---|
| 946 | if ( !pPatternEditor->isUsingTriplets() ) { |
|---|
| 947 | |
|---|
| 948 | for (uint i = 0; i < nNotes + 1; i++) { |
|---|
| 949 | uint x = 20 + i * m_nGridWidth; |
|---|
| 950 | |
|---|
| 951 | if ( (i % n4th) == 0 ) { |
|---|
| 952 | if (nResolution >= 4) { |
|---|
| 953 | p.setPen( QPen( res_1, 0, Qt::DotLine ) ); |
|---|
| 954 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 955 | } |
|---|
| 956 | } |
|---|
| 957 | else if ( (i % n8th) == 0 ) { |
|---|
| 958 | if (nResolution >= 8) { |
|---|
| 959 | p.setPen( QPen( res_2, 0, Qt::DotLine ) ); |
|---|
| 960 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 961 | } |
|---|
| 962 | } |
|---|
| 963 | else if ( (i % n16th) == 0 ) { |
|---|
| 964 | if (nResolution >= 16) { |
|---|
| 965 | p.setPen( QPen( res_3, 0, Qt::DotLine ) ); |
|---|
| 966 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 967 | } |
|---|
| 968 | } |
|---|
| 969 | else if ( (i % n32th) == 0 ) { |
|---|
| 970 | if (nResolution >= 32) { |
|---|
| 971 | p.setPen( QPen( res_4, 0, Qt::DotLine ) ); |
|---|
| 972 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 973 | } |
|---|
| 974 | } |
|---|
| 975 | else if ( (i % n64th) == 0 ) { |
|---|
| 976 | if (nResolution >= 64) { |
|---|
| 977 | p.setPen( QPen( res_5, 0, Qt::DotLine ) ); |
|---|
| 978 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 979 | } |
|---|
| 980 | } |
|---|
| 981 | } |
|---|
| 982 | } |
|---|
| 983 | else { // Triplets |
|---|
| 984 | uint nCounter = 0; |
|---|
| 985 | int nSize = 4 * MAX_NOTES / (nBase * nResolution); |
|---|
| 986 | |
|---|
| 987 | for (uint i = 0; i < nNotes + 1; i++) { |
|---|
| 988 | uint x = 20 + i * m_nGridWidth; |
|---|
| 989 | |
|---|
| 990 | if ( (i % nSize) == 0) { |
|---|
| 991 | if ((nCounter % 3) == 0) { |
|---|
| 992 | p.setPen( QPen( res_1, 0, Qt::DotLine ) ); |
|---|
| 993 | } |
|---|
| 994 | else { |
|---|
| 995 | p.setPen( QPen( res_3, 0, Qt::DotLine ) ); |
|---|
| 996 | } |
|---|
| 997 | p.drawLine(x, 0, x, m_nEditorHeight); |
|---|
| 998 | nCounter++; |
|---|
| 999 | } |
|---|
| 1000 | } |
|---|
| 1001 | } |
|---|
| 1002 | |
|---|
| 1003 | |
|---|
| 1004 | p.setPen(res_1); |
|---|
| 1005 | p.drawLine(0, 0, m_nEditorWidth, 0); |
|---|
| 1006 | p.drawLine(0, m_nEditorHeight - 1, m_nEditorWidth, m_nEditorHeight - 1); |
|---|
| 1007 | |
|---|
| 1008 | //paint the oktave |
|---|
| 1009 | if ( m_pPattern ) { |
|---|
| 1010 | int nSelectedInstrument = Hydrogen::get_instance()->getSelectedInstrumentNumber(); |
|---|
| 1011 | Song *pSong = Hydrogen::get_instance()->getSong(); |
|---|
| 1012 | |
|---|
| 1013 | std::multimap <int, Note*>::iterator pos; |
|---|
| 1014 | for ( pos = m_pPattern->note_map.begin(); pos != m_pPattern->note_map.end(); ++pos ) { |
|---|
| 1015 | Note *pNote = pos->second; |
|---|
| 1016 | assert( pNote ); |
|---|
| 1017 | if ( pNote->get_instrument() != pSong->get_instrument_list()->get( nSelectedInstrument ) ) { |
|---|
| 1018 | continue; |
|---|
| 1019 | } |
|---|
| 1020 | |
|---|
| 1021 | //check the note type |
|---|
| 1022 | if ( !pNote->get_noteoff() ) { |
|---|
| 1023 | uint x_pos = 20 + pNote->get_position() * m_nGridWidth; |
|---|
| 1024 | |
|---|
| 1025 | int oktave = 0; |
|---|
| 1026 | if ( pNote ) oktave = pNote->m_noteKey.m_nOctave; |
|---|
| 1027 | |
|---|
| 1028 | if (pNote->m_noteKey.m_nOctave == -3){ |
|---|
| 1029 | p.setBrush(QColor( 99, 160, 233 )); |
|---|
| 1030 | p.drawEllipse( x_pos-3, 70-3, 6, 6); |
|---|
| 1031 | } |
|---|
| 1032 | if (pNote->m_noteKey.m_nOctave == -2){ |
|---|
| 1033 | p.setBrush(QColor( 99, 160, 233 )); |
|---|
| 1034 | p.drawEllipse( x_pos-3, 60-3, 6, 6); |
|---|
| 1035 | } |
|---|
| 1036 | if (pNote->m_noteKey.m_nOctave == -1){ |
|---|
| 1037 | p.setBrush(QColor( 99, 160, 233 )); |
|---|
| 1038 | p.drawEllipse( x_pos-3, 50-3, 6, 6); |
|---|
| 1039 | } |
|---|
| 1040 | if (pNote->m_noteKey.m_nOctave == 0){ |
|---|
| 1041 | p.setBrush(QColor( 99, 160, 233 )); |
|---|
| 1042 | p.drawEllipse( x_pos-3, 40-3, 6, 6); |
|---|
| 1043 | } |
|---|
| 1044 | if (pNote->m_noteKey.m_nOctave == 1){ |
|---|
| 1045 | p.setBrush(QColor( 99, 160, 233 )); |
|---|
| 1046 | p.drawEllipse( x_pos-3, 30-3, 6, 6); |
|---|
| 1047 | } |
|---|
| 1048 | if (pNote->m_noteKey.m_nOctave == 2){ |
|---|
| 1049 | p.setBrush(QColor( 99, 160, 233 )); |
|---|
| 1050 | p.drawEllipse( x_pos-3, 20-3, 6, 6); |
|---|
| 1051 | } |
|---|
| 1052 | if (pNote->m_noteKey.m_nOctave == 3){ |
|---|
| 1053 | p.setBrush(QColor( 99, 160, 233 )); |
|---|
| 1054 | p.drawEllipse( x_pos-3, 10-3, 6, 6); |
|---|
| 1055 | } |
|---|
| 1056 | } |
|---|
| 1057 | } |
|---|
| 1058 | } |
|---|
| 1059 | |
|---|
| 1060 | //paint the note |
|---|
| 1061 | if ( m_pPattern ) { |
|---|
| 1062 | int nSelectedInstrument = Hydrogen::get_instance()->getSelectedInstrumentNumber(); |
|---|
| 1063 | Song *pSong = Hydrogen::get_instance()->getSong(); |
|---|
| 1064 | |
|---|
| 1065 | std::multimap <int, Note*>::iterator pos; |
|---|
| 1066 | for ( pos = m_pPattern->note_map.begin(); pos != m_pPattern->note_map.end(); ++pos ) { |
|---|
| 1067 | Note *pNote = pos->second; |
|---|
| 1068 | assert( pNote ); |
|---|
| 1069 | if ( pNote->get_instrument() != pSong->get_instrument_list()->get( nSelectedInstrument ) ) { |
|---|
| 1070 | continue; |
|---|
| 1071 | } |
|---|
| 1072 | |
|---|
| 1073 | if ( !pNote->get_noteoff() ) { |
|---|
| 1074 | uint x_pos = 20 + pNote->get_position() * m_nGridWidth; |
|---|
| 1075 | |
|---|
| 1076 | int oktave = 0; |
|---|
| 1077 | if ( pNote ) oktave = pNote->m_noteKey.m_nOctave; |
|---|
| 1078 | |
|---|
| 1079 | if (pNote->m_noteKey.m_key == 0 ){//note c |
|---|
| 1080 | p.setBrush(QColor( 0, 0, 0)); |
|---|
| 1081 | p.drawEllipse( x_pos-4, 200-4, 8, 8); |
|---|
| 1082 | } |
|---|
| 1083 | if (pNote->m_noteKey.m_key == 1 ){//note cis |
|---|
| 1084 | p.setBrush(QColor( 255, 255, 255 )); |
|---|
| 1085 | p.drawEllipse( x_pos-3, 190-3, 6, 6); |
|---|
| 1086 | } |
|---|
| 1087 | if (pNote->m_noteKey.m_key == 2 ){//note d |
|---|
| 1088 | p.setBrush(QColor( 0, 0, 0)); |
|---|
| 1089 | p.drawEllipse( x_pos-4, 180-4, 8, 8); |
|---|
| 1090 | } |
|---|
| 1091 | if (pNote->m_noteKey.m_key == 3 ){//note dis |
|---|
| 1092 | p.setBrush(QColor( 255, 255, 255)); |
|---|
| 1093 | p.drawEllipse( x_pos-3, 170-3, 6, 6); |
|---|
| 1094 | } |
|---|
| 1095 | if (pNote->m_noteKey.m_key == 4 ){//note e |
|---|
| 1096 | p.setBrush(QColor( 0, 0, 0)); |
|---|
| 1097 | p.drawEllipse( x_pos-4, 160-4, 8, 8); |
|---|
| 1098 | } |
|---|
| 1099 | if (pNote->m_noteKey.m_key == 5 ){//note f |
|---|
| 1100 | p.setBrush(QColor( 0, 0, 0)); |
|---|
| 1101 | p.drawEllipse( x_pos-4, 150-4, 8, 8); |
|---|
| 1102 | } |
|---|
| 1103 | if (pNote->m_noteKey.m_key == 6 ){//note fis |
|---|
| 1104 | p.setBrush(QColor( 255, 255, 255)); |
|---|
| 1105 | p.drawEllipse( x_pos-3, 140-3, 6, 6); |
|---|
| 1106 | } |
|---|
| 1107 | if (pNote->m_noteKey.m_key == 7 ){//note g |
|---|
| 1108 | p.setBrush(QColor( 0, 0, 0)); |
|---|
| 1109 | p.drawEllipse( x_pos-4, 130-4, 8, 8); |
|---|
| 1110 | } |
|---|
| 1111 | if (pNote->m_noteKey.m_key == 8 ){//note gis |
|---|
| 1112 | p.setBrush(QColor( 255, 255, 255)); |
|---|
| 1113 | p.drawEllipse( x_pos-3, 120-3, 6, 6); |
|---|
| 1114 | } |
|---|
| 1115 | if (pNote->m_noteKey.m_key == 9 ){//note a |
|---|
| 1116 | p.setBrush(QColor( 0, 0, 0)); |
|---|
| 1117 | p.drawEllipse( x_pos-4, 110-4, 8, 8); |
|---|
| 1118 | } |
|---|
| 1119 | if (pNote->m_noteKey.m_key == 10 ){//note ais |
|---|
| 1120 | p.setBrush(QColor( 255, 255, 255)); |
|---|
| 1121 | p.drawEllipse( x_pos-3, 100-3, 6, 6); |
|---|
| 1122 | } |
|---|
| 1123 | if (pNote->m_noteKey.m_key == 11 ){//note h |
|---|
| 1124 | p.setBrush(QColor( 0, 0, 0)); |
|---|
| 1125 | p.drawEllipse( x_pos-4, 90-4, 8, 8); |
|---|
| 1126 | } |
|---|
| 1127 | } |
|---|
| 1128 | } |
|---|
| 1129 | } |
|---|
| 1130 | } |
|---|
| 1131 | |
|---|
| 1132 | |
|---|
| 1133 | |
|---|
| 1134 | |
|---|
| 1135 | void NotePropertiesRuler::updateEditor() |
|---|
| 1136 | { |
|---|
| 1137 | Hydrogen *pEngine = Hydrogen::get_instance(); |
|---|
| 1138 | PatternList *pPatternList = pEngine->getSong()->get_pattern_list(); |
|---|
| 1139 | int nSelectedPatternNumber = pEngine->getSelectedPatternNumber(); |
|---|
| 1140 | if ( (nSelectedPatternNumber != -1) && ( (uint)nSelectedPatternNumber < pPatternList->get_size() ) ) { |
|---|
| 1141 | m_pPattern = pPatternList->get( nSelectedPatternNumber ); |
|---|
| 1142 | } |
|---|
| 1143 | else { |
|---|
| 1144 | m_pPattern = NULL; |
|---|
| 1145 | } |
|---|
| 1146 | |
|---|
| 1147 | |
|---|
| 1148 | // update editor width |
|---|
| 1149 | int editorWidth; |
|---|
| 1150 | if ( m_pPattern ) { |
|---|
| 1151 | editorWidth = 20 + m_pPattern->get_lenght() * m_nGridWidth; |
|---|
| 1152 | } |
|---|
| 1153 | else { |
|---|
| 1154 | editorWidth = 20 + MAX_NOTES * m_nGridWidth; |
|---|
| 1155 | } |
|---|
| 1156 | resize( editorWidth, height() ); |
|---|
| 1157 | |
|---|
| 1158 | |
|---|
| 1159 | if ( m_mode == VELOCITY ) { |
|---|
| 1160 | createVelocityBackground( m_pBackground ); |
|---|
| 1161 | } |
|---|
| 1162 | else if ( m_mode == PAN ) { |
|---|
| 1163 | createPanBackground( m_pBackground ); |
|---|
| 1164 | } |
|---|
| 1165 | else if ( m_mode == LEADLAG ) { |
|---|
| 1166 | createLeadLagBackground( m_pBackground ); |
|---|
| 1167 | } |
|---|
| 1168 | else if ( m_mode == NOTEKEY ) { |
|---|
| 1169 | createNoteKeyBackground( m_pBackground ); |
|---|
| 1170 | } |
|---|
| 1171 | |
|---|
| 1172 | // redraw all |
|---|
| 1173 | update(); |
|---|
| 1174 | } |
|---|
| 1175 | |
|---|
| 1176 | |
|---|
| 1177 | |
|---|
| 1178 | void NotePropertiesRuler::zoomIn() |
|---|
| 1179 | { |
|---|
| 1180 | if (m_nGridWidth >= 3){ |
|---|
| 1181 | m_nGridWidth *= 2; |
|---|
| 1182 | }else |
|---|
| 1183 | { |
|---|
| 1184 | m_nGridWidth *= 1.5; |
|---|
| 1185 | } |
|---|
| 1186 | updateEditor(); |
|---|
| 1187 | } |
|---|
| 1188 | |
|---|
| 1189 | |
|---|
| 1190 | |
|---|
| 1191 | void NotePropertiesRuler::zoomOut() |
|---|
| 1192 | { |
|---|
| 1193 | if ( m_nGridWidth > 1.5 ) { |
|---|
| 1194 | if (m_nGridWidth > 3){ |
|---|
| 1195 | m_nGridWidth /= 2; |
|---|
| 1196 | }else |
|---|
| 1197 | { |
|---|
| 1198 | m_nGridWidth /= 1.5; |
|---|
| 1199 | } |
|---|
| 1200 | updateEditor(); |
|---|
| 1201 | } |
|---|
| 1202 | } |
|---|
| 1203 | |
|---|
| 1204 | |
|---|
| 1205 | void NotePropertiesRuler::selectedPatternChangedEvent() |
|---|
| 1206 | { |
|---|
| 1207 | updateEditor(); |
|---|
| 1208 | } |
|---|
| 1209 | |
|---|
| 1210 | |
|---|
| 1211 | |
|---|
| 1212 | void NotePropertiesRuler::selectedInstrumentChangedEvent() |
|---|
| 1213 | { |
|---|
| 1214 | updateEditor(); |
|---|
| 1215 | } |
|---|
| 1216 | |
|---|
| 1217 | |
|---|
| 1218 | |
|---|