diff --git a/include/AutomationTrack.h b/include/AutomationTrack.h index b783c5905..ee55c31ac 100644 --- a/include/AutomationTrack.h +++ b/include/AutomationTrack.h @@ -28,7 +28,6 @@ #define AUTOMATION_TRACK_H #include "Track.h" -#include "TrackView.h" class AutomationTrack : public Track @@ -59,17 +58,4 @@ private: } ; - -class AutomationTrackView : public TrackView -{ -public: - AutomationTrackView( AutomationTrack* at, TrackContainerView* tcv ); - virtual ~AutomationTrackView() = default; - - void dragEnterEvent( QDragEnterEvent * _dee ) override; - void dropEvent( QDropEvent * _de ) override; - -} ; - - #endif diff --git a/include/AutomationTrackView.h b/include/AutomationTrackView.h new file mode 100644 index 000000000..148c05b6f --- /dev/null +++ b/include/AutomationTrackView.h @@ -0,0 +1,44 @@ +/* + * AutomationTrackView.h - declaration of class AutomationTrackView + * + * Copyright (c) 2008-2014 Tobias Doerffel + * Copyright (c) 2006-2008 Javier Serrano Polo + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef AUTOMATION_TRACK_VIEW_H +#define AUTOMATION_TRACK_VIEW_H + +#include "AutomationTrack.h" +#include "TrackView.h" + + +class AutomationTrackView : public TrackView +{ +public: + AutomationTrackView( AutomationTrack* at, TrackContainerView* tcv ); + virtual ~AutomationTrackView() = default; + + void dragEnterEvent( QDragEnterEvent * _dee ) override; + void dropEvent( QDropEvent * _de ) override; +} ; + + +#endif diff --git a/src/gui/AutomationTrackView.cpp b/src/gui/AutomationTrackView.cpp new file mode 100644 index 000000000..13bcddc00 --- /dev/null +++ b/src/gui/AutomationTrackView.cpp @@ -0,0 +1,88 @@ +/* + * AutomationTrackView.cpp + * + * Copyright (c) 2008-2014 Tobias Doerffel + * Copyright (c) 2006-2008 Javier Serrano Polo + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + #include "AutomationTrackView.h" + + #include "AutomationPattern.h" + #include "embed.h" + #include "Engine.h" + #include "ProjectJournal.h" + #include "StringPairDrag.h" + #include "TrackContainerView.h" + #include "TrackLabelButton.h" + + +AutomationTrackView::AutomationTrackView( AutomationTrack * _at, TrackContainerView* tcv ) : + TrackView( _at, tcv ) +{ + setFixedHeight( 32 ); + TrackLabelButton * tlb = new TrackLabelButton( this, + getTrackSettingsWidget() ); + tlb->setIcon( embed::getIconPixmap( "automation_track" ) ); + tlb->move( 3, 1 ); + tlb->show(); + setModel( _at ); +} + +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::projectJournal()-> + journallingObject( val.toInt() ) ); + if( mod != NULL ) + { + TimePos pos = TimePos( trackContainerView()-> + currentPosition() + + ( _de->pos().x() - + getTrackContentWidget()->x() ) * + TimePos::ticksPerBar() / + static_cast( trackContainerView()->pixelsPerBar() ) ) + .toAbsoluteBar(); + + if( pos.getTicks() < 0 ) + { + pos.setTicks( 0 ); + } + + TrackContentObject * tco = getTrack()->createTCO( pos ); + AutomationPattern * pat = dynamic_cast( tco ); + pat->addObject( mod ); + } + } + + update(); +} \ No newline at end of file diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 44a41b011..7ad5dcb76 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -6,6 +6,7 @@ SET(LMMS_SRCS gui/AudioDeviceSetupWidget.cpp gui/AutomatableModelView.cpp gui/AutomationPatternView.cpp + gui/AutomationTrackView.cpp gui/ControllerConnectionDialog.cpp gui/ControllerDialog.cpp gui/EffectControlDialog.cpp diff --git a/src/gui/widgets/TrackOperationsWidget.cpp b/src/gui/widgets/TrackOperationsWidget.cpp index 7e6d636ab..48a960744 100644 --- a/src/gui/widgets/TrackOperationsWidget.cpp +++ b/src/gui/widgets/TrackOperationsWidget.cpp @@ -32,7 +32,7 @@ #include #include "AutomationPattern.h" -#include "AutomationTrack.h" +#include "AutomationTrackView.h" #include "ColorChooser.h" #include "ConfigManager.h" #include "DataFile.h" diff --git a/src/tracks/AutomationTrack.cpp b/src/tracks/AutomationTrack.cpp index dfb0df480..034ad4251 100644 --- a/src/tracks/AutomationTrack.cpp +++ b/src/tracks/AutomationTrack.cpp @@ -24,14 +24,8 @@ * */ -#include "AutomationTrack.h" +#include "AutomationTrackView.h" #include "AutomationPattern.h" -#include "Engine.h" -#include "embed.h" -#include "ProjectJournal.h" -#include "StringPairDrag.h" -#include "TrackContainerView.h" -#include "TrackLabelButton.h" AutomationTrack::AutomationTrack( TrackContainer* tc, bool _hidden ) : @@ -82,63 +76,4 @@ void AutomationTrack::loadTrackSpecificSettings( const QDomElement & _this ) { setMuted( false ); } -} - - - - - -AutomationTrackView::AutomationTrackView( AutomationTrack * _at, TrackContainerView* tcv ) : - TrackView( _at, tcv ) -{ - setFixedHeight( 32 ); - TrackLabelButton * tlb = new TrackLabelButton( this, - getTrackSettingsWidget() ); - tlb->setIcon( embed::getIconPixmap( "automation_track" ) ); - tlb->move( 3, 1 ); - tlb->show(); - setModel( _at ); -} - -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::projectJournal()-> - journallingObject( val.toInt() ) ); - if( mod != NULL ) - { - TimePos pos = TimePos( trackContainerView()-> - currentPosition() + - ( _de->pos().x() - - getTrackContentWidget()->x() ) * - TimePos::ticksPerBar() / - static_cast( trackContainerView()->pixelsPerBar() ) ) - .toAbsoluteBar(); - - if( pos.getTicks() < 0 ) - { - pos.setTicks( 0 ); - } - - TrackContentObject * tco = getTrack()->createTCO( pos ); - AutomationPattern * pat = dynamic_cast( tco ); - pat->addObject( mod ); - } - } - - update(); -} - - +} \ No newline at end of file