Skip to content

Commit

Permalink
Fix sample track view in BB editor (#3002)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasp00 authored Sep 4, 2016
1 parent 6614f56 commit 08d54d3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 29 deletions.
1 change: 0 additions & 1 deletion include/AutomationPatternView.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class AutomationPatternView : public TrackContentObjectView
public slots:
/// Opens this view's pattern in the global automation editor
void openInAutomationEditor();
virtual void update();


protected slots:
Expand Down
1 change: 1 addition & 0 deletions include/BBEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public slots:
void addSteps();
void cloneSteps();
void removeSteps();
void addSampleTrack();
void addAutomationTrack();

protected slots:
Expand Down
4 changes: 4 additions & 0 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ TrackContentObjectView::~TrackContentObjectView()
*/
void TrackContentObjectView::update()
{
if( fixedTCOs() )
{
updateLength();
}
m_needsUpdate = true;
selectableObject::update();
}
Expand Down
13 changes: 0 additions & 13 deletions src/gui/AutomationPatternView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,6 @@ void AutomationPatternView::openInAutomationEditor()




void AutomationPatternView::update()
{
if( fixedTCOs() )
{
m_pat->changeLength( m_pat->length() );
}
TrackContentObjectView::update();
}




void AutomationPatternView::resetName()
{
m_pat->setName( QString::null );
Expand Down
12 changes: 12 additions & 0 deletions src/gui/editors/BBEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ BBEditor::BBEditor( BBTrackContainer* tc ) :

trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_bb_track"), tr("Add beat/bassline"),
Engine::getSong(), SLOT(addBBTrack()));
trackAndStepActionsToolBar->addAction(
embed::getIconPixmap("add_sample_track"),
tr("Add sample-track"), m_trackContainerView,
SLOT(addSampleTrack()));
trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_automation"), tr("Add automation-track"),
m_trackContainerView, SLOT(addAutomationTrack()));

Expand Down Expand Up @@ -210,6 +214,14 @@ void BBTrackContainerView::removeSteps()



void BBTrackContainerView::addSampleTrack()
{
(void) Track::create( Track::SampleTrack, model() );
}




void BBTrackContainerView::addAutomationTrack()
{
(void) Track::create( Track::AutomationTrack, model() );
Expand Down
2 changes: 0 additions & 2 deletions src/tracks/Pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,6 @@ PatternView::~PatternView()

void PatternView::update()
{
m_pat->changeLength( m_pat->length() );

if ( m_pat->m_patternType == Pattern::BeatPattern )
{
ToolTip::add( this,
Expand Down
30 changes: 17 additions & 13 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,14 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
QLinearGradient lingrad( 0, 0, 0, height() );
QColor c;
bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted();

// state: selected, muted, normal
c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor()
: painter.background().color() );

lingrad.setColorAt( 1, c.darker( 300 ) );
lingrad.setColorAt( 0, c );

if( gradient() )
{
p.fillRect( rect(), lingrad );
Expand All @@ -386,13 +386,17 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
}

p.setPen( !muted ? painter.pen().brush().color() : mutedColor() );

const int spacing = TCO_BORDER_WIDTH + 1;

const float ppt = fixedTCOs() ?
( parentWidget()->width() - 2 * TCO_BORDER_WIDTH )
/ (float) m_tco->length().getTact() :
pixelsPerTact();

QRect r = QRect( TCO_BORDER_WIDTH, spacing,
qMax( static_cast<int>( m_tco->sampleLength() *
pixelsPerTact() / DefaultTicksPerTact ), 1 ),
rect().bottom() - 2 * spacing );
qMax( static_cast<int>( m_tco->sampleLength() * ppt
/ DefaultTicksPerTact ), 1 ),
rect().bottom() - 2 * spacing );
m_tco->m_sampleBuffer->visualize( p, r, pe->rect() );

// disable antialiasing for borders, since its not needed
Expand All @@ -408,11 +412,11 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
p.setPen( c.lighter( 160 ) );
p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH,
rect().bottom() - TCO_BORDER_WIDTH );

// outer border
p.setPen( c.darker( 300 ) );
p.drawRect( 0, 0, rect().right(), rect().bottom() );

// draw the 'muted' pixmap only if the pattern was manualy muted
if( m_tco->isMuted() )
{
Expand All @@ -421,9 +425,9 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
p.drawPixmap( spacing, height() - ( size + spacing ),
embed::getIconPixmap( "muted", size, size ) );
}

// recording sample tracks is not possible at the moment

/* if( m_tco->isRecord() )
{
p.setFont( pointSize<7>( p.font() ) );
Expand All @@ -436,9 +440,9 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
p.setBrush( QBrush( textColor() ) );
p.drawEllipse( 4, 5, 4, 4 );
}*/

p.end();

painter.drawPixmap( 0, 0, m_paintPixmap );
}

Expand Down

0 comments on commit 08d54d3

Please sign in to comment.