Load/save automationPattern position. Allow dragging autoViews directly onto automationTrack

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1204 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2008-06-29 10:12:02 +00:00
parent 30aea72c9c
commit 8a5f5f9fdf
6 changed files with 51 additions and 18 deletions

View File

@@ -35,6 +35,13 @@
* data/themes/default/style.css:
Make toolbar colors a little more clear
* src/core/automation_pattern.cpp:
Save and load pattern position from project
* include/automation_track.h:
* src/tracks/automation_track.cpp:
Allow dragging automatable views directly onto an automation-track
2008-06-28 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/Makefile.am:

View File

@@ -69,6 +69,8 @@ public:
automationTrackView( automationTrack * _at, trackContainerView * _tcv );
virtual ~automationTrackView();
virtual void dragEnterEvent( QDragEnterEvent * _dee );
virtual void dropEvent( QDropEvent * _de );
private:
bbTrack * m_bbTrack;

View File

@@ -42,7 +42,6 @@ peakControllerEffectControls( peakControllerEffect * _eff ) :
void peakControllerEffectControls::loadSettings( const QDomElement & _this )
{
printf("peakControllerEffect loadSettings\n");
m_baseModel.setValue( _this.attribute( "base" ).toFloat() );
m_amountModel.setValue( _this.attribute( "amount" ).toFloat() );
m_muteModel.setValue( _this.attribute( "mute" ).toFloat() );

View File

@@ -227,6 +227,8 @@ float automationPattern::valueAt( const midiTime & _time )
void automationPattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setAttribute( "pos", startPosition() );
for( timeMap::const_iterator it = m_timeMap.begin();
it != m_timeMap.end(); ++it )
{
@@ -251,7 +253,7 @@ void automationPattern::loadSettings( const QDomElement & _this )
{
clear();
// m_objects.clear();
movePosition( _this.attribute( "pos" ).toInt() );
for( QDomNode node = _this.firstChild(); !node.isNull();
node = node.nextSibling() )
@@ -630,20 +632,12 @@ void automationPatternView::paintEvent( QPaintEvent * )
p.translate( 0.0f, max * height() / y_scale-1 );
p.scale( 1.0f, -h );
//QLinearGradient lin2grad( 0, min, 0, max );
QLinearGradient lin2grad( 0, min, 0, max );
const QColor cl = QColor( 255, 224, 0 );
const QColor cd = QColor( 229, 158, 0 );
//lingrad.setColorAt( min, c );
lin2grad.setColorAt( 1, cl );
/* if( min < 0 ) {
lin2grad.setColorAt( -min/y_scale, Qt::black );
lin2grad.setColorAt( 0, k );
}
else {*/
lin2grad.setColorAt( 0, cd );
// }
lin2grad.setColorAt( 0, cd );
for( automationPattern::timeMap::const_iterator it =
m_pat->getTimeMap().begin();
@@ -661,7 +655,7 @@ void automationPatternView::paintEvent( QPaintEvent * )
x2 = width() - TCO_BORDER_WIDTH;
}
p.fillRect( QRectF( x1, 0.0f, x2-x1, it.value() ),
lin2grad /*QColor( 255, 224, 0 )*/ );
lin2grad );
}
p.resetMatrix();

View File

@@ -81,13 +81,11 @@ void peakController::saveSettings( QDomDocument & _doc, QDomElement & _this )
void peakController::loadSettings( const QDomElement & _this )
{
printf("peakController loadSettings\n");
int effectId = _this.attribute( "effectId" ).toInt();
peakControllerEffectVector::iterator i;
for( i = s_effects.begin(); i != s_effects.end(); ++i )
{
printf( "%d %d\n", (*i)->m_effectId , effectId );
if( (*i)->m_effectId == effectId )
{
if( (*i)->m_effectId == effectId )

View File

@@ -31,9 +31,9 @@
#include "automation_pattern.h"
#include "embed.h"
#include "name_label.h"
#include "string_pair_drag.h"
#include "project_journal.h"
#include "track_container_view.h"
automationTrack::automationTrack( trackContainer * _tc, bool _hidden ) :
track( _hidden ? HiddenAutomationTrack : AutomationTrack, _tc )
@@ -126,6 +126,39 @@ automationTrackView::~automationTrackView()
{
}
void automationTrackView::dragEnterEvent( QDragEnterEvent * _dee )
{
stringPairDrag::processDragEnterEvent( _dee, "automatable_model" );
}
void automationTrackView::dropEvent( QDropEvent * _de )
{
QString type = stringPairDrag::decodeKey( _de );
QString val = stringPairDrag::decodeValue( _de );
if( type == "automatable_model" )
{
automatableModel * mod = dynamic_cast<automatableModel *>(
engine::getProjectJournal()->
getJournallingObject( val.toInt() ) );
if( mod != NULL )
{
midiTime pos = midiTime( getTrackContainerView()->currentPosition()
+ ( _de->pos().x() - getTrackContentWidget()->x() ) * midiTime::ticksPerTact() /
static_cast<int>( getTrackContainerView()->pixelsPerTact() ) )
.toNearestTact();
trackContentObject * tco = getTrack()->createTCO( pos );
automationPattern * pat = dynamic_cast< automationPattern *>( tco );
pat->addObject( mod );
pat->movePosition( pos );
}
}
update();
}