| 476 | |
| 477 | |
| 478 | void SampleTCOView::paintEvent( QPaintEvent * pe ) |
| 479 | { |
| 480 | QPainter painter( this ); |
| 481 | |
| 482 | if( !needsUpdate() ) |
| 483 | { |
| 484 | painter.drawPixmap( 0, 0, m_paintPixmap ); |
| 485 | return; |
| 486 | } |
| 487 | |
| 488 | setNeedsUpdate( false ); |
| 489 | |
| 490 | m_paintPixmap = m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() |
| 491 | ? QPixmap( size() ) : m_paintPixmap; |
| 492 | |
| 493 | QPainter p( &m_paintPixmap ); |
| 494 | |
| 495 | QLinearGradient lingrad( 0, 0, 0, height() ); |
| 496 | QColor c; |
| 497 | bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted(); |
| 498 | |
| 499 | // state: selected, muted, normal |
| 500 | c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor() |
| 501 | : painter.background().color() ); |
| 502 | |
| 503 | lingrad.setColorAt( 1, c.darker( 300 ) ); |
| 504 | lingrad.setColorAt( 0, c ); |
| 505 | |
| 506 | // paint a black rectangle under the pattern to prevent glitches with transparent backgrounds |
| 507 | p.fillRect( rect(), QColor( 0, 0, 0 ) ); |
| 508 | |
| 509 | if( gradient() ) |
| 510 | { |
| 511 | p.fillRect( rect(), lingrad ); |
| 512 | } |
| 513 | else |
| 514 | { |
| 515 | p.fillRect( rect(), c ); |
| 516 | } |
| 517 | |
| 518 | p.setPen( !muted ? painter.pen().brush().color() : mutedColor() ); |
| 519 | |
| 520 | const int spacing = TCO_BORDER_WIDTH + 1; |
| 521 | const float ppt = fixedTCOs() ? |
| 522 | ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH ) |
| 523 | / (float) m_tco->length().getTact() : |
| 524 | pixelsPerTact(); |
| 525 | |
| 526 | float nom = Engine::getSong()->getTimeSigModel().getNumerator(); |
| 527 | float den = Engine::getSong()->getTimeSigModel().getDenominator(); |
| 528 | float ticksPerTact = DefaultTicksPerTact * nom / den; |
| 529 | |
| 530 | QRect r = QRect( TCO_BORDER_WIDTH, spacing, |
| 531 | qMax( static_cast<int>( m_tco->sampleLength() * ppt / ticksPerTact ), 1 ), rect().bottom() - 2 * spacing ); |
| 532 | m_tco->m_sampleBuffer->visualize( p, r, pe->rect() ); |
| 533 | |
| 534 | // disable antialiasing for borders, since its not needed |
| 535 | p.setRenderHint( QPainter::Antialiasing, false ); |
nothing calls this directly
no test coverage detected