diff --git a/ChangeLog b/ChangeLog index 9f24d3ba1..7be1b4b6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,8 +23,12 @@ * src/gui/tracks/pattern_item.cpp: * include/gui/tracks/pattern_item.h: * include/gui/tracks/bb_tco_item.h: + * src/gui/main_window.cpp: - Add BB and Pattern subclasses - Play with some styling, about to move style code into lmmsStyle + - Add Caching support, but will soon expand with manual-QPixmapCache usage + to share common-TCO pixmaps between TCOs. + - Fix tickmarks on BB-TCOs 2009-02-09 Paul Giblock diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp index 9bcb5fb76..b629053e3 100644 --- a/src/gui/main_window.cpp +++ b/src/gui/main_window.cpp @@ -41,6 +41,7 @@ #include #include +#include #include "lmmsversion.h" @@ -207,6 +208,7 @@ mainWindow::mainWindow( void ) : QSize( 16*4, 32 ), 16 ); + QPixmapCache::setCacheLimit( 10240 ); QGraphicsView *view = new QGraphicsView( scene ); view->setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform ); view->setDragMode( QGraphicsView::RubberBandDrag ); diff --git a/src/gui/tracks/bb_tco_item.cpp b/src/gui/tracks/bb_tco_item.cpp index 9b2920853..0f077f0d9 100644 --- a/src/gui/tracks/bb_tco_item.cpp +++ b/src/gui/tracks/bb_tco_item.cpp @@ -8,7 +8,10 @@ #include "gui/tracks/track_content_object_item.h" #include "gui/tracks/track_container_scene.h" #include "gui/tracks/track_item.h" +#include "bb_track.h" +#include "bb_track_container.h" #include "track.h" +#include "engine.h" // Just some stuff while playing with theming ideas, // will be moved to lmmsStyle @@ -126,52 +129,35 @@ void BbTrackContentObjectItem::paint( QPainter * _painter, drawPath( _painter, path, col, "hah", m_hover ); const float cellW = TrackContainerScene::DEFAULT_CELL_WIDTH; - _painter->setOpacity(0.2); - _painter->setRenderHint( QPainter::Antialiasing, false ); - _painter->setPen( QColor(0, 0, 0) ); - for( int i = 0; i < m_tco->length().getTact(); ++i ) - { - float x = cellW * i; - _painter->drawLine(x, 2, x, rc.height()-4); + + bbTCO * bbTco = (bbTCO*)m_tco; + tact t = engine::getBBTrackContainer()->lengthOfBB( + bbTrack::numOfBBTrack( bbTco->getTrack() ) ); + + if( bbTco->length() > midiTime::ticksPerTact() && t > 0 ) + { + _painter->setOpacity(0.2); + _painter->setRenderHint( QPainter::Antialiasing, false ); + _painter->setPen( QColor(0, 0, 0) ); + + for( float x = t * cellW; x < rc.width()-2; x += t * cellW ) + { + _painter->drawLine(x, 3, x, rc.height()-5); + } + + _painter->translate( 1, 0 ); + _painter->setPen( col.lighter(160) ); + for( float x = t * cellW; x < rc.width()-2; x += t * cellW ) + { + _painter->drawLine(x, 2, x, rc.height()-5); + } + + _painter->setRenderHint( QPainter::Antialiasing, true ); } - _painter->translate( 1, 0 ); - _painter->setPen( col.lighter(160) ); - for( int i = 0; i < m_tco->length().getTact(); ++i ) - { - float x = cellW * i; - _painter->drawLine(x, 2, x, rc.height()-4); - } - - _painter->setRenderHint( QPainter::Antialiasing, true ); _painter->restore(); return; - - - QColor col0 = col.light( 130 ); - QColor col1 = col.light( 70 ); - QColor col2 = col.light( 40 ); - - QLinearGradient lingrad( 0, 0, 0, rc.height() ); - lingrad.setColorAt( 0, col0 ); - lingrad.setColorAt( 1, col1 ); - - QLinearGradient bordergrad( 0, 0, 0, rc.height() ); - bordergrad.setColorAt( 1, col2 ); - bordergrad.setColorAt( 0, col1 ); - - - rc.adjust( 0, 0, -1, -1 ); - - - _painter->setRenderHint( QPainter::Antialiasing, true ); - _painter->setBrush( lingrad ); - _painter->setPen( QPen( bordergrad, 1.5 ) ); // QColor( 6, 6, 6 ) ); - _painter->drawRoundedRect( rc, 4, 4 ); - _painter->setRenderHint( QPainter::Antialiasing, false ); - - _painter->restore(); } QVariant BbTrackContentObjectItem::itemChange( GraphicsItemChange _change, const QVariant & _value ) diff --git a/src/gui/tracks/track_content_object_item.cpp b/src/gui/tracks/track_content_object_item.cpp index c92bce418..42cdd8d33 100644 --- a/src/gui/tracks/track_content_object_item.cpp +++ b/src/gui/tracks/track_content_object_item.cpp @@ -23,6 +23,10 @@ TrackContentObjectItem::TrackContentObjectItem( TrackItem * _track, trackContent setAcceptHoverEvents( true ); setCursor( Qt::OpenHandCursor ); + // TODO: We will do our own caching to allow common-TCOs to share pixmaps + // But this works for now + setCacheMode( QGraphicsItem::DeviceCoordinateCache ); + midiTime startPos = _object->startPosition(); float x = TrackContainerScene::DEFAULT_CELL_WIDTH * startPos.getTicks() / midiTime::ticksPerTact(); @@ -154,6 +158,7 @@ QVariant TrackContentObjectItem::itemChange( GraphicsItemChange _change, const Q { setCursor( Qt::OpenHandCursor ); } + update(); } return QGraphicsItem::itemChange( _change, _value );