From 8a5f5f9fdffbe3951c5d77e607cf35d34a802217 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Sun, 29 Jun 2008 10:12:02 +0000 Subject: [PATCH] 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 --- ChangeLog | 7 ++++ include/automation_track.h | 2 + .../peak_controller_effect_controls.cpp | 1 - src/core/automation_pattern.cpp | 18 +++------ src/core/peak_controller.cpp | 2 - src/tracks/automation_track.cpp | 39 +++++++++++++++++-- 6 files changed, 51 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index a809dcfe66..b820568a7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 * plugins/Makefile.am: diff --git a/include/automation_track.h b/include/automation_track.h index 9991eca0d5..35f5c72074 100644 --- a/include/automation_track.h +++ b/include/automation_track.h @@ -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; diff --git a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp index 06aa7d744e..eaaeb288c1 100644 --- a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp @@ -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() ); diff --git a/src/core/automation_pattern.cpp b/src/core/automation_pattern.cpp index a0c1383b62..3408423d0b 100644 --- a/src/core/automation_pattern.cpp +++ b/src/core/automation_pattern.cpp @@ -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(); diff --git a/src/core/peak_controller.cpp b/src/core/peak_controller.cpp index 0959eed888..517b1c59da 100644 --- a/src/core/peak_controller.cpp +++ b/src/core/peak_controller.cpp @@ -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 ) diff --git a/src/tracks/automation_track.cpp b/src/tracks/automation_track.cpp index 0512fba853..a5e1430f44 100644 --- a/src/tracks/automation_track.cpp +++ b/src/tracks/automation_track.cpp @@ -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( + engine::getProjectJournal()-> + getJournallingObject( val.toInt() ) ); + if( mod != NULL ) + { + midiTime pos = midiTime( getTrackContainerView()->currentPosition() + + ( _de->pos().x() - getTrackContentWidget()->x() ) * midiTime::ticksPerTact() / + static_cast( getTrackContainerView()->pixelsPerTact() ) ) + .toNearestTact(); + + trackContentObject * tco = getTrack()->createTCO( pos ); + automationPattern * pat = dynamic_cast< automationPattern *>( tco ); + pat->addObject( mod ); + pat->movePosition( pos ); + } + } + + update(); +}