diff --git a/ChangeLog b/ChangeLog index b47152590..7cce2905e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,14 @@ * src/gui/cusis_style.cpp: Fix cache collision bug + * src/gui/tracks/pattern_item.cpp: + Place marks once-per-tact + + * src/gui/tracks/bb_tco_item.cpp: + * src/gui/tracks/track_content_object_item.cpp: + * src/gui/cusis_style.cpp: + Add per-TCO coloring and non-linear motion when dragging + 2009-02-19 Paul Giblock * include/track.h: diff --git a/src/gui/cusis_style.cpp b/src/gui/cusis_style.cpp index 0705ffc7b..df214f912 100644 --- a/src/gui/cusis_style.cpp +++ b/src/gui/cusis_style.cpp @@ -147,7 +147,7 @@ QLinearGradient darken( const QLinearGradient & _gradient ) QGradientStops stops = _gradient.stops(); for (int i = 0; i < stops.size(); ++i) { QColor color = stops.at(i).second; - stops[i].second = color.lighter(150); + stops[i].second = color.lighter(133); } QLinearGradient g = _gradient; @@ -195,7 +195,7 @@ void drawPath( QPainter *p, const QPainterPath &path, // highlight (bb) if (dark) - p->strokePath(path, QPen(borderCol.lighter(150), 2)); + p->strokePath(path, QPen(borderCol.lighter(133), 2)); else p->strokePath(path, QPen(borderCol, 2)); } @@ -919,22 +919,23 @@ void CusisStyle::drawTrackContentObject( QPainter * _painter, cache.fill( Qt::transparent ); QPainter painter( &cache ); - QColor col; - if( !_option->selected ) - { - col = QColor( 0x00, 0x33, 0x99 ); - } - else - { - col = QColor( 0x00, 0x99, 0x33 ); - } - - QColor colBorder = col.lighter(160); + QColor col = _option->userColor; + QColor colBorder; QColor col0; if( _option->type == LmmsStyleOptionTCO::BbTco ) - col0 = col; + { + colBorder = col; + col0 = _option->selected ? + QColor( 0x33, 0x00, 0x99 ) : + col.darker(140); + } else - col0 = col.darker(400); + { + colBorder = QColor( 0x00, 0x33, 0x99 ); + col0 = _option->selected ? + QColor( 0x33, 0x00, 0x99 ).darker(180) : + colBorder.darker(420); + } painter.setRenderHint( QPainter::Antialiasing, true ); @@ -957,7 +958,12 @@ void CusisStyle::drawTrackContentObject( QPainter * _painter, } painter.translate( 1, 0 ); - painter.setPen( col.lighter(160) ); + QColor faint = QColor::fromHsv( + colBorder.hue(), + colBorder.saturation()/2, + colBorder.value() ); + + painter.setPen( faint ); for( float x = t * cellW; x < rc.width()-2; x += t * cellW ) { painter.drawLine(x, 2, x, rc.height()-5); diff --git a/src/gui/tracks/bb_tco_item.cpp b/src/gui/tracks/bb_tco_item.cpp index 77ea3a4fd..9330cf868 100644 --- a/src/gui/tracks/bb_tco_item.cpp +++ b/src/gui/tracks/bb_tco_item.cpp @@ -62,14 +62,16 @@ void BbTrackContentObjectItem::paint( _painter->scale( 1.0f/xscale, 1.0f ); rc.setWidth( rc.width() * xscale ); + bbTCO * bbTco = (bbTCO*)m_tco; + // TODO: Use a proxy class LmmsStyleOptionTCO * options = new LmmsStyleOptionTCO(); options->type = LmmsStyleOptionTCO::BbTco; options->rect = rc; options->selected = isSelected(); options->hovered = m_hover; + options->userColor = bbTco->color(); - bbTCO * bbTco = (bbTCO*)m_tco; int trackNum = bbTrack::numOfBBTrack( bbTco->getTrack() ); options->duration = engine::getBBTrackContainer()->lengthOfBB( trackNum ); diff --git a/src/gui/tracks/pattern_item.cpp b/src/gui/tracks/pattern_item.cpp index 75f5949d1..9e2221541 100644 --- a/src/gui/tracks/pattern_item.cpp +++ b/src/gui/tracks/pattern_item.cpp @@ -63,7 +63,7 @@ void PatternItem::paint( options->rect = rc; options->selected = isSelected(); options->hovered = m_hover; - options->duration = 0; + options->duration = 1; engine::getLmmsStyle()->drawTrackContentObject( _painter, m_tco, options ); diff --git a/src/gui/tracks/track_content_object_item.cpp b/src/gui/tracks/track_content_object_item.cpp index 8e01ac651..5fbba2f4a 100644 --- a/src/gui/tracks/track_content_object_item.cpp +++ b/src/gui/tracks/track_content_object_item.cpp @@ -123,6 +123,29 @@ void TrackContentObjectItem::paint( QPainter * _painter, +float easeInOutQuad(float t, float b, float c, float d) +{ + float t_adj = 2.0f * (float)t / (float)d; + if (t_adj < 1) { + return c/2*t_adj*t_adj + b; + } else { + --t_adj; + return -c/2 * ((t_adj)*(t_adj-2) - 1) + b; + } +} + +// I think this was the best from Cubic thru Quint +float easeInOutQuart(float t, float b, float c, float d) +{ + float t_adj = 2.0f * (float)t / (float)d; + if (t_adj < 1) return c/2*t_adj*t_adj*t_adj*t_adj + b; + else { + t_adj -= 2.0f; + return -c/2 * (t_adj*t_adj*t_adj*t_adj - 2) + b; + } +} + + QVariant TrackContentObjectItem::itemChange( GraphicsItemChange _change, const QVariant & _value ) { @@ -149,6 +172,11 @@ QVariant TrackContentObjectItem::itemChange( GraphicsItemChange _change, } */ newPos.setY( m_trackItem->y() ); + float cellW = 16.0f; + float xmod = fmod( newPos.x(), cellW); + + newPos.setX( easeInOutQuart( xmod, newPos.x() - xmod, cellW, cellW ) ); + /* if( fmod( newPos.x(), 16 ) != 0 ) {